iconEuler Reference

Differential Equations

Numerical solvers for differential equations.

The lsoda method should be the method of choice. It is a very efficient adaptive method for ordinary diffential equations, which takes also care of stiff cases. But the Heun and Runge methods are available too, including an adaptive Runge method, which can be used for adaptive integration.

Vector fields can be plotted using the vectorfield function in plot2d.

There are also the interval algorithms mxmidlg and mxmiint.

function heun (f:string, t:real vector, y0:real vector)

  Solves the differential equation y'=f(x,y) at x=t with y(t[1])=y0.
  
  This function works also for systems of n differential equations.
  
  f must be a function with two parameters f(x,y), where x is scalar,
  and y is scalar or a 1xn row vector in the case of a system of
  differential equations. f must return a scalar, or a 1xn row vector
  respectively. Additional parameters for "heun" after a semicolon
  are passed to a function f. Alternatively, f can be an expression
  in x and y.
  
  y0 is the initial value y(t[1]), a scalar, or a 1xn row vector.
  t is the 1xm row vector of points, where the differential equation
  will be solved.
  
  f : function or expression in x and y
  t : row vector of points, where y(t) should be computed
  y0 : initial value, scalar or row vector
  
  The function returns a 1xm row vector of y, or a nxm matrix in the
  case of a system of n equations.
  
  See: 
runge (Differential Equations)
function runge (f:string, t:real vector, y0:real, ..
    steps:index=1)

  Solves the differential equation y'=f(x,y) at x=t with y(t[1])=y0.
  
  This function works also for systems of n differential equations.
  
  f must be a function with two parameters f(x,y), where x is scalar,
  and y is scalar or a vector in the case of a system of differential
  equations. f must return a scalar, or a vector respectively.
  Additional parameters for "runge" after a semicolon are passed to a
  function f. Alternatively, f can be an expression in x and y.
  
  y0 is the initial value y(t[1]), a scalar, or a 1xn row vector.
  t is the 1xm vector of points, where the differential equation will
  be solved.
  
  steps are optional intermediate steps between the t[i]. This
  parameter allows to take extra steps, which will not be stored into
  the solution.
  
  Note that f can work with row or column vectors, but the intial
  value must be of this form too. The return matrix will always
  consist of column vectors.
  
  f : function or expression in x and y
  t : row vector of points, where y(t) should be computed
  y0 : initial value, scalar or row vector
  steps : additional steps between the points of x
  
  Returns a row vector y(t[i]) for the elements of t. Im case of a
  system, the function returns a matrix with columns y(t[i]).
  
  See: 
heun (Differential Equations),
adaptiverunge (Differential Equations)
function adaptiverunge (f:string, x:real vector, y0:real, ..
    eps=epsilon(), initialstep=0.1)

  Solves the differential equation y'=f(x,y) at x=t with y(t[1])=y0
  adaptively.
  
  The function uses an adaptive step size between x[i] and x[i+1] to
  guarantee an accuracy eps. By default the accuracy is the default
  epsilon, but eps=... can be specified as an extra parameter.
  
  This function works also for systems of n differential equations.
  
  f must be a function with two parameters f(x,y), where x is scalar,
  and y is scalar or a vector in the case of a system of differential
  equations. f must return a scalar, or a vector respectively.
  Additional parameters for "adaptiverunge" after a semicolon are
  passed to a function f. Alternatively, f can be an expression in x
  and y.
  
  y0 is the initial value y(t[1]), a scalar or a vector. t is the 1xm
  vector of points, where the differential equation will be solved.
  
  Note that f can work with row or column vectors, but the intial
  value must be of this form too. The return matrix will always
  consist of column vectors.
  
  f : function or expression in x and y
  t : row vector of points, where y(t) should be computed
  y0 : initial value, scalar or row vector
  eps : accuracy of the adaptive method
  initialstep : initial step size
  
  Returns a row vector y(t[i]) for the elements of t. Im case of a
  system, the function returns a matrix with columns y(t[i]).
  
  See: 
heun (Differential Equations)
function ode (f:string, t:real vector, y:real, ..
    eps:real=epsilon(), warning:integer=false, reset:integer=false)

  Solves the differential equation y'=f(x,y) at x=t with y(t[1])=y0.
  
  This function works also for systems of n differential equations.
  The algorithm used is the LSODA algorithm for stiff equations.
  This algorithm switches between stiff and normal case autmatically.
  
  The LSODA algorithm is based on work by Linda R. Petzold  and
  Alan C. Hindmarsh, Livermore National Laboratory. The Euler version
  is based on a C source by Heng Li, MIT.
  
  f must be a function with two parameters f(x,y), where x is scalar,
  and y is scalar or a vector in the case of a system of differential
  equations. f must return a scalar, or a vector respectively.
  Additional parameters for "lsoda" after a semicolon are passed to a
  function f. Alternatively, f can be an expression in x and y.
  
  This is an adaptive algorithm. But for some functions, it is
  necessary to add intermediate points, especially if the function is
  close to 0 over wide subintervals. Otherwise, it has been observed
  that the algorithm fails. If you are sure that the problem does not
  fall under the problematic category, you can leave reset=false, which
  will interpolate intermediate points instead of resetting the
  algorithm every time. This is a huge benefit in terms of function
  evaluations. By default, reset is false.
  
  y0 is the initial value y(t[1]), a scalar, or a 1xn row vector.
  t is the 1xm vector of points, where the differential equation will
  be solved.
  
  Note that f can work with row or column vectors, but the intial
  value must be of this form too. The return matrix will always
  consist of column vectors.
  
  f : function or expression in x and y
  t : row vector of points, where y(t) should be computed
  y0 : initial value, scalar or row vector
  warning : toggles warnings from lsoda (but not errors)
  reset : reset the integration between iterations
  
  Returns a row vector y(t[i]) for the elements of t. Im case of a
  system, the function returns a matrix with columns y(t[i]).
  
  See: 
heun (Differential Equations),
runge (Differential Equations),
adaptiverunge (Differential Equations),
lsoda (Differential Equations)
function lsoda (f:string, t:real vector, y:real, ..
    eps:real=epsilon(), warning:integer=true, reset:integer=false)

  Solves the differential equation y'=f(x,y) at x=t with y(t[1])=y0.
  
  Alias to ode. See the documentation there.
  
  See: 
ode (Differential Equations)

Adaptive Integration

function adaptiveint (f:string, a:real scalar, b:real scalar, ..
    eps=epsilon(), steps=10)

  Returns the integral from a to b with the adaptive Runge method.
  
  f is an expression in x, which must not contain y, or a function
  in x. Make sure, that f is computed at each point with relative
  error eps or less. Additional parameters after a semicolon are
  passed to a function f.
  
  f : function or expression in x
  a,b : interval bounds
  eps : accuracy of the adaptive process
  steps : hint for a good step size
  
  See: 
adaptiverunge (Differential Equations),
integrate (Differential Equations),
integrate (Maxima Documentation)
function adaptiveintlsoda (f:string, a:real scalar, b:real scalar, ..
    eps=epsilon(), steps=10)

  Returns the integral from a to b with the adaptive Runge method.
  
  f is an expression in x, which must not contain y, or a function
  in x. Make sure, that f is computed at each point with relative
  error eps or less. Additional parameters after a semicolon are
  passed to a function f.
  
  f : function or expression in x
  a,b : interval bounds
  eps : accuracy of the adaptive process
  steps : hint for a good step size
  
  See: 
adaptiverunge (Differential Equations),
integrate (Differential Equations),
integrate (Maxima Documentation)
function integrate (f:string, a:real scalar, b:real scalar, ..
    eps=epsilon(), steps=10, method=0)

  Integrates f from a to b with the adaptive Runge method.
  
  Calls an adaptivintergrate method, depending on the lsoda
  parameter. The default is the adaptive Runge method. Note, that the
  fastest algorithm is still the gauss algorithm, which is the method
  of choice.
  
  method : 0=gauss, 1=adaptive Runge, 2=adaptive lsoda
  
  See: 
adaptiveint (Differential Equations),
adaptiveintlsoda (Differential Equations),
mxmintegrate (Maxima Functions for Euler),
mxmiint (Maxima Functions for Euler),
gauss (Gauss Qudrature)

Documentation Homepage