Question: ONLY DO PART C OF THE PROBLEM PLEASE HERE IS PART A and B % Part a ---------------------------------------------------------------- Ti=0; Tf=2; dt=0.05; Y(1)=3; t(1) =Ti; N=

ONLY DO PART C OF THE PROBLEM PLEASE

HERE IS PART A and B

%Part a---------------------------------------------------------------- Ti=0; Tf=2; dt=0.05; Y(1)=3; t(1) =Ti; N= round((Tf-Ti)/dt); a=4; for n=1:N Y(n+1)= (1+ a*dt) *Y(n); t(n+1) = dt + t(n); end figure plot(t, Y, '*', t, exp(a.*t),'o' ) % part b--------------------------------------------------------------- Ti=0; Tf=2; dt=0.05; X(1)=3; t(1) =Ti; q =.2./3; N= round((Tf-Ti)/dt); a=3; for n=1:N X(n+1)= ((1+ a*dt) * X(n)) + (dt*q); t(n+1) = dt + t(n); end figure plot(t, X, '*', t, exp(a.*t),'o' ) ONLY DO PART C OF THE PROBLEM PLEASE HERE IS PART A

Let Y_n be an approximate to the solution y(t) at t_n = n delta t. That is y(n delta t) almost equal to Y_n where n = 1, 2, N and delta t = T/N. We now write the differential equation y' = ay to a difference equation Y_n+1-Y_n/delta t = aY_n and we have Euler's method: Y_n+1 = (1 +(a delta t)Y_n The example below illustrates the MATLAB syntax to find/plot the approximates Y_n by using Euler's method for y' = ay. Euler's method %solve y'= a*y in the time interval 0 to 2, 2 with y(0)=3, a=5, Ti=0: Tf=2: dt=0.1: Y(1)=3: t(1) = Ti: N= round ((Tf-Ti)/dt): a=5: for n=1: N Y(n+1) = (1+ a+dt) *Y(n): t(n+1) = dt + t (n): end figure plot(t, Y, '*', t, exp(a.*t), 'o') plot the approximate Y and the exact solution y=exp(a*t) Recall in WS2 we found the mathematical model for the drug concentration y(t) in a patient's body at time t. Assume as the same as before that the drip feeds q = 0.2 grams per minute into the patient's arm, and the body eliminates the drug at the rate 3 grams per minute. (a) Recall that we had a differential equation of form Y' = aY where Y = y - y_infinity, and y_infinity is the steady state concentration. Write MATALB scripts using Euler's method to find the approximates Z_n for Y(t). Set T = 1, 2, 5 and delta t = 0.1, 0.05, 0.01, Draw the solution Y(t_n) and the approximates Z_n for various different values of A. (b) Write MATALB scripts using Euler's method to find the approximates X_n for y(t). Draw the solution X(t_n) and the approximates X_n for the same values of A that you chose in the first part. (c) For each T = 1, 2, 5 and delta t = 0.1, 0.05, 0.01, compare the results from the first part and the second part of the problems, by evaluating the differences between the exact solution and the approximates, which is called the error, and find the maximum absolute values using the following MATLAB scripts. Make a table for the errors for each T and delta t. Plot the errors, state what you found from the errors, and give suggestions how the errors can be minimized

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!