bisection plus algorithms presented by namir shammas 1

22
Bisection Plus Algorithms Presented by Namir Shammas 1

Upload: cornelius-fowler

Post on 27-Dec-2015

232 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Bisection Plus Algorithms Presented by Namir Shammas 1

Bisection Plus Algorithms

Presented by

Namir Shammas

1

Page 2: Bisection Plus Algorithms Presented by Namir Shammas 1

2

To the memory of esteemed and devoted PPC member

Jack Stout.

Dedication

Page 3: Bisection Plus Algorithms Presented by Namir Shammas 1

3

“The better is the enemy of the good”

-- Voltaire

My Creed

Page 4: Bisection Plus Algorithms Presented by Namir Shammas 1

4

Legacy Numerical Analysis Algorithms

• Legacy numerical analysis algorithms• Simple and straight to the point• Performed my human calculators• Kept as simple as possible

• First HP programmable calculators• Limited memory and program steps• Ideal for implementing legacy algorithms

• Second generation programmable calculators (HP-41C and on)• More memory and program space• More storage and use of solid state library modules

Page 5: Bisection Plus Algorithms Presented by Namir Shammas 1

5

Legacy Algorithms (cont.)

• Advent of personal computers (Apple, IBM, etc)• More memory• More power• Better display• Better mass storage• Better (and easier to read) programming languages (Basic, Pascal)

• Outcome?• We got spoiled!• Dare to develop more multistep algorithms• No longer limited by slow machines with limited memory

Page 6: Bisection Plus Algorithms Presented by Namir Shammas 1

6

Legacy Algorithms (cont.)

• Example of multistep algorithms• Runge-Kutta numerical integration method• Ostrowski root-seeking algorithm—two refinements for the root in

each iteration• Recent Chinese and Middle-Eastern mathematicians developed

more elaborate multistep algorithms for solving the roots of a nonlinear function. Each iteration has three or more refinements for the root. These algorithms reduce the number of iterations at the cost of a high number of function calls.

Page 7: Bisection Plus Algorithms Presented by Namir Shammas 1

7

Bisection Method• Slowest root-seeking method • Systematically shrinks root-bracketing interval (call it [A, B])

by halving it, until the desired tolerance is reached• Guaranteed to work if f(A)*f(B) <= 0.• Mentioned in numerical analysis books mainly for historical

reasons.• Question: Can we put the Bisection method on algorithmic

steroids?

Page 8: Bisection Plus Algorithms Presented by Namir Shammas 1

8

Yes We Can!

Page 9: Bisection Plus Algorithms Presented by Namir Shammas 1

9

Honestly! Do you all think this guy

is normal???

Page 10: Bisection Plus Algorithms Presented by Namir Shammas 1

10

Bisection Plus Method

• Each iteration of the Bisection Plus method calculates the midpoint, call it X1, and its associated function value f(X1).

• The new algorithm then calculates the slope and intercept of a line passing through X1 and either A or B. The method selects the interval endpoint whose function value has the opposite sign of f(X1).

• Why? To ensure the line passing through (X1 , f(X1)) lies inside the interval [A, B].

Page 11: Bisection Plus Algorithms Presented by Namir Shammas 1

11

Bisection Plus Method (cont.)

Page 12: Bisection Plus Algorithms Presented by Namir Shammas 1

12

Bisection Plus Method (cont.)

Page 13: Bisection Plus Algorithms Presented by Namir Shammas 1

13

Bisection Plus Method (cont.)

• Using this new line, the algorithm calculates X2--a better estimate for the root. The choice of using the proper endpoint and X1 ensures that X2 lies in the interval [A, B]. The algorithm also calculates f(X2).

• Each iteration ends up with the original interval-defining values A and B, and two new values, X1 and X2, within that interval. The process of shrinking the root-bracketing interval involves two tests:

Page 14: Bisection Plus Algorithms Presented by Namir Shammas 1

14

Bisection Plus Method (cont.)

• If f(X1)×f(X2) is negative, then the interval [X1, X2] replaces the interval [A, B] causing a quick reduction in the root-bracketing interval.

• If f(X1)×f(X2) is positive, then the method uses the value of f(A)×f(X2) to determine which of A or B is replaced by X2.

• It is worth pointing out that while both Newton’s method and the Bisection Plus calculate slope values, these values are different in context. Newton’s method calculate the tangent of f(X) at X. By contrast, the Bisection Plus method calculate the slope of the straight line between X1 and one of the endpoints. Thus, the Bisection Plus method is not vulnerable to values of X where the derivative of f(X) is near zero, as is the case with Newton’s method

Page 15: Bisection Plus Algorithms Presented by Namir Shammas 1

15

Bisection Plus Method (cont.)

Page 16: Bisection Plus Algorithms Presented by Namir Shammas 1

16

Bisection Plus Method (cont.)

Function [A, B] Toler Root Iterations Num Fx CallsExp(x)-4*x^2 [3, 5] 1E-8 4.30658 Bisec= 28

Bisec+ = 7Newton=6

Bisec= 30 Bisec+ = 18Newton=14

Exp(x)-3*x^2 [1, 4] 1E-8 3.73307 Bisec= 29 Bisec+ = 7Newton=10

Bisec= 31 Bisec+ = 18Newton=22

Exp(x)-3*x^2 [3, 4] 1E-8 3.73307 Bisec= 27Bisec+ = 6Newton=6

Bisec= 29Bisec+ = 16Newton=14

(X-2.345) * (X-12.345) * (X-23.456)

[1, 11] 1E-8 2.345 Bisec= 30 Bisec+ = 5Newton=9

Bisec= 32Bisec+ = 14Newton=20

(X-2.345) * (X-12.345) * (X-23.456)

[11, 22] 1E-8 12.345 Bisec= 29 Bisec+ = 4Newton=6

Bisec= 31Bisec+ = 12Newton=14

LN(X^4)-X [8,9] 1E-8 8.66125 Bisec= 27Bisec+ = 4Newton=4

Bisec= 29Bisec+ = 12Newton=10

Cos(X)-X [0.5,1] 1E-8 0.73908 Bisec= 26Bisec+ = 3Newton=4

Bisec= 28Bisec+ = 10Newton=10

Page 17: Bisection Plus Algorithms Presented by Namir Shammas 1

17

Bisection++ Method• The Bisection++ method picks up where the Bisection Plus

leaves off.• Each iteration of the Bisection Plus ends up with four points

at A, B, X1, and X2. The Bisection++ method uses these four points to perform an inverse quadratic Lagrangian interpolation to refine the guess at X2.

• Since a quadratic interpolation requires three points and we have four points, we need to choose three points and discard the fourth one.

Page 18: Bisection Plus Algorithms Presented by Namir Shammas 1

18

Bisection++ Method (cont.)

• Version 1 uses the points at X1 and X2, and either at A or B, depending on which of these two points has a smaller absolute function value. Thus, version 1 is simple to code.

• Version 2 maps the four points to an array of X and an array of Y=f(X), sorts these arrays in ascending order using the absolute values of Y. The method then uses the first three points in the sorted arrays to perform the inverse quadratic interpolation.

Page 19: Bisection Plus Algorithms Presented by Namir Shammas 1

19

Bisection++ Method (cont.)

• Version 3 is similar to version 2, except it does not sort the array of X and Y values and performs a cubic interpolation using the points at A, B, X1, and X2.

• Version 4 is basically the deluxe version of the above versions. This version performs a midpoint calculations followed by a linear, quadratic, and cubic interpolation.

Page 20: Bisection Plus Algorithms Presented by Namir Shammas 1

20

Bisection++ Method (cont.)

• Either version calculates an improved value of X2, call it X3. The method ensures that the value of X3 lies within the interval [A, B] before replacing X2 with X3. If not, the algorithm simply reuses the value of X2. The algorithm also calculates the new value of f(X2) and tests if its absolute value is less than a function tolerance value. If it is smaller, the iteration stops.

Page 21: Bisection Plus Algorithms Presented by Namir Shammas 1

21

Bisection++ Method (cont.)

• .Function [A, B] Toler/FxToler Root Iterations Num Fx Calls

Exp(x)-4*x^2 [3, 5] 1E-81E-8

4.30658 Bisec = 28 Bisec++ =3Newton=6

Bisec= 30 Bisec++ = 11Newton=14

Exp(x)-3*x^2 [1, 4] 1E-81E-4

3.73307 Bisec= 29 Bisec++ = 3Newton=13

Bisec= 31 Bisec++ = 10Newton=22

Exp(x)-3*x^2 [3, 4] 1E-81E-4

3.73307 Bisec= 27Bisec++ = 2Newton=6

Bisec= 29Bisec++ = 8Newton=14

(X-2.345) * (X-12.345) * (X-23.456)

[1, 11] 1E-81E-4

2.345 Bisec= 30 Bisec++ = 3Newton=9

Bisec= 32Bisec++ = 10Newton=20

(X-2.345) * (X-12.345) * (X-23.456)

[11, 22] 1E-81E-4

12.345 Bisec= 29 Bisec++ = 3Newton=6

Bisec= 31Bisec++ = 9Newton=14

LN(X^4)-X [8,9] 1E-81E-4

8.613169 Bisec= 27Bisec++ = 1Newton=4

Bisec= 29Bisec++ = 5Newton=10

Cos(X)-X [0.5,1] 1E-81E-4

0.73908 Bisec= 26Bisec++ = 1Newton=4

Bisec= 28Bisec++ = 5Newton=10

Page 22: Bisection Plus Algorithms Presented by Namir Shammas 1

22

Thank You!!