## 2019年8月17日土曜日

### 数学 - Python - 微分積分学 - 微分法 - 曲線とその接線 - 法線の方程式、2次方程式、3次方程式

1. $\begin{array}{l}\frac{\mathrm{dx}}{\mathrm{dt}}=2t\\ \frac{\mathrm{dy}}{\mathrm{dt}}=3-3{t}^{2}=3\left(1-{t}^{2}\right)\end{array}$

よって、求める法線の方程式は、

$\begin{array}{l}x={c}^{2}-3\left(1-{c}^{2}\right)\left(t-c\right)\\ y=3c-{c}^{3}+2c\left(t-c\right)\end{array}$

コード

Python 3

#!/usr/bin/env python3
from sympy import pprint, symbols
from sympy.plotting import plot_parametric

print('4.')

t, c = symbols('t, c')
x = t ** 2
y = 3 * t - t ** 3
x0 = c ** 2 - 3 * (1 - c ** 2) * (t - c)
y0 = 3 * c - c ** 3 + 2 * c * (t - c)
x1 = c ** 2 + 2 * c * (t - c)
y1 = 3 * c - c ** 3 + 3 * (1 - c ** 2) * (t - c)

p = plot_parametric((x, y, (t, -2, 2)),
*[(x3.subs({c: c0}), y3.subs({c: c0}), (t, t1, t2))
for c0, (t1, t2) in [(-1.2, (-2, 0)),
(-1, (-2, 1)),
(-0.5, (-2, 2)),
(0, (-2, 2)),
(2, (1, 2))]
for x3, y3 in [(x0, y0), (x1, y1)]],
show=False)
colors = ['red', 'green', 'blue', 'brown', 'orange',
'purple', 'pink', 'gray', 'skyblue', 'yellow']

for o, color in zip(p, colors):
o.line_color = color

p.show()
p.save('sample4.png')


C:\Users\...>py sample4.py
4.

c:\Users\...>