How do I find the derivative and integral in NumPy?
?
2014-06-20 13:35:07 UTC
How do I find the derivative and integral in numpy? Can someone tell me how to do it in numpy?
Three answers:
Jeroonk
2014-06-21 10:03:59 UTC
Do you want the numerical derivative (finite difference) and/or numerical integral (quadrature)?
For finite differences, have a look at numpy.diff: http://docs.scipy.org/doc/numpy/reference/generated/numpy.diff.html or numpy.gradient: http://docs.scipy.org/doc/numpy/reference/generated/numpy.gradient.html .
Numerical quadrature is not part of NumPy (which is simply a library for vectorized numerical calculations), but implemented in SciPy (containing many specialized functions and numerical algorithms). Have a look at http://docs.scipy.org/doc/scipy/reference/tutorial/integrate.html .
If you want symbolic calculations instead (like Mathematica or Maple would provide), NumPy or SciPy are the wrong tool for the job. Instead, have a look at SymPy, a library symbolic computation. For derivatives and integrals, see http://docs.sympy.org/latest/tutorial/calculus.html .
?
2014-06-20 23:42:33 UTC
> Boss, it's like this: NumPy is a series of modules that are tuned for numerical analysis. But that
> doesn't give them magical powers, so that you can push in your calculus book, and shake, and hey,
> presto, with Numpy out comes derivatives when wanted, and Integrals if needed. You still need to learn
> python, and you haven't done that yet. It's sort of a prerequisite, man. Come on now, you can do it. But
> get some walking in before you ask about mountain-climbing, okay?
>
> John (gnujohn)
Greywolf
2014-06-20 13:44:59 UTC
Read the NumPy documentation.http://www.numpy.org/
ⓘ
This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.