접선 그리기 함수의 특정한 점에서 접선의 기울기는 그 지점에서의 미분값과 같습니다. a=symbols("a") f=(a-1)**2 df=f.diff('a') df 2a - 2 함수 f위의 점(3, f(3))에서의 접선 식은 다음과 같이 계산할 수 있습니다. slope=df.subs(a, 3); slope 4 $$\begin{align} y&=\text{slope}\times x+b \\ b&= y - \text{slope}\times x\\&=f(3)-f^\prime(3)\times 3\end{align}$$ b=f.subs(a, 3)-slope*3 eq=slope*a+b; eq 4a−8 위에서 생성한 두 식 f와 eq(접선식)에 대한 그래프를 작성합니다. 그래프 작성에 필요한 함수 plot()과 scatter() 그리고 축 설정은 조각함수 작성 에서 적용한 것과 같습니다. x=np.linspace(-1, 5, 100) fy=[f.subs(a, i) for i in x] eqy=[eq.subs(a, i) for i in x] fig, ax=plt.subplots(figsize=(4, 3)) ax.plot(x, fy, color="g", label=r"f(x)=(x-1)^2") ax.plot(x, eqy, color="b", label="g(x)=4x-8") ax.scatter(3, f.subs(a, 3), s=50, c="b") ax.spines['left'].set_position(("data", 0)) ax.spines['bottom'].set_position(("data", 0)) ax.spines['right'].set_visible(False) ax.spines['top'].set_visible(Fa...
python 언어를 적용하여 통계(statistics)와 미적분(Calculus), 선형대수학(Linear Algebra)을 소개합니다. 이 과정에서 빅데이터를 다루기 위해 pytorch를 적용합니다.