0

It is given in the paper titled: A Simple Calculator Algorithm by: Lyle Cook, James McWilliam; the way to iteratively find using the cube root using the square root operation is to perform the set of two operations alternatively: (i) Take the square root twice; (ii) multiply by the original number, ...

I want to know first why this approach is deemed useful, i.e. on what basis. It is also stated on the last page(#54) that a better way is to take the square root thrice, instead of twice. So, what is the reason for taking $y^\frac{1}{2\sqrt 2}$. (sorry, if not represented root properly, request correct way then)

Second, I tried to find the value obtained by program, by giving inputs : $57, 24, 8$. Request suggestions for improvements.

enter image description here

jiten
  • 4,524
  • 2
    "It is also stated on the last page(#54) that a better way is to take the square root thrice, instead of twice." No, it is stated that taking the square root thrice gives you the 7th root. –  Apr 03 '18 at 15:59

3 Answers3

1

As explained in the paper, it is based on the infinite sum of geometric progression: $\sum_1^\infty(1/4)^n=1/3$. The number that you get after taking square root twice at each iteration is an approximation of the cubic root. I am not sure why they are suggesting to take the square root thrice, I do not think it's going to be an improvement.

Vasili
  • 10,690
1

First addressing why it is useful, well, first it's a good party trick with a basic calculator without a $x^y$ button.

Alice: "If a calculator only has $\sqrt{}$, some numbers, and multiplication, what can you compute or approximate?"

Bob: "Obviously, the square root and multiplication"

Alice: "What if I can estimate the cube root of any number that you give to me? "

Bob:" Is it some sort of binary search, that is trivial isn't it?"

and then Alice gets to perform this trick. What is even cooler is

In theory, it is possible to approximate any real root using a calculator with a square root key.

Alright, now, going on to the maths:

Starting from $x_1=r$,

Define:

$$x_{k+1} =(x_k+1)r$$

We can easily prove by induction that this is just a geometric series with the first term being $r$ and common ratio $r$,$$x_{k+1}= \sum_{i=1}^{k+1}r^i=\frac{r(1-r^{k+1})}{1-r}$$

Hence as $k \to \infty$, if $|r|<1, r \ne 0$, $$x_{k+1} \to \frac{r}{1-r}=\frac{1}{\frac1r-1}$$

If we pick $r= \frac14$, then the sequence converges to $\frac1{4-1}=\frac13$.

If we pick $r = \frac1{2^n}$, then the sequence converges to $\frac1{2^n-1}$

and we have $y^{x_k} \to y^{(\frac1r-1)^{-1}}.$ If we pick $r = \frac14$, then $y^{x_k} \to y^\frac13$.

Taking square root twice means $\frac14$ at the power indices and multiply by itself once means plus $1$ in the power index.

Comments about your program:

  • There isn't a need to store every single values in a matrix if the purpose is just to print it.
  • In the presence of a well established approximated solution, rather than asking for maximum number of iterations, perhaps just ask for the error tolerance and use a while loop to terminate when the error tolerance is satisfied.

Comments on comparison between bisection and this method:

For binary search that begins with interval length $1$: to shrink it up to $10^{-8}$. We need $8\log_2 10 \approx 26.5$ steps.

For this method.

Note that $x_k$ increases.

We want $$57^\frac13-57^{x_k}< \epsilon$$ $$\log_{57}(57^\frac13 - \epsilon) <{x_k}$$

$$ \frac{r}{1-r}(1-r^k)> \log_{57}(57^\frac13 - \epsilon)$$

$$r^k < 1- 3\log_{57}(57^\frac13 - \epsilon)$$ $$4^k > \frac{1}{ 1- 3\log_{57}(57^\frac13 - \epsilon)}$$

$$k > - \log_4 ( 1- 3\log_{57}(57^\frac13 - \epsilon))$$

From the computation $k$ needs to be at least $15$ which is reflected in your computation.

This method is faster when

$$-\log_4 ( 1- 3 \log_y ( y^{\frac13}-\epsilon) < - \log_2 \epsilon$$

$$ 1- 3 \log_y ( y^{\frac13}-\epsilon) > \epsilon^2$$

$$ \frac{1- \epsilon^2}3 > \log_y ( y^{\frac13}-\epsilon) $$

$$ y^{\frac13} - y^{\frac{1-\epsilon^2}3}< \epsilon$$

Siong Thye Goh
  • 149,520
  • 20
  • 88
  • 149
  • Thanks a lot. I request a way in which the comparison with the actual cube root is not there, as it makes the purpose small/limited. However, I feel that if some alternate way is there to stop further iterations, then it can be only one- finding if few iterations (with the number pre-defined or may be chosen dynamically?) lead to any change. It enters then in realm of numerical approximation. May be goes in field of AI, where local/global search is done. Also, when you state that "In the presence of a well established approximated solution', hope you are referring to method used in the paper. – jiten Apr 04 '18 at 03:53
  • 1
    A possible termination condition is you cube the solution that you find and compare with $y$. $\frac{1}{1/(1/8)-1}=\frac{1}{8-1}=\frac17$. – Siong Thye Goh Apr 04 '18 at 04:33
  • But, how is $\frac{1}{7}$ helping to find $\frac{1}{3}$ is not clear. May be some power of $3$ and $7$, i.e $\exists m,n \in \mathbb{Z+},, 3^m \approx 7^n$, or $3^m=7^n$. – jiten Apr 04 '18 at 04:38
  • 1
    If you take square root two times and multiply by $y$, repeat the procedure, you are trying to estimate $y^\frac13$. If you take square root $3$ times, and multiply by $y$, repeat the procedure, you are trying to estimate $y^\frac17$. The two procedure are estimating different things. – Siong Thye Goh Apr 04 '18 at 04:40
  • So, the paper is hinting by the third power of square root something achieving the result, but without any logical basis. – jiten Apr 04 '18 at 04:44
  • 1
    "huh, without logical basis?", the paper is using geometric series as shown in the lower left of the picture. – Siong Thye Goh Apr 04 '18 at 04:48
  • Thanks a lot, will read more carefully in future. I am sorry, but may be due to seeing such paper after a very long time am getting errors in comprehension. Actually, the second method is for $7$th root. It is error due to reading carelessly. – jiten Apr 04 '18 at 04:53
  • Please explain in my post at: https://math.stackexchange.com/q/2723608/424260, in particular my doubts raised to @TheCount, and also to the selected answer by 'Acccumulation'. May be, for the latter, I have later already addressed the issues raised for the 'contradiction' approach in the edited OP, but still ambiguous about it. – jiten Apr 06 '18 at 00:33
  • Your answer referred to the binary search approach for finding cube roots(or any root). This is implemented (actually copied, from book on 'Programming with python' by Padmanabhan) at: http://py3.codeskulptor.org/#user301_C9hSKk4iB5_5.py. Will improve it soon. – jiten Apr 06 '18 at 02:03
  • Regarding suggestion to have bound by error, have modified program at: http://py3.codeskulptor.org/#user301_PwVWVVllTI_7.py with inputs: 57, 8. Want to ask: (i) reason behind binary search based approximation approach (let (b)), at: http://py3.codeskulptor.org/#user301_C9hSKk4iB5_6.py, taking more number of iterations than the above geometric series based approach (let, (a)). (ii) Also, why approximation obtained in (a) is better in far lesser iterations. Actual cube root is 3.8485011312768050, while (b) gives in $27$ iterations: 3.84850113839; (a) gives in $15$ iterations: 3.8485011264464424. – jiten Apr 07 '18 at 07:32
  • 1
    Included some comments in the comparison of two methods. – Siong Thye Goh Apr 07 '18 at 07:59
  • Am unable to compute the value (approximately) $15$ as you got in the first half of your analysis. So please elaborate your answer to get the value of $15$. The expression under consideration reduces to just: $k \gt -\log_4 3 \log_{57}(10^{-8}) => k\gt -\log_4 -24 \log_{57} 10 => k\gt (1+\log_46)\log_{57}10$ $= (2.292481)*1.75587 = 4.0252 \implies k \ge 5$. Don't know if going in the right direction. Also, request some resource for geometric series based approach & could get 'only' this at: https://math.stackexchange.com/a/1315686/424260, but am highly doubtful about its applicability even. – jiten Apr 07 '18 at 10:38
  • It is too tough for my level. Request chat. Please open chat room, am waiting in round-robin mode. – jiten Apr 07 '18 at 17:23
  • 1
    hmm... how does one create chat .... – Siong Thye Goh Apr 07 '18 at 17:32
  • Thanks a lot. It is at the bottom of one's profile page, with link 'Chat', from where the link takes to all the open chat rooms, with a link on the bottom right for creating new chat room. I have opened one at : https://chat.stackexchange.com/rooms/75671/geometric-approach-for-approximating-cube-roots – jiten Apr 07 '18 at 17:38
  • Request to look at a seemingly simple question: It is easy to solve $x^3-1=0$ by having the form $(x-1)(x^2+x+1)=0$
    The $3$ roots are: $x=1$, $x=\frac{-1\pm i\sqrt 3}{2}$.

    But, solving the equation $x^3+1=0\implies x^3 -1=-2 \implies (x-1)(x^2+x+1)=-2$ leads to $x-1=-2\implies x=-1$.
    The solution $x^2+x+1=-2$ will lead to $x^2+x+3=0$ with roots $x =\frac{-1\pm i \sqrt{11}}{2}$.

    But, the answer is $x =-1, \frac{1\pm i \sqrt{3}}{2}$.

    – jiten Apr 09 '18 at 01:23
  • 1
    $(x-1)(x^2+x+1) = -2 $ does not imply $x-1=-2$. – Siong Thye Goh Apr 09 '18 at 02:31
  • 1
    $ab = -2$ does not imply $a=-2$ or $b=-2$. btw, try not to ask a new question in a comment. – Siong Thye Goh Apr 09 '18 at 02:43
0

An algorithm producing the cubic root of $x$ positive starts from $x_0=y_0=x$ and iterates the steps:

  • Compute $x_{k+1}=\sqrt{\sqrt{y_k}}$
  • Compute $y_{k+1}=x_{k+1}x$

Then, indeed, $$\lim x_k=x^{1/3}$$ because $$\frac14\left(1+\frac14+\frac1{4^2}+\frac1{4^3}+\cdots\right)=\frac13$$

Likewise, the algorithm starting from $u_0=v_0=x$ and iterating the step:

  • Compute $u_{k+1}=\sqrt{\sqrt{\sqrt{v_k}}}$
  • Compute $v_{k+1}=u_{k+1}x$

yields $$\lim u_k=x^{1/7}$$ because $$\frac18\left(1+\frac18+\frac1{8^2}+\frac1{8^3}+\cdots\right)=\frac17$$

Did
  • 279,727
  • You have specified the sequence of steps in reverse, as from the second iteration onward they have specified the first step as $y_{k+1}=x_{k+1}x$. Also, the first iteration only involves taking of square root twice for the first case. – jiten Apr 03 '18 at 21:48
  • This algorithm produces the desired result. Others do as well. So there is nothing "in reverse" here. – Did Apr 04 '18 at 07:09