Engineering Numerical Analysis
Engineering Numerical Analysis
Engineering Numerical Analysis
Qais Fadhil
إعداد
مىفق يحيى عثمان
أستاذ مساعد
1
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
2
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
The Aims
1. General aims:
This course will provide the student with a foundation in
mathematical principles and to solve the differential equations with
classic mathematics and numerical methods.
.) (نصف السنة. درجة امتحان فصلي نظري20 ويتضمن: الفصل األول-
. درجة امتحان فصلي نظري20 ويتضمن: الفصل الثاني-
) حضور الطالب+ درجات (امتحانات سريعة10 : أعمال السنة-
) درجة50 (فيكون السعي السنوي من
درجة50 : االمتحان النهائي-
) درجة011 (فتكون الدرجة النهائية من
3
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
Syllabus: :المنهاج
week Topics
0 First Order Differential Equations
2 Methods of Solving First Order D.E.
3 Applications on First Order D.E.
4 Second Order Linear D.E. with Constant Coefficients
5 Applications on Second Order D.E.
6 Higher Order Linear D.E.
7 Applications on Higher Order D.E.
8 Integrating Factors
9 Fourier series for Periodic Functions
10 Even and Odd Functions
11 Applications on Fourier Series
12 Power Series
13 Solution of ODE by Power Series
14 Numerical Solution of Nonlinear D.E.
15 Simple Iteration Method
16 Newton-Raphson Method
17 Interpolation
18 Lagrange Interpolation
19 Solution of Linear Instantaneous D.E.
20 Direct and Indirect Method
21 Numerical Integration
22 Numerical Differentiation
23 Solving Partial D.E.
24 Applications
25 Newton Method for Curve Editing
26 Solving Ordinary D.E.
27 Runge-Kutta Method
28 Power Series
29 Exponential Equations
30 Frobenos Method
References: :المصادر
4
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
5
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
6
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
Engineering Analysis
Using Modeling
can be solved
using either or:
Classical Mathematics
(First term of year) Numerical Methods
(Second term of year)
Definitions:
# Partial D.E.: (P.D.E.): If the unknown function depends on two or more independent
variables, the differential equation is a partial differential equation.
7
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
# Order of D.E.: Is the order of the highest derivative that appears in the D.E.
# First Order D.E.: A differential equation which contains only in addition to y and
given functions of x and constants.
# Linear D.E.: When the dependent variable (like y) and its derivatives ( ́ ) are
of first degree.
Therefore, the general linear ordinary D.E. of order n must take the form:
( ) ( ) ( ) ( ) ( )
and any D.E. cannot be put in this form is called "Nonlinear D.E.".
Examples:
…………………… Linear first order O.D.E.
………………… …Linear second order O.D.E.
( ) . . Non-linear third order O.D.E.(y'''y')
…… Linear second order O.D.E.
………..Non-linear second order O.D.E.(y y')
…………… …… Non-linear second order O.D.E.(sin y)
……………………Non-linear second order O.D.E.(y' y'')
( ) …………………Non-linear first order O.D.E.(y')2
………………Linear second order O.D.E.
8
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
# General solution of D.E.: (G.S.): When solving the D.E. to find the function that
satisfies the D.E. The solution with the unknown constants of (integration or
solution) is called "General Solution".
# Particular solution of D.E.: (P.S.): When the values of the unknown constants of
(integration or solution) are determined using initial or boundary conditions,
the solution is called "Particular Solution".
Note that:
The standard form for a first-order D.E. in the unknown function y(x) is:
y' = f(x,y) or dy/dx = f(x,y) (like dy/dx = x3 + 2y = f(x,y))
where the derivative y′ appears only on the left side. Many, but not all, first-order
differential equations can be written in standard form by algebraically solving for y′ and
then setting f (x,y) equal to the right side of the resulting equation.
9
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
d
Example#1: Solve the D.E. :
d
Solution: This equation can be written in the form:
(x2+2) dx – y dy = 0 which is separable with A(x) = x2+2 and B(y) = -y.
Integrating both sides, gives: ∫(x2+2) dx - ∫y dy = ∫0 then solving gives;
OR √
d √
Example#2: Solve the D.E.:
d
Solution: separating variables and integrating both sides:
∫ ∫
√
| | ( | | ) G.S.
∫9 y dy =∫ -4 x dx or 9 y2/2 = -2 x2 + c1
√
or G.S. (where c2 = c1/2)
11
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
therefore; OR ( ) ………..(G.S.)
If the D.E. has the form: M(x,y) dx + N(x,y) dy =0 then this D.E. is called exact D.E.
Now, if the exactness condition is satisfied, solve the D.E. using u=∫ M dx + k(y)
where, u=u(x,y),and k(y) is constant of integration, then after this integration derive
Solution: first test for exactness condition: M(x,y)= x3+3xy2 and N(x,y)= 3x2y+y3
and;
11
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
so, ∫ ( ) ∫( ) ( ) ( ) …(1)
d ( )
To find k(y): d
d ( )
cancelling similar terms from the two sides; ( )
d
and;
which are not equal, so the D.E. is not exact! Therefore, to change it to exact we need
to multiply it by a function called "Integrating Factor" (I.F.)
Now, multiply the given non-exact D.E. by I.F.=( ), to get a new equation:
12
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
( ) ( )
OR I.F.(y) = ∫ ( )
( ) ( ) …. NOT EXACT
( ) ( )
Try I.F.; I.F.(x) = ∫ ( )
( ) ∫ ( ( ) ( )) ∫ , Here ignore c
c ( )
( ) ( )
therefore,
multiply the D.E. by x3, we get; 2x3 sin(y2)dx + x4y cos(y2)dy = 0
( ( )) ( ) ( ( )) ( ) o.k.
∫ ( ) ( ) ( ), ( ) ( ) ( )
and; ( ) ( ) …… G.S.
Substituting for the initial condition that x = 2, y = (π/2)0.5 into the G.S., we get:
therefore, ( ) ( ) …… P.S.
13
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
1) Homogenous D.E.:
y' + p(x) y = 0 this equation can be easily solved by separating variables;
d
( ) ∫ ( )
2) Non-homogenous D.E.:
Here; y' + p(x) y = r(x)
d d
OR d ( ) ( )
d
, this means that this D.E. is not exact, to change it to exact multiply
it by I.F.;
( ) ∫ ( ) ∫ ( ) ∫
( ) ∫ d
∫ d ( ) ∫ d
multiply the two sides by I.F. (x);
∫ d ∫ d
or ( )
∫ d ∫ d
integrating w.r.t. x ∫
∫ d
divide both sides by and putting ∫
2x
Example#1: Solve the following linear D.E.: y' - y = e
d
Example#1: Solve the D.E.
d
Solution: This D.E. is not separable, nor exact, try to change it to Bernoulli eqn.
d d
( ) … (1)
d d
15
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
∫ d
H.W.:
A) Find the G.S. for the following D.E.s:
1) 2 x 3 y 2 dx 3x 4 y 1 dy 0
2) y y sin x e
cos x
3) 2 x 3 y 2 dx 3x 4 y 1 dy 0
16
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
Example#1: The tank in figure contains 200 gallons of water in which 40 lb of salt are
dissolved. Five gallons of brine, each containing 2 lb of dissolved salt, run into the
tank per minute, and the mixture, kept uniform by stirring, runs out at the same
rate. Find the amount of salt y(t) at any time t.
OR …. G.S.
Note: the initial amount of salt in the tank is y(0)=40 Ib (given above);
Thus; y = 40 = 400 – 40 ce0, c = 360/40 substituting in the G.S.;
Now, y(t) = 400 - 360 e-0.025t (Ib) (P.S.) (amount of salt in the tank at any time t)
Example#2: Assume that the tank in Ex.#1 above contains 1000 gallons of water in
which 200 lb of salt are dissolved. Fifty gallons of brine, each containing (1+cos t)
lb of dissolved salt, run into the tank per minute, and the mixture, kept uniform by
stirring, runs out at the same rate. Find the amount of salt y(t) at any time t.
Solution: The time rate of change of salt is: y' = dy/dt = salt inflow rate –
salt outflow rate.
OR y' = In - Out
In = 50*(1+cos t) lb/min.
17
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
(∫ ( ) )
Example#3: Suppose that you turn off the heat in your home at night 2 hrs before you
go to bed; call this time (t = 0). If temperature T at t = 0 is 66 0F and at the time you
go to bed (t = 2) has dropped to 63 0F. What temperature can you expect in the
morning, say 8 hrs later (t = 10)? This process of cooling off will depend on the
outside temperature TA, which is assumed to be constant at 32 0F.
Solution: Newton's Law of Cooling shows that the time rate of change dT/dt of
temperature T of a body is proportional to the difference between T and the
outside temperature TA.
dT/dt = k (T-TA) = k (T-32), where k is unknown constant of proportionality.
d
separating variables; , integrating; ln(T-32) = k t + c1
( ) ( ) ( )
1) Homogenous Equations:
For second order homogenous linear D.E., a general solution will be of the form:
y = c1 y1 + c2 y2 , where c1 & c2 are two arbitrary constants, and y1 & y2 are two
suitable solutions. Now, for the initial value problem, there must be two initial
conditions: y(xo) = ko, y'(xo) = k1
Where p(x) and q(x) are constants and not functions of x, the D.E. is called "an
equation with constant coefficients";
Here a&b are "constant coefficients".
in operator form: D2 + aD + b = 0
characteristic equation: λ2 + aλ + b = 0
( √ b) ( √ )
( √ b) ( √ )
Now; y = 6 e 2 x + 4 e -3 x … P.S.
Here, λ1= λ2= λ = -a / 2, and y = c1y1+c2y2 = c1 eλ x + c2 x eλ x (i.e. multiply the second term by x)
( √ b) ( √ )
( √ b) ( √ )
(here a2 - 4b = 0) and λ1 = λ2 = λ = -a / 2 = -4
therefore, y = c1y1 + c2y2 = c1 e -4 x + c2 x e -4 x …. G.S.
21
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
Using √ and making the term a2- 4b positive by pulling out (-1) from the root
( √ ) ( √ ) ( √b )
( )
( )
a a
( )
( )
( ) …. G.S.
( √ ) ( √( ) )
( √ ) ( √( ) )
and; w = 2 ( ) …. G.S.
using the first initial condition y(0) = 0 gives; y(0) = A = 0
22
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
1) Un-damped System:
Hooke’s law: The restoring force F of a spring is
equal and opposite to the forces applied to the
spring and is proportional to the extension
(contraction) of the spring as a result of the
applied force; that is, F = −kl, where k denotes
the constant of proportionality, generally called
the spring constant, l is the extension (or Δ).
For example A steel ball weighing 128 lb is suspended from a spring, and the spring is
stretched 2 ft from its original length. Thus, F = -128 lb. Hooke’s law then gives -128 =
-k(2), or k = 64 lb/ft. OR simply k = F/Δ = 128/2 , so; k = 64 lb/ft.
To determine the equation of motion y(t) for this mechanical system;
From Newton's 2nd law; m*a = F OR m y'' = F
where F is the resultant of all forces acting on the body
at time t. Assuming downward direction as +ve, when Un-stretched
spring So
stretching the spring, an upward force is Fo = +k. So -a-
(Hooke's law) F=k.So y
System in static
Now, from equilibrium in vertical direction at static equilibrium
-b-
System in
case (b): ∑Fv = 0, -F + W = 0 motion
therefore, -k So + mg = 0, -c-
and, k So = mg W=mg
a
y = A cos wt + B sin wt, where; √b √ (a = 0)
2) Damped System:
If we connect the mass to a dashpot, we have to take the
corresponding viscous damping into account. The damping force
(Fd) has the direction opposite to the instantaneous motion, and it
is proportional to the velocity y' of the mass.
Now, Fd = -c y' (negative because it is opposite to motion)
Dashpot c
where, c is damping constant and has units of mass/second.
Damped System
24
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
k.y
now, ∑Fv = m av
+W - k So – ky - cy' = my'', but W = k So k.So
c
the roots are; √
c
and, √
I/ Over damping; c2-4mk > 0 OR c2 > 4mk, gives "distinct real roots" (λ1, λ2)
t t
Here c is so large that c2 > 4mk, y(t) = c1 e λ1 + c2 e λ2 …G.S.
The body here do not oscillate.
II/ Critcal damping; c2-4mk = 0 OR c2 = 4mk, gives a "real double root" (λ)
Here B = 0 and λ1=λ2= -
and , y(t) = (c1 + c2 t) e –a t / 2 …. G.S.
The body here can have at most one passage through the equilibrium position.
III/ Under damping; c2-4mk < 0 OR c2 < 4mk, gives " conjugate complex roots".
This is the most interesting case; here c is so small that c2 < 4mk, then;
c
√ √
c a
gives;
Example#1: Solve the previous example (iron ball) but if the system has damping
constant given by:
1. c = 200 kg/sec.
2. c = 179.8 kg/sec.
3. c = 100 kg/sec.
2) Non-homogenous Equations:
y'' + p(x) y' + q(x) y = r(x) (non-homogenous 2nd order linear D.E.)
The general solution of this D.E. is of the form: y(x) = yh (x) + yp (x)
where [yh] is homogenous solution = c1 y1(x) + c2 y2(x)
and [yp] is any particular solution for the right hand side of the D.E. (r(x)),
and the final particular solution is obtained by getting values for c 1&c2 in yh (x).
26
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
Example#1: Solve the initial value problem for the non-homogenous equation:
y'' + 2y' + 101y = 10.4ex, y(0) = 1.1, y'(0) = -0.9
27
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
yh = A cos2x + B sin2x
For the non-homogenous part, suggest the choice: yp = k2x2+k1x+ko, then y''p = 2k2
For yp choose yp = k ex. But we see that ex is a solution of yh, therefore our new
suggestion must be; yp = k x ex, thus y'p = k(ex+x ex) & y''p = k(2 ex+x ex)
y = c1 ex + c2 e2x – x ex …. G.S.
Example#4: Solve the initial value problem: y'' + 2y' + y = e–x, y(0) = -1, y'(0) = 1
28
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
Assume yp= k e–x. But e–x is a solution of yh, therefore, assume yp = k x e–x which is
also a solution of yh. Therefore assume yp = k x2 e–x, and y'p = k(2x-x2)e-x, and y''p = k(2-
4x+x2)e-x
substituting gives; k(2-4x+x2)e-x +2k(2x-x2)e-x +kx2 e-x =2k e-x =e-x, gives k = 1/2
therefore, y = (c1+c2x)e-x + 0.5x2 e-x …. G.S.
the first initial conditions gives y(0) =c1 = -1, differentiating gives;
y'(0) = c2 - c1 = 1, OR c2 = 0
therefore, y = (0.5 x2 -1) e-x …. P.S.
29
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
31
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
lb/ft
OR; ( ) ( )
Solving gives a real double root , and benefitting from the two initial conditions;
H.W: Repeat the same example above but with 5 lbs exerted force when the velocity is
√
2 ft/sec. Answer: ( ) ( )
31
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
Joseph Fourier: (1768-1830) French physicist and mathematician form Paris, accompanied
Napoleon to Egypt. He developed the theory of heat conduction (heat equation) using these
series which then became a most important tool in mathematical physics.
# Periodic Function: A function f(x) is called periodic if it is defined for all x such
that:
f(x+p) = f(x), where p any positive number and called a "period" of f(x) or
length of interval.
( ) ∑ ( b )
Integrating on both sides from –π to π:
∫ ( ) ∫ ∑ ( b )
∫ ( ) ∫ ∑ ( ∫ b ∫ )
This gives; ∫ ( )
32
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
∫ ( ) n = 1,2,3,….
Example#1: Find the Fourier series of the periodic function in figure below.
The formula is:
( ) , ( ) ( )
f(x
k )
x
-π 0 π 2π
-k
Solution: ∫ ( ) *∫ ∫ +
| |
This can be seen from that area under curve of f(x) between –π and π is zero.
∫ ( ) *∫ ( ) ∫ +
* | | +
because sin nx = 0 at –π, 0, π for all n = 1,2,3,…
b ∫ ( ) *∫ ( ) ∫ +
c c
* | | + , since cos(-α)=cos α and cos 0=1
b ( ( ) ) ( )
Now, cosπ = -1, cos2π = 1, cos3π = -1,…..etc., so in general:
33
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
, and thus ,
Therefore; the Fourier coefficients for bn:
b b b b b b
And the Fourier series of f(x) is:
( ) ( )
Now, ( ) ( )
y
odd if g(-x)=-g(x) y = g(x)
where; ∫ ( ) ∫ ( ) , n = 1,2,3,…
where; b ∫ ( ) , n = 1,2,3,…
34
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
Example#1: Find the two Fourier half-range expansions for the periodic
function in figure below. The formula is: f(x)
k
( ) {
( ) x
0 L/2 L
( )
Similarly, for the second integral;
∫ ( ) ( ) | ∫
( ) ( )
After cancelling sine terms and L2 terms, an will be:
( )
Thus a1(n=1) = 0, ( ) , a3(n=3) = 0, a4(n=4) = 0, a5(n=5) = 0, ( )
-L 0 L/2 L x
-k
Odd extension
35
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
Power Series:
Is a standard method for solving linear ODEs with variable coefficients. It gives
solutions in the form of power series. These series can be used for computing values,
graphing curves, proving formulas, and exploring properties of solutions.
So the power series (in powers of x-x0) is:
Then substitute
36
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
….. G.S.
Also, we can generalize the Power Series formula to solve the second order ODE s of
the form:
Then we use;
Add terms of like powers of x (x0, x , x2,….) and equate the sum obtained to zero;
37
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
Numerical Analysis
Numeric methods: are methods that are suitable for solving, numerically and
approximately, the difficult problems on computers, calculators, or even on hands.
Degree of accuracy (D): is number of significant figures after the digit or number of
significant digits. For example the number 3.4148 has 4D (or 4S) accuracy, and the
number 6394.21 has 2D (or 2S) accuracy.
the error of ̃
Hence;
Note: We always work with absolute value of error because its sign is not important.
38
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
Iteration Method: Is a method to find x-value in which we start from an initial guess
(which may be poor) and compute step by step (in general better and better)
approximations of an unknown solution of f.
This method is done by changing the equation f(x) = 0 to x = g(x), then we choose an xo
to compute x1 = g(xo), x2 = g(x1), and so on. In general:
CONVERGES
S
DIVERGES
39
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
CONVERGES
CONVERGES
Note: At convergence, the solution goes into a specific value and more iterations give
more accurate value. Therefore we need (Degree of Accuracy) to stop the iterations.
41
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
Example#1: Set up a Newton iteration for computing the square root x of a given
positive number c and apply it to c = 2. Find the approximate solution to 6D
accuracy, starting from x0 = 1.
Solution:
x5 = 1.414214. Note that x4 and x5 are equal to the sixth significant figure, and this
means that the solution to 6D accuracy is x = 1.414214.
Example#2: Apply Newton’s method to the equation f(x)=x 3+x-1=0, use 6D accuracy.
Solution: From Newton’s formula, we get: Starting from x0 = 1
x5 = 0.682328. Note that x4 and x5 are the same to the sixth significant digit, therefore,
the approximate solution to 6D is x = 0.682328.
41
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
Solution:
n xn-1 xn Nn Dn xn-1-xn
1 2.000000 1.900000 -0.000740 -0.174005 -0.004253
2 1.900000 1.895747 -0.000002 -0.006986 -0.000252
3 1.895747 1.895494
4 1.895494 1.895494
Now, let:
42
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
Given (x0,f0), (x1,f1), (x2,f2),…,(xn,fn) with arbitrarily spaced xj, Lagrange had the idea
of multiplying each fj by a polynomial that is 1 at xj and 0 at the other n nodes and then
taking the sum of n+1 polynomials.
p1 = L0 f0 + L1 f1
where,
Therefore,
and,
43
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
Example#2: Compute ln9.2 by Quadratic Lagrange Interpolation from the data given in
example#1 and the additional third value ln11.0 = 2.3979, use 4D accuracy.
44
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
Example#1: compute cosh0.56 from the four values in the following table and estimate
the error, use 6D accuracy.
45
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
Example#2: Compute a 7D-value of the Bessel function J0(x) for x =1.72 from the four
values in the following table, using (a) Newton’s forward formula,
(b) Newton’s backward formula.
Solution: Note that the two methods have the same table completion; the difference is
only in notations.
46
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
47
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
4
Example#1: Interpolate f(x) = x on the interval by the cubic spline g(x)
corresponding to the nodes xo = -1, x1 = 0, x2 = 1 and satisfying the conditions
( ) ( ) ( ) ( )
48
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
1A
1A
1B
(A) (B)
Figure (1) (A) Rectangular rule, (B) Trapezoidal rule.
49
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
…… to (6D) accuracy
51
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
H.W. #1: Using Simpson's rule and a 5D accuracy, evaluate the integral:
/2
x
J
/6 sin x
dx with n = 4.
1
J 1 2 e x dx
2
with n = 10.
0
H.W. #3: Use the trapezoidal rule to 5D-accuracy to evaluate the integral:
1
J 1 e x dx
2
with n = 10.
0
51
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
Example#1: Apply the Euler method to the following initial value problem, choosing
h=0.2 and computing y1,…..,y5, and using 3D accuracy then find the error.
́ ( )
Solution: Here f(x, y) = x + y; hence f(xn, yn) = xn + yn, and we see that:
yn+1 = yn + 0.2(xn + yn)
Now; y1 = yx=0.2 = y0 + 0.2(x0+y0) = 0 + 0.2(0+0) = 0
Also; y2 = yx=0.4 = y1 + 0.2(x1+y1) = 0 + 0.2(0.2+0) = 0.04
y3 = yx=0.6 = y2 + 0.2(x2+y2) = 0.04 + 0.2(0.4+0.04) = 0.128
y4 = 0.274, y5 = 0.489
52
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
∫ ∫
∫ ∫ ( ) ( )
x -x x
Therefore, y = e [-e (x+1)+c] = c e – x - 1…….. G.S.
x
Now, substitute for x = 0, y = 0 gives c = 1 and y = e – x – 1 ….. is P.S.
Now, Do the following table:
53
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
Example#2: Apply Runge-Kutta method to the initial value problem given in the
previous example with the same h = 0.2, and computing five steps to 6D
accuracy, then find the percentage error.
Curve Fitting:
Where;
Example#1: Using the method of Least Squares fit a straight line for the following four
points:
Solution:
55
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
Example#2: Fit a parabola through the data: (0,5), (2,4), (4,1), (6,6), and (8,7).
Solution: For the normal equations we need n = 5, Σxj = 20, Σxj2 = 120, Σxj3 = 800, Σxj4
= 5664, Σyj = 23, Σxjyj = 104, Σxj2 yj = 696. Hence these equations are:
56
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
are matrices. The numbers (or functions) inside the matrix are called entries or, less
commonly, elements of matrix. The first matrix in up has two rows, which are the
horizontal lines of entries. Furthermore, it has three columns, which are the vertical
lines of entries. The second and third matrices are square matrices, which mean that
each has as many rows as columns 3 and 2, respectively. The entries of the second
matrix have two indices, signifying their location within the matrix. The first index is
the number of the row and the second is the number of the column, so that together the
entry’s position is uniquely identified. For example, (read a two three) is in Row 2 and
Column 3, etc.
Matrices having just a single row or column are called vectors. Thus, the fourth
matrix has just one row and is called a row vector. The last matrix has just one column
and is called a column vector.
Example#2: We are given a system of linear equations, briefly a linear system, such as:
57
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
where x1, x2, and x3 are unknowns. We form the coefficient matrix, call it A, by listing
the coefficients of the unknowns in the position in which they appear in the linear
equations.
[ ][ ] [ ]
OR: A x = b
Also from,
This new matrix is called augmented matrix of A. Here we just wrote the column
matrix b at the end of matrix A.
Matrix A has m rows and n columns which are called size of the matrix.
A vector is a matrix with only one row or column. Its entries are called the
components of the vector.
Thus
,
Example#3:
59
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
Example#4:
Example#5:
Also,
61
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
Matrix Multiplication:
Example#6:
Example#7:
61
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
So,
Example#8:
Also,
62
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
Special Matrices:
63
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
Now, consider the following system of linear equations of triangular form (upper):
Back Substitution: means that we solve the last equation, x2 = -26/13 = -2, and then
work back to obtain x1 = (2-5x2)/2 = 6
Example#1:
(1)
Solution:
(2)
64
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
65
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
Inverse of a Matrix:
Example#1:
66
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
Solution:
Therefore;
67
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
68
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
* +* + * +
* +
because;
The solution of this quadratic (2 nd order) equation gives two Eigen values;
.
(b1) Eigenvectors of A corresponding to . This vector is obtained by substituting
with (arbitrary), and solve for x1 and x2:
This is done by assuming x1 = t (arbitrary assumption) gives x2 = 2t, so the x’s corresponding to is:
69
Third Year / Surveying Eng. Dept "Engineering and Numerical Analysis" Assist. Prof. Dr. Qais Fadhil
[ ]
To find Eigenvectors, we apply Gauss elimination method to the system ( ) , first with λ = 5,
and then with λ = -3,
”Good Luck”
71