## 2019年9月14日土曜日

### 数学 - Python - 解析学 - 各種の初等関数 - 三角関数(続き)、逆三角関数 - 正弦と余弦、指数関数、微分、等式

1. $\begin{array}{l}\frac{d}{\mathrm{dx}}\left(A{e}^{ax}\mathrm{cos}\left(bx\right)+B{e}^{ax}\mathrm{sin}\left(bx\right)\right)\\ =a{e}^{ax}\left(A\mathrm{cos}\left(bx\right)+B\mathrm{sin}\left(bx\right)\right)\\ +{e}^{ax}\left(-Ab\mathrm{sin}\left(bx\right)+Bb\mathrm{cos}\left(bx\right)\right)\\ ={e}^{ax}\left(\left(Ba-Ab\right)\mathrm{sin}\left(bx\right)+\left(Aa+Bb\right)\mathrm{cos}\left(bx\right)\right)\\ \left\{\begin{array}{l}-Ab+Ba=0\\ Aa+Bb=1\end{array}\\ \left\{\begin{array}{l}-Aab+B{a}^{2}=0\\ Aab+B{b}^{2}=b\end{array}\\ B\left({a}^{2}+{b}^{2}\right)=b\\ B=\frac{b}{{a}^{2}+{b}^{2}}\\ -Ab+\frac{ab}{{a}^{2}+{b}^{2}}=0\\ A=\frac{a}{{a}^{2}+{b}^{2}}\end{array}$

コード

Python 3

#!/usr/bin/env python3
from sympy import pprint, symbols, product, sin, cos, exp, solve, Derivative

print('3.')

a, b = symbols('a, b', nonzero=True)
A, B, x = symbols('A, B, x')
f = A * exp(a * x) * cos(b * x) + B * exp(a * x) * sin(b * x)
g = exp(a * x) * cos(b * x)
df = Derivative(f, x, 1).doit()

for o in [df, solve(df - g, A, B, dict=True)]:
pprint(o)
print()

d = {A: a / (a ** 2 + b ** 2), B: b / (a ** 2 + b ** 2)}
left = df.subs(d)
right = g.subs(d)

for o in [left, right, left.factor() == right.factor()]:
pprint(o)
print()


C:\Users\...>py sample3.py
3.
a⋅x                 a⋅x                 a⋅x                 a⋅x
A⋅a⋅ℯ   ⋅cos(b⋅x) - A⋅b⋅ℯ   ⋅sin(b⋅x) + B⋅a⋅ℯ   ⋅sin(b⋅x) + B⋅b⋅ℯ   ⋅cos(b⋅x)

⎡⎧   -B⋅a⋅sin(b⋅x) - B⋅b⋅cos(b⋅x) + cos(b⋅x)⎫⎤
⎢⎨A: ───────────────────────────────────────⎬⎥
⎣⎩           a⋅cos(b⋅x) - b⋅sin(b⋅x)        ⎭⎦

2  a⋅x             2  a⋅x
a ⋅ℯ   ⋅cos(b⋅x)   b ⋅ℯ   ⋅cos(b⋅x)
──────────────── + ────────────────
2    2             2    2
a  + b             a  + b

a⋅x
ℯ   ⋅cos(b⋅x)

True

C:\Users\...>