How to: Numerical Derivative in Python

preview_player
Показать описание
Learn how to take a simple numerical derivative of data using a difference formula in Python.

Here we use "Spyder" IDE as the Python Shell and the following libraries: numpy and matplotlib

Here is the script:

import numpy as np

def func(x,A,B):
return A*x**2+B*x

ylist = func(xlist,2,1.4)

def D(xlist,ylist):
xprime=[]
for i in range(len(yprime)):
xtemp = (xlist[i+1]+xlist[i])/2
return xprime, yprime

xprime, yprime = D(xlist,ylist)

xprime2, yprime2 = D(xprime,yprime)
Рекомендации по теме
Комментарии
Автор

Awesome, it would be really cool if you can show the same with the help and paper and then use the numerical computation around it. Looking forward for these kind of videos on regular basis... Appreciate all your efforts

adilmajeed
Автор

Simple but outstanding. Deep gratitude! Thank you.

dhammapaal
Автор

Brilliant video, very well explained! Thanks for posting :)

brendanhall
Автор

Awesome explanation mate ! great work !

joaocarlosbredadossantos
Автор

Great man, but i want something. Im trying to make a code with a table of the function f and its derivative valuated but i dont know how to print without any error

juanagustingonzalez
Автор

With this method, that is np.diff(y) / np.diff(x) will compute the gradient of the data points but the derivative will have one less data point, what can be done about that?

RoronoaZoro-tdjj
Автор

How to inputs a polynomial in standard algebraic notation and outputs
the first derivative of that polynomial? (python)

If both the inputted polynomial and its derivative
should be represented as strings.

blewblew
join shbcf.ru