Presentation is loading. Please wait.

Presentation is loading. Please wait.

Numerical Calculation Part 1: Equations &Roots Dr.Entesar Ganash (Bisection's Method)

Similar presentations


Presentation on theme: "Numerical Calculation Part 1: Equations &Roots Dr.Entesar Ganash (Bisection's Method)"— Presentation transcript:

1 Numerical Calculation Part 1: Equations &Roots Dr.Entesar Ganash (Bisection's Method)

2 Bisection's Method A general idea: This is another numerical method, which could be used to solve a general equation f(x)=0. The method depends on the intermediate value theorem for continuous functions. If a function f(x) is continuous on the interval [a, b] and sign of f(a) ≠ sign of f(b), then: there is a value c ∈ [a..b] such that: f(c) = 0 i.e., there is a root c in the interval [a, b] It is a successive approximation method that makes an interval, which has a root of the function f(x) narrow. It will bisect the interval in two parts and test which one has a function root. It will continue bisect the interval until the resulting interval becomes really small. Then the root is approximately equal to any value in the final interval. f(x) x In [a,b] From: http://www.mathcs.emory.edu/~cheung/Courses/170/Syllabus/07/bisection.html

3 A Structure Plan: A structure plan to execute Bisection's method: 1.Estimate a required accuracy (Epsilon). 2.try to find two initial values of x ( and ) such that that means both functions have different signs. So, at least one root must lie some where between them. 3.Calculate maximum bisection N from inequality 4.Repeat N times (a) & (b) steps a) Find the mid point, call it, which is the estimated root of the interval [, ]. It is given by, also Find. b) Test whether if this condition is right..then let otherwise let 5. Print root and then end a program. The efficient thing of Bisection's method is number of bisections, which is needed for getting a good accuracy can be calculated before beginning as will be seen below.

4 Example Write a program using Bisection’s method to solve this equation starting with two guesses repetitions. PROGRAM BISECTION IMPLICIT NONE Integer::k,N ! a counter & a maximum bisection Real :: eps,XL,XR !required accuracy (epsilon)& two initial guesses Real :: xm ! a mid point Eps=1E-6 xL=1.0 ; xR=2.0 N=log(ABS(XL-XR)/eps)/log(2.0)+1 !N must exceed formula value DO K=1,N XM=(XL+XR)/2.0 If(F(XL)*F(XM) <0.0)THEN XR=XM Else XL=XM END IF END DO Solving

5 Write(*,*)'Number of bisection:‘ N Write(*,*)'The root is approximately =',XM Contains !-------------------------- !Function Subprogram f is to solve f(x)=0 !-------------------------- REAL FUNCTION f(x) Implicit none Real::f,x f=x**3+x-3 End FUNCTION f !-------------------------- END PROGRAM BISECTION continue Solving 1

6 The result:

7 Exercise Write a program compute the position( x & y co-ordinate) and the velocity (magnitude &direction) of projectile, given t, the time since launch, u, the launch velocity, a, the initial angle of launch(in degrees) and g, the acceleration due gravity. The horizontal & vertical displacement are given by the formulae The velocity has magnitude V such that Where its horizontal & vertical components And V makes an angle with the ground such that

8 References Hahn, B.D., 1994, Fortran 90 For Scientists and Engineers, Elsevier. http://www.mathcs.emory.edu/~cheung/Courses/170/Syllabus/07/bisection.html http://mat.iitm.ac.in/home/sryedida/public_html/caimna/transcendental/bracketing %20methods/bisection/bisection.html Univ.,


Download ppt "Numerical Calculation Part 1: Equations &Roots Dr.Entesar Ganash (Bisection's Method)"

Similar presentations


Ads by Google