Higher Index Roots

Posted By: Dooley

Higher Index Roots - 01/14/17 06:16

I am looking for a way to calculate the root of a number beyond the square root. For instance, how would I calculate the cube-root of a number? Or the fourth root? etc...

I found sqrt(), pow(), exp() and log() in the manual, but none of these seem to do what I'm looking for.
Posted By: txesmi

Re: Higher Index Roots - 01/14/17 06:38


Posted By: Superku

Re: Higher Index Roots - 01/16/17 16:39

The n-th root of a number x can be written as x^(1.0/n), so just put that in the second argument of your pow() function.
Posted By: Dooley

Re: Higher Index Roots - 01/20/17 06:42

Thanks guys.
I found this function on another thread and modified it a bit:

Quote:
function Root(var num, var expo)
{
return(exp(log(num)/expo));
}

root_number = Root(2,12);


So, if I plug any two numbers into the Root function it will give me the number that multiplies by itself "expo" times to make "num."

i.e. 1.05946309436 is the twelfth root of two. So if you multiply it by itself 12 times, you get 2. This equation can get this number if you plug in 2 as num and 12 as expo. You could do this with any two numbers.

Higher math is difficult for me, so this is a great forum to have! If anyone can use this equation for something, please go ahead.
© 2024 lite-C Forums