# HP Forums

Full Version: HP 42s square/nth root
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

Does anyone have a quick solution for "square and/or nth root" with the HP 42s. Do I have to write a short Programm for this?

Thank's
Robin

BTW:
Oh I'm already waiting soo long for an HP 42s replacement, how long will I have to wait for it, if it will be similar to the delays of the 33s ;-)

I'm not sure what you are looking for but would it be to take the cubic root of nine the.

9 enter
3 1/x and
y^x.

Did that do it or are you looking for something else.

Kim

sorry, in my hurry I wrote square instead of cube..

Im searching for the function "x root y" which isn't on the 42s. It should take the nth root of a number, like "3rd root of 27 would equal 3".

In most HP calculators, there is no nth root key. Since obtaining the nth root is the same than applying the inverse of the nth power, you apply the already described sequence...

To get the P-th root of Q you should key:

value of Q

ENTER

value of P

1/X

Y^X

For example, "the fourth root of 16" is the same than "16 at the 1/4 power"

16

ENTER

4

1/X (result: 0.25)

Y^X (result: 2 q.e.d.)

Thank's, Kim and Andrés - that's all i wanted to know :-).

So the missing key shows how little some people (like me) know about math ;-) ..and I found it finally in the original manual, too ;-)

I would prefer not seeing that key on a new layout now as i know how to do it without, so the keyboard stays clearer.

Same thing with the x^2 key on my HP 42s. could also press enter * , the only advantage is the saving of the t-Stack wenn using x^2.

Edited: 31 Jan 2004, 12:08 p.m.

You are welcome!

Robin posted --

Quote:
"I would prefer not seeing that key [y^(1/x) key] on a new layout now as i know how to do it without, so the keyboard stays clearer."

One advantage of the special key for "root" exponents is that real-valued odd-integer roots of negative numbers can be found directly. For example, on a 32Sii,

(-8)^(1/3) using the "x-th root of y" function gives -2.000 as the answer.

However, using 1/x, then y^x on any calculator to find a real-valued result will give an error message, because

```(-8)^(1/3) = exp{ln[(-8)^(1/3)]} = exp[1/3*ln(-8)]
```

which is undefined due to "ln" of negative argument.

In complex mode, the 15C (flag 8 set) and the 42S ("CRES" set) will give

```1+i*sqrt(3) = 1.00 + i1.732
```

as the answer to (-8)^(1/3), using 1/x and y^x.

Edited: 31 Jan 2004, 3:22 p.m.

Karl: the situation you describe happened indeed with the first HP models (at least as far as the HP25) but about the time the HP27 and the HP67 were introduced, the case of the odd-integer roots of negative numbers was included as a valid, non error case. Without resorting to complex modes, many HP models (from about 1977 on) will give -2 as the cubic root of -8.

When in complex mode, the HP15C and the HP42S will give the principal value for the cubic root of -8, which is the root located in the first quadrant; that is why the answer is a complex number. In real mode, the answer will be -2 and no error condition will be claimed.

Andrès, what Karl wrote happens exactly with my HP 42S. Maybe there where different ROMS? I don't think so, but who knows..

Anyway, I just hope we don't touch negative cube roots in our exam, it would surprise me because we haven't done something with them so far.

BTW: Couldn't I just take the cube root of the positive value and then at last change the sign???

Robin, Karl:

I made a mistake, I apologize. Yhe evolution around 1977 was to accept negative entries for INTEGER POWERS, not roots (fractional powers), as I mistakenly stated.

Before evolution (HP25), (-2)^3 displays Error

After evolution (HP27,67,41), (-2)^3 displays -8

While the workaround is not very complex (no pun intended!), it will take some steps from a scarce memory pool when developing programs for these calculators; that is why this was a welcome advance. For manual operations, it was not a big issue.

Yhank you!

Andres, Robin --

Good, informative discussion. I think we're all on the same page, and have it right. I learned a couple things myself, regarding the enhancements of early units and why one of the complex-valued roots of (-8)^(1/3) is considered the "primary" root. (The other root, of course, is the complex conjugate of the primary.)

Robin is right that taking the negatvie-integer root of the absolute value of the argument, then negating the answer, is the workaround. In fact, this is what I suspect is the basis of the algorithm on improved later HP's for integer exponents of negative numbers:

For x > 0.00 (floating-point) and n an integer,

```(-x)^n = exp[n*ln(x)]*[(-1)^n]   (change sign of result if n is odd)
```

Of course, this applies only if n is an integer.

Now, if y = 0 in y^x, x must be positive -- Negative x yields divide by 0, and x = 0 yields undefined 0^0 -- READERS: Please don't launch that thread again!.

Makes one appreciate what a complete implementation of mathematical functionality entails, doesn't it?

Edited: 1 Feb 2004, 3:49 p.m.

Quote:
Now, if y = 0 in y^x, x must be positive -- Negative x yields divide by 0, and x = 0 yields undefined 0^0 -- READERS: Please don't launch that thread again!

TOO LATE! 8^)

-Ernie

"Now, if y = 0 in y^x, x must be positive -- Negative x yields divide by 0, and x = 0 yields

Have a look at this interesting link:

My own opinion is that assigning 0^0 the value 1 is far more useful and consistent that simply leaving it undefined. It isn't more 'true', just more useful.

Also, I've found it very intuitive and enlightening to consider the value of the function x^n for integer, positive n to actually mean the number of times you need to multiply 1 by n to compute the result. So:

```        X^1 = 1 * X          (multiply 1 by X once)
X^2 = 1 * X * X      (multiply 1 by X twice)
X^3 = 1 * X * X * X  (multiply 1 by X thrice)
and so on. Then we have, naturally:
X^0 = 1              (multiply 1 by X zero times)
and further, when X happens to be zero:
0^0 = 1             (multiply 1 by 0 zero times)
```
So this natural definition fully coincides with the usual
values of x^n for integer, positive n, and has no problem
at all when either x or n or both are zero.

For negative n, just change "multiply" to "divide".

Best regards from V.