MATLAB Mathematics - SERC - Index of
MATLAB Mathematics - SERC - Index of MATLAB Mathematics - SERC - Index of
5 Differential Equations Problem Size, Memory Use, and Computation Speed Question How large a problem can I solve with the ODE suite? Answer The primary constraints are memory and time. At each time step, the solvers for nonstiff problems allocate vectors of length n, where n is the number of equations in the system. The solvers for stiff problems but also allocate an n-by-n Jacobian matrix. For these solvers it may be advantageous to use the sparse option. If the problem is nonstiff, or if you are using the sparse option, it may be possible to solve a problem with thousands of unknowns. In this case, however, storage of the result can be problematic. Try asking the solver to evaluate the solution at specific points only, or call the solver with no output arguments and use an output function to monitor the solution. I'm solving a very large system, but only care about a couple of the components of y. Is there any way to avoid storing all of the elements? What is the startup cost of the integration and how can I reduce it? Yes. The user-installable output function capability is designed specifically for this purpose. When you call the solver with no output arguments, the solver does not allocate storage to hold the entire solution history. Instead, the solver calls OutputFcn(t,y,flag) at each time step. To keep the history of specific elements, write an output function that stores or plots only the elements you care about. The biggest startup cost occurs as the solver attempts to find a step size appropriate to the scale of the problem. If you happen to know an appropriate step size, use the InitialStep property. For example, if you repeatedly call the integrator in an event location loop, the last step that was taken before the event is probably on scale for the next integration. See ballode for an example. 5-44
Initial Value Problems for ODEs and DAEs Time Steps for Integration Question The first step size that the integrator takes is too large, and it misses important behavior. Can I integrate with fixed step sizes? Answer You can specify the first step size with the InitialStep property. The integrator tries this value, then reduces it if necessary. No. Error Tolerance and Other Options Question How do I choose RelTol and AbsTol? Answer RelTol, the relative accuracy tolerance, controls the number of correct digits in the answer. AbsTol, the absolute error tolerance, controls the difference between the answer and the solution. At each step, the error e in component i of the solution satisfies |e(i)|
- Page 128 and 129: 4 Function Functions Troubleshootin
- Page 130 and 131: 4 Function Functions A three-dimens
- Page 132 and 133: 4 Function Functions Parameterizing
- Page 134 and 135: 4 Function Functions “Anonymous F
- Page 136 and 137: 5 Differential Equations Initial Va
- Page 138 and 139: 5 Differential Equations odephas3 o
- Page 140 and 141: 5 Differential Equations This secti
- Page 142 and 143: 5 Differential Equations The basic
- Page 144 and 145: 5 Differential Equations 2 Code the
- Page 146 and 147: 5 Differential Equations function.
- Page 148 and 149: 5 Differential Equations One way to
- Page 150 and 151: 5 Differential Equations y0, yp0 Ve
- Page 152 and 153: 5 Differential Equations For exampl
- Page 154 and 155: 5 Differential Equations 1 0.8 0.6
- Page 156 and 157: 5 Differential Equations 2.5 Soluti
- Page 158 and 159: 5 Differential Equations To run thi
- Page 160 and 161: 5 Differential Equations 2 u′ i =
- Page 162 and 163: 5 Differential Equations dydt(i+1,:
- Page 164 and 165: 5 Differential Equations refine = 4
- Page 166 and 167: 5 Differential Equations Example: A
- Page 168 and 169: 5 Differential Equations function [
- Page 170 and 171: 5 Differential Equations Note The R
- Page 172 and 173: 5 Differential Equations 1 Robertso
- Page 174 and 175: 5 Differential Equations The MATLAB
- Page 176 and 177: 5 Differential Equations Summary of
- Page 180 and 181: 5 Differential Equations Error Tole
- Page 182 and 183: 5 Differential Equations Troublesho
- Page 184 and 185: 5 Differential Equations Function d
- Page 186 and 187: 5 Differential Equations dde23 prod
- Page 188 and 189: 5 Differential Equations The exampl
- Page 190 and 191: 5 Differential Equations solution y
- Page 192 and 193: 5 Differential Equations Example: C
- Page 194 and 195: 5 Differential Equations Changing D
- Page 196 and 197: 5 Differential Equations BVP Functi
- Page 198 and 199: 5 Differential Equations two-point
- Page 200 and 201: 5 Differential Equations The input
- Page 202 and 203: 5 Differential Equations 2 Pass the
- Page 204 and 205: 5 Differential Equations 3 Code the
- Page 206 and 207: 5 Differential Equations Finding Un
- Page 208 and 209: 5 Differential Equations vectorized
- Page 210 and 211: 5 Differential Equations There is a
- Page 212 and 213: 5 Differential Equations 3 Solve on
- Page 214 and 215: 5 Differential Equations hold off T
- Page 216 and 217: 5 Differential Equations Note The d
- Page 218 and 219: 5 Differential Equations legend('An
- Page 220 and 221: 5 Differential Equations Here, v(1-
- Page 222 and 223: 5 Differential Equations solution v
- Page 224 and 225: 5 Differential Equations Note The D
- Page 226 and 227: 5 Differential Equations After disc
5 Differential Equations<br />
Problem Size, Memory Use, and Computation Speed<br />
Question<br />
How large a problem can I<br />
solve with the ODE suite?<br />
Answer<br />
The primary constraints are memory and time. At each time step,<br />
the solvers for nonstiff problems allocate vectors <strong>of</strong> length n,<br />
where n is the number <strong>of</strong> equations in the system. The solvers for<br />
stiff problems but also allocate an n-by-n Jacobian matrix. For<br />
these solvers it may be advantageous to use the sparse option.<br />
If the problem is nonstiff, or if you are using the sparse option, it<br />
may be possible to solve a problem with thousands <strong>of</strong> unknowns.<br />
In this case, however, storage <strong>of</strong> the result can be problematic.<br />
Try asking the solver to evaluate the solution at specific points<br />
only, or call the solver with no output arguments and use an<br />
output function to monitor the solution.<br />
I'm solving a very large<br />
system, but only care about<br />
a couple <strong>of</strong> the components<br />
<strong>of</strong> y. Is there any way to<br />
avoid storing all <strong>of</strong> the<br />
elements?<br />
What is the startup cost <strong>of</strong><br />
the integration and how<br />
can I reduce it?<br />
Yes. The user-installable output function capability is designed<br />
specifically for this purpose. When you call the solver with no<br />
output arguments, the solver does not allocate storage to hold the<br />
entire solution history. Instead, the solver calls<br />
OutputFcn(t,y,flag) at each time step. To keep the history <strong>of</strong><br />
specific elements, write an output function that stores or plots<br />
only the elements you care about.<br />
The biggest startup cost occurs as the solver attempts to find a<br />
step size appropriate to the scale <strong>of</strong> the problem. If you happen to<br />
know an appropriate step size, use the InitialStep property. For<br />
example, if you repeatedly call the integrator in an event location<br />
loop, the last step that was taken before the event is probably on<br />
scale for the next integration. See ballode for an example.<br />
5-44