Post Reply 
HP50G Bisection methode
07-29-2015, 11:37 AM (This post was last modified: 07-29-2015 11:39 AM by Namir.)
Post: #4
RE: HP50G Bisection methode
(07-24-2015 04:35 PM)Gilles Wrote:  
(07-24-2015 12:01 PM)tigger Wrote:  I would like to program the Bisection Methode.
Is there anybody who can help me with it.
Hi

It seems there is a problem with your example as there is no root for this function between 1 and 2

here is an example (not optimised), in RPL, aprox mode with a modified function (X^5-5) :

Code:
'F(X)=X^5-5' DEFINE
 1. 2.
 
« 
 IF OVER F OVER F > THEN SWAP END
 0. -> A B C
 « 
  DO
   A B + 2. / DUP 'C' STO  
   IF 'F(C)<0' THEN 'A' STO ELSE 'B' STO END
  UNTIL 'ABS(F(C))<0.01' END
  C
 »
»

Your code assumes F(A)<0 and that's risky, because if F(A)>0 your implementation will not work. The traditional Bisection algorithm uses the test F(A)*F(C)>0 instead to determine if we set A=C (when that condition is true) and B=C otherwise.

I assume the RPL code should be:

Code:
'F(X)=X^5-5' DEFINE
 1. 2.
 
« 
 IF OVER F OVER F > THEN SWAP END
 0. -> A B C
 « 
  DO
   A B + 2. / DUP 'C' STO  
   IF 'F(A)*F(C)>0' THEN 'A' STO ELSE 'B' STO END
  UNTIL 'ABS(F(C))<0.01' END
  C
 »
»

Namir
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
HP50G Bisection methode - tigger - 07-24-2015, 12:01 PM
RE: HP50G Bisection methode - Gilles - 07-24-2015, 04:35 PM
RE: HP50G Bisection methode - Namir - 07-29-2015 11:37 AM
RE: HP50G Bisection methode - Namir - 07-29-2015, 11:31 AM
RE: HP50G Bisection methode - acser - 10-02-2020, 11:30 PM
RE: HP50G Bisection methode - Albert Chan - 10-03-2020, 02:03 AM
RE: HP50G Bisection methode - Albert Chan - 10-04-2020, 03:04 PM
RE: HP50G Bisection methode - acser - 10-07-2020, 09:15 PM
RE: HP50G Bisection methode - John Keith - 10-08-2020, 11:55 AM
RE: HP50G Bisection methode - acser - 10-08-2020, 12:55 PM



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