Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(a) Write a function function [u,T] = BackEuler(f,df,a,b,N,ya,maxiter,tol) that

ID: 3865318 • Letter: #

Question

(a) Write a function function [u,T] = BackEuler(f,df,a,b,N,ya,maxiter,tol) that implements the Backward Euler method for a scalar differential equation y' (t) = f(t, y). Here, N is the number of steps in the discretization and df refers to the function fy(t, y).To calculate ui+1 at each step, run Newton’s method with ui as the initial guess. Perform at most maxiter number of iterations at each step and terminate early if successive values are less than tol.

(b) Solve the combustion model equation y' (t) = y^2*(1 y), 0 t 2000, y(0) = 0.9 using your code in (a) with maxiter = 20, tol = 1012 and N = 5, 10, 20. Plot the results on the same axes

PLEASE HELP SOLVING THIS CLEARLY ITS URGENT

Explanation / Answer

(a)

function [u,T]=beul(f,df,a,b,ya,N)

h=(b-a)/N;

T=linspace(a,b,N+1);

u=zeros(N+1,length(ya));

u(1,:)=ya;
for i=1:N
x0=u(i,:)’;
x1=x0-inv(eye(length(ya))-h*feval(df,T(i),x0))*(x0-h*feval(f,T(i),x0)’-u(i,:)’);
while (norm(x1-x0)>0.0001)
x0=x1;
x1=x0-inv(eye(length(ya))-h*feval(df,T(i),x0))*(x0-h*feval(f,T(i),x0)’-u(i,:)’);
end
u(i+1,:)=x1’;
end

end

(b) Define the f and df properly