How calculate the twelfth root of two?

2.5k Views Asked by At

Is there a function for twelfth root of two?

I'm not a mathematician and for me it is difficult to understand the article on wikipedia. Maybe you can help me.

What I know so far which is not much:

4 to the power of 3 = 64, but how find base 4 and exp 3 when only 64 is given? Is that even possible and if so which function to use?

Now how I calculated the 12th root of 2 and which needs insane computation and I'm sure there's a better solution:

in Python

class Test():
    def __init__(self):
        self.factor = 0.0000001         #precision
        self.twelfth_root_of_two = 1    #result 12th root of 2
        self.max_two = 0                #root of 2

    def test_(self):
        """ 1 < x < 2 """
        exit = True
        while exit:
            self.twelfth_root_of_two += self.factor
            if self.max_two < 2:
                self.max_two = self.twelfth_root_of_two ** 12                
                print("self.max_two ", self.max_two)
            else:
                exit = False
                print("aprox. twelfth_root_of_two =", self.twelfth_root_of_two, " aprox. max_two = ", self.max_two)

if __name__ == "__main__":
    t = Test()
    t.test_()

Output:

aprox. twelfth_root_of_two = 1.0594632000347186  aprox. max_two =  2.000000128565274   

I'm happy with the result but like I said before it need lot of computation time. Please when write an answer keep in mind that I'm a dummy in math.

4

There are 4 best solutions below

1
On BEST ANSWER

I'm going to give a much simpler answer because I think the question you have isn't "what algorithm can I use to find a 12-th root?" but rather, "what function gives me 12-th roots?"

A 12-th root is a generalization of a square or cube root. We write the 12-th root of 2 as $\sqrt[12]2$ and this is the number whose 12-th power is 2. The important fact that you're missing is that

$$\Large \sqrt[12]2 = 2^{\frac1{12}}.$$ In general: the $n$-th root of $x$ is exactly the same thing as the $\frac1n$-th power of $x$.

The reason for this boils down to how exponents work:

$$ x^a \times x^b = x^{a + b}.$$

For example $2^2 \times 2^5 = 2^7$.

And we can work this rule backwards as well:

$$ 2^{\frac12} \times 2^{\frac12} = 2^{\frac12 + \frac12} = 2^1 = 2. $$

So as you can see: $2^{\frac12}$ times itself is 2. But this is exactly the property that defines the square root of 2. So it must be that $2^{\frac12} = \sqrt2$.

Likewise: $$ \underbrace{2^{\frac1{12}} \times 2^{\frac1{12}} \times \dots \times 2^{\frac1{12}}}_{12} = 2^{\frac1{12} + \frac1{12} + \dots + \frac1{12}} = 2. $$

To implement this in a programing language, you either use the math.pow function or you use the expression 2^(1/12). For example, in Python:

from math import *

print(2**(1./12))
print(math.pow(2, 1./12))

### Output ###
> 1.0594630943592953
> 1.0594630943592953
1
On

A much faster algorithm would be to use bisection. Example code.

An even faster algorithm would be to use Newton's method. Example code.

An alternative approach would be to use exponentiation and logarithms, rewriting it as $\sqrt[12]2=\exp(\ln(2)/12)$, and then computing those instead. Methods to compute the logarithm are given here and the exponential function can be computed using $e^x=1+x+\frac12x^2+\dots=\sum_{n=0}^\infty\frac{x^n}{n!}$. Example code.

0
On

If you're writing code:

Mathematica

N[2^(1/12), 50]

1.0594630943592952645618252949463417007792043174942

This takes $0.000055$ seconds on a Mac laptop.

You can perform this online for free here.

0
On

For sure, using logarithms is the fastest way.

If you consider numerical methods, you could add to Newton (already mentioned), Halley or Householer methods which will be faster. To give you an idea with you specific problem, the respective iterates would be (strating with $x_0=1$ $$\left( \begin{array}{cccc} n & \text{Newton}& \text{Halley}& \text{Householder}\\ 0 & 1.0000000000000000000 & 1.0000000000000000000 & 1.0000000000000000000 \\ 1 & 1.0833333333333333333 & 1.0571428571428571429 & 1.0594563986409966025 \\ 2 & 1.0621535720389191386 & 1.0594629613204438376 & 1.0594630943592952646 \\ 3 & 1.0595002626538398464 & 1.0594630943592952645 & \\ 4 & 1.0594631015299053084 & 1.0594630943592952646 & \\ 5 & 1.0594630943592955315 & & \\ 6 & 1.0594630943592952646 & & \end{array} \right)$$ Higher order methods exist (even with no name -have a look here). Stll starting with $x_0=1$, I reported below the value of the $\color{red} {first}$ iterate of these mathods a function of their order of convergence $$\left( \begin{array}{cc} n & \text{first iterate } x_1^{(n)} \\ 2 & 1.0833333333333333333 \\ 3 & 1.0571428571428571429 \\ 4 & 1.0594563986409966025 \\ 5 & 1.0594823085602654137 \\ 6 & 1.0594627235147087099 \\ 7 & 1.0594628790506061380 \\ 8 & 1.0594631054838494395 \\ 9 & 1.0594630966380679034 \\ 10 & 1.0594630941466093270 \\ 11 & 1.0594630943383971350 \\ 12 & 1.0594630943626246685 \\ 13 & 1.0594630943594391537 \\ 14 & 1.0594630943592493746 \\ 15 & 1.0594630943592950602 \\ 16 & 1.0594630943592958362 \\ 17 & 1.0594630943592952476 \\ 18 & 1.0594630943592952581 \\ 19 & 1.0594630943592952650 \\ 20 & 1.0594630943592952646 \end{array} \right)$$