Python Forum
Differentiation with exponential functions
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Differentiation with exponential functions
#1
i have been writing a python script for work that calculates some figures for me
it's basically two parts, one part is for when the data calls for a polynomial function, the other part is for when the data calls for an exponential function
for the polynomial functions, i've been using numpy polyfit to calcluate f(x) and f'(x), example code below
x = np.array(expg[xtype]) # x-values
y = np.array(expg[ytype]) # y-values 
py = np.polyfit(x,y, 2) # equation from x and y values
py0 = np.polyder(np.poly1d(py)) # 1st derivative of function py
print('Value at zero for first derivative of eq1',py0(0))
is there something similar to polyfit for exponential functions? right now i'm using curve_fit, my code looks like this
x = np.array(expg[xtype]) # x-values
y = np.array(expg[ytype]) #y-values
def f(x, a, b, c):
	return a * np.exp(-b * x) + c 
paramsy, extrasy = curve_fit(f, x, y) # gives me the exponential function equation i'm looking for, i use this to make graphs later
print('1st deriv value at 0', paramsy[0]*paramsy[1]) # basically i just do the chain rule here since i only need the value for f'(0)
Is there a better way to find the first derivative of exponential functions? Ideally, something similar to polyfit
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Laplacian Exponential Diffusion Kernel ainisyarifaah 1 1,712 Nov-25-2021, 06:21 PM
Last Post: Gribouillis
  how to fit an exponential function to multiple data python_newbie09 1 2,822 Sep-24-2019, 08:12 AM
Last Post: scidam
  help on exponential smoothing and linear regression hkyeung 1 3,129 Sep-02-2017, 09:31 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020