Question: MATLAB question: Develop code that will implement Euler's method for a first-order differential equation defined in a file myode. Use the same conventions as the

MATLAB question:

Develop code that will implement Euler's method for a first-order differential equation defined in a file myode. Use the same conventions as the inbuilt Matlab functions (e.g., ode45 - if your function is called euler, I should be able to run it as [t,y] = euler(@myode,tspan,y0). Your method should refine the step size until you have achieved convergence. As a test function, use dx/dt = -2x with x(0) = 10 . Integrate over t = [0 4].

Modify your Euler's code to implement a general second-order Runge-Kutta method. Use the same test function as above. Solve the test function analytically.

For Euler's and Heun's methods, make a plot showing how the absolute true error varies with step-size (you need to solve the problem by hand to obtain the true error). Do your results agree with your expectations?

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!