0% found this document useful (0 votes)
305 views126 pages

Numerical Methods Lecture (Autosaved)

To determine the nutritional content of each mixture, we can set up a matrix multiplication problem. Let A be the matrix with nutritional information per cup of each nut. Let B be the matrix with the number of cups of each nut in each mixture. Then AB will give us the nutritional content of each mixture. Specifically, we would set up the matrices as: A = [[protein_almonds, fat_almonds, carbs_almonds], [protein_cashews, fat_cashews, carbs_cashews], [protein_pecans, fat_pecans, carbs_pecans]] B = [[6, 3, 1], [3,

Uploaded by

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

Numerical Methods Lecture (Autosaved)

To determine the nutritional content of each mixture, we can set up a matrix multiplication problem. Let A be the matrix with nutritional information per cup of each nut. Let B be the matrix with the number of cups of each nut in each mixture. Then AB will give us the nutritional content of each mixture. Specifically, we would set up the matrices as: A = [[protein_almonds, fat_almonds, carbs_almonds], [protein_cashews, fat_cashews, carbs_cashews], [protein_pecans, fat_pecans, carbs_pecans]] B = [[6, 3, 1], [3,

Uploaded by

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

NUMERICAL METHODS

BY
ENGR. JORGE P. BAUTISTA
EE, MEP-ECE
REFERENCES
- Applied Numerical Analysis (1994), 5th ed,
Gerald and Wheatley, Addison Wesley
- Numerical Methods for Engineers (2002) 4th
ed, Chapra and Canale, McGraw Hills
- Numerical methods in Engineering Practice (
1986), Al-Khafaji and Tooley,CBS College
Publishing
- https://www.symbolab.com/solver/taylor-
series-calculator/taylor%20ln%5Cleft(x-
1%5Cright)%2C2
COURSE OUTLINE
1. APPROXIMATION AND ERRORS
2. MATRIX AND DETERMINANTS
3. LINEAR EQUATIONS
4. NON-LINEAR EQUATIONS
5. EIGEN VECTORS
6. CURVE FITTING AND INTERPOLATIONS
7. NUMEIRCAL DIFFERENTIATION
8. NUMERICAL INTEGRATION
Lesson No. 1
Approximation and Errors
Lesson objectives: at the end of the lesson,
the student would be able to
1. Explain the need of numerical analysis
2. Recognize the importance of numerical
approximations and errors
3. Write the series expansion of binomial
theorem, Taylor and Mclaurin’s
What is numerical methods?
Numerical analysis is the study
of algorithms that use
numerical approximation (as opposed to
general symbolic manipulations) for the
problems of mathematical analysis (as
distinguished from discrete mathematics).
Problems that can not be solved
analytically can be solved using
numerical methods.
f(x) = x – tan x , x2 + 4x = -4, etc
The numerical solutions of engineering
problems involves repeated operations. In
this lesson we shall examine the question
of errors in terms of their sources and they
may affect the solution of engineering
problems. In the analysis of the accuracy
of calculated results, the numerical
analyst should be capable of tracing all
the possible sources of errors in each
stage of the computational process and
determine the extent to which these errors
can affect the final answer.
Algorithm - a step by step procedure that
produces a systematic solution to a
problem.
Programmming:
1. Excel
2. c++
3. MATLAB
Concept of Errors
Sources of errors
1. Gross errors – due to human , mechanical or
electrical mistakes
2. Round-off errors
0.33333333… to 0.3333
with error = 0.00003333
0.6666666… to 0.6667
with error = 0.0000334
3. Introduction of constant in as many decimal
places like , e and √7
Three types of error often occur in a
computation, the initial data, truncation
and round-off.
Initial data errors are caused by idealistic
assumption made to simplify the model,
inaccurate measurement of data,
miscopying of figures or the inaccurate
representation of mathematical
constants.
Truncation error occurs when the analyst is force
to use mathematical techniques that give
approximate rather than exact answers
usually encountered in numerical methods.
Rounding-off error is caused by the disregard in
the use of significant figure.
Et = true value – approximation
Et = exact value of the error
True fractional relative error = true error/true
value
If this is multiplied by 100%, it is known as relative
error.
A short coming of this definition is that it takes
no account of the order of magnitude of the
value under examination.
The errors associated with both calculations
and measurements can be characterized
with regard to their accuracy and
precision. Accuracy refers to how closely
a computed or measured values agrees
with the true value. Precision refers to how
closely individual computed or measured
values agree with each other. These
concepts can be illustrated graphically
using an analogy from target practice.
The bullet holes on each target can be
thought of as the prediction of a
numerical technique whereas the bull’s
eye represent the truth. Inaccuracy also
called bias is defined as systematic
deviation from the truth. Imprecision also
called uncertainty refers to the
magnitude of the scatter.
Example no. 1
Suppose that you have the task of
measuring the lengths of a bridge and a
rivet and come up with 9999 and 9 cm
respectively. If the true values are 10,000
cm and 10 cm, respectively. Compute
a. The true error
b. The true percent relative error for each
case.
Both of them have an error of 1cm, the
relative error of the rivet is much greater
and the impact is high.
2. The equation below is the expansion of ex
ex = 1 + x + x2/2! + x3/3! + x4/4! + x5/5! … +
xn/n!
Estimate e0.5 and determine the amount of
error for each incremental terms.
3. A parachutist of mass 68.1kg jumps out of
a stationary hot air balloon. The drag
coefficient is 12.5kg/s. To compute the
velocity prior to opening the cute is
v(t) = gm(1 – e-(c/m)t)/c
where g = gravitational force
m = mass of the falling object
c = drag coefficient
Determine the terminal velocity of the man.
4. Evaluate the polynomial
y = x3 – 7x2 + 8x - 0.35 at x = 1.374. use 3
digit arithmetic with chopping. Evaluate the
percent relative error.
re-evaluate the polynomial using Horne’s
method.
Binomial theorem
Construct the Pascal’s triangle:
From binomial polynomial:
(x + y)0 = 1
(x + y)1 = x + y
(x+ y)2 = x2 + 2xy + y2
(x + y)3 = x3 + 3x2y + 3xy2 + y3
Notice the coefficient of the terms.
The coefficient of the first term decreases
while the coefficient of the second term
increases.
The binomial expansion
The binomial theorem states that:
(x+y)n = nk = 0 C(n,k) xn-k yk

The numerical part: C(n,k)


The literal part:
xn-k yk
For the number of term, i
k=i-1
Example No. 2
1. Expand the given binomials
a. (2x – 4y)4
b. (ex + ey)3
2. Find the 4th term of the given binomials
a. (3x + 2y2)6
b. (2xy – 3z3)7
3. Find the middle terms of the following
binomials
a. (4x2 + y3)5
b. (4x -2 + 3y)4
4. Find the coefficient of x4y3 in the binomial
(3x + 2y)n
Taylor and Maclaurin’s series
Taylor Theorem: if the function f and its first
n+1 derivatives are continuous on an
interval containing a and x, then the
value of the function at x is
f(x) = C0 + C1(x-x0) + C2(x-x0)2 + C3(x-x0)3 +…
Where C’s are the constants to be
evaluated. If f(x) and its devatives exist at
x0 then the C’s can be evaluated by
successive differentiation
Then evaluate f(x) and its derivative at x = x0
and substitute the C’s at f(x)
Therefore,
f(x) = f(x0) + f’(x0) (x-x0)/1! + f”(x0)(x-x0 )2 /2!
+ …+ fn(x –x0)n/n!
This is the Taylor series centered at X0
If the expansion is x0 = 0 then it is called
MacLaurin’s series.
Example no. 3
1. Find the 5th degreeTaylor series expansion of
ln(x) centered at X0= 1 and use this to
evaluate ln(2)
2. Find the 5th degree Maclaurin series
expansion of problem 1 and evaluate ln(2)
3. Repeat no. 1 using
a. f(x) = -0.1x4 – 1.5x3 – 0,5x2 - 0.25x + 1.4
centered at 0.5 and use this to approximate
the value at x = 1.1
b. f(x) = ex centered at X0 = 1 and use this to
approximate the value at x = 0.5
Assignment no. 1
1. Find the 6th term in (x/4 + y/2)10
2. Find the 4th degree Taylor expansion of
e-x centered at X0 = 0.2 and use this to
approximate the value at x = 0.2
3. find the 4th degree Maclaurin series of
problem 2 and evaluate e-0.9
4. Find the 4th degree Taylor expansion for
f(x) = cos(x) centered at X0 = . And
evaluate at x = π/6
Lesson no. 2
Matrix and Determinants
At the end of the lesson, the student would
be able to
1. State the types of matrices
2. Evaluate the given matrices
3. Calculate the determinants of a given
matrix
Types of matrices:
1. Column vector and row matrix
2. Null matrix
3. Square matrix
4. Triangular matrix
5. Diagonal matrix
6. Scalar matrix
7. Identity matrix
8. Symmetric matrix
9. Submatrix
The rank of a matrix
The column rank of A is the dimension of
the column space of A, while the row
rank of A is the dimension of the row
space of A.
The rank of a matrix is defined as (a) the
maximum number of linearly
independent column vectors in the matrix
or (b) the maximum number of linearly
independent row vectors in the matrix.
Both definitions are equivalent.
By echelon form
For example, the matrix A given by
1 2 1
A = -2 -3 1
3 5 0
Given:
1 2 4 4
A= 3 4 8 0
Since the matrix has more than zero
elements, its rank must be greater than
zero. And since it has fewer rows than
columns, its maximum rank is equal to the
maximum number of linearly independent
rows. And because neither row is linearly
dependent on the other row, the matrix
has 2 linearly independent rows; so its rank
is 2.
conjugate of a matrix
2 + j3 1 – j2 j3
A= 4 5 + j5 -j2
1 – j1 -3 4
Example no. 3
Given the following matrix
A = 2 -1 4 B= 3 6 2
3 4 0 4 3 -2
1 -3 -6 0 -2 3
C= 3 -2 -1 D= 0 4
2 4 7 4 -1
3 -2
Evaluate
1. 3A – 2B
2. AB – BA
3. DC + AB
4. A2 + 3A -9I WHERE I = Identity matrix of
order 3
5. BT + ATB
The following matrix consists of a shoe
store’s inventory of flip flops, clogs, and
Mary Janes in sizes small, medium, and
large:
The store wants to know how much their
inventory is worth for all the shoes. How
should we set up the matrix multiplication
to determine this the best way?
A nut distributor wants to know the
nutritional content of various mixtures of
almonds, cashews, and pecans. Her
supplier has provided the following
nutrition information:
Her first mixture, a protein blend, consists of 6
cups of almonds, 3 cups of cashews, and 1
cup of pecans. Her second mixture, a low fat
mix, consists of 3 cups of almonds, 6 cups of
cashews, and 1 cup of pecans. Her third
mixture, a low carb mix consists of 3 cups of
almonds, 1 cup of cashews, and 6 cups of
pecans. Determine the amount of protein,
carbs, and fats in a 1 cup serving of each of
the mixtures.
Determinants
The determinant is a property of a square
matrix. It plays a significant role in the
solution of many engineering problems.
These includes the solution of sets of linear
algebraic equations, determination of the
stability of structural, mechanical and
electrical systems.
Example No. 4
Given a matrix
2 4 -1
A= -1 3 0
2 3 -1

. Find its determinant using the basket


method
EXAMPLE NO. 5
Given the matrix
3 4 1 0
-1 2 2 1
A = 2 2 3 -1
1 3 -2 0
Find the determinant using
1. Co-factor method
2. Upper triangle method
3. Chio’s method
4. Dodson’s method
Properties of determinant(applicable to
square matrix
1. The determinant of a matrix and its
transpose are equal.
2. If each element of any row or column of
a matrix then its determinant is zero.
3. If any two rows or column of a matrix are
proportional then its determinant is 0.
4. If any two rows or column is
interchanged, then it is changed in the
determinant is changed in sign
Chio’s method
Dodson’s Method
Example No. 6
Find the inverse of matrix A
-2 4 1
A= 1 3 0
3 -5 2
Assignment no. 2

1. Given the matrix


4 -1 2 -2 3
3 4 -7 2 5
1 -9 1 4 7
9 10 1 8 3
5 4 3 2 1
Find the determinant using
a. Upper triangle method
b. Chio’s method
c. Co-factor method
d. Dodson’s Method
2. Obtain the inverse of the given matrix
3 6 -7
4 0 6
-1 1 10
Laboratory Activity No. 1
1. Write a program to determine the
determinant of an any size of matrix using
a. Upper triangle method
b. Co-factor method
2. Write a program to present the inverse of
a matrix
Lesson No. 3
Solutions to Linear Equations
At the end of the lesson, the student would
be able to
1. Analyze problems involving systems of
linear equations
2. Apply the methods of solving systems of
linear equations
The systems of linear equations can be solve
using
1. Cramer’s rule
2. Gauss elimination method
3. Gauss-Jordan Method
4. LU Factorization Method (Crout’s
method)
5. Square root method (cholesky’s)
6. Doolittle method
7. Jacobi’s method
8. Gauss-Seidel method
Example no. 7
3x + y - z = 2
x - 2y + z = -9
4x + 3y + 2z = 1
Using
a. cramer’s rule
b. Gauss elimination method
c. Gauss Jordan
d. Crout’s method
Crout’s Method (LU Factorization)
For the given matrix
a11 a12 a13 b1
[A] = a21 a22 a23 b2
a31 a32 a33 b3

1 0 0 u11 u12 u13 c1


= L21 1 0 0 u22 u23 c2
L31 L32 1 0 0 u33 c3
Using square root method(Choleskey’s)
limited to equations involving symmetrical
coefficients.
3X + 2Y – 4Z = 60
2X – 2Y – 7Z = 33
-4X – 7Y + Z = -93
Choleskey’s method
For the given matrix
a11 a12 a13
[A] = a21 a22 a23
a31 a32 a33

L11 0 0 L11 L21 L31


= L21 L22 0 0 L22 L32
L31 L32 L33 0 0 L33
Doolittle Method
For the given matrix
a11 a12 a13 b1
[A] = a21 a22 a23 b2
a31 a32 a33 b3

1 0 0 u11 u12 u13


= M21 1 0 0 u22 u23
M31 M32 1 0 0 u33
Iterative method: applicable to systems that
are diagonally dominant
2x - 8y - z = -6.4
7x - y + z = 7.3
x + 2y + 9z = 13.6
Assignment No. 3
1. Given the sets of linear equations:
12x + 4y - 7z = 38
4x + 3y + 8z = 40
-7x + 8y - 4z = 31
1. gauss-jordan
2. cholesky’s method
3. Using jacobi and gauss-seidel
-2w + x = -1
w - 2x + y = 0
x - 2y + z = 0
y - 2z = 0
3. Solve using
a. Crout’s method
b. Doolittle method
5X1 + 4X2 + X3 = 2
10X1 + 9X2 + 4X3 = 13
10X1 + 13X2 + 15X3 = -69
Laboratory Activity No. 2
1. Write a program that will solve for the
unknown of a system of linear equation
using gauss jordan and cholesky’s
method
2. Write a program that will iterate sets of
equation using jacobi and gauss-seidel
method
Lesson no. 4
Solutions to Non-Linear
Equations
Lesson objectives: at the end of the lesson,
the student would be able to
1. Enumerate the types of solutions to non-
linear equations
2. Perform the algorithm of non-linear
equations
The roots of a non-linear equations can be
determined using the following methods
1. Graphical method
2. Direct search method
3. Interval halving (method of bisection)
4. Regula falsi ( method of false position)
5. Secant method
6. Newton-Raphson 1st and 2nd method
A simple method for obtaining an
estimated root of the equation f(x) = 0 is
to make plot of the function and observe
where it crosses the x axis. This point,
which represents the a value for which f(x)
= 0 provides a rough approximation of the
root.
Example no. 8
Use graphical approach to determine the
drag coefficient c needed for
parachutist of mass m = 68.1kg to have a
velocity of 40m/s after free falling for time
t = 10 sec.
f(c) = gm/c (1 – e-(c/mt)) - v
Direct search method
Let the function be y = f(x), the function is
said to pass the x-axis at a point x which is
actually the exact root. The idea is to
begin at a stating point xi and search
along the x-axis in increment Δx until we
find two successive points xi and xi+1 = xi +
Δx whose line segment contains a root.
1. Estimate the initial interval [xi , xi=1] where
xi+1 = xi + Δx
2. Determine f(xi) and f(xi+1)
3. Evaluate the sign change, that is,
f(xi)f(xi+1) < 0. the change in sign
indicates that the root has been passed
in the given interval. Revert to the
previous value of xi and use a smaller
increment by dividing the given
increment by 2 will make the increment
smaller. Then go to step 2.
4. If f(xi)f(xi+1) > 0 continue iteration until the
desired tolerance limit T ≥ f(xi+1)
Example no. 9
Determine the approximated root of the
given equations using direct search
method with tolerance limit of 0.0001
1. f(x) = x3 – 2.5x2 – 1.8x + 2.356 [0,1] with an
increment of 0.3
2. f(x) = e-x - x [0,1] 0.2 increment
Interval halving is also known as bisection
method or Bolzano method. This method
follow its name because its strategy is to
halve the interval [xi,xi+1] denoted by
xr = (xi + xi+1)/2
1. Establish xi and xi+1 as the initial interval
such that f(xi)f(xi+1)<0.
2. Compute a new approximation for the
root called the midpoint xr such that
xr = (xi+ xi+1)/2
3. Calculate f(xi),f(xi+1) and f(xr) and check if
the latter satisfies the specified tolerance
wherein T≥f(xr), if it satisfy, end the
iteration
4. If f(xi)f(xr)<0, set xi+1 = xr, else xi= xr for the
next iteration
5. Do step 2
Example no. 10
Use the same equations as in example 9
then find the roots using interval halving
method
The method of false position was develop to
improve the interval halving method. The
algorithm is as follows
1. Choose lower and upper estimates xi and xi+1
such that f(xi)f(xi+1)<0.
2. Compute the new approximation
xr = xi+1f(xi) – xif(xi+1)/ f(xi) – f(xi+1)
3. Establish a tolerance for the function such
that T≥f(xr). if the criterion is met, then
terminate the computation otherwise
continue
4. Evaluate f(xi)f(xr), if the product is negative,
then set xi+1 = xr and go to step 2 otherwise
set xi = xr
Example no. 11
Use the same equations as in example 9
Assignment no. 4
1. f(x) = -0.4x2 + 2.2x + 4.7 (bisection
method)
2. f(x) = x3.3 – 79 (false position)
3. f(x) = √x – x ( direct search method)
increment of 0.1
4. f(x) = ex – 3x2 (newton –raphson 1st
method)
5. f(x) = e-x – 0.5sinx (secant method)
Newton-Raphson
One of the popular method used for solving non
linear equations .also known as method of
tangents.
1. Determine the initial approximation of the
root.
2. Find the first derivative of the function then
evaluate at x = xi. If f’(xi) = 0, then go to step
1.
3. Establish the tolerance e.g T = 10-6
4. Compute a new approximation to the root
xi+1 = xi – f(xi)/f’(xi)
5. Check tolerance then end, otherwise go to
step 4.
Newton-Raphson (2nd method)
1. Determine initial estimate for xk
2. Find the first and second derivative of f(x)
at xk, make sure that they are not both
equal to zero.
3. Establish the tolerance value for the
function T ≥f(f(xk+1)
4. Compute a new approximation for the
root.
xk+1 = xk + [f”(xk)/2f’(xk) – f’(xk)/f(xk)]-1
5. End the iteration if the tolerance limit has
been met otherwise continue iteration
Secant method. The algorithm is as follows
1. Choose lower and upper estimates xi and
xi+1 such that f(xi)f(xi+1)<0.
2. Compute the new approximation
xi+2 = xi – [f(xi)(xi+1 – xi)]/[f(xi+1) – f(xi)]
3. If f(xi+2)≥T, then stop else repeat 2
Laboratory Activity No. 3

1. Write a program using


a. bisection method
b. false position
c. 1st method newton-raphson
f(x) = 23.33 + 79.35x – 88.09x2 + 41.6x3 –
8.68x4 + 0.658x5
Lesson No. 5
Eigen Vectors
Lesson Objectives: at the end of the lesson,
the student would be able to
1. Understand the theory of eigen vectors
2. Apply eigenvectors in a given set of
equations
3. Determine the eigenvalues of a given
sets of equations
Eigenvalues and eigenvectors feature
prominently in the analysis of linear
transformations. The prefix eigen- is adopted
from the German word eigen for "proper",
"inherent"; "own", "individual", "special";
"specific", "peculiar", or
"characteristic".]Originally utilized to
study principal axes of the rotational motion
of rigid bodies, eigenvalues and eigenvectors
have a wide range of applications, for
example in stability analysis, vibration
analysis, atomic orbitals, facial recognition,
and matrix diagonalization.
In essence, an eigenvector v of a linear
transformation T is a non-zero vector that,
when T is applied to it, does not change
direction. Applying T to the eigenvector only
scales the eigenvector by the scalar value λ,
called an eigenvalue. This condition can be
written as the equation
T(v) = λv
referred to as the eigenvalue
equation or eigenequation. In general, λ may
be any scalar. For example, λ may be
negative, in which case the eigenvector
reverses direction as part of the scaling, or it
may be zero or complex.
The Mona Lisa example pictured at right
provides a simple illustration. Each point
on the painting can be represented as a
vector pointing from the center of the
painting to that point. The linear
transformation in this example is called
a shear mapping.
In this shear mapping the red arrow changes
direction but the blue arrow does not. The blue
arrow is an eigenvector of this shear mapping
because it doesn't change direction, and since
its length is unchanged, its eigenvalue is 1.
Linear transformations can take many
different forms, mapping vectors in a
variety of vector spaces, so the
eigenvectors can also take many forms.
For example, the linear transformation
could be a differential operator like d/dx,
in which case the eigenvectors are
functions called eigenfunctions that are
scaled by that differential operator, such
as
d/dx eλx
Let A be an nxn matrix. A scalar λ is said to be
an eigenvalue of A if there exist a non zero
vector x such that the vector equation
Aλ = λx
Or
(A – λI)x = 0 is satisfied. In this case, the vector
x is called the eigenvector of A.
For the above equation to have a non-trivial
solution that is there exist at least one non
zero unknown value, then the following
determinant must be used
│A – λI│ = 0 thjs is called the characteristic
equation of A.
Properties of eigenvalues
1. The determinant of A is the product of its
eigenvalues.
2. The trace of matrix A, that is the sum of its
diagonal elements, is also the sum of all
eigenvalues
3. The eigenvalues of kth power of Ak is λ1k,
λ2k , λ3k . . .
4. The martrix A is invertible if and only if
every eigenvalue is non zero.
5. If A is invertible, then the eigenvalues
of A−1 are 1/λ1, 1/λ2, ..., 1/λn and each
eigenvalue's geometric multiplicity
coincides.
6. If the eigen value is zero it means that the
eigenvector is in the null space.
Example no. 12
Find the characteristics equation, eigen
values and eigenvector of the given
matrix. Draw the vector space diagram
1. A = 2 1
1 2
2. A = 0.8 0.3
0.2 0.7
3. A = 0 2 1
-1 3 1
-1 1 2
4. 1 2
2 4
5. 1 -1 0
-1 2 -1
0 -1 1
Assignment no. 5
Determine the characteristic equation,
eigenvalues and eigenvector o f the
given matrix and draw the eigenspace
1. A = 2 -3
-1 3
2. A = 2 -1 0
-1 3 -1
0 -1 2
3. A = 3 -2 0
-2 5 -2
0 -2 -2
Lesson No. 6
Curve Fitting and Interpolation
Lesson Objectives: at the end of the lesson,
the student would be able to
1. Understand the properties of curve fitting
2. Obtain the general equation using
interpolation
Data is often given for discrete values along
a continuum. However, you may require
estimates at points between the discrete
values. In addition, you may require a
simplified version of a complicated
function. One way to do this is to
compute values of the function at a
number of discrete values along the
range of interest. Then a simpler function
may be derived to fit these values. Both of
these applications are known as curve
fitting.
There are two general approaches for
curve fitting that are distinguished from
the other on the basis of the amount of
error associated with the data.
1. Least squares regression – it attempts to fit
a simpler function through a set of data
points without the wiggle problem
associated with higher order polynomials.
The graphical representation of the least
square method
Two types of applications are generally
encountered when fitting experimental
data: trend analysis and hypothesis
testing
Trend analysis – represent the process of
using the pattern of the data to make
prediction. It may be used to predict or
forecast values of the dependent
variable. This can involve extrapolation
beyond the limits of the observed data.
2. Hypothesis testing – an existing
mathematical model is compared with
measured data. If the model coefficient is
unknown, it may be necessary to
determine values that fit the observed
data.
Linear regression:
Given a set of N data points, a linear
function is assumed to exist between the
dependent variable f and the
independent variable x, that is,
y(x) = a0 + a1x + e
Where a1 and a0 are the coefficients
representing the intercept and the slope
while e is the residue or error between the
model and the observation.
One strategy for fitting a best line through
the data would be to minimize the sum of
the residual errors for all available data
n Σ
I = 1 ei =
n Σ
I = 1 (yi – a0 – a1x)
Where n = total number of points.
The least square fit for straight line is
a1 = nΣxiyi - Σxi Σy1 / nΣxi2 - (Σxi)2
a0 = y’ – a1x’
Where y’ and x’ are the means of y and x
respectively
Example No. 13
1. Use linear regression to fit the following
data set:
x 0 1 2 3 5
y 0 1.4 2.2 3.5 4.4
2. The following data represents the time in
seconds of a parachutist to fall from the
sky with calculated velocities. Obtain the
approximate fit of line.
Time 1 2 3 4 5 6 7
Vel 10 16.3 23 27.5 31 35.6 41
Non linear regression
Given a non-linear function
y = a1xa2 (simple power equation)
Transform to linear equation
lny = ln[a1xa2]
= ln a1 + a2lnx
Let a1’ = ln a1
x’ = ln x
y’ = ln y
therefore
y’ = a1’’ + a2x’
exponential model
y = a1ea2x
same as the simple power equation.
a1’ = (Σyi’ Σxi’2 - Σxi’ Σyi’xi’ ) / [nΣ x1’2 -
(Σxi’)2]
a2 = nΣyi’xi’ – Σxi’ Σyi’ / nΣxi’2 - (Σxi’)2

a1’ = (Σyi’ Σxi2 - Σxi Σyi’xi ) / [nΣ x12 - (Σxi)2]


a2 = nΣyi’xi – Σxi Σyi’ / nΣxi2 - (Σxi)2
Example No. 14
The following data were plotted and shown
to exhibit behavior that can be best
described by the function y = a1xa2 and y
= a1ea2x
X 1 2 3 4
Y 1 4 8 14
Polynomial regression
The least square procedure can be
extended to fit the data to a higher order
polynomial
y = a 0 + a 1 x + a 2 x2 + e
Where e = the residual or error
(n)a0 + (Σxi)a1 + (Σxi2)a2 = Σyi
(Σxi)a0 + (Σxi2)a1 + (Σxi3)a2 = Σxiyi
(Σxi2)a0 + (Σxi3)a1 + (Σxi4)a2 = Σxi2yi
Example no. 15
Fit a second order polynomial to the data
given
X 0 1 2 3 4 5
Y 2.1 7.7 13.6 27.2 40.9 60
Multiple regression
f = a 1 + a 2x + a 3y
na1 + (Σxi)a2 + (Σyi)a3 = Σfi
(Σxi)a1 + (Σxi2 )a2 + (Σxiyi)a3 = Σfixi
(Σyi) a1 + (Σxiyi)a2 + (Σyi2) a3 = Σfiyi
Example no. 17
Develop a functional approximation of the
given data using
I = a 1 + a 2R + a 3t
I 5.3 7.8 7.6 9.7 10.5 12.6
R 66 70 88 140 151 160
t 1.5 1.0 0.8 0.5 0.3 0.1
Assignment no. 6
1. Given the points below;
x 0 1 2 3 5
y 0 1.4 2.2 3.5 4.4
a. Fit a linear regression
b. Fit a polynomial regression
2. Given the points below
x 1 2 3 5
y 1 4 8 18
determine the equation for simple power
equation and exponential model.
Interpolating polynomials:
1. Lagrange interpolation method (uneven
intervals)
let f(x) be a function of the points x that are
not equally spaced. The interpolating
polynomial is given by
P(r) = L0(x)f(x0) + L1(x)f(x1) + L2(x)f(x2) + … +
LN(x)f(xN)
Or simply
P(x) = Σni = 0 Li(x)f(xi)
Where Li(x) is called Lagrange coefficient
defined by
Li(x) = πNj=0 i≠j (x-xj)/(xi – xj)
In this method there is no need to construct
the Newton Difference formula.
Example No. 18
Use lagrange formula to find the
interpolating polynomial and to
approximate the functional value at x =
2.0 for the following set of data
X 0 1 3 4
F(x) -2 4 3 6
Interpolation at equally spaced points
1. Newton’s Forward Difference formula
For any function f(x) with equally spaced
points x0 x1 x2 … xN, we establish the
forward difference formula for the values
f(x0) f(x1) f(x2) … f(xN) as follows
(r ) = r(r - 1) . . . (r - i + 1) for any integer i > 0
i
r = (x – x0)/h
Where h = common difference
The order of the polynomial is determined when it
becomes constant.
Example no.19
Using the following data, find the third
degree interpolating polynomial using
NFDF.
x 4 6 8 10
f(x) 1 3 8 20
Newton-Gregory Backward Difference
Formula
Newton’s Backward Difference formula is
constructed differently as follows

f(x) @ P s(s + 1)
s(s + 1) . . . (s +
n(x) =
Ñ2fn +...+ n -1) Ñnfn
fn +
sÑfn + 2! n!
Assignment No. 7
Use newton forward formula to estimate the
polynomial of the given points
X 2 5 8 11
f(x) 7.5 141 634.5 1731
Use lagrange equation to estimate the
polynomial of the given points
x 0 1 2 4
f(x) 1 1 2 -2

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy