MATLAB Mathematics - SERC - Index of
MATLAB Mathematics - SERC - Index of MATLAB Mathematics - SERC - Index of
5 Differential Equations 1 0.8 0.6 0.4 0.2 0 −0.2 −0.4 −0.6 −0.8 −1 0 2 4 6 8 10 12 Example: Stiff Problem (van der Pol Equation) vdpode illustrates the solution of the van der Pol problem described in “Example: The van der Pol Equation, m = 1000 (Stiff)” on page 5-12. The differential equations y′ 1 = y 2 2 y′ 2 = µ(1 – y 1 )y 2 – y 1 involve a constant parameter µ . As µ increases, the problem becomes more stiff, and the period of oscillation becomes larger. When µ is 1000 the equation is in relaxation oscillation and the problem is very stiff. The limit cycle has portions where the solution components change slowly and the problem is quite stiff, alternating with regions of very sharp change where it is not stiff (quasi-discontinuities). By default, the solvers in the ODE suite that are intended for stiff problems approximate Jacobian matrices numerically. However, this example provides a nested function J(t,y) to evaluate the Jacobian matrix ∂f ⁄ ∂y analytically at 5-20
Initial Value Problems for ODEs and DAEs (t,y) for µ = MU. The use of an analytic Jacobian can improve the reliability and efficiency of integration. To run this example, click on the example name, or type vdpode at the command line. From the command line, you can specify a value of µ as an argument to vdpode. The default is µ = 1000. function vdpode(MU) %VDPODE Parameterizable van der Pol equation (stiff for large MU) if nargin < 1 MU = 1000; % default end tspan = [0; max(20,3*MU)]; y0 = [2; 0]; options = odeset('Jacobian',@J); % Several periods [t,y] = ode15s(@f,tspan,y0,options); plot(t,y(:,1)); title(['Solution of van der Pol Equation, \mu = ' num2str(MU)]); xlabel('time t'); ylabel('solution y_1'); axis([tspan(1) tspan(end) -2.5 2.5]); --------------------------------------------------------------- function dydt = f(t,y) dydt = [ y(2) MU*(1-y(1)^2)*y(2)-y(1) ]; end % End nested function f --------------------------------------------------------------- function dfdy = J(t,y) dfdy = [ 0 1 -2*MU*y(1)*y(2)-1 MU*(1-y(1)^2) ]; end % End nested function J end 5-21
- Page 104 and 105: 4 Function Functions Function Summa
- Page 106 and 107: 4 Function Functions You can also c
- Page 108 and 109: 4 Function Functions 25 20 15 10 5
- Page 110 and 111: 4 Function Functions Minimizing Fun
- Page 112 and 113: 4 Function Functions To try fminsea
- Page 114 and 115: 4 Function Functions Plotting the R
- Page 116 and 117: 4 Function Functions The number of
- Page 118 and 119: 4 Function Functions and displays t
- Page 120 and 121: 4 Function Functions end function s
- Page 122 and 123: 4 Function Functions States of the
- Page 124 and 125: 4 Function Functions 100 80 60 40 2
- Page 126 and 127: 4 Function Functions You can verify
- 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 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 178 and 179: 5 Differential Equations Problem Si
- 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
5 Differential Equations<br />
1<br />
0.8<br />
0.6<br />
0.4<br />
0.2<br />
0<br />
−0.2<br />
−0.4<br />
−0.6<br />
−0.8<br />
−1<br />
0 2 4 6 8 10 12<br />
Example: Stiff Problem (van der Pol Equation)<br />
vdpode illustrates the solution <strong>of</strong> the van der Pol problem described in<br />
“Example: The van der Pol Equation, m = 1000 (Stiff)” on page 5-12. The<br />
differential equations<br />
y′ 1 = y 2<br />
2<br />
y′ 2 = µ(1 – y 1 )y 2 – y 1<br />
involve a constant parameter µ .<br />
As µ increases, the problem becomes more stiff, and the period <strong>of</strong> oscillation<br />
becomes larger. When µ is 1000 the equation is in relaxation oscillation and<br />
the problem is very stiff. The limit cycle has portions where the solution<br />
components change slowly and the problem is quite stiff, alternating with<br />
regions <strong>of</strong> very sharp change where it is not stiff (quasi-discontinuities).<br />
By default, the solvers in the ODE suite that are intended for stiff problems<br />
approximate Jacobian matrices numerically. However, this example provides<br />
a nested function J(t,y) to evaluate the Jacobian matrix ∂f ⁄ ∂y analytically at<br />
5-20