0% found this document useful (0 votes)
24 views

3 - Numerical Methods - Nov 2022

1. Numerical methods are used to find roots, interpolate data points, differentiate and integrate functions, and solve systems of linear equations. 2. Root finding methods include bisection, false position, secant, and Newton-Raphson. Interpolation uses Lagrange polynomials and Newton's divided differences. Differentiation can be estimated using forward, backward, and central differences. Integration techniques are midpoint, trapezoidal, and Simpson's rules. 3. Linear systems can be solved iteratively using Jacobi or Gauss-Seidel methods, which repeatedly update the variable values until convergence is reached.

Uploaded by

byron.yumol.l
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

3 - Numerical Methods - Nov 2022

1. Numerical methods are used to find roots, interpolate data points, differentiate and integrate functions, and solve systems of linear equations. 2. Root finding methods include bisection, false position, secant, and Newton-Raphson. Interpolation uses Lagrange polynomials and Newton's divided differences. Differentiation can be estimated using forward, backward, and central differences. Integration techniques are midpoint, trapezoidal, and Simpson's rules. 3. Linear systems can be solved iteratively using Jacobi or Gauss-Seidel methods, which repeatedly update the variable values until convergence is reached.

Uploaded by

byron.yumol.l
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Numerical methods

1 Root finding 1.4 Secant method

1.1 Method of bisection Given an equation in one variable f (x) = 0.

Given an equation in one variable f (x) = 0, • Select two guess values x0 and x1 .

• Calculate f (x0 ) and f (x1 ).


• Select two initial guess values a0 and b0 ,
where a0 < b0 . • Determine the next guess value using the for-
mula
a0 + b0
• Calculate c0 = .
2 f (xn−1 )
xn = xn−1 −
f (xn−1 ) − f (xn−2 )
• Find f (a0 ), f (b0 ) and f (c0 ). xn−1 − xn−2
• Select the new guess interval based on the method of false position.
above values. Call this new interval [a1 , b1 ].
• Repeat step 3 until the guess value converges
– If f (a0 )· f (c0 ) < 0, then a root is some- to a certain value.
where within the interval [a0 , c0 ]. Example. Find the positive solution of the
– If f (b0 )· f (c0 ) < 0, then a root is some- equation 2 sin x = x.
where within the interval [b0 , c0 ].
– If f (a0 ) · f (c0 ) = 0 or f (b0 ) · f (c0 ) = 0,
2 Interpolation
then c0 is a root.
2.1 Lagrange interpolation
• Repeat the previous steps until an and bn are
Given n + 1 points (xi , yi ), it is required to find a
very close to each other.
polynomial function P(x) of degree n such that
P(xi ) = yi , where i ∈ {0, 1, 2, · · · , n}. Then
1.2 Method of false position !
n
x − xm
Same as method of bisection, except use P(x) = ∑ y j ∏
j=0 0⩽m⩽n ∩ m̸= j x j − xm
an f (bn ) − bn f (an )
cn = . 2.2 Newton’s divided difference method
f (bn ) − f (an )
Given n + 1 points (xi , yi ), it is required to find a
1.3 Newton-Rhapson method polynomial function P(x) of degree n such that
P(xi ) = yi , where i ∈ {0, 1, 2, · · · , n}. Then
Given an equation in one variable f (x) = 0. !
n j−1

• Select a guess value x0 . P(x) = ∑ a j ∏ (x − xi )


j=0 i=0

• Calculate f (x0 ) and f ′ (x0 ). where a j is computed using the following table.

x y 1st 2nd ···


• Determine the next guess value using the for-
mula x0 y0 [y0 , y1 ] [y0 , y1 , y2 ] · · ·
f (xn−1 ) x1 y1 [y1 , y2 ] [y1 , y2 , y3 ] · · ·
xn = xn−1 − ′ . x2 y2 [y2 , y3 ] [y2 , y3 , y4 ]
f (xn−1 )
x3 y3 [y3 , y4 ]
• Repeat step 3 until the guess value converges x4 y4
.. ..
to a certain value. . .

Engr. Jaydee N. Lucero 1


Numerical methods

where 4.2 Trapezoidal rule


[yk , yk+1 , · · · , yk+n ] Assume that f (x) is continuous on [a, b]. Let n be
[yk+1 , yk+2 , · · · , yk+n ] − [yk , yk+1 , · · · , yk+(n−1) ] b−a
= a positive integer and ∆x = . If [a, b] is di-
xk+n − xk n
vided into n subintervals, each of length ∆x, with
Example. If P is a cubic function such that endpoints at P = {x0 , x1 , x2 , · · · , xn }, then
P(2) = 5, P(3) = 7, P(4) = 12 and P(5) = 19,
Z b
find P(6). ∆x  
f (x) dx ≈ 1 2 2 ··· 2 1
a 2

3 Differentiation 4.3 Simpson’s one-third rule

3.1 First derivative Assume that f (x) is continuous on [a, b]. Let n be
b−a
Forward difference a positive integer and ∆x = . If [a, b] is di-
n
f (x0 + h) − f (x0 ) vided into n subintervals, each of length ∆x, with
f ′ (x0 ) ≈ endpoints at P = {x0 , x1 , x2 , · · · , xn }, then
h
Backward difference Z b
∆x  
′ f (x0 ) − f (x0 − h) f (x) dx ≈ 1 4 2 4 2 ··· 2 4 1
f (x0 ) ≈ a 3
h
Central difference In the Simpson’s rule, n must be an even integer.
f (x0 + h) − f (x0 − h) If n is odd, the last subinterval must be approxi-
f ′ (x0 ) ≈ mated using trapezoidal rule.
2h

3.2 Second derivative Example. In a standard normal distribution,


find the probability that a z-score lies between
Central difference 1 and 2. In other words, calculate the definite
f (x0 + h) − 2 f (x0 ) + f (x0 − h) integral
f ′′ (x0 ) ≈ Z 2
h2 1 2
√ e−z /2 dz.
Example. A particle moves along a straight 1 2π
line with +x-axis to the right. Its position x(t)
in meters at any time t in seconds is given by
the function 5 Systems of linear equations
x(t) = sin(cos(tan x)) 5.1 Jacobi iteration
Given a system of n linear equations in n variables
Find the velocity and acceleration of the parti- {x1 , x2 , · · · , xn }.
cle at t = 2 seconds.
• Assume guess values for x1 , x2 · · · , xn .

4 Integration • Using these guess values, calculate new val-


ues of x1 , x2 , · · · , xn at the same time.
4.1 Midpoint rule
• Repeat step 2 until the values converge.
Assume that f (x) is continuous on [a, b]. Let n
b−a
be a positive integer and ∆x = . If [a, b] is 5.2 Gauss-Seidel iteration
n
divided into n subintervals, each of length ∆x, and
mi is the midpoint of the ith subinterval, then Given a system of n linear equations in n variables
Z b n {x1 , x2 , · · · , xn }.
f (x) dx ≈ ∑ f (mi )∆x
a i=1
• Assume guess values for x1 , x2 · · · , xn .

Engr. Jaydee N. Lucero 2


Numerical methods
 
• Using these guess values, calculate new val- h k2
• k3 = h f xn + , yn +
ues of x1 , x2 , · · · , xn one at a time. Once the 2 2
new value of a variable is calculate, immedi-
• k4 = h f (xn + h, yn + k3 )
ately replace the previous value and use it in
subsequent calculations. k1 + 2k2 + 2k3 + k4
• yn+1 = yn +
6
• Repeat step 2 until the values converge.
Example. Solve the first-order differential
Example. Solve the system of equations equation
dy √ √
= x+ y

2x + 3y − 5z = −4
 dx
3x − 5y + 6z = 7 . with initial condition x = 0, y = 0.

6x − y − 4z = 9

6 Differential equations
6.1 Euler method
Given the differential equation dy/dx = f (x, y)
with initial condition f (x0 ) = y0 ,

• Pick a marching step h.

• k1 = h f (xn , yn )

• yn+1 ≈ yn + k1

6.2 Midpoint method


Given the differential equation dy/dx = f (x, y)
with initial condition f (x0 ) = y0 ,

• Pick a marching step h.

• k1 = h f (xn , yn )
 
h k1
• k2 = h f xn + , yn +
2 2
• yn+1 = yn + k2

6.3 Runge-Kutta method


Given the differential equation dy/dx = f (x, y)
with initial condition f (x0 ) = y0 ,

• Pick a marching step h.

• k1 = h f (xn , yn )
 
h k1
• k2 = h f xn + , yn +
2 2

Engr. Jaydee N. Lucero 3

You might also like