This document discusses Euler's method for numerically approximating solutions to first-order initial value problems. It begins by introducing Euler's method and its use of tangent lines to approximate the solution curve. Examples are provided to illustrate the application of the method and analyze errors compared to exact solutions. The discussion notes that Euler's method relies on a sequence of tangent lines to different solution curves, so accuracy depends on whether the family of solutions is converging or diverging. It emphasizes the importance of error bounds when exact solutions are unknown.
These slides contain information about Euler method,Improved Euler and Runge-kutta's method.How these methods are helpful and applied to our questions are detailed discussed in the slides.
These slides contain information about Euler method,Improved Euler and Runge-kutta's method.How these methods are helpful and applied to our questions are detailed discussed in the slides.
Numerical method (curve fitting)
***TOPICS ARE****
Linear Regression
Multiple Linear Regression
Polynomial Regression
Example of Newton’s Interpolation Polynomial And example
Example of Newton’s Interpolation Polynomial And example
Computer Oriented Numerical Analysis
What is interpolation?
Many times, data is given only at discrete points such as .
So, how then does one find the value of y at any other value of x ?
Well, a continuous function f(x) may be used to represent the data values with f(x) passing through the points (Figure 1). Then one can find the value of y at any other value of x .
This is called interpolation
Newton’s Divided Difference Formula:
To illustrate this method, linear and quadratic interpolation is presented first.
Then, the general form of Newton’s divided difference polynomial method is presented.
Numerical method (curve fitting)
***TOPICS ARE****
Linear Regression
Multiple Linear Regression
Polynomial Regression
Example of Newton’s Interpolation Polynomial And example
Example of Newton’s Interpolation Polynomial And example
Computer Oriented Numerical Analysis
What is interpolation?
Many times, data is given only at discrete points such as .
So, how then does one find the value of y at any other value of x ?
Well, a continuous function f(x) may be used to represent the data values with f(x) passing through the points (Figure 1). Then one can find the value of y at any other value of x .
This is called interpolation
Newton’s Divided Difference Formula:
To illustrate this method, linear and quadratic interpolation is presented first.
Then, the general form of Newton’s divided difference polynomial method is presented.
Iteration for Euler method by using Projectile motion
I have used the projectile motion and implement the Euler method for calculating the values of iteration to reach time at 0.2 secs.We can change it to study the response after 0.2 secs
CALIFORNIA STATE UNIVERSITY, NORTHRIDGEMECHANICAL ENGINEERIN.docxRAHUL126667
CALIFORNIA STATE UNIVERSITY, NORTHRIDGE
MECHANICAL ENGINEERING DEPARTMENT
MARCH 30 2015
ME 309
HOMEWORK #3
Ahmed Mohammed
Problem statement
1. Write a general computer code to solve system of up to five couples first order initial value problems using Heun and Newton iteration trapezoidal methods. These are combined in the same algor4thim in such way that Heun’s method is automatically employed to provide the initial guess at each time step for the Newton iteration required by fully implicit Heun’s method, and no iterations are needed. The complete pseudo-language algorithm is attached.
Test this code by solving the following problem.
Use step size h= 0.1, 0.05 and 0.025. Solve the problem first with explicit Hun’s method, and then with implicit Newton iteration integration for each value of h. employ a convergence tolerance E= 0.000001 for the Newton iteration of the trapezoidal method. The exact solution to this problem is,
Make a table of results of convergence tests (based on the exact solution) at t=1, 2, 3, 4 & 6. This table should include the exact value, the computed solution, the error and the error ratios from successive step size for each of the required values of t. discuss how these results compare with theory. Also discuss what factors should influence the choice of convergence tolerance E for the Newton iterations, and whether the specified value given above is appropriate.
2. Solve the following problem using only the newton iteration trapezoidal method.
Employ step size h=0.1, 0.05, 0.01 and iteration convergence tolerance E= 0.000001. Consider the h=0.01 solution to be the “exact” in order to carry out convergence testes between the h= 0.1 and h=0.05 solutions at t=0.5, 1, 1.5, 2. Make a table, similar to the table in problem number 1.
Mathematical Description
HEUN’S METHOD
Heun’s Method, explained in a short manner, uses the line tangent to the function at the beginning of an interval. Now if a small step is applied to it, the error with the function result will be small. Heun’s method can be explained in more detailed in the following way:
2.-
To obtain solution point (t1,y1) we can use the fundamental theorem of calculus and integrate y’(t) over [t0,t1] to get
3.- Solving for y(t1) we find,
4.- We can use a numerical integration to approximate definite integral. If we use trapezoidal rule with step size h = t1 – t0, then we get
5.- We still need to find, y(t1) but an estimation for this value will work. After this we get the following, which is the Heun’s method.
6.- When this process is repeated it generates a sequence of points that approximate the solution curve y =y(t). At each step, Euler’s method is used as a prediction then the trapezoidal rule helps to make the correction to obtain the final value. [1]
Newton’s Method
It is way to approximate the roots of an equation by taking out the curve in the equation and then replace with a tangent line. Then, it find ...
MATLAB sessions: Laboratory 3
MAT 275 Laboratory 3
Numerical
Solution
s by Euler and Improved Euler Methods
(scalar equations)
In this session we look at basic numerical methods to help us understand the fundamentals of numerical
approximations. Our objective is as follows.
1. Implement Euler’s method as well as an improved version to numerically solve an IVP.
2. Compare the accuracy and efficiency of the methods with methods readily available in MATLAB.
3. Apply the methods to specific problems and investigate potential pitfalls of the methods.
Instructions: For your lab write-up follow the instructions of LAB 1.
Euler’s Method
To derive Euler’s method start from y(t0) = y0 and consider a Taylor expansion at t1 = t0 + h:
y(t1) = y(t0) + y
′(t0)(t1 − t0) + . . .
= y0 + hf(t0, y(t0)) + . . .
= y0 + hf(t0, y0) + . . .
For small enough h we get an approximation y1 for y(t1) by suppressing the . . ., namely
y1 = y0 + hf(t0, y0) (L3.1)
The iteration (L3.1) is repeated to obtain y2 ≃ y(t2), . . . such that
yn+1 = yn + hf(tn, yn)
tn+1 = tn + h
Geometrically, the approximation made is equivalent to replacing the
solution curve by the tangent line at (t0, y0). From the figure we have
f(t0, y0) = f(t0, y(t0)) = y
′(t0) = tan θ =
y1 − y0
h
,
from which (L3.1) follows.
.
...........
...........
...........
..........s
s
y0
y1
y(t1)
t0 t1
θ
h
�
�
�
�
�
�
As an example consider the IVP
y′ = 2y = f(t, y) with y(0) = 3.
Note that here f does not explicitly depend on t (the ODE is called autonomous), but does implicitly
through y = y(t). To apply Euler’s method we start with the initial condition and select a step size h.
Since we are constructing arrays t and y without dimensionalizing them first it is best to clear these
names in case they have been used already in the same MATLAB work session.
>> clear t y % no comma between t and y! type help clear for more info
>> y(1)=3; t(1)=0; h=0.1;
c⃝2011 Stefania Tracogna, SoMSS, ASU
hamadalmershed
Typewritten Text
%%%%%%%%%%%%
hamadalmershed
Typewritten Text
hamadalmershed
Typewritten Text
hamadalmershed
Typewritten Text
hamadalmershed
Typewritten Text
xxxxxxxxxxxxxxxxxxxx
hamadalmershed
Typewritten Text
sssssssssssssssssssss
hamadalmershed
Typewritten Text
hamadalmershed
Typewritten Text
eeeeeeeeeeeeeeeeeee
hamadalmershed
Typewritten Text
hamadalmershed
Typewritten Text
wwwwwwwwwwwwwww
hamadalmershed
Typewritten Text
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
hamadalmershed
Typewritten Text
XXXXXXXXXXXXX
hamadalmershed
Typewritten Text
MATLAB sessions: Laboratory 3
Since f is simple enough we may use the inline syntax:
>> f=inline(’2*y’,’t’,’y’)
f =
Inline function:
f(t,y) = 2*y
Note that the initialization y(1)=3 should not be interpreted as “the value of y at 1 is 3”, but rather “the
first value in the array y is 3”. In other words the 1 in y(1) is an index, not a time value! Unfortunately,
MATLAB indices in arrays must be positive (a legacy from Fortran...). The ...
This math project, my final exam grade in the class, was broken up into three parts that were completed throughout the semester. The project required the use of proofs, MATLAB, and LaTeX software to present a professional document -- a presentation of our work. In the project, I proved various key components of numerical methods for approximation, and I worked through single-value decomposition problems and reduction of large-scale ordinary differential equations. Much of the project required MATLAB programming and computation, and the final report was typed into LaTeX to display properly.
I am Martha Anderson. I love exploring new topics. Academic writing seemed an exciting option for me. After working for many years with statisticsassignmenthelp.com as a statistics Assignment Help Expert, I have assisted many students with their Data Analysis assignments. I can proudly say, each student I have served is happy with the quality of the solution that I have provided.
This is testing Algorithm Writing For this assessment we will be c.pdfaroraopticals15
This is testing Algorithm Writing
For this assessment we will be combining while and if control structures together.
(A):Write a pseudocode (pen and paper) algorithm that solves the ODE y\'= f(t, y) using Euler’s
method.
(B):Convert this algorithm into MATLAB syntax, as the function euler method .
B1:Your inputs should be the start time t0, the end time tend, the function f, an initial condition
y0 and an initial step size h.
B2:If h × f(t, y) at any point exceeds 1, your function should halve the step size h.
B3:Equally, if h × f(t, y) at any point drops below 0.01, your function should double the step
size h.
B4:You should also make sure that the final solution step doesn’t ‘overshoot’ tend. (i.e. change
h during the final step to exactly reach tend).
B5:Your MATLAB code should use the function header below, and be wellcommented with a
sensible layout.
(C)Include your pseudocode algorithm, as well as the MATLAB code in your Portfolio
submission. Also include a discussion of when the code could break, or give incorrect outputs
(you DO NOT need to design your code to avoid these).
Solution
Answer:)
A)
The derivative term in the first order ivp:
y\' = f(t, y),
y(t0) = y0
is approtimated by making use of Taylor series approtimation of the dependent variable y(t) at
the point ti+1. That is
y(ti+1) = y(ti+ Dt) = y(ti) + Dty\'(ti) + (Dt2 / 2)y\'\'(ti) + . . .
= y(ti) + Dtf(ti, yi) + (Dt2 / 2)y\'\'(ti) + . . .
(... y\'(ti) = f(ti, yi))
if the infinite series is truncated from the term Dt2 onwards, then
y(ti+1) = y(ti) + Dt y\'(ti) (or)
yi+1 = yi + Dt fi for all i
That is,
for i = 0, y1 = y0 + Dt f0
i = 1, y2 = y1 + Dt f1
!
i = n-1, yn = yn-1 + Dt fn-1
Since y0 and hence f0 are known (from initial condition) in the equation corresponding to i = 0,
all the terms on the r.h.s are known. So y1 that is, y at t1 is calculated easily from this equation.
Similarly once y1 is known, r.h.s of the equation corresponding to i = 1 is also known so y2 can
be computed. As we proceed in the same way until i = n-1, yn can be obtained. This is an etplicit
method because in any equation there is only one unknown which can be separated to the left
side of the equation.
Local truncation error :
The error in the approtimation, that is the difference between the exact solution at ti+1 and the
numerical solution yi+1 is called the local truncation error (assumed that yi+1 is calculated with
exact arithmetic with out any round off error).
Ti+1 = y(ti+1) - yi+1
= y(ti+1) - yi - Dtfi
= h2/2 y\'(t) (by Taylor series & remainder theorem)
where ti < t < ti+1. Hence the order of the local truncation error for Euler scheme is
O(Dt2) as Dt -> 0.
1. Ch 2.7: Numerical Approximations:
Euler’s Method
Recall that a first order initial value problem has the form
If f and ∂f/∂y are continuous, then this IVP has a unique
solution y = φ(t) in some interval about t0.
When the differential equation is linear, separable or exact,
we can find the solution by symbolic manipulations.
However, the solutions for most differential equations of
this form cannot be found by analytical means.
Therefore it is important to be able to approach the problem
in other ways.
00 )(),,( ytyytf
dt
dy
==
2. Direction Fields
For the first order initial value problem
we can sketch a direction field and visualize the behavior of
solutions. This has the advantage of being a relatively
simple process, even for complicated equations. However,
direction fields do not lend themselves to quantitative
computations or comparisons.
,)(),,( 00 ytyytfy ==′
3. Numerical Methods
For our first order initial value problem
an alternative is to compute approximate values of the
solution y = φ(t) at a selected set of t-values.
Ideally, the approximate solution values will be accompanied
by error bounds that ensure the level of accuracy.
There are many numerical methods that produce numerical
approximations to solutions of differential equations, some of
which are discussed in Chapter 8.
In this section, we examine the tangent line method, which is
also called Euler’s Method.
,)(),,( 00 ytyytfy ==′
4. Euler’s Method: Tangent Line Approximation
For the initial value problem
we begin by approximating solution y = φ(t) at initial point t0.
The solution passes through initial point (t0, y0) with slope
f(t0,y0). The line tangent to solution at initial point is thus
The tangent line is a good approximation to solution curve on
an interval short enough.
Thus if t1 is close enough to t0,
we can approximate φ(t1) by
( )( )0000 , ttytfyy −+=
,)(),,( 00 ytyytfy ==′
( )( )010001 , ttytfyy −+=
5. Euler’s Formula
For a point t2 close to t1, we approximate φ(t2) using the line
passing through (t1, y1) with slope f(t1,y1):
Thus we create a sequence yn of approximations to φ(tn):
where fn = f(tn,yn).
For a uniform step size h = tn – tn-1, Euler’s formula becomes
( )
( )
( )nnnnn ttfyy
ttfyy
ttfyy
−⋅+=
−⋅+=
−⋅+=
++ 11
12112
01001
( )( )121112 , ttytfyy −+=
,2,1,0,1 =+=+ nhfyy nnn
6. Euler Approximation
To graph an Euler approximation, we plot the points
(t0, y0), (t1, y1),…, (tn, yn), and then connect these points with
line segments.
( ) ( )nnnnnnnn ytffttfyy ,where,11 =−⋅+= ++
7. Example 1: Euler’s Method (1 of 3)
For the initial value problem
we can use Euler’s method with h = 0.1 to approximate the
solution at t = 0.1, 0.2, 0.3, 0.4, as shown below.
( )( )( )
( )( )( )
( )( )( ) 80.3)1.0(88.22.08.988.2
88.2)1.0(94.12.08.994.1
94.1)1.0(98.2.08.998.
98.)1.0(8.90
334
223
112
001
≈−+=⋅+=
≈−+=⋅+=
≈−+=⋅+=
=+=⋅+=
hfyy
hfyy
hfyy
hfyy
0)0(,2.08.9 =−=′ yyy
8. Example 1: Exact Solution (2 of 3)
We can find the exact solution to our IVP, as in Chapter 1.2:
( )
( )t
Ct
ey
ky
ekkey
Cty
dt
y
dy
yy
yyy
2.0
2.0
149
491)0(
,49
2.049ln
2.0
49
492.0
0)0(,2.08.9
−
−
−=⇒
−=⇒=
±=+=
+−=−
−=
−
−−=′
=−=′
9. Example 1: Error Analysis (3 of 3)
From table below, we see that the errors are small. This is
most likely due to round-off error and the fact that the
exact solution is approximately linear on [0, 0.4]. Note:
t Exact y Approx y Error % Rel Error
0.00 0 0.00 0.00 0.00
0.10 0.97 0.98 -0.01 -1.03
0.20 1.92 1.94 -0.02 -1.04
0.30 2.85 2.88 -0.03 -1.05
0.40 3.77 3.8 -0.03 -0.80
100ErrorRelativePercent ×
−
=
exact
approxexact
y
yy
10. Example 2: Euler’s Method (1 of 3)
For the initial value problem
we can use Euler’s method with h = 0.1 to approximate the
solution at t = 1, 2, 3, and 4, as shown below.
Exact solution (see Chapter 2.1):
( )
( )
( )
( )
15.4)1.0()15.3)(2(3.0415.3
15.3)1.0()31.2)(2(2.0431.2
31.2)1.0()6.1)(2(1.046.1
6.1)1.0()1)(2(041
334
223
112
001
≈+−+=⋅+=
≈+−+=⋅+=
=+−+=⋅+=
=+−+=⋅+=
hfyy
hfyy
hfyy
hfyy
1)0(,24 =+−=′ yyty
t
ety 2
4
11
2
1
4
7
++−=
11. Example 2: Error Analysis (2 of 3)
The first ten Euler approxs are given in table below on left.
A table of approximations for t = 0, 1, 2, 3 is given on right.
See text for numerical results with h = 0.05, 0.025, 0.01.
The errors are small initially, but quickly reach an
unacceptable level. This suggests a nonlinear solution.
t Exact y Approx y Error % Rel Error
0.00 1.00 1.00 0.00 0.00
0.10 1.66 1.60 0.06 3.55
0.20 2.45 2.31 0.14 5.81
0.30 3.41 3.15 0.26 7.59
0.40 4.57 4.15 0.42 9.14
0.50 5.98 5.34 0.63 10.58
0.60 7.68 6.76 0.92 11.96
0.70 9.75 8.45 1.30 13.31
0.80 12.27 10.47 1.80 14.64
0.90 15.34 12.89 2.45 15.96
1.00 19.07 15.78 3.29 17.27
t Exact y Approx y Error % Rel Error
0.00 1.00 1.00 0.00 0.00
1.00 19.07 15.78 3.29 17.27
2.00 149.39 104.68 44.72 29.93
3.00 1109.18 652.53 456.64 41.17
4.00 8197.88 4042.12 4155.76 50.69
t
ety 2
4
11
2
1
4
7
:SolutionExact
++−=
12. Example 2: Error Analysis & Graphs (3 of 3)
Given below are graphs showing the exact solution (red)
plotted together with the Euler approximation (blue).
t Exact y Approx y Error % Rel Error
0.00 1.00 1.00 0.00 0.00
1.00 19.07 15.78 3.29 17.27
2.00 149.39 104.68 44.72 29.93
3.00 1109.18 652.53 456.64 41.17
4.00 8197.88 4042.12 4155.76 50.69
t
ety 2
4
11
2
1
4
7
:SolutionExact
++−=
13. General Error Analysis Discussion (1 of 4)
Recall that if f and ∂f/∂y are continuous, then our first order
initial value problem
has a solution y = φ(t) in some interval about t0.
In fact, the equation has infinitely many solutions, each one
indexed by a constant c determined by the initial condition.
Thus φ is the member of an infinite family of solutions that
satisfies φ(t0) = y0.
00 )(),,( ytyytfy ==′
14. General Error Analysis Discussion (2 of 4)
The first step of Euler’s method uses the tangent line to φ at
the point (t0, y0) in order to estimate φ(t1) with y1.
The point (t1, y1) is typically not on the graph of φ, because y1
is an approximation of φ(t1).
Thus the next iteration of Euler’s method does not use a
tangent line approximation to φ, but rather to a nearby
solution φ1 that passes through the point (t1, y1).
Thus Euler’s method uses a
succession of tangent lines
to a sequence of different
solutions φ, φ1, φ2,… of the
differential equation.
15. Error Analysis Example:
Converging Family of Solutions (3 of 4)
Since Euler’s method uses tangent lines to a sequence of
different solutions, the accuracy after many steps depends on
behavior of solutions passing through (tn, yn), n = 1, 2, 3, …
For example, consider the following initial value problem:
The direction field and graphs of a few solution curves are
given below. Note that it doesn’t matter which solutions we
are approximating with tangent lines, as all solutions get closer
to each other as t increases.
Results of using Euler’s method
for this equation are given in text.
2/
326)(1)0(,23 ttt
eetyyyey −−−
−−==⇒=−+=′ φ
16. Error Analysis Example:
Divergent Family of Solutions (4 of 4)
Now consider the initial value problem for Example 2:
The direction field and graphs of solution curves are given
below. Since the family of solutions is divergent, at each step
of Euler’s method we are following a different solution than
the previous step, with each solution separating from the
desired one more and more as t increases.
4112471)0(,24 2t
etyyyty ++−=⇒=+−=′
17. Error Bounds and Numerical Methods
In using a numerical procedure, keep in mind the question of
whether the results are accurate enough to be useful.
In our examples, we compared approximations with exact
solutions. However, numerical procedures are usually used
when an exact solution is not available. What is needed are
bounds for (or estimates of) errors, which do not require
knowledge of exact solution. More discussion on these issues
and other numerical methods is given in Chapter 8.
Since numerical approximations ideally reflect behavior of
solution, a member of a diverging family of solutions is harder
to approximate than a member of a converging family.
Also, direction fields are often a relatively easy first step in
understanding behavior of solutions.