Spaces:
Sleeping
Sleeping
eaglelandsonce
commited on
Commit
•
582f428
1
Parent(s):
5c62ad1
Create sympyappoutlier.py
Browse files- sympyappoutlier.py +33 -0
sympyappoutlier.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sympy as sp
|
2 |
+
|
3 |
+
def evaluate_derivative():
|
4 |
+
# Define the variables
|
5 |
+
u = sp.symbols('u')
|
6 |
+
x = sp.symbols('x')
|
7 |
+
|
8 |
+
# Define the outer function
|
9 |
+
f_outer = sp.sin(u)
|
10 |
+
|
11 |
+
# Calculate the derivative of the outer function
|
12 |
+
f_outer_prime = sp.diff(f_outer, u)
|
13 |
+
|
14 |
+
# Define the inner function
|
15 |
+
g = sp.exp(x) - 2*x + 1
|
16 |
+
|
17 |
+
# Calculate the derivative of the inner function
|
18 |
+
g_prime = sp.diff(g, x)
|
19 |
+
|
20 |
+
# Substitute g(x) into the derivative of the outer function
|
21 |
+
f_prime = f_outer_prime.subs(u, g)
|
22 |
+
|
23 |
+
# Multiply by the derivative of the inner function
|
24 |
+
f_prime = f_prime * g_prime
|
25 |
+
|
26 |
+
# Evaluate the derivative at x=1
|
27 |
+
result = f_prime.subs(x, 1)
|
28 |
+
|
29 |
+
return result
|
30 |
+
|
31 |
+
# Execute the function
|
32 |
+
result = evaluate_derivative()
|
33 |
+
print(result)
|