Mercurial > hg > octave-nkf
annotate doc/interpreter/diffeq.txi @ 15879:f69530e3600d
make docstrings for __java_init__ and __java_exit__ available unconditionally
* ov-java.cc (F__java_init__, F__java_exit__): Move function
definitions outside of HAVE_JAVA conditional.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 02 Jan 2013 19:18:15 -0500 |
parents | c3fd61c59e9c |
children | b028df1b1e81 |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
12578
diff
changeset
|
1 @c Copyright (C) 1996-2012 John W. Eaton |
7018 | 2 @c |
3 @c This file is part of Octave. | |
4 @c | |
5 @c Octave is free software; you can redistribute it and/or modify it | |
6 @c under the terms of the GNU General Public License as published by the | |
7 @c Free Software Foundation; either version 3 of the License, or (at | |
8 @c your option) any later version. | |
9 @c | |
10 @c Octave is distributed in the hope that it will be useful, but WITHOUT | |
11 @c ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
12 @c FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
13 @c for more details. | |
14 @c | |
15 @c You should have received a copy of the GNU General Public License | |
16 @c along with Octave; see the file COPYING. If not, see | |
17 @c <http://www.gnu.org/licenses/>. | |
3294 | 18 |
4167 | 19 @node Differential Equations |
3294 | 20 @chapter Differential Equations |
21 | |
6700 | 22 Octave has built-in functions for solving ordinary differential equations, |
23 and differential-algebraic equations. | |
8828 | 24 All solvers are based on reliable ODE routines written in Fortran. |
3294 | 25 |
26 @menu | |
27 * Ordinary Differential Equations:: | |
28 * Differential-Algebraic Equations:: | |
29 @end menu | |
30 | |
12578
f5a780d675a1
Clean up operator and function indices in documentation.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
31 @cindex differential equations |
3294 | 32 @cindex ODE |
33 @cindex DAE | |
34 | |
4167 | 35 @node Ordinary Differential Equations |
3294 | 36 @section Ordinary Differential Equations |
37 | |
38 The function @code{lsode} can be used to solve ODEs of the form | |
39 @tex | |
40 $$ | |
41 {dx\over dt} = f (x, t) | |
42 $$ | |
43 @end tex | |
10668
72585f1ca7a2
Replace @ifinfo with @ifnottex.
Rik <octave@nomad.inbox5.com>
parents:
9209
diff
changeset
|
44 @ifnottex |
3294 | 45 |
46 @example | |
9067
8970b4b10e9f
Cleanup documentation for quad.texi and diffeq.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
47 @group |
3294 | 48 dx |
49 -- = f (x, t) | |
50 dt | |
9067
8970b4b10e9f
Cleanup documentation for quad.texi and diffeq.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
51 @end group |
3294 | 52 @end example |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10668
diff
changeset
|
53 |
10668
72585f1ca7a2
Replace @ifinfo with @ifnottex.
Rik <octave@nomad.inbox5.com>
parents:
9209
diff
changeset
|
54 @end ifnottex |
3294 | 55 |
56 @noindent | |
10668
72585f1ca7a2
Replace @ifinfo with @ifnottex.
Rik <octave@nomad.inbox5.com>
parents:
9209
diff
changeset
|
57 using Hindmarsh's ODE solver @sc{lsode}. |
3294 | 58 |
6700 | 59 |
60 | |
3373 | 61 @DOCSTRING(lsode) |
3294 | 62 |
4115 | 63 @DOCSTRING(lsode_options) |
64 | |
3294 | 65 Here is an example of solving a set of three differential equations using |
66 @code{lsode}. Given the function | |
67 | |
68 @cindex oregonator | |
69 | |
70 @example | |
71 @group | |
72 function xdot = f (x, t) | |
73 | |
74 xdot = zeros (3,1); | |
75 | |
76 xdot(1) = 77.27 * (x(2) - x(1)*x(2) + x(1) \ | |
77 - 8.375e-06*x(1)^2); | |
78 xdot(2) = (x(3) - x(1)*x(2) - x(2)) / 77.27; | |
79 xdot(3) = 0.161*(x(1) - x(3)); | |
80 | |
81 endfunction | |
82 @end group | |
83 @end example | |
84 | |
85 @noindent | |
86 and the initial condition @code{x0 = [ 4; 1.1; 4 ]}, the set of | |
87 equations can be integrated using the command | |
88 | |
89 @example | |
90 @group | |
91 t = linspace (0, 500, 1000); | |
92 | |
93 y = lsode ("f", x0, t); | |
94 @end group | |
95 @end example | |
96 | |
97 If you try this, you will see that the value of the result changes | |
98 dramatically between @var{t} = 0 and 5, and again around @var{t} = 305. | |
99 A more efficient set of output points might be | |
100 | |
101 @example | |
102 @group | |
14856
c3fd61c59e9c
maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
103 t = [0, logspace(-1, log10(303), 150), \ |
c3fd61c59e9c
maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
104 logspace(log10(304), log10(500), 150)]; |
3294 | 105 @end group |
106 @end example | |
107 | |
108 See Alan C. Hindmarsh, @cite{ODEPACK, A Systematized Collection of ODE | |
109 Solvers}, in Scientific Computing, R. S. Stepleman, editor, (1983) for | |
110 more information about the inner workings of @code{lsode}. | |
111 | |
4167 | 112 @node Differential-Algebraic Equations |
3294 | 113 @section Differential-Algebraic Equations |
114 | |
4115 | 115 The function @code{daspk} can be used to solve DAEs of the form |
3294 | 116 @tex |
117 $$ | |
118 0 = f (\dot{x}, x, t), \qquad x(t=0) = x_0, \dot{x}(t=0) = \dot{x}_0 | |
119 $$ | |
120 @end tex | |
6700 | 121 @ifnottex |
3294 | 122 |
123 @example | |
124 0 = f (x-dot, x, t), x(t=0) = x_0, x-dot(t=0) = x-dot_0 | |
125 @end example | |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10668
diff
changeset
|
126 |
6700 | 127 @end ifnottex |
3294 | 128 |
129 @noindent | |
6700 | 130 where |
131 @tex | |
132 $\dot{x} = {dx \over dt}$ | |
133 @end tex | |
134 @ifnottex | |
135 @math{x-dot} | |
136 @end ifnottex | |
9067
8970b4b10e9f
Cleanup documentation for quad.texi and diffeq.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
137 is the derivative of @math{x}. The equation is solved using Petzold's |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10668
diff
changeset
|
138 DAE solver @sc{daspk}. |
4115 | 139 |
140 @DOCSTRING(daspk) | |
141 | |
142 @DOCSTRING(daspk_options) | |
3294 | 143 |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10668
diff
changeset
|
144 Octave also includes @sc{dassl}, an earlier version of @sc{daspk}, |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10668
diff
changeset
|
145 and @sc{dasrt}, which can be used to solve DAEs with constraints |
4115 | 146 (stopping conditions). |
3294 | 147 |
8286
6f2d95255911
fix @seealso references to point to existing anchors
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7018
diff
changeset
|
148 @DOCSTRING(dassl) |
6f2d95255911
fix @seealso references to point to existing anchors
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7018
diff
changeset
|
149 |
6f2d95255911
fix @seealso references to point to existing anchors
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7018
diff
changeset
|
150 @DOCSTRING(dassl_options) |
6f2d95255911
fix @seealso references to point to existing anchors
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7018
diff
changeset
|
151 |
4115 | 152 @DOCSTRING(dasrt) |
153 | |
154 @DOCSTRING(dasrt_options) | |
3294 | 155 |
156 See K. E. Brenan, et al., @cite{Numerical Solution of Initial-Value | |
157 Problems in Differential-Algebraic Equations}, North-Holland (1989) for | |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10668
diff
changeset
|
158 more information about the implementation of @sc{dassl}. |