## 2019年9月18日水曜日

### 数学 - Python - 微分積分学 - 微分法 - 曲線、平方根、逆数、接線、法線、垂線、接線影、法線影、長さ

1. $y\text{'}=\frac{\sqrt{2p}}{2\sqrt{x}}$

接線影、法線影、接線の長さ、法線の長さはそれぞれ、

$\begin{array}{l}\left|\frac{y}{y\text{'}}\right|\\ =\sqrt{2px}·\frac{2\sqrt{x}}{\sqrt{2p}}\\ =2\left|x\right|\\ \left|yy\text{'}\right|\\ =\frac{\sqrt{2p}}{2\sqrt{x}}·\sqrt{2px}\\ =p\\ \left|\frac{y}{y\text{'}}\sqrt{1+{\left(y\text{'}\right)}^{2}}\right|\\ =2\left|x\right|\sqrt{1+\frac{2p}{4x}}\\ =\sqrt{4{x}^{2}+2px}\\ \left|y\sqrt{1+{\left(y\text{'}\right)}^{2}}\right|\\ =\sqrt{2px}·\sqrt{1+\frac{p}{2x}}\\ =\sqrt{2px+{p}^{2}}\end{array}$

2. $\begin{array}{l}y=\frac{{C}^{2}}{x}\\ y\text{'}=-\frac{{C}^{2}}{{x}^{2}}\\ \left|\frac{y}{y\text{'}}\right|\\ =\left|\frac{{C}^{2}}{x}·\left(-\frac{{x}^{2}}{{C}^{2}}\right)\right|\\ =\left|x\right|\\ \left|yy\text{'}\right|\\ =\left|\frac{{C}^{2}}{x}·\left(-\frac{{C}^{2}}{{x}^{2}}\right)\right|\\ =\frac{{C}^{4}}{\left|{x}^{3}\right|}\\ \left|\frac{y}{y\text{'}}\sqrt{1+{\left(y\text{'}\right)}^{2}}\right|\\ =\left|x\right|\sqrt{1+\frac{{C}^{4}}{{x}^{4}}}\\ =\sqrt{{x}^{2}+\frac{{C}^{4}}{{x}^{2}}}\\ \left|y\sqrt{1+{\left(y\text{'}\right)}^{2}}\right|\\ =\frac{{C}^{2}}{\left|x\right|}\sqrt{1+\frac{{C}^{4}}{{x}^{4}}}\end{array}$

コード

Python 3

#!/usr/bin/env python3
from sympy import pprint, symbols, Derivative, plot, solve, sqrt

x, C = symbols('x, C')
p = symbols('p', positive=True)

f = sqrt(2 * p * x)
g = C ** 2 / x

gs = []
ls = []
px = 1
p0 = 2
C0 = 3
s = {p: 2, C: 3}
for i, h in enumerate([f, g], 28):
print(f'({i})')
m = Derivative(h, x, 1).doit()
gs.append(m.subs({x: px}) * (x - px) + h.subs({x: px}))
ls.append(-1 / m.subs({x: px}) * (x - px) + h.subs({x: px}))
d = Derivative(h, x, 1).doit()
for o in [abs(h / d), abs(h * d), abs(h / d * sqrt(1 + d ** 2)),
abs(h * sqrt(1 + d ** 2))]:
pprint(o.simplify())
print()

fs = [f, g] + gs + ls
p = plot(*[(h.subs(s), (x, x1, x2))
for h in fs
for x1, x2 in [(-10, -0.1), (0.1, 10)]],
ylim=(-10, 10),
legend=True, 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('sample28.png')


C:\Users\...>py sample28.py
(28)
2⋅│x│

p

│      _______│
│     ╱ p     │
√2⋅│x⋅  ╱  ─ + 2 │
│  ╲╱   x     │

│       _______│
│      ╱ p     │
√p⋅│√x⋅  ╱  ─ + 2 │
│   ╲╱   x     │

(29)
│x│

│ 4│
│C │
│──│
│ 3│
│x │

│        ________│
│       ╱  4     │
│      ╱  C      │
│x⋅   ╱   ── + 1 │
│    ╱     4     │
│  ╲╱     x      │

│         ________│
│        ╱  4     │
│ 2     ╱  C      │
│C ⋅   ╱   ── + 1 │
│     ╱     4     │
│   ╲╱     x      │
│─────────────────│
│        x        │

c:\Users\...>