ODE solver - Using Lie series and FFT
Contents
Overview
- [Still being edited by Beau]
- An Ordinary Differential Equation is a method of describing the behaviour of things such dynamical systems.
- This ODE Solver uses Lie Series and a Fourier Transform (FFT) as a method of calculating the behaviour of the system.
• In mathematics, an Ordinary Differential Equation (or ODE) is a relation that contains functions of only one independent variable, and one or more of its derivatives with respect to that variable.
- • A simple example is Newton's second law of motion. In general, the force F depends upon the position of the particle x(t) at time t, and thus the unknown function x(t) appears on both sides of the differential equation, as is indicated in the notation F(x(t)).
- • In the case where the equation is linear, it can be solved by analytical methods. Unfortunately, most of the interesting differential equations are non-linear and, with a few exceptions, cannot be solved exactly. Approximate solutions are arrived at using computer approximations
APLX ODE Solver Code
This is as given in Robert J. Korsan's article in Apl Congress 1973, p 267, with just a few comments added.
lie
lie;Z;A;Y0;N;EPS ⍝ ⍝ Apl Congress 1973, p 267. Robert J. Korsan. ⍝ 'Solves ODEs using Lie series' ' ' ' Equation is 1 <-> ((D Y) T) = fn Y T' ' ' ' with initial condition 1 <-> Y0 = Y T ← 0 ' ' ' 'Enter No. of terms : ' N←⎕ ' ' 'Enter initial condition Y0 : ' Y0←⎕ EPS←1E¯10 Z←fn 2 1∘.○○2×(¯1+⍳128)÷128 A←,¯1 0↓¯1 0⌽⌽fft Z A←64↑A÷128 A←A×EPS<|A A←⌽A←(¯1+(A>0)⍳1)↓A←⌽A ' ' ' the coefficients of the Lie series are : ' R←Y0 calcfj A R←R÷!⍳⍴R 'I3,X2,E20.8' ⎕FMT(¯1+⍳⍴R),[1.5]R←Y0,R
calcfj
R←Y0 calcfj A;ALF;J;T ⍝ ⍝ Apl Congress 1973, p 267. Robert J. Korsan. ⍝ Evaluator for Lie series' ⍝ R←Y0⊥⌽A J←2 ALF←1↓Aׯ1+⍳⍴A lp:ALF←+⌿(1-⍳⍴A)⌽((⍴A),¯1+(⍴A)+⍴ALF)↑A∘.×ALF T←Y0⊥⌽ALF ALF←1↓ALFׯ1+⍳⍴ALF R←R,T →(N<J←J+1)⍴0 →lp
fft
fn
- This describes the system under study.
- [examples will follow - Beau]
Variants
I also have this code as APL\11 or aplc plain text - contact me if you need these : J.B.W.Webber@kent.ac.uk
CategoryScience CategoryMaths CategoryAlgorithm CategoryAplX
APL Wiki