0% found this document useful (0 votes)
12 views27 pages

FENG345 Lec3

The document discusses numerical methods for finding roots of functions, particularly in engineering contexts where analytical solutions may not be available. It covers various root-finding methods including graphical methods, bisection, and Newton-Raphson, providing examples and MATLAB programming solutions for practical applications. The bisection method is highlighted for its reliability and convergence properties, despite its slower speed compared to other methods.

Uploaded by

Sadettin Şahin
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)
12 views27 pages

FENG345 Lec3

The document discusses numerical methods for finding roots of functions, particularly in engineering contexts where analytical solutions may not be available. It covers various root-finding methods including graphical methods, bisection, and Newton-Raphson, providing examples and MATLAB programming solutions for practical applications. The bisection method is highlighted for its reliability and convergence properties, despite its slower speed compared to other methods.

Uploaded by

Sadettin Şahin
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/ 27

FENG 345 Numerical Methods for

Engineers I

Lecture 3

Roots (Bracketing Methods)


Dr. Osman Nuri Şahin
1
Introduction
• The roots of a function appear in most engineering design problems.
• Even with simple functions, e.g., 𝑓 𝑥 = 𝑒 −𝑥 − 𝑥 the roots cannot
find analytically. The only way is to use numerical techniques.
Second-order polynomial equation:
ax + bx + c = 0
2

analytical solution:

( )
x = − b  b − 4ac / 2a
2

• For many real problems, such as a 6th-order polynomial, an analytical


solution does not exist. Then the numerical approach must be used.
2
Introduction

3
Introduction
Root Finding Methods:
• Graphical Method
• Bisection Method (Binary search)
• Secant Method
• Modified Secant
• Successive approximation
• Newton-Raphson method

4
GRAPHICAL METHODS
• A simple method for obtaining an estimate of the root of the equation
𝑓 (𝑥) = 0 is to make a plot of the function and observe where it
crosses the 𝑥 axis.
• It provides a rough approximation of the root.

5
Example
• Use the graphical approach to determine the mass of the bungee
jumper with a drag coefficient of 0.25 𝑘𝑔/𝑚 to have a velocity of
36 𝑚/𝑠 after 4 𝑠 of free fall. Note: The acceleration of gravity is
9.81 𝑚/𝑠 2 .

• The function crosses the m axis between 140 and 150 kg. Visual
inspection of the plot provides a rough estimate of the root of 145 kg.
6
INITIAL GUESSES
• There are a number of general ways that a root may occur in an
interval prescribed by a lower bound 𝑥𝑙 and an upper bound 𝑥𝑢 .

• if both 𝑓 𝑥𝑙 and 𝑓 𝑥𝑢 have the same sign, either there will be no


roots or there will be an even number of roots 7
INITIAL GUESSES

• if the function has different signs at the end points, there will be an
odd number of roots in the interval.

8
INITIAL GUESSES
• There are some exceptions
⁻ Multiple roots that occur when the function is tangential to the x axis.
⁻ Discontinuous functions where end points of opposite sign bracket an
even number of roots.

9
BISECTION METHOD
• If 𝑓(𝑥) is real and continuous in the interval from 𝑥𝑙 to 𝑥𝑢 and 𝑓 𝑥𝑙
and 𝑓 𝑥𝑢 have opposite signs, that is,

• then there is at least one real root between 𝑥𝑙 and 𝑥𝑢 .

10
Example
• Use bisection to solve the same problem approached graphically in
first example.
Solution:The first step in bisection is to guess two values of the
unknown (in the present problem, 𝑚) that give values for 𝑓(𝑚) with
different signs. From the graphical solution, we can see that the
function changes sign between values of 50 and 200.

Note that the exact value of the root is 142.7376.

11
Example
• the new interval extends from 𝑥𝑙 = 125 to 𝑥𝑢 = 200. A revised root
estimate can then be calculated as

• the root is now in the lower interval between 125 and 162.5.

• which represents a percent relative error of 𝜀𝑡 = 0.709%.

12
Example
• When 𝜀𝑎 becomes less than a prespecified stopping criterion 𝜀𝑠 , the
computation is terminated.

13
BISECTION METHOD
• One of the benefits of the bisection method is that the number of
iterations required to attain an absolute error can be computed before
starting the computation. The absolute error is

• After the first iteration, the error becomes

• a general formula relating the error and the number of iterations n is

14
BISECTION METHOD
• If 𝐸𝑎,𝑑 is the desired error, this equation can be solved for

• In previous example the initial interval was ∆𝑥0 = 200 – 50 = 150.


After eight iterations, the absolute error was

15
BISECTION METHOD
• Advantage:
- Bisection method always converge no matter how far you start from
the actual root.
• Disadvantage:
- However, it cannot be used to find roots when the function is tangent
to the axis and does not pass through the axis. For example: 𝑓 𝑥 =
𝑥 2.
- Also, it converges slowly compared with other methods.

16
Example

17
3. Roots of polynomials:

Example 3.1 Write the MatLAB program to find the roots of (24x+300+3x2)(-4+5x3+20x)=0
p=
Solution: a1=[3,24,300]; a2=[5,0,20,-4];a=conv(a1,a2),p=roots(a) -4.0000 + 9.1652i
-4.0000 - 9.1652i
15x 5 + 120 x 4 + 1560 x 3 + 468x 2 + 5904 x − 1200 = 0 -0.0990 + 2.0073i
-0.0990 - 2.0073i
0.1981 + 0.0000i

Example 3.2 u ( t ) = −3t 3 + 120 + 60 t Write the MatLAB program to find u(0.4). Do the claculation by a calculator.
Compare the results.

Solution: t=0.4;u=-3*t^3+120+60*t u=143.8080

Alternative: a=[-3,0,60,120];u=polyval(a,0.4)

Commands: roots, conv, polyval


Home Excercise 3.1 (Chapra and Canale)

(p.200)

Write the form of the step response of the system.


Chapra (p.47)

Home Excercise 3.2

L=600 cm, E=20000 kN/cm2, I=22.5 cm4, w0=2 N/cm


Find maximum deflection and its location.
Home Excercise 3a.2

L=600 cm, E=20000 kN/cm2, I=22.5 cm4, w0=2 N/cm


Find maximum deflection and its location.
dy
Solution: = K ( −5x 4 + 6L2 x 2 − L4 ) = 0
dx
L=600e-2;pyd=[-5,0,6*L^2,0,-L^4];xext=roots(pyd)
xext =
-6.0000 L=600e-2;E=20000*1000/(1e-2)^2;iz=22.5e-8;w0=2/1e-2;
6.0000 x=2.6863; K=w0/(120*E*iz*L);
-2.6833 Valid py=K*[-1,0,2*L^2,0,-L^4,0];yext=polyval(py,x)
2.6833 solution
yext=-13.7384 mm at xext=2.6863 m
Home Excercise 3.3

Consider the beam under uniformly distributed load. It is clamped at A and has a roller
Home Excersise 3.4 support at B. The deflection function found with Bernoulli-Euler beam theory is given
q0 below, for the values L=800 mm, q0=10 kN/m. E=200 GPa, I=20 cm4.

B EIu = 2833.33x 3 − 416.6667 x 4 − 2000 x 2


A
a) Find the maximum deflection and its location. b) Plot u versus x
3b. Bisection Method
Example 3b.1
gm  gc 
v( t ) = tanh  t 
c  m 

Solution: 9.81m  (9.81)(0.25)  m=100:1:200;


f (m) = tanh  ( 4)  − 36 = 0 f=sqrt(9.81*m/0.25).*tanh(sqrt(9.81*0.25./m)*4)-36;
0.25  m  plot(m,f)
x=m
xL + xu
1) x L = 50, x u = 200 xr = = 125
2
x L = 125, x u = 200 x r = 162.5
2) f(50) f(125)=(-4.579)(-0.409)=1.871 >0
162.5 − 125
a = (100) = 23.0769 %
152.5
3) f(125) f(162.5)=(-0.409)(0.359)=-0.147 x L = 125, x u = 162.5 x r = 143.75
143.75 − 162.5
a = (100) = −13.04 %
143.75
xL xu xr εa
4 125 143.75 134.3750 -6.9767
5 134.3750 143.75 139.0625 3.3708

x=m 9.81x  (9.81)(0.25)  s =
0 .5
f (x) = tanh  ( 4)  − 36 = 0 n
100 %
0.25  x  10

% bisect.m
clc,clear,close all
xL=50;xu=200;xr=(xL+xu)/2;epss=0.5/(10^5)*100;kerr=1; ans = 0 18.0000 142.7378
for n=2:1:100;
fr=fx(xr);fL=fx(xL);
if fL*fr>0;xL=xr;end
if fL*fr<0;xu=xr;end
xrp=xr;xr=(xL+xu)/2;
epsa=(xr-xrp)/xr*100;xrp=xr;if abs(epsa)<epss;kerr=0;break;end
end
[kerr,n,xr]

% fx.m
function [f]=fx(x);
f=sqrt(9.81*x/0.25).*tanh(sqrt(9.81*0.25./x)*4)-36;
Solution: 9.81
Home Excercise 3b.1 1 = 90(tan 0 ) − (8100) + 1.8
( 2)(900) cos 0
2

44.145
f = 90(tan x ) − 2
+ 0 .8 = 0
cos x
th0=0:1:80;x=th0;f=fx(x);plot (x,f)

% bisect.m
clc,clear,close all
xL=30;xu=45;xr=(xL+xu)/2;epss=0.5/(10^5)*100;kerr=1;
for n=2:1:100;
fr=fx(xr);fL=fx(xL);
if fL*fr>0;xL=xr;end
if fL*fr<0;xu=xr;end
xrp=xr;xr=(xL+xu)/2;
epsa=(xr-xrp)/xr*100;xrp=xr;
if abs(epsa)<epss;kerr=0;break;end
end
[kerr,n,xr]

% fx.m x=37.9590 for xL=30,xu=45


function [f]=fx(x);
x=51.5318 for xL=45,xu=55
f=90*tand(x)-44.145./(cosd(x)).^2+0.8;
Write a MatLAB program to find θ0.
Solution:
Home Excercise 3b.2
x=0:1:10;f=fx(x);plot (x,f)
−x
f (x) = e −x =0

Write a MatLAB program to find x.


% bisect.m
clc,clear,close all
xL=0;xu=2;xr=(xL+xu)/2;epss=0.5/(10^5)*100;kerr=1;
for n=2:1:100;
fr=fx(xr);fL=fx(xL);
if fL*fr>0;xL=xr;end
if fL*fr<0;xu=xr;end
xrp=xr;xr=(xL+xu)/2;
epsa=(xr-xrp)/xr*100;xrp=xr;
if abs(epsa)<epss;kerr=0;break;end
end
[kerr,n,xr]

% fx.m
function [f]=fx(x); x=0.5671
f=exp(-x)-x;
Example 3.3 Consider the mass-spring-dashpot system. The mathematical model is given as mx + kx = f − cx
x(t) The governing difeferential equation can be organized as: mx + cx + kx = f
For the free vibration under initial conditions f=0. Then, mx + cx + kx = 0
k
m Try the free vibration solution as x(t)=est.
f ( t ) Applying the solution to the differential equation gives ms 2 e st + cse st + ke st = 0
c
Eigenvalue equation can be obtained as ms 2 + cs + k = 0
a) Take m=2, c=60, k=280. Write the MatLAB program to find the eigenvalues. Also, find the eigenvalues by the calculator.
Compare the results. Write the form of the free vibration response.
b) Take m=2, c=30, k=280. Write the MatLAB program to find the eigenvalues. Also, find the eigenvalues by the calculator.
Compare the results. Write the form of the free vibration response.
Solution: a) d=[2,60,280];p=roots(d) 2s + 60s + 280 = 0
2 − 60  60 2
− 4( 2)(280) s1 = −24.2195, s 2 = −5.7805
s1, 2 =
2( 2)
The form of free vibration: x(t)=A1e -24.2195t +A2e -5.7805t A1 and A2 are determined by initial conditions
− 30  30 2 − 4( 2)(280) s = −7.5 + 9.1515i, s = −7.5 − 9.1515i
b) d=[2,30,280];p=roots(d) 2s + 30s + 280 = 0
2
s1, 2 = 1 2
2( 2)
The form of free vibration: x(t)=Ae-7.5tcos(9.1515t-ϕ) A and ϕ are determined by initial conditions
Example 3.4 Consider the problem given in Example 3.2. If f(t)=est, the reponse can be x(t)=H(s)est.
Then, from the differential equation: ms 2 Hest + csHest + kHest = est
1
The transfer function can be found as: H (s) =
ms 2 + cs + k

The denominator of the transfer function is the eigenvalue equation.


The steady state step input response as t→∞ can be found as xss=H(0)=1/k

a) Write the form of the steady state response for the values given in Example 3.2 (a)
b) Write the form of the steady state response for the values given in Example 3.2 (b)

Solution: a) s1 = −24.2195, s 2 = −5.7805 x(t)=A1e-24.2195t+A2e-5.7805t+1/280

a) s1 = −24.2195, s 2 = −5.7805 x(t)=A1e-24.2195t+A2e-5.7805t+1/280


A1 and A2 are determined by inverse Laplace Transform
b) s1 = −7.5 + 9.1515i, s 2 = −7.5 − 9.1515i x(t)=Ae-7.5tcos(9.1515t-ϕ)+1/280
A and ϕ are determined byinverse Laplace Transform

You might also like