Solver:
Filter:
MathLib/Classes (extension) | Math | Libraries > MathLib > Solvers

Solver
ExtensionExtension

numerical solver of systems of Ordinary Differential Equations of any order

Description

Solver is the base class to inherit from to implement numerical solving methods for ODEs.

Part of MathLib, a diverse library of mathematical functions.

WARNING: This class can be quite cpu intensive and with small dt values can completly freeze supercollider. ODE's of higher order are solved by converting them to systems of equations of the first order.

ODEs of the first order take the form:

y' = F(t,y)

where F:RxR -> R and y = y(t) and y' the derivative of f.

Systems of equations take the form:

dy1/dt = F1(t,y1) ... dyn/dt = Fn(t,yn)

or in vector form:

DY = F^(t,Y)

where F^ = { F1,...,Fn}, Y = { Y1,...,Yn}, and DY is the jacobian matrix of Y.

ODEs of order N take the form:

y = F(t,y,dy/dt,...,dNy/dtN)

and Systems of M equation of order N take the form;

dNy1/dtN = F1(t,y,dy1/dt,...,dN-1y1/dtN-1) ... dNyM/dtN = FM(t,y,dyM/dt,...,dN-1yM/dtN-1)

or in vector form

DY = F^(t,Y,DY,...,DNY)

Class Methods

.new

Create a solver for a one dimensional equation or system of equations.

Arguments:

f

see -f below

dt

calculation time step in seconds

t

initial time

y

initial position: a number or array of numbers

.newHO

Create a solver for a higher dimensional equation or system of equations.

Arguments:

f

see -f below

dt

calculation time step in seconds

t

initial time

y

initial position: a number or array of numbers

Instance Methods

.order

Set or return the order of the ODE

.f

f is the function F defining the equation DY = F^(t,Y,DY,...,DNY), and can take the following forms:

D ODE{ |t,y| ... }
System of 1D ODEs[{ |t,y| ... },...,{ |t,y| ... }]
N-order ODE{ |t,y,dy,..., dN-1y| ... }
System of M, N-order ODEs[{ |t,y,dy1,..., dN-1y1,...,dyM,..., dN-1yM| ... } ,...,{ |t,y,dy1,..., dN-1y1,...,dyM,..., dN-1yM| ... }]

.dt

Set or return calculation time step in seconds

.t

Set or return time in seconds

.y

It can take the following forms:

1D ODEy
System of 1D ODEs[y1,...,yn]
N-order ODE[y,dy,..., dN-1y]
System of M, N-order ODEs[[y1,dy1,..., dN-1y1],...,[yM,dy1,..., dN-1yM]]

The value can be reset and the calculation will continue from there.

.next

Get the next value from the solver.

In general this will be: [[y1,y'1,...,y1^(n-1)],...,[yM,y'M,...,yM^(n-1)]]

Examples

NOTE: For the gui examples the ixiViews and wslib quarks are needed.

First order ODE

Second order ODE

System of second order ODE

Chaotic pendulum

Authors

Miguel Negro, 2009.