ไม่สามารถเล่นวิดีโอนี้
ขออภัยในความไม่สะดวก

How to: Numerical Derivative in Python

แชร์
ฝัง
  • เผยแพร่เมื่อ 25 ก.ย. 2020
  • Learn how to take a simple numerical derivative of data using a difference formula in Python.
    Script and resources to download can be found at: www.hageslab.c...
    Here we use "Spyder" IDE as the Python Shell and the following libraries: numpy and matplotlib
    Here is the script:
    import numpy as np
    import matplotlib.pyplot as plt
    def func(x,A,B):
    return A*x**2+B*x
    xlist = np.linspace(0,10,100)
    ylist = func(xlist,2,1.4)
    plt.figure(1,dpi=120)
    plt.plot(xlist,ylist,label="Function")
    def D(xlist,ylist):
    yprime = np.diff(ylist)/np.diff(xlist)
    xprime=[]
    for i in range(len(yprime)):
    xtemp = (xlist[i+1]+xlist[i])/2
    xprime = np.append(xprime,xtemp)
    return xprime, yprime
    xprime, yprime = D(xlist,ylist)
    plt.plot(xprime,yprime,label="Derivative")
    xprime2, yprime2 = D(xprime,yprime)
    plt.plot(xprime2,yprime2,label="2nd Derivative")
    plt.legend()

ความคิดเห็น • 8

  • @adilmajeed8439
    @adilmajeed8439 3 ปีที่แล้ว +6

    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

  • @sandrofilho7798
    @sandrofilho7798 4 หลายเดือนก่อน

    perfect video, thanks!

  • @dhammapaal
    @dhammapaal 11 หลายเดือนก่อน

    Simple but outstanding. Deep gratitude! Thank you.

  • @joaocarlosbredadossantos9720
    @joaocarlosbredadossantos9720 2 ปีที่แล้ว

    Awesome explanation mate ! great work !

  • @brendanhall6644
    @brendanhall6644 2 ปีที่แล้ว

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

  • @RoronoaZoro-td9jj
    @RoronoaZoro-td9jj 3 หลายเดือนก่อน

    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?

  • @juanagustingonzalez9148
    @juanagustingonzalez9148 5 หลายเดือนก่อน

    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

  • @blewblew3555
    @blewblew3555 2 ปีที่แล้ว

    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.