Here, I would like to install sympy in Python and solve simultaneous ordinary differential equations.
https://docs.sympy.org/latest/index.html
First, I will write an example of the differentiation of a basic function using sympy.
python
import sympy as sym
x = sym.Symbol('x')
h = x**3 + 3*x + 1
h.diff(x,1)
Let's solve the simultaneous first-order ordinary differential equations.
python
x = sym.Symbol('x')
f = sym.Function('f')
g = sym.Function('g')
h = sym.Function('h')
eq1 = sym.Eq(f(x).diff(x,1),g(x)+h(x))
eq2 = sym.Eq(g(x).diff(x,1),h(x)+f(x))
eq3 = sym.Eq(h(x).diff(x,1),f(x)+g(x))
sym.dsolve([eq1, eq2, eq3])
Let's get along and solve the PDE.
The partial differential calculation itself is possible.
python
x = sym.Symbol('x')
y = sym.Symbol('y')
u = x**2 - y**2
u.diff(x,1)
However, even if I try to do the following calculation, the answer does not come out well.
python
x = sym.Symbol('x')
y = sym.Symbol('y')
u = x**2 - y**2
v = sym.Function('v')
eq1 = sym.Eq(u.diff(x,1), v(x,y).diff(y,1))
eq2 = sym.Eq(u.diff(y,1), -v(x,y).diff(x,1) )
sym.dsolve([eq1, eq2])
Hmm ... It corresponds to the equivalent of the second year of university, but it is not possible to correspond a little when it is equivalent to the third grade or higher. (; ^ _ ^ A
Recommended Posts