Scientific Computing Lab Results Worksheet 2 Dr. Miriam Mehl Institut für Informatik Scientific Computing in Computer Science
Worksheet 2 – Solution
1) m-file Euler_implicit.m for (k=2:size(tk,2)) y_it = y(k-1); dy=1.0; %Newton iteration while (abs(dy)>=0.0001) dy = (y(k-1) - y_it + dt*rhs(y_it))/ (dt*rhs_y(y_it)-1); y_it = y_it - dy; end y(k)=y_it; end
Worksheet 2 – Solution 2) m-file Adams_Moulton.m y_it = y(k-1); x = y_it + (1/2)*dt*rhs(y_it); %Newton iteration d=1-7*dt+(49/4)*dt^2+(7/5)*dt*x; if (d>0) dy=1; it=1; while (abs(dy)>0.0001) …
Worksheet 2 – Solution 3) m-file AdamsMoulton_linear_1.m for (k=2:size(tk,2)) a=(1/2)*dt*7*y(k-1); y(k)=(y(k-1)+2*a-(a/10)*y(k-1))/ (1+(a/10)); end
Worksheet 2 – Solution
dt1/21/41/81/161/32 error–– error red.––– explicit Euler q=1
Worksheet 2 – Solution dt1/21/41/81/161/32 error–– error red.––– Heun q=2
Worksheet 2 – Solution dt1/21/41/81/161/32 error error red.– implicit Euler q=1
Worksheet 2 – Solution dt1/21/41/81/161/32 error– error red.–– Adams Moulton q=2
Worksheet 2 – Solution dt1/21/41/81/161/32 error error red.– Adams Moulton linearisation 1 q=1
Worksheet 2 – Solution dt1/21/41/81/161/32 error error red.– Adams Moulton linearisation 2 q=1
Worksheet 2 – Solution dtExpl. Euler HeunImpl. Euler Adams Moulton Adams Moulton l1 Adams Moulton l2 1/2X–XO 1/4XXXX 1/8XXXXXX 1/16XXXXXX 1/32XXXXXX