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

MATLAB needed Estimate Functions Theory: Read the document Euler, Heun and web d

ID: 3831733 • Letter: M

Question

MATLAB needed

Estimate Functions

Theory:

Read the document Euler, Heun and web data for RK4. You can also find these methods described in detail on the web.

Requirements:

1. Write a main function that cycles until user chooses to stop.

2. Use Buttons to choose the method that will be used, e.g. Euler, Heun or RK4.

3. Use any method of your choice to select one of the following functions to be estimated. Also use any method to input the parameters required before calling the chosen function.

a. f1’ = 10x^4 -6x   the derivative of f1 = 2x^5 -3x^2 -5

b. f2’ = 28x^6 -15x^4 +6x^2 -1 the derivative of f2 = 4x^7 - 3x^5 +2x^3 - x

4. This main function will then call the one of three embedded functions:

a. Euler

b. Heun

c. RK4

d. For the 3 above embedded functions:

i. Input parameters

1. The derivative function as an autonomous function

2. The initial point

3. Number of points

4. Interval width.

ii.The output should be a 2xn ( number of points) array of x and y

5. Write a fourth embedded function that computes the actual function’s points to compare with the selected method chosen. This function will also output a 2xn array.

6. The main function will then output to the command window the 2 arrays of 2xn points for comparison. This is how to can check your work.

Explanation / Answer

In the last lab you learned to use Heuns's Method to generate a numerical solution to an initial value problem of the form:

y = f(x, y)

y(xo) = yo

We discussed the fact that Heun's Method was an improvement over the rather simple Euler Method, and that though it uses Euler's method as a basis, it goes beyond it, attempting to compensate for the Euler Method's failure to take the curvature of the solution curve into account. Heun's Method is one of the simplest of a class of methods called predictor-corrector algorithms. In this lab we will address one of the most powerful predictor-corrector algorithms of all—one which is so accurate, that most computer packages designed to find numerical solutions for differential equations will use it by default—the fourth order Runge-Kutta Method. (For simplicity of language we will refer to the method as simply the Runge-Kutta Method in this lab, but you should be aware that Runge-Kutta methods are actually a general class of algorithms, the fourth order method being the most popular.)

The Runge-Kutta algorithm may be very crudely described as "Heun's Method on steroids." It takes to extremes the idea of correcting the predicted value of the next solution point in the numerical solution. (It should be noted here that the actual, formal derivation of the Runge-Kutta Method will not be covered in this course. The calculations involved are complicated, and rightly belong in a more advanced course in differential equations, or numerical methods.) Without further ado, using the same notation as in the previous two labs, here is a summary of the method

then, each of the ki gives us an estimate of the size of the y-jump made by the actual solution across the whole width of the interval. The first one uses Euler's Method, the next two use estimates of the slope of the solution at the midpoint, and the last one uses an estimate of the slope at the right end-point. Each ki uses the earlier ki as a basis for its prediction of the y-jump.

This means that the Runge-Kutta formula for yn+1, namely:

yn+1 = yn + (1/6)(k1 + 2k2 + 2k3 + k4)

is simply the y-value of the current point plus a weighted average of four different y-jump estimates for the interval, with the estimates based on the slope at the midpoint being weighted twice as heavily as the those using the slope at the end-points.