(a) Implement the Crank-Nicolson method (function y = CrankNicolson(func,t,y1)) defined as ti+1 +ti yi + Yi+1 4+1 = y +

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

(a) Implement the Crank-Nicolson method (function y = CrankNicolson(func,t,y1)) defined as ti+1 +ti yi + Yi+1 4+1 = y +

Post by answerhappygod »

A Implement The Crank Nicolson Method Function Y Cranknicolson Func T Y1 Defined As Ti 1 Ti Yi Yi 1 4 1 Y 1
A Implement The Crank Nicolson Method Function Y Cranknicolson Func T Y1 Defined As Ti 1 Ti Yi Yi 1 4 1 Y 1 (66.71 KiB) Viewed 26 times
(a) Implement the Crank-Nicolson method (function y = CrankNicolson(func,t,y1)) defined as ti+1 +ti yi + Yi+1 4+1 = y + (ti+1 – t) 2 2 to solve initial value problems of the form y(t) = f(t, y(t)). t. (b) Using the problem y(t) = 10 cos(t) - 2y(t) with y(0) = 1 and 0 <<< 1 solve the ODE using backward Euler, forward Euler, and Crank-Nicolson for different number of time steps n = 24, 25,... 29 and compute the error to the reference solution. The expression error = max(abs(yref-y)); will compute the error max lyrej (ti) – yil 1 if yref is the vector of exact values at points t; and y is the vector of y values computed with one of the methods. Output a table for each of the three methods with three columns each: time step size, corresponding error, and error rate. Note: the exact solution to this ODE is given by: y(t) = -3e-24 + 2 sin(t) + 4 cos(t). Make sure you get the rates we are expecting from the orders as discussed in lecture. Finally, make sure you are not confusing number of time steps n with the number of points ti.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply