2019年9月16日月曜日

数学 - Python - 解析学 - 各種の初等関数 - 三角関数(続き)、逆三角関数 - 正弦と余弦、対数関数、微分、帰納法

1. $\begin{array}{l}f\text{'}\left(x\right)=-a·\mathrm{sin}\left(\mathrm{log}x\right)·\frac{1}{x}+b\mathrm{cos}\left(\mathrm{log}x\right)·\frac{1}{x}\\ =\frac{1}{x}\left(-a·\mathrm{sin}\left(\mathrm{log}x\right)+b\mathrm{cos}\left(\mathrm{log}x\right)\right)\\ f\text{'}\text{'}\left(x\right)=\frac{-a·\mathrm{cos}\left(\mathrm{log}x\right)-b\mathrm{sin}\left(\mathrm{log}x\right)+a·\mathrm{sin}\left(\mathrm{log}x\right)-b\mathrm{cos}\left(\mathrm{log}x\right)}{{x}^{2}}\\ =-\frac{1}{{x}^{2}}\left(b\mathrm{sin}\left(\mathrm{log}x\right)+a·\mathrm{cos}\left(\mathrm{log}x\right)-a·\mathrm{sin}\left(\mathrm{log}x\right)+b\mathrm{cos}\left(\mathrm{log}x\right)\right)\end{array}$

よって、

$\begin{array}{l}{x}^{2}f\text{'}\text{'}\left(x\right)+xf\text{'}\left(x\right)+f\left(x\right)\\ =-b\mathrm{sin}\left(\mathrm{log}x\right)-a·\mathrm{cos}\left(\mathrm{log}x\right)+a·\mathrm{sin}\left(\mathrm{log}x\right)-b\mathrm{cos}\left(\mathrm{log}x\right)\\ -a·\mathrm{sin}\left(\mathrm{log}x\right)+b\mathrm{cos}\left(\mathrm{log}x\right)\\ +a·\mathrm{cos}\left(\mathrm{log}x\right)+b\mathrm{sin}\left(\left(ogx\right)\\ =0\end{array}$

2. $\begin{array}{l}{f}^{\left(n\right)}\left(x\right)\\ =\frac{d}{\mathrm{dx}}{f}^{\left(n-1\right)}\left(x\right)\\ =\frac{d}{\mathrm{dx}}\left(\frac{1}{{x}^{n-1}}\left({a}_{n-1}\mathrm{cos}\left(\mathrm{log}x\right)+{b}_{n-1}\mathrm{sin}\left(\mathrm{log}x\right)\right)\right)\\ =\frac{\left(-{a}_{n-1}\mathrm{sin}\left(\mathrm{log}x\right)\frac{1}{x}+{b}_{n-1}\mathrm{cos}\left(\mathrm{log}x\right)\frac{1}{x}\right){x}^{n-1}}{{x}^{2\left(n-1\right)}}\\ -\frac{\left({a}_{n-1}\mathrm{cos}\left(\mathrm{log}x\right)+{b}_{n-1}\mathrm{sin}\left(\mathrm{log}x\right)\right)\left(n-1\right){x}^{n-2}}{{x}^{2\left(n-1\right)}}\\ =\frac{1}{{x}^{n}}\left(\left(-{a}_{n-1}+{b}_{n-1}\right)\mathrm{cos}\left(\mathrm{log}x\right)+\left(-{a}_{n-1}-{b}_{n-1}\right)\mathrm{sin}\left(\mathrm{log}x\right)\right)\\ {x}^{n}{f}^{\left(n\right)}\left(x\right)=\left(-{a}_{n-1}+{b}_{n-1}\right)\mathrm{cos}\left(\mathrm{log}x\right)+\left(-{a}_{n-1}-{b}_{n-1}\right)\mathrm{sin}\left(\mathrm{log}x\right)\end{array}$

よって帰納法により成り立つ。

（証明終）

コード

Python 3

#!/usr/bin/env python3
from sympy import pprint, symbols, sin, cos, log, Derivative, plot

print('5.')

print('(a)')
x, a, b = symbols('x, a, b')
f = a * cos(log(x)) + b * sin(log(x))
d1 = Derivative(f, x, 1).doit()
d2 = Derivative(f, x, 2).doit()
eq = x ** 2 * d2 + x * d1 + f

for o in [eq, eq.expand()]:
pprint(o)
print()

print('(b)')
n = symbols('n', integer=True, nonnegative=True)
for n in range(5):
g = x ** n * Derivative(f, x, n)
for o in [g, g.doit()]:
pprint(o)
print()

p = plot(*[Derivative(f.subs({a: 2, b: 3}), x, n).doit() for n in range(5)],
(x, 0.1, 10.1),
ylim=(-5, 5),
show=False,
legend=True)

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('sample5.png')


C:\Users\...>py sample5.py
5.
(a)
⎛  a⋅sin(log(x))   b⋅cos(log(x))⎞
a⋅sin(log(x)) - b⋅cos(log(x)) + x⋅⎜- ───────────── + ─────────────⎟
⎝        x               x      ⎠

0

(b)
a⋅cos(log(x)) + b⋅sin(log(x))

a⋅cos(log(x)) + b⋅sin(log(x))

∂
x⋅──(a⋅cos(log(x)) + b⋅sin(log(x)))
∂x

⎛  a⋅sin(log(x))   b⋅cos(log(x))⎞
x⋅⎜- ───────────── + ─────────────⎟
⎝        x               x      ⎠

2
2  ∂
x ⋅───(a⋅cos(log(x)) + b⋅sin(log(x)))
2
∂x

a⋅sin(log(x)) - a⋅cos(log(x)) - b⋅sin(log(x)) - b⋅cos(log(x))

3
3  ∂
x ⋅───(a⋅cos(log(x)) + b⋅sin(log(x)))
3
∂x

-a⋅sin(log(x)) + 3⋅a⋅cos(log(x)) + 3⋅b⋅sin(log(x)) + b⋅cos(log(x))

4
4  ∂
x ⋅───(a⋅cos(log(x)) + b⋅sin(log(x)))
4
∂x

-10⋅a⋅cos(log(x)) - 10⋅b⋅sin(log(x))

C:\Users\...>