.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Math::GSL::ODEIV 3pm" .TH Math::GSL::ODEIV 3pm "2020-11-09" "perl v5.32.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Math::GSL::ODEIV \- functions for solving ordinary differential equation (ODE) initial value problems .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Math::GSL::ODEIV qw /:all/; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Here is a list of all the functions in this module : .IP "\(bu" 4 \&\f(CW\*(C`gsl_odeiv_step_alloc($T, $dim)\*(C'\fR \- This function returns a pointer to a newly allocated instance of a stepping function of type \f(CW$T\fR for a system of \f(CW$dim\fR dimensions.$T must be one of the step type constant above. .IP "\(bu" 4 \&\f(CW\*(C`gsl_odeiv_step_reset($s)\*(C'\fR \- This function resets the stepping function \f(CW$s\fR. It should be used whenever the next use of s will not be a continuation of a previous step. .IP "\(bu" 4 \&\f(CW\*(C`gsl_odeiv_step_free($s)\*(C'\fR \- This function frees all the memory associated with the stepping function \f(CW$s\fR. .IP "\(bu" 4 \&\f(CW\*(C`gsl_odeiv_step_name($s)\*(C'\fR \- This function returns a pointer to the name of the stepping function. .IP "\(bu" 4 \&\f(CW\*(C`gsl_odeiv_step_order($s)\*(C'\fR \- This function returns the order of the stepping function on the previous step. This order can vary if the stepping function itself is adaptive. .IP "\(bu" 4 \&\f(CW\*(C`gsl_odeiv_step_apply \*(C'\fR .IP "\(bu" 4 \&\f(CW\*(C`gsl_odeiv_control_alloc($T)\*(C'\fR \- This function returns a pointer to a newly allocated instance of a control function of type \f(CW$T\fR. This function is only needed for defining new types of control functions. For most purposes the standard control functions described above should be sufficient. \f(CW$T\fR is a gsl_odeiv_control_type. .IP "\(bu" 4 \&\f(CW\*(C`gsl_odeiv_control_init($c, $eps_abs, $eps_rel, $a_y, $a_dydt) \*(C'\fR \- This function initializes the control function c with the parameters eps_abs (absolute error), eps_rel (relative error), a_y (scaling factor for y) and a_dydt (scaling factor for derivatives). .IP "\(bu" 4 \&\f(CW\*(C`gsl_odeiv_control_free \*(C'\fR .IP "\(bu" 4 \&\f(CW\*(C`gsl_odeiv_control_hadjust \*(C'\fR .IP "\(bu" 4 \&\f(CW\*(C`gsl_odeiv_control_name \*(C'\fR .IP "\(bu" 4 \&\f(CW\*(C`gsl_odeiv_control_standard_new($eps_abs, $eps_rel, $a_y, $a_dydt)\*(C'\fR \- The standard control object is a four parameter heuristic based on absolute and relative errors \f(CW$eps_abs\fR and \f(CW$eps_rel\fR, and scaling factors \f(CW$a_y\fR and \f(CW$a_dydt\fR for the system state y(t) and derivatives y'(t) respectively. The step-size adjustment procedure for this method begins by computing the desired error level D_i for each component, D_i = eps_abs + eps_rel * (a_y |y_i| + a_dydt h |y'_i|) and comparing it with the observed error E_i = |yerr_i|. If the observed error E exceeds the desired error level D by more than 10% for any component then the method reduces the step-size by an appropriate factor, h_new = h_old * S * (E/D)^(\-1/q) where q is the consistency order of the method (e.g. q=4 for 4(5) embedded \s-1RK\s0), and S is a safety factor of 0.9. The ratio E/D is taken to be the maximum of the ratios E_i/D_i. If the observed error E is less than 50% of the desired error level D for the maximum ratio E_i/D_i then the algorithm takes the opportunity to increase the step-size to bring the error in line with the desired level, h_new = h_old * S * (E/D)^(\-1/(q+1)) This encompasses all the standard error scaling methods. To avoid uncontrolled changes in the stepsize, the overall scaling factor is limited to the range 1/5 to 5. .IP "\(bu" 4 \&\f(CW\*(C`gsl_odeiv_control_y_new($eps_abs, $eps_rel)\*(C'\fR \- This function creates a new control object which will keep the local error on each step within an absolute error of \f(CW$eps_abs\fR and relative error of \f(CW$eps_rel\fR with respect to the solution y_i(t). This is equivalent to the standard control object with a_y=1 and a_dydt=0. .IP "\(bu" 4 \&\f(CW\*(C`gsl_odeiv_control_yp_new($eps_abs, $eps_rel)\*(C'\fR \- This function creates a new control object which will keep the local error on each step within an absolute error of \f(CW$eps_abs\fR and relative error of \f(CW$eps_rel\fR with respect to the derivatives of the solution y'_i(t). This is equivalent to the standard control object with a_y=0 and a_dydt=1. .IP "\(bu" 4 \&\f(CW\*(C`gsl_odeiv_control_scaled_new($eps_abs, $eps_rel, $a_y, $a_dydt, $scale_abs, $dim) \*(C'\fR \- This function creates a new control object which uses the same algorithm as gsl_odeiv_control_standard_new but with an absolute error which is scaled for each component by the array reference \f(CW$scale_abs\fR. The formula for D_i for this control object is, D_i = eps_abs * s_i + eps_rel * (a_y |y_i| + a_dydt h |y'_i|) where s_i is the i\-th component of the array scale_abs. The same error control heuristic is used by the Matlab ode suite. .IP "\(bu" 4 \&\f(CW\*(C`gsl_odeiv_evolve_alloc($dim)\*(C'\fR \- This function returns a pointer to a newly allocated instance of an evolution function for a system of \f(CW$dim\fR dimensions. .IP "\(bu" 4 \&\f(CW\*(C`gsl_odeiv_evolve_apply($e, $c, $step, $dydt, \e$t, $t1, \e$h, $y)\*(C'\fR \- This function advances the system ($e, \f(CW$dydt\fR) from time \f(CW$t\fR and position \f(CW$y\fR using the stepping function \f(CW$step\fR. The new time and position are stored in \f(CW$t\fR and \f(CW$y\fR on output. The initial step-size is taken as \f(CW$h\fR, but this will be modified using the control function \f(CW$c\fR to achieve the appropriate error bound if necessary. The routine may make several calls to step in order to determine the optimum step-size. If the step-size has been changed the value of \f(CW$h\fR will be modified on output. The maximum time \f(CW$t1\fR is guaranteed not to be exceeded by the time-step. On the final time-step the value of \f(CW$t\fR will be set to \f(CW$t1\fR exactly. .IP "\(bu" 4 \&\f(CW\*(C`gsl_odeiv_evolve_reset($e)\*(C'\fR \- This function resets the evolution function \f(CW$e\fR. It should be used whenever the next use of \f(CW$e\fR will not be a continuation of a previous step. .IP "\(bu" 4 \&\f(CW\*(C`gsl_odeiv_evolve_free($e)\*(C'\fR \- This function frees all the memory associated with the evolution function \f(CW$e\fR. .PP This module also includes the following constants : .IP "\(bu" 4 \&\f(CW$GSL_ODEIV_HADJ_INC\fR .IP "\(bu" 4 \&\f(CW$GSL_ODEIV_HADJ_NIL\fR .IP "\(bu" 4 \&\f(CW$GSL_ODEIV_HADJ_DEC\fR .SS "Step Type" .IX Subsection "Step Type" .IP "\(bu" 4 \&\f(CW$gsl_odeiv_step_rk2\fR \- Embedded Runge-Kutta (2, 3) method. .IP "\(bu" 4 \&\f(CW$gsl_odeiv_step_rk4\fR \- 4th order (classical) Runge-Kutta. The error estimate is obtained by halving the step-size. For more efficient estimate of the error, use the Runge-Kutta-Fehlberg method described below. .IP "\(bu" 4 \&\f(CW$gsl_odeiv_step_rkf45\fR \- Embedded Runge-Kutta-Fehlberg (4, 5) method. This method is a good general-purpose integrator. .IP "\(bu" 4 \&\f(CW$gsl_odeiv_step_rkck\fR \- Embedded Runge-Kutta Cash-Karp (4, 5) method. .IP "\(bu" 4 \&\f(CW$gsl_odeiv_step_rk8pd\fR \- Embedded Runge-Kutta Prince-Dormand (8,9) method. .IP "\(bu" 4 \&\f(CW$gsl_odeiv_step_rk2imp\fR \- Implicit 2nd order Runge-Kutta at Gaussian points. .IP "\(bu" 4 \&\f(CW$gsl_odeiv_step_rk2simp\fR .IP "\(bu" 4 \&\f(CW$gsl_odeiv_step_rk4imp\fR \- Implicit 4th order Runge-Kutta at Gaussian points. .IP "\(bu" 4 \&\f(CW$gsl_odeiv_step_bsimp\fR \- Implicit Bulirsch-Stoer method of Bader and Deuflhard. This algorithm requires the Jacobian. .IP "\(bu" 4 \&\f(CW$gsl_odeiv_step_gear1\fR \- M=1 implicit Gear method. .IP "\(bu" 4 \&\f(CW$gsl_odeiv_step_gear2\fR \- M=2 implicit Gear method. .PP For more information on the functions, we refer you to the \s-1GSL\s0 offcial documentation: .SH "EXAMPLE" .IX Header "EXAMPLE" The example is taken from . .PP .Vb 6 \& use strict; \& use warnings; \& use Math::GSL::Errno qw($GSL_SUCCESS); \& use Math::GSL::ODEIV qw/ :all /; \& use Math::GSL::Matrix qw/:all/; \& use Math::GSL::IEEEUtils qw/ :all /; \& \& sub func { \& my ($t, $y, $dydt, $params) = @_; \& my $mu = $params\->{mu}; \& $dydt\->[0] = $y\->[1]; \& $dydt\->[1] = \-$y\->[0] \- $mu*$y\->[1]*(($y\->[0])**2 \- 1); \& return $GSL_SUCCESS; \& } \& \& sub jac { \& my ($t, $y, $dfdy, $dfdt, $params) = @_; \& \& my $mu = $params\->{mu}; \& my $m = gsl_matrix_view_array($dfdy, 2, 2); \& gsl_matrix_set( $m, 0, 0, 0.0 ); \& gsl_matrix_set( $m, 0, 1, 1.0 ); \& gsl_matrix_set( $m, 1, 0, (\-2.0 * $mu * $y\->[0] * $y\->[1]) \- 1.0 ); \& gsl_matrix_set( $m, 1, 1, \-$mu * (($y\->[0])**2 \- 1.0) ); \& $dfdt\->[0] = 0.0; \& $dfdt\->[1] = 0.0; \& return $GSL_SUCCESS; \& } \& \& my $T = $gsl_odeiv_step_rk8pd; \& my $s = gsl_odeiv_step_alloc($T, 2); \& my $c = gsl_odeiv_control_y_new(1e\-6, 0.0); \& my $e = gsl_odeiv_evolve_alloc(2); \& my $params = { mu => 10 }; \& my $sys = Math::GSL::ODEIV::gsl_odeiv_system\->new(\e&func, \e&jac, 2, $params ); \& my $t = 0.0; \& my $t1 = 100.0; \& my $h = 1e\-6; \& my $y = [ 1.0, 0.0 ]; \& gsl_ieee_env_setup; \& while ($t < $t1) { \& my $status = gsl_odeiv_evolve_apply ($e, $c, $s, $sys, \e$t, $t1, \e$h, $y); \& last if $status != $GSL_SUCCESS; \& printf "%.5e %.5e %.5e\en", $t, $y\->[0], $y\->[1]; \& } \& gsl_odeiv_evolve_free($e); \& gsl_odeiv_control_free($c); \& gsl_odeiv_step_free($s); .Ve .SH "AUTHORS" .IX Header "AUTHORS" Jonathan \*(L"Duke\*(R" Leto and Thierry Moisan .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright (C) 2008\-2020 Jonathan \*(L"Duke\*(R" Leto and Thierry Moisan .PP This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.