# SciPy 3d plotting Integral of $\int x^y dx$ for $y$ in $[-4,4]$

Ideally, I would like to get the symbolic/algebraic integral of the function and plot the resulting surface in 3d. I am not sufficiently versed in SciPy to know if this is even really possible.

• You can compute the integral directly, although it is not continuous at $y=-1$. – nicoguaro Oct 11 '18 at 17:20
• Can someone tell me what the downvote was for, so I can avoid that in the futureß – user20460 Jan 15 '19 at 6:05
• I didn't down voted your question. Nevertheless, I would say that the main point is that your question, add phrased, might be off topic since it seems to ask how to do a particular task in a particular software. So it falls closer to programming than computational science. Even taking that apart, the question would be better showing what have you tried and where are you struggling. As a final comment, you have one comment and an answer but you didn't seem to consider these. – nicoguaro Jan 15 '19 at 14:24

As you may know:

$$\int x^y \, dx = \dfrac{x^{y+1}}{y+1},$$

with $$y \neq 1.$$ If you want to plot the function $$\dfrac{x^{y+1}}{y+1}$$ for a specific $$y$$ using Matplotlib, here is the answer:

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

x = np.linspace(-4, 4, 30)
y = np.linspace(-4, 4, 30)

def func(x, y, expn):
return x ** (1 + expn) / (1 + expn)

X, Y = np.meshgrid(x, y)

# Choose the exponent you want. In this case, you change expn from -4 to 4
Z = func(X, Y, -3.9)

fig = plt.figure()
ax = Axes3D(fig)
ax.plot_surface(X, Y, Z)
ax.set_proj_type('ortho')
plt.show()


As you can see, I am plotting a surface instead of a line.