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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started