Find an approximation for the solution of the initial value problem x\'\'+tx\'+x
ID: 3003249 • Letter: F
Question
Find an approximation for the solution of the initial value problemx''+tx'+x^3=0, x(0)=0, x'(0)=1 on the interval [0;2] with the step h=0.4.
PLEASE SHOW YOUR WORK ^^
Explanation / Answer
Find an approximation for the solution of the initial value problem x''+tx'+x^3=0, x(0)=0, x'(0)=1 on the interval [0;2] with the step h=0.4. x''+tx'+x^3=0 x' = y ==> x'' = y' x''+tx'+x^3=0 ==> y' + t y + x^3=0 => y' =-t y - x^3 Thus second order ODE reduces to linear system of ODE x' = y, x(0) =0 y' =-t y - x^3, y(0) = x'(0) =1 Euler's method x_{n+1} = x_{n} + h y_{n}, x_{0}=0 y_{n+1} = y_{n} + h( - t_{n} y_{n} - (x_{n})^3 ), y_{0} =1 %% % euler rule clear euler h=0.4 ; tmin=0; tmax=2; n= (tmax -tmin)/h; t(1)= 0; x(1) =0; y(1)=1; disp(' t x y ') disp('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~') for i=1:(n+1 ) t(i+1) = t(1)+ i*h; x(i+1) = x(i) + h* y(i); y(i+1) = y(i) + h*(-t(i)*y(i) - (x(i))^3); fprintf('%5.2f%17.7f%19.7f ', t(i), x(i), y(i) ); end eul1agus t x y ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 0.00 0.0000000 1.0000000 0.40 0.4000000 1.0000000 0.80 0.8000000 0.8144000 1.20 1.1257600 0.3489920 1.60 1.2653568 -0.3892104 2.00 1.1096726 -0.9505150
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.