annotate libs/commons-math-2.1/docs/userguide/ode.html @ 10:5f2c5fb36e93

commons-math-2.1 added
author dwinter
date Tue, 04 Jan 2011 10:00:53 +0100
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
2
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
3
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
4
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
5
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
6
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
7
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
8
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
9
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
10
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
11
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
12
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
13 <html xmlns="http://www.w3.org/1999/xhtml">
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
14 <head>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
15 <title>Math - The Commons Math User Guide - Ordinary Differential Equations Integration</title>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
16 <style type="text/css" media="all">
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
17 @import url("../css/maven-base.css");
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
18 @import url("../css/maven-theme.css");
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
19 @import url("../css/site.css");
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
20 </style>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
21 <link rel="stylesheet" href="../css/print.css" type="text/css" media="print" />
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
22 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
23 </head>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
24 <body class="composite">
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
25 <div id="banner">
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
26 <span id="bannerLeft">
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
27
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
28 Commons Math User Guide
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
29
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
30 </span>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
31 <div class="clear">
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
32 <hr/>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
33 </div>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
34 </div>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
35 <div id="breadcrumbs">
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
36
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
37
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
38
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
39
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
40
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
41
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
42
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
43
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
44 <div class="xright">
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
45
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
46
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
47
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
48
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
49
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
50
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
51
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
52 </div>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
53 <div class="clear">
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
54 <hr/>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
55 </div>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
56 </div>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
57 <div id="leftColumn">
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
58 <div id="navcolumn">
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
59
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
60
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
61
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
62
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
63
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
64
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
65
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
66
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
67 <h5>User Guide</h5>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
68 <ul>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
69
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
70 <li class="none">
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
71 <a href="../userguide/index.html">Contents</a>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
72 </li>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
73
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
74 <li class="none">
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
75 <a href="../userguide/overview.html">Overview</a>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
76 </li>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
77
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
78 <li class="none">
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
79 <a href="../userguide/stat.html">Statistics</a>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
80 </li>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
81
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
82 <li class="none">
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
83 <a href="../userguide/random.html">Data Generation</a>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
84 </li>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
85
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
86 <li class="none">
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
87 <a href="../userguide/linear.html">Linear Algebra</a>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
88 </li>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
89
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
90 <li class="none">
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
91 <a href="../userguide/analysis.html">Numerical Analysis</a>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
92 </li>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
93
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
94 <li class="none">
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
95 <a href="../userguide/special.html">Special Functions</a>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
96 </li>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
97
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
98 <li class="none">
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
99 <a href="../userguide/utilities.html">Utilities</a>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
100 </li>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
101
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
102 <li class="none">
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
103 <a href="../userguide/complex.html">Complex Numbers</a>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
104 </li>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
105
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
106 <li class="none">
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
107 <a href="../userguide/distribution.html">Distributions</a>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
108 </li>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
109
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
110 <li class="none">
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
111 <a href="../userguide/fraction.html">Fractions</a>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
112 </li>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
113
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
114 <li class="none">
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
115 <a href="../userguide/transform.html">Transform Methods</a>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
116 </li>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
117
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
118 <li class="none">
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
119 <a href="../userguide/geometry.html">3D Geometry</a>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
120 </li>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
121
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
122 <li class="none">
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
123 <a href="../userguide/optimization.html">Optimization</a>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
124 </li>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
125
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
126 <li class="none">
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
127 <strong>Ordinary Differential Equations</strong>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
128 </li>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
129
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
130 <li class="none">
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
131 <a href="../userguide/genetics.html">Genetic Algorithms</a>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
132 </li>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
133 </ul>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
134 <a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy">
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
135 <img alt="Built by Maven" src="../images/logos/maven-feather.png"></img>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
136 </a>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
137
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
138
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
139
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
140
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
141
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
142
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
143
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
144
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
145 </div>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
146 </div>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
147 <div id="bodyColumn">
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
148 <div id="contentBox">
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
149 <div class="section"><h2><a name="a13_Ordinary_Differential_Equations_Integration"></a>13 Ordinary Differential Equations Integration</h2>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
150 <div class="section"><h3><a name="a13.1_Overview"></a>13.1 Overview</h3>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
151 <p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
152 The ode package provides classes to solve Ordinary Differential Equations problems.
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
153 </p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
154 <p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
155 This package solves Initial Value Problems of the form y'=f(t,y) with t<sub>0</sub>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
156 and y(t<sub>0</sub>)=y<sub>0</sub> known. The provided integrators compute an estimate
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
157 of y(t) from t=t<sub>0</sub> to t=t<sub>1</sub>.
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
158 </p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
159 <p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
160 All integrators provide dense output. This means that besides computing the state vector
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
161 at discrete times, they also provide a cheap mean to get both the state and its derivative
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
162 between the time steps. They do so through classes extending the
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
163 <a href="../apidocs/org/apache/commons/math/ode/sampling/StepInterpolator.html">StepInterpolator</a>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
164 abstract class, which are made available to the user at the end of each step.
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
165 </p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
166 <p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
167 All integrators handle multiple discrete events detection based on switching
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
168 functions. This means that the integrator can be driven by user specified discrete events
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
169 (occurring when the sign of user-supplied <i>switching function</i> changes). The steps are
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
170 shortened as needed to ensure the events occur at step boundaries (even if the integrator
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
171 is a fixed-step integrator). When the events are triggered, integration can
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
172 be stopped (this is called a G-stop facility), the state vector can be changed, or integration
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
173 can simply go on. The latter case is useful to handle discontinuities in the differential
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
174 equations gracefully and get accurate dense output even close to the discontinuity.
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
175 </p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
176 <p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
177 All integrators support setting a maximal number of evaluations of differential
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
178 equations function. If this number is exceeded, an exception will be thrown during
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
179 integration. This can be used to prevent infinite loops if for example error control or
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
180 discrete events create a really large number of extremely small steps. By default, the
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
181 maximal number of evaluation is set to <code>Integer.MAX_VALUE</code> (i.e. 2<sup>31</sup>-1
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
182 or 2147483647). It is recommended to set this maximal number to a value suited to the ODE
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
183 problem, integration range, and step size or error control settings.
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
184 </p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
185 <p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
186 The user should describe his problem in his own classes which should implement the
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
187 <a href="../apidocs/org/apache/commons/math/ode/FirstOrderDifferentialEquations.html">FirstOrderDifferentialEquations</a>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
188 interface. Then he should pass it to the integrator he prefers among all the classes that implement
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
189 the <a href="../apidocs/org/apache/commons/math/ode/FirstOrderIntegrator.html">FirstOrderIntegrator</a>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
190 interface. The following example shows how to implement the simple two-dimensional problem:
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
191 <ul><li>y'<sub>0</sub>(t) = ? × (c<sub>1</sub> - y<sub>1</sub>(t))</li>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
192 <li>y'<sub>1</sub>(t) = ? × (y<sub>0</sub>(t) - c<sub>0</sub>)</li>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
193 </ul>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
194
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
195 with some initial state y(t<sub>0</sub>) = (y<sub>0</sub>(t<sub>0</sub>), y<sub>1</sub>(t<sub>0</sub>)).
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
196 In fact, the exact solution of this problem is that y(t) moves along a circle
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
197 centered at c = (c<sub>0</sub>, c<sub>1</sub>) with constant angular rate ?.
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
198 </p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
199 <div class="source"><pre>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
200 private static class CircleODE implements FirstOrderDifferentialEquations {
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
201
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
202 private double[] c;
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
203 private double omega;
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
204
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
205 public CircleODE(double[] c, double omega) {
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
206 this.c = c;
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
207 this.omega = omega;
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
208 }
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
209
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
210 public int getDimension() {
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
211 return 2;
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
212 }
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
213
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
214 public void computeDerivatives(double t, double[] y, double[] yDot) {
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
215 yDot[0] = omega * (c[1] - y[1]);
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
216 yDot[1] = omega * (y[0] - c[0]);
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
217 }
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
218
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
219 }
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
220 </pre>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
221 </div>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
222 <p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
223 Computing the state y(16.0) starting from y(0.0) = (0.0, 1.0) and integrating the ODE
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
224 is done as follows (using Dormand-Prince 8(5,3) integrator as an example):
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
225 </p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
226 <div class="source"><pre>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
227 FirstOrderIntegrator dp853 = new DormandPrince853Integrator(1.0e-8, 100.0, 1.0e-10, 1.0e-10);
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
228 FirstOrderDifferentialEquations ode = new CircleODE(new double[] { 1.0, 1.0 }, 0.1);
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
229 double[] y = new double[] { 0.0, 1.0 }; // initial state
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
230 dp853.integrate(ode, 0.0, y, 16.0, y); // now y contains final state at time t=16.0
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
231 </pre>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
232 </div>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
233 </div>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
234 <div class="section"><h3><a name="a13.2_Continuous_Output"></a>13.2 Continuous Output</h3>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
235 <p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
236 The solution of the integration problem is provided by two means. The first one is aimed towards
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
237 simple use: the state vector at the end of the integration process is copied in the y array of the
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
238 <code>FirstOrderIntegrator.integrate</code> method, as shown by previous example. The second one
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
239 should be used when more in-depth information is needed throughout the integration process. The user
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
240 can register an object implementing the
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
241 <a href="../apidocs/org/apache/commons/math/ode/sampling/StepHandler.html">StepHandler</a> interface or a
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
242 <a href="../apidocs/org/apache/commons/math/ode/sampling/StepNormalizer.html">StepNormalizer</a> object wrapping
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
243 a user-specified object implementing the
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
244 <a href="../apidocs/org/apache/commons/math/ode/sampling/FixedStepHandler.html">FixedStepHandler</a> interface
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
245 into the integrator before calling the <code>FirstOrderIntegrator.integrate</code> method. The user object
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
246 will be called appropriately during the integration process, allowing the user to process intermediate
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
247 results. The default step handler does nothing. Considering again the previous example, we want to print the
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
248 trajectory of the point to check it really is a circle arc. We simply add the following before the call
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
249 to integrator.integrate:
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
250 </p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
251 <div class="source"><pre>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
252 StepHandler stepHandler = new StepHandler() {
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
253 public void reset() {}
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
254
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
255 public boolean requiresDenseOutput() { return false; }
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
256
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
257 public void handleStep(StepInterpolator interpolator, boolean isLast) throws DerivativeException {
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
258 double t = interpolator.getCurrentTime();
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
259 double[] y = interpolator.getInterpolatedY();
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
260 System.out.println(t + &quot; &quot; + y[0] + &quot; &quot; + y[1]);
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
261 }
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
262 };
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
263 integrator.addStepHandler(stepHandler);
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
264 </pre>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
265 </div>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
266 <p><a href="../apidocs/org/apache/commons/math/ode/ContinuousOutputModel.html">ContinuousOutputModel</a>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
267 is a special-purpose step handler that is able to store all steps and to provide transparent access to
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
268 any intermediate result once the integration is over. An important feature of this class is that it
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
269 implements the <code>Serializable</code> interface. This means that a complete continuous model of the
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
270 integrated function throughout the integration range can be serialized and reused later (if stored into
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
271 a persistent medium like a file system or a database) or elsewhere (if sent to another application).
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
272 Only the result of the integration is stored, there is no reference to the integrated problem by itself.
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
273 </p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
274 <p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
275 Other default implementations of the <a href="../apidocs/org/apache/commons/math/ode/sampling/StepHandler.html">StepHandler</a>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
276 interface are available for general needs
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
277 (<a href="../apidocs/org/apache/commons/math/ode/sampling/DummyStepHandler.html">DummyStepHandler</a>,
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
278 <a href="../apidocs/org/apache/commons/math/ode/sampling/StepNormalizer.html">StepNormalizer</a>) and custom
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
279 implementations can be developed for specific needs. As an example, if an application is to be
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
280 completely driven by the integration process, then most of the application code will be run inside a
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
281 step handler specific to this application.
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
282 </p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
283 <p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
284 Some integrators (the simple ones) use fixed steps that are set at creation time. The more efficient
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
285 integrators use variable steps that are handled internally in order to control the integration error
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
286 with respect to a specified accuracy (these integrators extend the
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
287 <a href="../apidocs/org/apache/commons/math/ode/AdaptiveStepsizeIntegrator.html">AdaptiveStepsizeIntegrator</a>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
288 abstract class). In this case, the step handler which is called after each successful step shows up
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
289 the variable stepsize. The <a href="../apidocs/org/apache/commons/math/ode/sampling/StepNormalizer.html">StepNormalizer</a>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
290 class can be used to convert the variable stepsize into a fixed stepsize that can be handled by classes
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
291 implementing the <a href="../apidocs/org/apache/commons/math/ode/sampling/FixedStepHandler.html">FixedStepHandler</a>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
292 interface. Adaptive stepsize integrators can automatically compute the initial stepsize by themselves,
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
293 however the user can specify it if he prefers to retain full control over the integration or if the
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
294 automatic guess is wrong.
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
295 </p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
296 </div>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
297 <div class="section"><h3><a name="a13.3_Discrete_Events_Handling"></a>13.3 Discrete Events Handling</h3>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
298 <p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
299 ODE problems are continuous ones. However, sometimes discrete events must be
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
300 taken into account. The most frequent case is the stop condition of the integrator
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
301 is not defined by the time t but by a target condition on state y (say y[0] = 1.0
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
302 for example).
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
303 </p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
304 <p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
305 Discrete events detection is based on switching functions. The user provides
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
306 a simple <a href="../apidocs/org/apache/commons/math/ode/events/EventHandler.html">g(t, y)</a>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
307 function depending on the current time and state. The integrator will monitor
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
308 the value of the function throughout integration range and will trigger the
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
309 event when its sign changes. The magnitude of the value is almost irrelevant,
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
310 it should however be continuous (but not necessarily smooth) for the sake of
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
311 root finding. The steps are shortened as needed to ensure the events occur
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
312 at step boundaries (even if the integrator is a fixed-step integrator).
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
313 </p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
314 <p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
315 When an event is triggered, the event time, current state and an indicator
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
316 whether the switching function was increasing or decreasing at event time
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
317 are provided to the user. Several different options are available to him:
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
318 </p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
319 <ul><li>integration can be stopped (this is called a G-stop facility),</li>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
320 <li>the state vector or the derivatives can be changed,</li>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
321 <li>or integration can simply go on.</li>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
322 </ul>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
323 <p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
324 The first case, G-stop, is the most common one. A typical use case is when an
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
325 ODE must be solved up to some target state is reached, with a known value of
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
326 the state but an unknown occurrence time. As an example, if we want to monitor
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
327 a chemical reaction up to some predefined concentration for the first substance,
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
328 we can use the following switching function setting:
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
329 </p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
330 <div class="source"><pre>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
331 public double g(double t, double[] y) {
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
332 return y[0] - targetConcentration;
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
333 }
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
334
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
335 public int eventOccurred(double t, double[] y, boolean increasing) {
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
336 return STOP;
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
337 }
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
338 </pre>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
339 </div>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
340 <p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
341 The second case, change state vector or derivatives is encountered when dealing
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
342 with discontinuous dynamical models. A typical case would be the motion of a
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
343 spacecraft when thrusters are fired for orbital maneuvers. The acceleration is
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
344 smooth as long as no maneuvers are performed, depending only on gravity, drag,
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
345 third body attraction, radiation pressure. Firing a thruster introduces a
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
346 discontinuity that must be handled appropriately by the integrator. In such a case,
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
347 we would use a switching function setting similar to this:
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
348 </p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
349 <div class="source"><pre>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
350 public double g(double t, double[] y) {
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
351 return (t - tManeuverStart) * (t - tManeuverStop);
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
352 }
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
353
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
354 public int eventOccurred(double t, double[] y, boolean increasing) {
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
355 return RESET_DERIVATIVES;
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
356 }
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
357 </pre>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
358 </div>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
359 <p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
360 The third case is useful mainly for monitoring purposes, a simple example is:
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
361 </p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
362 <div class="source"><pre>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
363 public double g(double t, double[] y) {
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
364 return y[0] - y[1];
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
365 }
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
366
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
367 public int eventOccurred(double t, double[] y, boolean increasing) {
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
368 logger.log(&quot;y0(t) and y1(t) curves cross at t = &quot; + t);
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
369 return CONTINUE;
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
370 }
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
371 </pre>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
372 </div>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
373 </div>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
374 <div class="section"><h3><a name="a13.4_Available_Integrators"></a>13.4 Available Integrators</h3>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
375 <p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
376 The tables below show the various integrators available for non-stiff problems. Note that the
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
377 implementations of Adams-Bashforth and Adams-Moulton are adaptive stepsize, not fixed stepsize
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
378 as is usual for these multi-step integrators. This is due to the fact the implementation relies
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
379 on the Nordsieck vector representation of the state.
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
380 </p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
381 <p><table class="bodyTable"><tr class="a"><td><font size="+2">Fixed Step Integrators</font></td>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
382 </tr>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
383 <tr class="b"><font size="+1"><td>Name</td>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
384 <td>Order</td>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
385 </font></tr>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
386 <tr class="a"><td><a href="../apidocs/org/apache/commons/math/ode/nonstiff/EulerIntegrator.html">Euler</a></td>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
387 <td>1</td>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
388 </tr>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
389 <tr class="b"><td><a href="../apidocs/org/apache/commons/math/ode/nonstiff/MidpointIntegrator.html">Midpoint</a></td>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
390 <td>2</td>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
391 </tr>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
392 <tr class="a"><td><a href="../apidocs/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaIntegrator.html">Classical Runge-Kutta</a></td>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
393 <td>4</td>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
394 </tr>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
395 <tr class="b"><td><a href="../apidocs/org/apache/commons/math/ode/nonstiff/GillIntegrator.html">Gill</a></td>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
396 <td>4</td>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
397 </tr>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
398 <tr class="a"><td><a href="../apidocs/org/apache/commons/math/ode/nonstiff/ThreeEighthesIntegrator.html">3/8</a></td>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
399 <td>4</td>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
400 </tr>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
401 </table>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
402 </p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
403 <p><table class="bodyTable"><tr class="b"><td><font size="+2">Adaptive Stepsize Integrators</font></td>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
404 </tr>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
405 <tr class="a"><font size="+1"><td>Name</td>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
406 <td>Integration Order</td>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
407 <td>Error Estimation Order</td>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
408 </font></tr>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
409 <tr class="b"><td><a href="../apidocs/org/apache/commons/math/ode/nonstiff/HighamHall54Integrator.html">Higham and Hall</a></td>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
410 <td>5</td>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
411 <td>4</td>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
412 </tr>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
413 <tr class="a"><td><a href="../apidocs/org/apache/commons/math/ode/nonstiff/DormandPrince54Integrator.html">Dormand-Prince 5(4)</a></td>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
414 <td>5</td>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
415 <td>4</td>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
416 </tr>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
417 <tr class="b"><td><a href="../apidocs/org/apache/commons/math/ode/nonstiff/DormandPrince853Integrator.html">Dormand-Prince 8(5,3)</a></td>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
418 <td>8</td>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
419 <td>5 and 3</td>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
420 </tr>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
421 <tr class="a"><td><a href="../apidocs/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerIntegrator.html">Gragg-Bulirsch-Stoer</a></td>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
422 <td>variable (up to 18 by default)</td>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
423 <td>variable</td>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
424 </tr>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
425 <tr class="b"><td><a href="../apidocs/org/apache/commons/math/ode/nonstiff/AdamsBashforthIntegrator.html">Adams-Bashforth</a></td>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
426 <td>variable</td>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
427 <td>variable</td>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
428 </tr>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
429 <tr class="a"><td><a href="../apidocs/org/apache/commons/math/ode/nonstiff/AdamsMoultonIntegrator.html">Adams-Moulton</a></td>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
430 <td>variable</td>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
431 <td>variable</td>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
432 </tr>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
433 </table>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
434 </p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
435 </div>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
436 <div class="section"><h3><a name="a13.5_Derivatives"></a>13.5 Derivatives</h3>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
437 <p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
438 If in addition to state y(t) the user needs to compute the sensitivity of the state to
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
439 the initial state or some parameter of the ODE, he will use the classes and interfaces
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
440 from the <a href="../apidocs/org/apache/commons/math/ode/jacobians/package-summary.html">org.apache.commons.ode.jacobians</a>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
441 package instead of the top level ode package. These classes compute the jacobians
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
442 dy(t)/dy<sub>0</sub> and dy(t<sub>0</sub>)/dp where y<sub>0</sub> is the initial state
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
443 and p is some ODE parameter.
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
444 </p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
445 <p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
446 The classes and interfaces in this package mimic the behavior of the classes and
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
447 interfaces of the top level ode package, only adding parameters arrays for the jacobians.
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
448 The behavior of these classes is to create a compound state vector z containing both
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
449 the state y(t) and its derivatives dy(t)/dy<sub>0</sub> and dy(t<sub>0</sub>)/dp and
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
450 to set up an extended problem by adding the equations for the jacobians automatically.
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
451 These extended state and problems are then provided to a classical underlying integrator
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
452 chosen by user.
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
453 </p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
454 <p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
455 This behavior imply there will be a top level integrator knowing about state and jacobians
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
456 and a low level integrator knowing only about compound state (which may be big). If the user
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
457 wants to deal with the top level only, he will use the specialized step handler and event
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
458 handler classes registered at top level. He can also register classical step handlers and
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
459 event handlers, but in this case will see the big compound state. This state is guaranteed
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
460 to contain the original state in the first elements, followed by the jacobian with respect
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
461 to initial state (in row order), followed by the jacobian with respect to parameters (in
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
462 row order). If for example the original state dimension is 6 and there are 3 parameters,
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
463 the compound state will be a 60 elements array. The first 6 elements will be the original
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
464 state, the next 36 elements will be the jacobian with respect to initial state, and the
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
465 remaining 18 will be the jacobian with respect to parameters. Dealing with low level
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
466 step handlers and event handlers is cumbersome if one really needs the jacobians in these
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
467 methods, but it also prevents many data being copied back and forth between state and
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
468 jacobians on one side and compound state on the other side.
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
469 </p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
470 <p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
471 In order to compute dy(t)/dy<sub>0</sub> and dy(t<sub>0</sub>)/dp for any t, the algorithm
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
472 needs not only the ODE function f such that y'=f(t,y) but also its local jacobians
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
473 df(t, y, p)/dy and df(t, y, p)/dp.
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
474 </p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
475 <p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
476 If the function f is too complex, the user can simply rely on internal differentiation
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
477 using finite differences to compute these local jacobians. So rather than the <a href="../apidocs/org/apache/commons/math/ode/FirstOrderDifferentialEquations.html">FirstOrderDifferentialEquations</a>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
478 interface he will implement the <a href="../apidocs/org/apache/commons/math/ode/jacobians/ParameterizedODE.html">ParameterizedODE</a>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
479 interface. Considering again our example where only ? is considered a parameter, we get:
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
480 </p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
481 <div class="source"><pre>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
482 public class BasicCircleODE implements ParameterizedODE {
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
483
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
484 private double[] c;
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
485 private double omega;
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
486
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
487 public BasicCircleODE(double[] c, double omega) {
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
488 this.c = c;
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
489 this.omega = omega;
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
490 }
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
491
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
492 public int getDimension() {
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
493 return 2;
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
494 }
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
495
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
496 public void computeDerivatives(double t, double[] y, double[] yDot) {
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
497 yDot[0] = omega * (c[1] - y[1]);
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
498 yDot[1] = omega * (y[0] - c[0]);
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
499 }
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
500
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
501 public int getParametersDimension() {
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
502 // we are only interested in the omega parameter
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
503 return 1;
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
504 }
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
505
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
506 public void setParameter(int i, double value) {
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
507 omega = value;
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
508 }
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
509
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
510 }
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
511 </pre>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
512 </div>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
513 <p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
514 This ODE is provided to the specialized integrator with two arrays specifying the
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
515 step sizes to use for finite differences (one array for derivation with respect to
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
516 state y, one array for derivation with respect to parameters p):
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
517 </p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
518 <div class="source"><pre>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
519 double[] hY = new double[] { 0.001, 0.001 };
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
520 double[] hP = new double[] { 1.0e-6 };
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
521 FirstOrderIntegratorWithJacobians integrator = new FirstOrderIntegratorWithJacobians(dp853, ode, hY, hP);
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
522 integrator.integrate(t0, y0, dy0dp, t, y, dydy0, dydp);
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
523 </pre>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
524 </div>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
525 <p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
526 If the function f is simple, the user can simply provide the local jacobians
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
527 by himself. So rather than the <a href="../apidocs/org/apache/commons/math/ode/FirstOrderDifferentialEquations.html">FirstOrderDifferentialEquations</a>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
528 interface he will implement the <a href="../apidocs/org/apache/commons/math/ode/jacobians/ODEWithJacobians.html">ODEWithJacobians</a>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
529 interface. Considering again our example where only ? is considered a parameter, we get:
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
530 </p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
531 <div class="source"><pre>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
532 public class EnhancedCircleODE implements ODEWithJacobians {
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
533
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
534 private double[] c;
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
535 private double omega;
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
536
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
537 public EnhancedCircleODE(double[] c, double omega) {
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
538 this.c = c;
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
539 this.omega = omega;
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
540 }
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
541
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
542 public int getDimension() {
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
543 return 2;
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
544 }
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
545
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
546 public void computeDerivatives(double t, double[] y, double[] yDot) {
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
547 yDot[0] = omega * (c[1] - y[1]);
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
548 yDot[1] = omega * (y[0] - c[0]);
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
549 }
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
550
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
551 public int getParametersDimension() {
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
552 // we are only interested in the omega parameter
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
553 return 1;
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
554 }
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
555
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
556 public void computeJacobians(double t, double[] y, double[] yDot, double[][] dFdY, double[][] dFdP) {
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
557
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
558 dFdY[0][0] = 0;
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
559 dFdY[0][1] = -omega;
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
560 dFdY[1][0] = omega;
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
561 dFdY[1][1] = 0;
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
562
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
563 dFdP[0][0] = 0;
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
564 dFdP[0][1] = omega;
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
565 dFdP[0][2] = c[1] - y[1];
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
566 dFdP[1][0] = -omega;
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
567 dFdP[1][1] = 0;
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
568 dFdP[1][2] = y[0] - c[0];
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
569
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
570 }
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
571
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
572 }
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
573 </pre>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
574 </div>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
575 <p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
576 This ODE is provided to the specialized integrator as is:
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
577 </p>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
578 <div class="source"><pre>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
579 FirstOrderIntegratorWithJacobians integrator = new FirstOrderIntegratorWithJacobians(dp853, ode);
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
580 integrator.integrate(t0, y0, dy0dp, t, y, dydy0, dydp);
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
581 </pre>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
582 </div>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
583 </div>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
584 </div>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
585
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
586 </div>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
587 </div>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
588 <div class="clear">
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
589 <hr/>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
590 </div>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
591 <div id="footer">
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
592 <div class="xright">&#169;
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
593 2003-2010
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
594
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
595
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
596
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
597
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
598
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
599
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
600
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
601
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
602
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
603 </div>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
604 <div class="clear">
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
605 <hr/>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
606 </div>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
607 </div>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
608 </body>
5f2c5fb36e93 commons-math-2.1 added
dwinter
parents:
diff changeset
609 </html>