Solutions to ODEs

1 / 92

Solutions to ODEs - PowerPoint PPT Presentation

Solutions to ODEs. A general form for a first order ODE is Or alternatively. A general form for a first order ODE is Or alternatively We desire a solution y(x) which satisfies (1) and one specified boundary condition. .

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

Solutions to ODEs

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

Solutions to ODEs

A general form for a first order ODE is
• Or alternatively
• We desire a solution y(x) which satisfies (1) and one specified boundary condition.
To do this we divide the interval in the independent variable x for the interval [a,b] into subintervals or steps.
To do this we divide the interval in the independent variable x for the interval [a,b] into subintervals or steps.
• Then the value of the true solution is approximated at n+1 evenly spaced values of x.
• Such that,
• where,
We denote the approximation at the base pts by so that
• The true derivation dy/dx at the base points is approximated by or just
• where
We denote the approximation at the base pts by so that
• The true derivation dy/dx at the base points is approximated by or just
• where
• Assuming no roundoff error the difference in the calculated and true value is the truncation error,
Numerical algorithms for solving 1st order odes for an initial condition are based on one of two approaches:
• Direct or indirect use of the Taylor series expansion for the solution function
• Use of open or closed integration formulas.
The various procedures are classified into:
• One-step: calculation of given the differential equation and
• Multi-step: in addition the previous information they require values of x and y outside of the interval under consideration
The first method considered is the Taylor series method.
• It forms the basis for some of the other methods.

Taylor Expansion

For this method we express the solution about some starting point using a Taylor expansion.
Where
• And
• etc.
Consider the example, where
• And initial condition
Consider the example, where
• And initial condition
• Differentiating and then applying initial conditions,
Consider the example, where
• And initial condition
• Differentiating and then applying initial conditions,
Consider the example, where
• And initial condition
• Differentiating and then applying initial conditions,
Consider the example, where
• And initial condition
• Differentiating and then applying initial conditions,
Continuing,

. .

. .

Here the third derivative and higher are zero.

Substituting these values into Taylor expansion gives,
• To determine the error lets consider compare this to the analytic solution.
Substituting these values into Taylor expansion gives,
• To determine the error lets consider compare this to the analytic solution.
• To do this we will integrate the differential equation.
Integrating,
• Simplifying,
Homework (Due Thursday)
• Consider the function
• Initial condition
• Write the Taylor expansion and show that it can be written in the form,
• Show if terms up to are retained, the error is,
Stepping from to follows from the Taylor expansion of about .
• Equivalently stepping from to can be accomplished from the Taylor expansion of about .
Stepping from to follows from the Taylor expansion of about .
• Equivalently stepping from to can be accomplished from the Taylor expansion of about .
Algorithms for which the last term in expansion is dropped are of order hn.
• The error is or order hn+1.
• The local truncation error is bounded as follows
• where
However differentiation of can be complicated.
• Direct Taylor expansion is not used other than the simplest case,
• Big Oh is the order of the algorithm.
Usually only the value of is the only value of that is known, therefore must be replaced by .
• Thus,
• In general,

which is known as Euler’s method.

Euler’s Method

y

y1

y(x)

y(x0)

y(x1

h

x0

x1

x

• The geometric interpretation is shown the diagram.

y

y1

y(x)

y(x0)

y(x1

h

x0

x1

x

• The solution across the interval[x0,x1] is assumed to follow the line tangent to y(x) at x0.
When the method is applied repeatedly across several intervals in sequence, the numerical solution traces out a polygon segment with sides of slope fi, i=0,1,2,…,(n-1).
The simple Euler method is a linear approximation, and only works if the function is linear (or at least linear in the interval).
The simple Euler method is a linear approximation, and only works if the function is linear (or at least linear in the interval).
• This is inherently inaccurate.
• Because of this inaccuracy small step sizes are required when using the algorithm.
From the graph, as h -> 0, the approximation becomes better because the curve in the region becomes approx. linear.

y

y1

y(x)

y(x0)

y(x1

h

x0

x1

x

Modified Euler

• The average slope may be approximated by the mean of the slopes at the beginning and the end of the interval.
• The average slope may be approximated by the mean of the slopes at the beginning and the end of the interval.
• This modified Euler may be written as the arithmetic average,

or

However it is not possible to implement this directly.
• Instead we first “predict” a value for using the simple Euler method.
• Then use this value to determine the gradient of the slope at . This gives a “corrected” value for .
• However since the predicted value is not usually accurate, is also inaccurate.

Corrector curve using

values of predictor

Predictor curve using

the Simple Euler

True value

Runge-Kutta Methods

The solution of a differential equation using higher order derivatives of the Taylor expansion is not practical.
The solution of a differential equation using higher order derivatives of the Taylor expansion is not practical.
• Since for only the simplest functions, these higher orders are complicated. Also there is no simple algorithm which can be developed.
• This is because each series expansion is unique.
However we have methods which use only 1st order derivates while simulating higher order(producing equivalent results).
• These one step methods are called Runge-Kutta methods.
However we have methods which use only 1st order derivates while simulating higher order(producing equivalent results).
• These one step methods are called Runge-Kutta methods.
• Approximation of the second, third and fourth order (retaining h2, h3, h4 respectively in the Taylor expansion) require estimation at 2, 3 , 4 pts respectively in the interval (xi,xi+1).
The Runge-Kutta methods have algorithms of the form,
• where is the increment function.
• The increment function is a suitably chosen approximation to on the interval .
The Runge-Kutta methods have algorithms of the form,
• where is the increment function.
• The increment function is a suitably chosen approximation to on the interval .
• Because of the amount of algebra involved, on the simplest case(2nd order) will be derived in detail.

Derivation of the 2nd order Runge-Kutta

Let be the weighted average of two derivative evaluations and on the interval ,
• Then,
• Let,
• The constants p and q will be established.
Expanding in a Taylor series for a function of two variables and dropping terms higher than h,
• NB: 1st few terms in two-variable Taylor series,
Recall:
• Substituting for ,
Recall:
• Substituting for ,
Using the chain rule can be written as,
• Equating like terms in equation 1 and 2,
Assuming that we compare coefficients. So that,
• Therefore,
• However we have four unknowns and only three equations.
• We have the variable b which can be chosen arbitrarily.
• Two common choices are and
For . and we get,
• which can be written as,
• where
• This improved Euler method or Heun’s Method.
For . and we get,
• where
• This improved polygon method or the modified Euler’s Method.
• Consider the 3rd order Runge-Kutta,
• approximate the derivative at the points on the interval.
• Consider the 3rd order Runge-Kutta,
• approximate the derivative at the points on the interval.
• For this case,
Third order Runge-Kutta algorithms are of the form,
• To determine a,b,c,p,r and s,
Third order Runge-Kutta algorithms are of the form,
• To determine a,b,c,p,r and s,
• Expand as a Taylor series.
Third order Runge-Kutta algorithms are of the form,
• To determine a,b,c,p,r and s,
• Expand as a Taylor series.
• Compare coefficients of the Runge-Kutta and Taylor series.
The equations formed are,
• Two of the constants a,b,c,p,r,s are arbitrary.
• If is a function of x only then this reduces to the Simpson’s rule.