feat: chain rule
This commit is contained in:
@@ -55,6 +55,17 @@ def t_calculate_e_limit():
|
||||
def t_calculate_derivative(f, x, step_size):
|
||||
return (f(x + step_size) - f(x)) / (x +step_size - x)
|
||||
|
||||
def t_build_derivative_from_limit(f):
|
||||
x, s = symbols("x s")
|
||||
slope_f = (f.subs(x, x + s) - f) / (x + s - x) # Slope function
|
||||
return limit(slope_f, s, 0)
|
||||
|
||||
def t_calculate_derivative_limit(f, x_target):
|
||||
x = symbols("x")
|
||||
slope_f = t_build_derivative_from_limit(f)
|
||||
return slope_f.subs(x, x_target)
|
||||
|
||||
|
||||
def t_build_derivate(f):
|
||||
return diff(f)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user