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

WRITE A MATLAB CODE TO SOLVE THE FOLLOWING PROBLEM using numerical methods for s

ID: 3868799 • Letter: W

Question

WRITE A MATLAB CODE TO SOLVE THE FOLLOWING PROBLEM

using numerical methods for scientists and engineers 3rd edition

THE RESULTS SHOULD BE AS FOLLOW

Problem # 2 P-2 Consider the following stiff ODE system: -998x-1998), x(0)-1 (dy -1000x -2000y, y(0)-2 dt a) b) c) Solve the system with fourth order Runge-Kutta method using h = 0.0001 Solve with the implicit built-in ode23tb Plot the results in subplots with the solution x(0,1) and y(0,1) superimposed on the graphs for comparison with the results in the table below Exact solution Euler's implicit method h = 0.1 Euler's explicit Euler's explicit method h = 0.1 . 298.8 -298 method h = 0.0001 -1.63906946 -0.82035509 1.63910225 1.63861386 0.82037150 0.80528053 Hints: For RK4 with the designated step h, the required solution is at step 1000, while for ode23tb it is at stejp 15.

Explanation / Answer

function [ t,x] = Untitled2(h) %UNTITLED2 Summarx of this function goes here % Detailed etplanation goes here t = 0:h:3; u=t.^2; x(1) = 0; fx = @(t,x) 2*u; for i=1:(length(t)-1) k1 = fx(t(i),x(i)); k2 = fx(t(i)+0.5*h,x(i)+0.5*h*k1); k3 = fx(t(i)+0.5*h,x(i)+0.5*h*k2); k4 = fx(t(i)+h,x(i)+k3*h); x(i+1) = x(i) + (1/6)*(k1+2*k2+2*k3+k4)*h; end end