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]].
import math
import matplotlib . pyplot as plt
# Initial conditions
y0 = 2.0
# Time step and final time
dt = 1.0 # days
tf = 364 .0 # days
# Empty lists to hold the time and solution
tt = [ ]
yy = [ ]
# Append initial values
tt.append (0.0)
yy . append (y0)
# Parameters of our equation
a = 0.01
omega = 2.0*math.pi/365.0
# Iteration
while tt [−1] <= tf :
r = a*yy[−1]*(1+math . sin(omega*tt[ − 1 ]))
yy.append(yy[−1]+ r*dt)
tt.append (tt[−1]+dt)
plt.figure(1)
plt.plot(tt,yy,'.')
plt.xlabel('Time[days]')
plt.ylabel('Rats[rats]')
plt.title('Euler Solution')
plt.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 12:14, 15 January 2016

A Differential Equation Solving System is an equation solving system that can apply a differential equation solving algorithm to solve a differential equation solving task.

import math import matplotlib . pyplot as plt

  1. Initial conditions

y0 = 2.0

  1. Time step and final time

dt = 1.0 # days tf = 364 .0 # days

  1. Empty lists to hold the time and solution

tt = [ ] yy = [ ]

  1. Append initial values

tt.append (0.0) yy . append (y0)

  1. Parameters of our equation

a = 0.01 omega = 2.0*math.pi/365.0

  1. Iteration

while tt [−1] <= tf : r = a*yy[−1]*(1+math . sin(omega*tt[ − 1 ])) yy.append(yy[−1]+ r*dt) tt.append (tt[−1]+dt) plt.figure(1) plt.plot(tt,yy,'.') plt.xlabel('Time[days]') plt.ylabel('Rats[rats]') plt.title('Euler Solution') plt.show( )