Browse Source

symbolic ODE and series

master
commit
10cdca6bd2
4 changed files with 31 additions and 0 deletions
  1. +2
    -0
      readme.md
  2. +10
    -0
      scripts/program-02a.py
  3. +10
    -0
      scripts/program-02b.py
  4. +9
    -0
      scripts/program-02c.py

+ 2
- 0
readme.md View File

@ -0,0 +1,2 @@
# Dynamical systems examples Lynch
Repository for examples related with book Dynamical system with applications using Python by Stephen Lynch.

+ 10
- 0
scripts/program-02a.py View File

@ -0,0 +1,10 @@
# Program 02a: A simple separable ODE. See Example 1.
from sympy import dsolve, Eq, Function, symbols, pprint
t = symbols('t')
x = symbols('x', cls=Function)
dxdt = x(t).diff(t)
de = Eq(dxdt, -t/x(t))
print('Program 02a:\n')
pprint(de)
sol = dsolve(de, x(t))
pprint(sol)

+ 10
- 0
scripts/program-02b.py View File

@ -0,0 +1,10 @@
# Program 02b: The logistic equation; example 4-ch2.
from sympy import dsolve, Eq, Function, symbols, pprint
t, b, d = symbols('t beta sigma')
P = symbols('P', cls=Function)
dPdt = P(t).diff(t)
de = Eq(dPdt, P(t)*(b-d*P(t)))
print('program 02b:\n')
pprint(de)
sol = dsolve(de, P(t))
pprint(sol)

+ 9
- 0
scripts/program-02c.py View File

@ -0,0 +1,9 @@
# Program 02c: Power series solution first order ODE; exa 7 chp 2
from sympy import dsolve, Function, pprint
from sympy.abc import t
x = Function('x')
dxdt = x(t).diff(t)
ode = dxdt+t*x(t)-t**3
sol = dsolve(ode, hint='1st_power_series', n=8, ics={x(0): 1})
print('Solution:\n')
pprint(sol)

Loading…
Cancel
Save