Page 123 -
P. 123
y(k)=((4*a/dt^2+2*b/dt+c)^(-1))*...
(y(k-1)*(4*a/dt^2+2*b/dt)+D(k-1)*(4*a/dt+b)+...
+a*D2(k-1)+u(k));
D(k)=(2/dt)*(y(k)-y(k-1))-D(k-1);
D2(k)=(4/dt^2)*(y(k)-y(k-1))-(4/dt)*D(k-1)-D2
(k-1);
end
plot(t,y,t,u,'--')
The dashed curve is the temporal profile of the source term.
In-Class Exercise
Pb. 4.38 Plot the amplitude of y and its dephasing from u as function of a
for large t, for 0.1 < a < 5.
Application 2
Solve, over the interval 0 < t < 1, the following second-order differential
equation:
2
dy dy
(1− t 2 ) 2 − 2t + 20 =y 0 (4.37)
dt dt
with the initial conditions: y(t = 0) = 3/8 and y′(t = 0) = 0.
Then, compare your numerical result with the analytical solution to this
problem:
1
y = ( 35 t − 30 t + 3) (4.38)
4
2
8
Solution: Edit and execute the following script M-file:
tin=0;
tfin=1;
t=linspace(tin,tfin,2000);
N=length(t);
a=1-t.^2;
© 2001 by CRC Press LLC