-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.py
More file actions
29 lines (23 loc) · 807 Bytes
/
functions.py
File metadata and controls
29 lines (23 loc) · 807 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import sympy as sp
# Define a function for differentiation
def differentiate(expr, var):
return sp.diff(expr, var)
# Define a function for integration
def integrate(expr, var):
return sp.integrate(expr, var)
# Define a function for finding limits
def limit(expr, var, point):
return sp.limit(expr, var, point)
# Define a function for finding critical points
def critical_points(expr, var):
derivative = sp.diff(expr, var)
return sp.solve(derivative, var)
# Example usage
if __name__ == "__main__":
x = sp.symbols('x')
expr = x**2 + 3*x + 2
print("Function:", expr)
print("Derivative:", differentiate(expr, x))
print("Integral:", integrate(expr, x))
print("Limit as x approaches 1:", limit(expr, x, 1))
print("Critical Points:", critical_points(expr, x))