기초
[파이썬] 미분 - 그래프 ( sympy 모듈 ) - 수학
파이썬 서퍼
2021. 1. 14. 15:41
728x90
from sympy import *
init_printing()
x, y = symbols('x y')
fx = x**3 + 2*x**2 - 4*x - 2 # 방정식
display(Eq(y, fx))
plot(fx, (x, -5, 5), ylim=(-10, 10)) # 그래프
◎ 도함수 / 도함수 해
diff(fx, x) # 도함수
solve(diff(fx, x), x) # 도함수-해
◎ 극대값 / 극소값
ans = solve(diff(fx, x), x)
ans_list = [] # 극대값, 극소값
for i in range(len(ans)):
ans_tuple = ()
ans_tuple = ans_tuple + (ans[i], fx.subs(x, ans[i]))
ans_list.append(ans_tuple)
ans_list
반응형