Question: Answer the following questions about this program: (a) What differential equation is solved by this program? (b) What is the initial condition? (c) What does
Answer the following questions about this program:
(a) What differential equation is solved by this program?
(b) What is the initial condition?
(c) What does the variable a represent?
(d) What does the variable b represent?
(e) What does the variable c represent?
(f) What numerical method is implemented by the for loop in lines 5–19?
(g) What numerical method is implemented by the while loop in lines 10–18?
(h) What is the purpose of the if block in lines 15–17?
(i) What is the value of t at the end of the program?
(j) What type of continuation method is used?
1 function problem4_12 2 = 1; 3 4 5 6 7 8 10 y = t = 0; dt = 1e-4; 25 for i=1:8e3 t = t + dt; 11 12 13 14 15 16 17 18 19 20 21 function b = getb (y, a, t, dt) 22 b = y - a - dt* (y^2 + cos (y*t)); 23 24 end a = y; b = getb (y, a, t, dt); k = 1; while abs (b) > le-4 c = getc (y, t, dt); y = y b/c; b = getb (y, a, t, dt); k = k + 1; if k > 20 break end end - function c = getc (y, t, dt) c = 1 dt* (2*y - t*sin (y*t));
Step by Step Solution
3.36 Rating (152 Votes )
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
