Differential Equation Solving System: Difference between revisions

From GM-RKB
Jump to navigation Jump to search
No edit summary
No edit summary
Line 4: Line 4:
** [[Taylor Series Method System]].
** [[Taylor Series Method System]].
** [[Euler Method System]].
** [[Euler Method System]].
Python Implementation in [[Euler Solver]]
import math\\
import ma t p lo t lib . p y p lo t a s p l t
# I n i t i a l c o n d i t i o n s
y0 = 2 .0
# Time s t e p and f i n a l t i me
dt = 1 .0 # days
t f = 3 6 4 .0 # days
# Empty l i s t s t o h o ld t h e t i me and s o l u t i o n
t t = [ ]
yy = [ ]
# Append i n i t i a l v a l u e s
t t . append ( 0 . 0 )
yy . append ( y0 )
# Paramet ers o f our e q u a t i o n
a = 0 .0 1
omega = 2 .0 *math . p i / 3 6 5 .0
# I t e r a t i o n
while t t [ − 1] < = t f :
r = a * yy [ − 1] * (1+math . s i n ( omega *t t [ − 1 ]) )
yy . append ( yy[ −1]+ r *dt )
t t . append ( t t [ −1]+ dt )
p l t . f i g u r e ( 1 )
p l t . p lo t ( t t , yy , '. ')
p l t . x l a b e l ( 'Time [ days ] ')
p l t . y l a b e l ( 'Rats [ r a t s ] ')
p l t . t i t l e ( 'Euler S o lu t io n ')
p l t . show ( )
** [[Runge-Kutta Method System]], that applies a [[Runge-Kutta algorithm]].
** [[Runge-Kutta Method System]], that applies a [[Runge-Kutta algorithm]].
** [[Predictor-Corrector Method System]].
** [[Predictor-Corrector Method System]].

Revision as of 13:36, 14 January 2016