feat: chain rule
This commit is contained in:
17
src/main.py
17
src/main.py
@@ -1,8 +1,10 @@
|
||||
from sympy import diff, limit, oo, symbols
|
||||
|
||||
from modules.math import (
|
||||
t_build_partial_derivate,
|
||||
t_build_derivate,
|
||||
t_build_derivative_from_limit,
|
||||
t_build_partial_derivate,
|
||||
t_calculate_derivative_limit,
|
||||
t_calculate_e,
|
||||
t_calculate_e_limit,
|
||||
t_compound_interest,
|
||||
@@ -37,4 +39,17 @@ if __name__=="__main__":
|
||||
partial_derivative_y = t_build_partial_derivate((3 * y ** 3) + 2 * z ** 2, y)
|
||||
partial_derivative_z = t_build_partial_derivate((3 * y ** 3) + 2 * z ** 2, z)
|
||||
print(partial_derivative_y, partial_derivative_z)
|
||||
print(t_build_derivative_from_limit(x ** 2))
|
||||
print(t_calculate_derivative_limit(x ** 2, 2))
|
||||
|
||||
## Chain rule
|
||||
# for a given function y (lets say y = x ** 2 + 1) and another z (lets say z = y ** 3 - 2), we can find a derivativeof z with respect to x by multiplying the derivatives
|
||||
# normal derivative calc
|
||||
x = symbols("x")
|
||||
z = (x ** 2 + 1) ** 3 - 2
|
||||
print(t_build_derivate(z))
|
||||
# chain rule calc
|
||||
x, y, z = symbols("x y z")
|
||||
y_f = x ** 2 + 1
|
||||
z_f = y ** 3 - 2
|
||||
print(t_build_derivate(y_f), t_build_derivate(z_f))
|
||||
|
||||
Reference in New Issue
Block a user