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

PRELIM

This document discusses numerical solutions to civil engineering problems. It introduces numerical methods like Taylor series and the bisection method to solve differential equations numerically. The bisection method uses interval halving to find roots of equations. It works by repeatedly narrowing the interval until the solution is found. The false position method is also introduced, which uses linear interpolation between two points to iteratively estimate the root of an equation. Examples are provided to demonstrate applying these numerical methods.
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views

PRELIM

This document discusses numerical solutions to civil engineering problems. It introduces numerical methods like Taylor series and the bisection method to solve differential equations numerically. The bisection method uses interval halving to find roots of equations. It works by repeatedly narrowing the interval until the solution is found. The false position method is also introduced, which uses linear interpolation between two points to iteratively estimate the root of an equation. Examples are provided to demonstrate applying these numerical methods.
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 22

MATH 130 – NUMERICAL SOLUTIONS TO CE PROBLEM

Objective: At the end of this lesson, you should be able to:


1. Learn how to solve numerical problems
2. Define what is numerical solution works
3. Calculate numerical values using different methods

WHAT IS NUMERICAL SOLUTION?

- IN THIS SECTION WE APPLY VARIOUS NUMERICAL METHODS to several physics problems


after setting them up. We first describe how to work with second-order equations, such as the nonlinear
pendulum problem. We will see that there is a bit more to numerically solving differential equations than
to just running standard routines. As we explore these problems, we will introduce other methods and
provide some MATLAB code indicating how one might set up the system.

DISCUSSIONS:

1. TAYLOR SERIES

Definition - In the previous section we started looking at writing down a power series representation of a
function. The problem with the approach in that section is that everything came down to needing to be able to
relate the function in some way to

and while there are many functions out there that can be related to this function there are many more that simply
can’t be related to this. So, without taking anything away from the process we looked at in the previous section,
what we need to do is come up with a more general method for writing a power series representation for a
function. So, for the time being, let’s make two assumptions. First, let’s assume that the function f(x) does in
fact have a power series representation about x=a,

Next, we will need to assume that the function, f(x), has derivatives of every order and that we can in fact find
them all. Now that we’ve assumed that a power series representation exists, we need to determine what the
coefficients, cn, are. This is easier than it might at first appear to be. Let’s first just evaluate everything at x = a.
This gives,

f(a)=C0

So, all the terms except the first are zero and we now know what c0 is. Unfortunately, there isn’t any other value
of x that we can plug into the function that will allow us to quickly find any of the other coefficients. However,
if we take the derivative of the function (and its power series) and then plug it in x=a we get,
and we now know c.

Let’s continue with this idea and find the second derivative.

So, it looks like,

Using the third derivative gives,

Using the fourth derivative gives,

Hopefully, by this time you’ve seen the pattern here. It looks like, in general, we’ve got the following formula
for the coefficients.

This even works for n=0 if you recall that 0! =1 and define f(0)(x) =f(x).

So, provided a power series representation for the function f(x) about x=a exists the Taylor Series for f(x)
about x=a is,

TAYLOR SERIES;

Example:

1. Find the Taylor Series for f(x) = sin (x) about x = 0

As with the last example, we’ll start off in the same manner.

.
So, we get a similar pattern for this one. Let’s plug the numbers into the Taylor Series.

In this case, we only get terms that have an odd exponent on x and as with the last problem once we ignore the
zero terms there is a clear pattern and formula. So, renumbering the terms as we did in the previous example,
we get the following Taylor Series.

EXERCISES:

1. f(x) = cos(4x) about x = 0

2. ln (3+4x) about x = 0
2. Bisection method

Definition: The bisection method is used to find the roots of a polynomial equation. It separates the
interval and subdivides the interval in which the root of the equation lies. The principle behind this
method is the intermediate theorem for continuous functions. It works by narrowing the gap between the
positive and negative intervals until it closes in on the correct answer. This method narrows the gap by
taking the average of the positive and negative intervals. It is a simple method and it is relatively slow.
The bisection method is also known as interval halving method, root-finding method, binary search
method or dichotomy method.

Follow the below procedure to get the solution for the continuous function:

For any continuous function f(x),

 Find two points, say a and b such that a < b and f(a)* f(b) < 0

 Find the midpoint of a and b, say “t”

 t is the root of the given function if f(t) = 0; else follow the next step

 Divide the interval [a, b] – If f(t)*f(a) <0, there exist a root between t and a

– else if f(t) *f (b) < 0, there exist a root between t and b

 Repeat above three steps until f(t) = 0.

The bisection method is an approximation method to find the roots of the given equation by repeatedly
dividing the interval. This method will divide the interval until the resulting interval is found, which is
extremely small.

Example: Determine the root of the given equation x2-3 = 0 for x = [1, 2]

Solution:

Given: x2-3 = 0

Let f(x) = x2-3

Now, find the value of f(x) at a= 1 and b=2.

f(x=1) = 12-3 = 1 – 3 = -2 < 0

f(x=2) = 22-3 = 4 – 3 = 1 > 0

The given function is continuous, and the root lies in the interval [1, 2].

Let “t” be the midpoint of the interval.

I.e., t = (1+2)/2

t =3 / 2
t = 1.5

Therefore, the value of the function at “t” is

f(t) = f(1.5) = (1.5)2-3 = 2.25 – 3 = -0.75 < 0

If f(t)<0, assume a = t.

and

If f(t)>0, assume b = t.

f(t) is negative, so a is replaced with t = 1.5 for the next iterations.

The iterations for the given functions are:

no. a b c f(a) f(b) f(x)

1 1 2 1.5 -2 1 -0.75

2 1.5 2 1.75 -0.75 1 0.062

3 1.5 1.75 1.625 -0.75 0.0625 -0.359

4 1.625 1.75 1.6875 0.3594 0.0625 -0.1523

5 1.6875 1.75 1.7188 -0.1523 0.0625 -0.0457

6 1.7188 1.75 1.7344 0.0457 0.0625 0.0081

7 1.7188 1.7344 1.7266 -0.0457 0.0081 0.0189

So, at the seventh iteration, we get the final interval [1.7266, 1.7344]

Hence, 1.7344 is the approximated solution.

 MATLAB CODE:
 RESULT OF THE CODE:

Exercises for bisection method:

 Find the root and its coordinates;

1. f(x) = x+ 4

2. f(x) = 3x + 6
3. FALSE – POSITION METHOD ( REGULAR FALSE)

Definition - Method of False Position (Regula-Falsi Method) Method of False Position (aka Linear
Interpolation Method) is an iterative method of finding roots of a given equation using a straight line
connecting two points in the curve. Using this straight line, the current estimate is based on the
intersection of the straight line and the x-axis. Consider the curve shown below. Point(xr,0) is an
estimate of the root of the curve y =f(x). Using similar triangles,

Also, the curve y = f(x) will meet the x-axis at a certain point between A[a, f(a)] and B[b, f(b)].

Now, the equation of the chord joining A[a, f(a)] and B[b, f(b)] is given by:

Let y = 0 be the point of intersection of the chord equation (given above) with the x-axis. Then,

This can be simplified as:

Thus, the first approximation is x1 = [af(b) – bf(a)]/ [f(b) – f(a)]

Also, x1 is the root of f(x) if f(x1) = 0.

If f(x1) ≠ 0 and if f(x1) and f(a) have opposite signs, then we can write the second approximation as:

x2 = [af(x1) – x1f(a)]/ [f(x1) – f(a)]

Similarly, we can estimate x3, x4, x5, and so on.

 Example:

1. Find a root for the equation 2ex sin x = 3 using the false position method and correct it to three
decimal places with three iterations.

Solution:

Given equation: 2ex sin x = 3

This can be written as: 2ex sin x – 3 = 0

Let f(x) = 2ex sin x – 3

So, f(0) = 2e0 sin 0 – 3

=0–3

= -3 < 0

And f(1) = 2e1 sin 1 – 3

= 2e sin 1 – 3
= 1.5747 > 0

That means the root of f(x) lies between 0 and 1.

Let a = 0 and b = 1.

The first approximation = x1 = [af(b) – bf(a)]/ [f(b) – f(a)]

= [0(1.5747) – 1(-3)]/ [1.5747 – (-3)]

= 3/4.5747

= 0.6557

Thus, x1 = 0.6557

Now, substitute x = 0.6557 in f(x).

So, f(0.6557) = 2e0.6557 sin(0.6557) – 3

= 2.3493 – 3

= -0.6507 < 0

As we know, f(1) > 0

That means a root lies between 0.6557 and 1.

Let a = 0.6557

The second approximation = x2 = [af(x1) – x1f(a)]/ [f(x1) – f(a)]

= [0.6557(1.5747) – 1(-0.6507)]/ [1.5747 – (-0.6507)]

= (1.0325 + 0.6507)/(2.2254)

= 1.6832/2.2254

= 0.7563

Therefore, x2 = 0.7563

Let us substitute 0.7563 in f(x).

So, f(0.7563) = 2e0.7563 sin(0.7563) – 3

= 2.9239 – 3

= -0.0761 < 0

We know that f(1) > 0

Thus, a root lies between 0.7563 and 1.

Hence, the third approximation = x3 = [af(x2) – x2f(a)]/ [f(x2) – f(a)]

= [(0.7563)(1.5747) – 1(-0.0761)]/ [1.5747 – (-0.0761)]

= (1.1909 + 0.0761)/1.6508

= 1.2670/1.6508
= 0.7675

So, x3 = 0.768

Therefore, the best approximation of the root up to three decimal places is 0.768 (up to three decimal
places).

EXAMPLE FOR MATLAB CODE:


RESULT OF THE CODE:

PRACTICE:

 EXCERCISES

1. Find a root for the equation x3 – 3x + 1 = 0 using the false position method and correct it to three
decimal places with three iterations.

2. Find the root correct to two decimal places of the equation xex = cos x, using the regular false
method.
4. INCREMENTAL SEARCH METHOD

Definition: The approximate locations of the roots are best determined by plotting the function. Often a
very rough plot, based on a few points, is sufficient to provide reasonable starting values. Another useful
tool for detecting and bracketing roots is the incremental search method.

The basic idea behind the incremental search method is simple: If f(x1) and f(x2) have opposite signs,
then there is at least one root in the interval (x1, x2). If the interval is small enough, it is likely to contain
a single root. Thus the zeros of f (x) can be detected by evaluating the function at intervals ∆x and
looking for a change in sign.

There are several potential problems with the incremental search method:

It is possible to miss two closely spaced roots if the search increment x is larger than the spacing of the
roots. A double root (two roots that coincide) will not be detected. Certain singularities (poles) of f (x)

can be mistaken for roots. For example, f (x) = tan x changes sign at x = ± π, n = 1, 3, 5, . . ., as shown
in Figure

However, these locations are


not true zeroes, because the
function does not cross the x-axis.
EXAMPLE:

EXAMPLE FPR MATLAB CODE:


RESULT OF THE CODE:

5. FIXED INTERACTION METHOD

Definition: The fixed point iteration method in numerical analysis is used to find an approximate solution to
algebraic and transcendental equations. Sometimes, it becomes very tedious to find solutions to cubic, bi-
quadratic and transcendental equations; then, we can apply specific numerical methods to find the solution; one
among those methods is the fixed point iteration method.

The fixed point iteration method uses the concept of a fixed point in a repeated manner to compute the solution
of the given equation. A fixed point is a point in the domain of a function g such that g(x) = x. In the fixed point
iteration method, the given function is algebraically converted in the form of g(x) = x.

Suppose we have an equation f(x) = 0, for which we have to find the solution. The equation can be expressed as
x = g(x). Choose g(x) such that |g’(x)| < 1 at x = x o where xo,is some initial guess called fixed point iterative
scheme. Then the iterative method is applied by successive approximations given by x n = g(xn – 1), that is, x1 =
g(xo), x2 = g(x1) and so on.

Algorithm of Fixed Point Iteration Method


 Choose the initial value xo for the iterative method. One way to choose x o is to find the values x = a and
x = b for which f(a) < 0 and f(b) > 0. By narrowing down the selection of a and b, take x o as the average
of a and b.
 Express the given equation, in the form x = g(x) such that |g’(x)| < 1 at x = x o. If there more than one
possibility of g(x), choose the g(x) which has the minimum value of g’(x) at x = xo.
 By applying the successive approximations xn = g(xn – 1), if f is a continuous function, we get a sequence
of {xn} which converges to a point lo, which is the approximate solution of the given equation.

Example 1:

Find the first approximate root of the equation 2x3 – 2x – 5 = 0 up to 4 decimal places.

Solution:

Given f(x) = 2x3 – 2x – 5 = 0

As per the algorithm, we find the value of xo, for which we have to find a and b such that f(a) < 0 and f(b) > 0

Now, f(0) = – 5

f(1) = – 5

f(2) = 7

Thus, a = 1 and b = 2

Therefore, xo = (1 + 2)/2 = 1.5

Now, we shall find g(x) such that |g’(x)| < 1 at x = xo

2x3 – 2x – 5 = 0

⇒ x = [(2x + 5)/2]1/3

g(x) = [(2x + 5)/2]1/3 which satisfies |g’(x)| < 1 at x = 1.5

Now, applying the iterative method xn,= g(xn – 1) for n = 1, 2, 3, 4, 5, …

For n = 1; x1 = g(xo) = [{2(1.5) + 5}/2]1/3 = 1.5874

For n = 2; x2 = g(x1) = [{2(1.5874) + 5}/2]1/3 = 1.5989

For n = 3; x3 = g(x2) = [{2(1.5989) + 5}/2]1/3 = 1.60037

For n = 4; x4 = g(x3) = [{2(1.60037) + 5}/2]1/3 = 1.60057

For n = 5; x5 = g(x4) = [{2(1.60057) + 5}/2]1/3 = 1.60059

For n = 6; x6 = g(x5) = [{2(1.60059) + 5}/2]1/3 = 1.600597 ≈ 1.6006

The approximate root of 2x3 – 2x – 5 = 0 by the fixed point iteration method is 1.6006.

Example 2:

Find the first approximate root of the equation cos x = 3x – 1 up to 4 decimal places.

Solution:

Let f(x) = cos x – 3x + 1 = 0

As per the algorithm, we find the value of xo, for which we have to find a and b such that f(a) < 0 and f(b) > 0

Now, f(0) = 2
f(𝜋/2) = -3𝜋/2 – 1 < 0

Hence, xo is a value lying between 0 and 𝜋/2, for ease of calculation let us take xo = 0

Now, we shall find g(x) such that |g’(x)| < 1 at x = xo

cos x – 3x + 1 = 0

⇒ x = (cos x + 1)/3

Then g(x) = (cos x + 1)/3 which satisfies |g’(x)| < 1 at x = 0

Now, applying the iterative method xn,= g(xn – 1) for n = 1, 2, 3, 4, 5, …

For n = 1; x1 = g(xo) = (cos 0 + 1)/3 = ⅔ = 0.66667

For n = 2; x2 = g(x1) = {cos (0.66667) + 1}/3 = 0.595296

For n = 3; x3 = g(x2) = {cos (0.595296) + 1}/3 = 0.609328

For n = 4; x4 = g(x3) = {cos (0.609328) + 1}/3 = 0.6066778

For n = 5; x5 = g(x4) = {cos (0.6066778) + 1}/3 = 0.607182

For n = 6; x6 = g(x5) = {cos (0.607182) + 1}/3 = 0.607086

For n = 7; x7 = g(x6) = {cos (0.607086) + 1}/3 = 0.607105

For n = 8; x8 = g(x7) = {cos (0.607105) + 1}/3 = 0.607101 ≈ 0.6071

The approximate root of cos x = 3x – 1 by the fixed-point iteration method is 0.6071.

CODE EXAMPLE FOR MATLAB:

RESULT OF THE CODE:


PRACTICE

 EXERCISES:

1. Find the first approximate root of the equation x3 – x – 1 = 0 up to 4 decimal places.

2. Find the first approximate root of the equation x3 – 3x – 5 = 0 up to 4 decimal places.

3. Find the first approximate root of the equation 2x3 – 7x2 – 6x + 1 = 0 up to 4 decimal places.
6. NEWTON RHAPSON METHOD

Definition: The Newton Raphson Method is referred to as one of the most commonly used techniques for
finding the roots of given equations. It can be efficiently generalised to find solutions to a system of equations.
Moreover, we can show that when we approach the root, the method is quadratically convergent. In this article,
you will learn how to use the Newton Raphson method to find the roots or solutions of a given equation, and the
geometric interpretation of this method.

Newton Raphson Method Formula

Let x0 be the approximate root of f(x) = 0 and let x1 = x0 + h be the correct root. Then f(x1) = 0

⇒ f(x0 + h) = 0….(1)

By expanding the above equation using Taylor’s theorem, we get:

f(x0) + hf1(x0) + … = 0

⇒ h = -f(x0) /f’(x0)

Therefore, x1 = x0 – f(x0)/ f’(x0)

Now, x1 is the better approximation than x0.

Similarly, the successive approximations x2, x3, …., xn+1 are given by
This is called Newton Raphson formula.

Example 1:

Find a real root of the equation -4x + cos x + 2 = 0, by Newton Raphson method up to four decimal places,
assuming x0 = 0.5.

Solution:

Given equation: -4x + cos x + 2 = 0

x0 = 0/5

Let f(x) = -4x + cos x + 2

f’(x) = -4 – sin x

Now,

f(0) = -4(0) + cos 0 + 2 = 1 + 2 = 3 > 0

f(1) = -4(1) + cos 1 + 2 = -4 + 0.5403 + 2 = -1.4597 < 0

Thus, a root lies between 0 and 1.

Let us find the first approximation.

x1 = x0 – f(x0)/f’(x0)

= 0.5 – [-4(0.5) + cos 0.5 + 2]/ [-4 – sin 0.5]

= 0.5 – [(-2 + 2 + cos 0.5)/ (-4 – sin 0.4)]

= 0.5 – [cos 0.5/ (-4 – sin 0.5)]

= 0.5 – [0.8775/ (-4 – 0.4794)]

= 0.5 – (0.8775/-4.4794)

= 0.5 + 0.1958

= 0. 6958

SAMPLE OF MATLAB:
RESULT OF THE CODE:

PRACTICE

 EXERCISES:

1. f(x)=x^3-x-1

2. f(x)=x^3+2x^2+x-1
7. SECANT METHOD

Definition: The secant method is a root-finding procedure in numerical analysis that uses a series of roots of
secant lines to better approximate a root of a function f. Let us learn more about the second method, its formula,
advantages and limitations, and secant method solved example with detailed explanations in this article.

The tangent line to the curve of y = f(x) with the point of tangency (x 0, f(x0) was used in Newton’s approach.
The graph of the tangent line about x = α is essentially the same as the graph of y = f(x) when x 0 ≈ α. The root
of the tangent line was used to approximate α.

Consider employing an approximating line based on ‘interpolation’. Let’s pretend we have two root estimations
of root α, say, x0 and x1. Then, we have a linear function

q(x) = a0 + a1x

using q(x0) = f (x0), q(x1) = f (x1).

Secant Method Steps

The secant method procedures are given below using equation (1).

Step 1: Initialization

x0 and x1 of α are taken as initial guesses.

Step 2: Iteration

In the case of n = 1, 2, 3, …,
until a specific criterion for termination has been met (i.e., The desired accuracy of the answer or the maximum
number of iterations has been attained).

Secant Method Convergence

If the initial values x0 and x1 are close enough to the root, the secant method iterates xn and converges to a root of
function f. The order of convergence is given by φ, where

Which is the golden ratio.

The convergence is particularly superlinear, but not really quadratic. This solution is only valid under certain
technical requirements, such as f being two times continuously differentiable and the root being simple in the
question (i.e., having multiplicity 1).

There is no certainty that the secant method will converge if the beginning values are not close enough to the
root. For instance, if the function f is differentiable on the interval [x0, x1], and there is a point on the interval
where f’ =0, the algorithm may not converge.

Example:

Compute two iterations for the function f(x) = x3 – 5x + 1 = 0 using the secant method, in which the real roots of
the equation f(x) lies in the interval (0, 1).

Solution:

Using the given data, we have,

x0 = 0, x1 = 1, and

f(x0) = 1, f(x1) = -3

Using the secant method formula, we can write

x2 = x1 – [(x0 – x1) / (f(x0) – f(x1))]f(x1)

Now, substitute the known values in the formula,

= 1 – [(0 – 1) / ((1-(-3))](-3)

= 0.25.

Therefore, f(x2) = – 0.234375

Performing the second approximation, ,

x3 = x2 – [( x1 – x2) / (f(x1) – f(x2))]f(x2)

=(- 0.234375) – [(1 – 0.25)/(-3 – (- 0.234375))](- 0.234375)

= 0.186441

Hence, f(x3) = 0.074276


SAMPLE OF MATLAB:

RESULT OF THE CODE

PRACTICE

 EXERCISES:

1. Compute the root of x2e−x/2−1=0 in the interval [0, 2] using the secant method. The root should be
correct to three decimal places. The initial values are 1.42 and 1.43.

2. Is the secant method converging faster than the bisection method?

You might also like