# HP Forums

Full Version: (11C/15C) Extended power function
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
(11C/15C) Extended power function

Hi,

A long time ago, I had to solve some equations like
f(t) = 2 + XROOT(3, (1 - 5t)) = 0
where XROOT(3, -8)=-2
But the HP15C (or the HP11C) could not handle -8^(1/3) without returning ERROR 0, out of the complex mode

So, I composed a function to compute Y^X with Y and X as decimal or natural numbers
It gave the following program for the HP15C
(The program also runs on the HP11C by using CF 0, SF 0 or F?0 instead of CF 8, SF 8 and F?8)

Code:
``` f LBL E ENTER g INT x=y (5) GTO .9 g CLx g LSTx f FRAC 1/x g RND g CF 8 2 ÷ f FRAC g x=0 GTO .9 g SF 8 R↓ x↔y x>0 (1) g CF 8 g ABS g LN x e^x g F? 8 CHS g CF 8 g RTN f LBL .9 R↓ y^x g RTN f LBA A 5 CHS x 1 + 3 1/x GSB E   // calls extended Y^X 2 + g RTN```

With this usage :

-8
ENTER
3 1/x
GSB E
returns -2

Further, A is the function to solve

So, 0 ENTER 0
f SOLVE A returns 1.8 after running near a minute

Keep you safe !
(04-05-2021 10:53 AM)Nihotte(lma) Wrote: [ -> ](11C/15C) Extended power function

I have found out a copy of the decision tree which clarifies the process of the function. Here is a restitution, below:

Y^x
-----

Code:
``` x is a natural number (set of N)     --> general case x is a rational number (set of Q)     1/x is even number  (as 1/ 1/2)        Y >= 0           --> general case        Y < 0            F?8 enabled               --> Solution is a complex number (set of C)            F?8 is disabled               --> ERROR 0    1/x is odd number   (as 1/ 1/3)       --> -e^(x*ln(|Y|))   where  ln is natural logarithm and |Y| is abs function on Y```

By extension, you can unterstand that you should generalize the use of the F?0 flag between HP11C and HP15C and just authorize g SF 8 before running the search, in the case you want to avoid the ERROR 0 and open the resulting to the complex solution (x is even and Y is negative).

So, just read CF 0, SF 0 and F?0 in the initial code !

Keep you safe !

Laurent
Reference URL's
• HP Forums: https://www.hpmuseum.org/forum/index.php
• :