Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.

# Thread: Calculating Root Values beyond Math.sqrt

1. ## Calculating Root Values beyond Math.sqrt

Well, it's been a while since I last visited CF, but I'm finally back and, for the life of me, am drawing a total blank on something that seems like it should be fairly easy to handle.

The Math.sqrt() function works just fine if all a person needs is the Square Root of a number, but what about needing the Cube Root or even a 4th Root of a number?

My first instinct was to use the Math.pow(x,y) function with a negative value for "y." For instance;

var z=Math.pow(27,-3)

This should return a value of 3. Unfortunately, this doesnt seem to work when I tested it through the W3 reference pages, so I am looking for a clue as to how I might go about finding such values, or if it is even possible through Javascript.

Oh, and for the record, I did miss everyone. Some of you have helped me out tremendously in the past. Hope all of you have had wonderful holidays and a good life while I was away.

Greason

• To get the nth root of something you do it to the power of 1/n:

4 ^ 1/2 = 2

8 ^ 1/3 = 2

16 ^ 1/4 = 2

• Duh! I should have thought of that!

Thanks bunches.

Greason

•

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•