Differential Equation Solving System: Difference between revisions

From GM-RKB
Jump to navigation Jump to search
No edit summary
No edit summary
Line 3: Line 3:
* <B>Example(s):</B>
* <B>Example(s):</B>
** [[Taylor Series Method System]].
** [[Taylor Series Method System]].
** [[Euler Method System]].
** <p>[[Euler Method System]].
import math
import math
import matplotlib . pyplot as plt
import matplotlib.pyplot as plt
# Initial conditions
# Initial conditions
y0 = 2.0
y0 = 2.0
Line 30: Line 30:
plt.ylabel('Rats[rats]')
plt.ylabel('Rats[rats]')
plt.title('Euler Solution')
plt.title('Euler Solution')
plt.show( )
plt.show( )</p>
** [[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:17, 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( )