(11C) Roots of f(x)=0 in an Interval

12202018, 07:38 AM
(This post was last modified: 12202018 07:39 AM by Gamo.)
Post: #1




(11C) Roots of f(x)=0 in an Interval
Found this Solver Program from
HP19C Solutions Book (Mathematics 1977) on Page 13 According to this solutions book this solver find Roots in an Interval. This program uses a "halfinterval" search to find the real roots of an equation f(x)=0 in a closed interval [a,b] Specify Accuracy Tolerance and search increment. The program then begins at the left of the interval and compares the functional values a the ends of the interval. I have test these roots searching speed between the Newton's Method program from the HP11C User's Handbook with this HP19C Solution Book and found that the HalfInterval Method is faster than the Newton's Method.  Procedure: [A] Tolerance and Search Increment values [B] Interval [x1,x2] [C] Search for Roots [R/S] for more Roots **Available Register** R0 and R9 up to any available space.  Example from 19C Solutions Book X^3  8X^2 + 5X + 14 = 0 Set Tolerance 10^6 and increment by 1 Interval between 10 to 10 Enter your equation at LBL E STO 0 3 Y^X RCL 0 X^2 8 x  5 RCL 0 x + 1 4 + RTN Tolerance and Search Increment: [EEX] [CHS] 6 [ENTER] 1 [A] Interval: 10 [CHS] [ENTER] 10 [B] Search for Roots: [C] display 1 [R/S] 2 [R/S] 7 Answer: x1 = 1 x2 = 2 x3 = 7  Program: Code:
Gamo 

12202018, 10:25 AM
Post: #2




RE: (11C) Roots of f(x)=0 in an Interval
(12202018 07:38 AM)Gamo Wrote: I have test these roots searching speed between the Newton's Method program from the The convergence speed of the binary search is linear while it is quadratic for Newton's method. Therefore, I am somewhat skeptical of this statement. For comparison, here is a skeleton for Newton's method for polynomials that uses Horner's method to compute both \(f(x)\) and \(f'(x)\): Code: 01 RCL I The coefficients of the polynomial are entered in the registers 0, 1, 2, … Example: Your polynomial \(x^3  8x^2 + 5x + 14\) is entered as: 1 STO 0 8 STO 1 5 STO 2 14 STO 3 The degree n is entered as nE3 in register I: 0.003 STO I The initial guess (e.g. 2.5) is entered in X and Y: 2.5 ENTER R/S 2.015384615 It returns an improved estimate. You can iterate the process for as long as you like by pressing R/S: 2.5 2.015384615 2.000030948 2.000000000 After only 3 iterations we end up with the exact result. Cheers Thomas 

12202018, 07:21 PM
Post: #3




RE: (11C) Roots of f(x)=0 in an Interval
(12202018 07:38 AM)Gamo Wrote: According to this solutions book this solver find Roots in an Interval. This is usually called bisection. A simple but ineffective method. (12202018 07:38 AM)Gamo Wrote: I have test these roots searching speed between the Newton's Method program from the HP11C User's Handbook with this HP19C Solution Book and found that Bisection converges faster than Newton? Tell me about it. ;) Sorry, Gamo, but bisection is a simple but not very effective moethod for finding roots of a function. Newton's method usually is much faster. Of course for the particular example you give bisection works nicely: according to the input data the program checks the function at –10, –9, –8, ..., 8, 9 and 10 while the roots are at –1, 2 and 7. This means that the bisection algorithm does not even have to be applied, the three roots are directly found at the ends of an interval. The advantage of this program is its ability to find multiple roots within an interval. But this should be combined with a method that is more effective than bisection. For instance the secant method or regula falsi. Here you can also specify an interval but the root within that interval is found much faster. I would recommend a modifed regula falsi, e.g. the Illinois method. BTW, coding polynomials in RPN can be done much simpler and faster with Horner's method. Most important, this avoids the use of the y^x function which is very slow. You better do it this way: Code: LBL E Now, what about a program that uses the given basic structure but provides faster root finding e.g. with a regula falsi approach? Dieter 

« Next Oldest  Next Newest »

User(s) browsing this thread: 1 Guest(s)