HP Forums

Full Version: HP50G Bisection methode
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I would like to program the Bisection Methode.
Is there anybody who can help me with it.

I am an absolute beginner.

I have the function y=x^5-5.
I assume the result between 1 and 2:
We first define the function F(X).
Now save 2 in a variable called B and 1 in a variable called A.
We have to find the midpoint between A and B, our new approximation, C.

Can anbody help me to go on.

I would like to program other easy stuff.
(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
 »
»
(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.

I am an absolute beginner.

I have the function y=x^5.
I assume the result between 1 and 2:
We first define the function F(X).
Now save 2 in a variable called B and 1 in a variable called A.
We have to find the midpoint between A and B, our new approximation, C.

Can anbody help me to go on.

I would like to program other easy stuff.

The root for y=x^5 (or for any y=x^n) is zero, not in the interval [1, 2]. You can start with an interval of, say, [-1, 1].

Namir
(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
Reference URL's