HP50G Bisection methode
07-24-2015, 12:01 PM (This post was last modified: 07-31-2015 03:51 PM by tigger.)
Post: #1
 tigger Junior Member Posts: 39 Joined: Jul 2015
HP50G Bisection methode
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, 04:35 PM (This post was last modified: 07-24-2015 04:43 PM by Gilles.)
Post: #2
 Gilles Member Posts: 162 Joined: Oct 2014
RE: HP50G Bisection methode
(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-29-2015, 11:31 AM
Post: #3
 Namir Senior Member Posts: 711 Joined: Dec 2013
RE: HP50G Bisection methode
(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-29-2015, 11:37 AM (This post was last modified: 07-29-2015 11:39 AM by Namir.)
Post: #4
 Namir Senior Member Posts: 711 Joined: Dec 2013
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
 « Next Oldest | Next Newest »

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