While this might be obvious to some of you I only recently realized that the method used to calculate the square root in probably most HP-calculators is in fact closely related to Horner's method.

Let's assume we want to calculate the square root of 41 thus solving the equation:

x^{2}- 41 = 0.

First we apply a trick which can be found in Cochran's patent and multiply the whole equation by 5:

5x^{2}+ 0x - 205 = 0

Now let's consider the following simple coordinate transformations:

- shift: x' = x - 1

- zoom: x' = 10 * x

What happens to a quadratic equation if we apply these transformations?

## Shift

P(x) = ax^{2}+ bx + c

= Q_{1}(x)(x-1) + c'

= (Q_{2}(x)(x-1) + b')(x-1) + c'

= (a'(x-1) + b')(x-1) + c'

= (a'x' + b')x' + c'

Thus by continued polynominal division we can get the coefficients of the transformed polynominal.

We can use Horner's method to calculate the remainders.

## Zoom

ax^{2}+ bx + c = 0 | * 100

100ax^{2}+ 100bx + 100c = 0

ax'^{2}+ 10bx' + 100c = 0

a'x'^{2}+ b'x' + c' = 0

By comparing the coefficents we get:

a' = a

b' = 10b

c' = 100c

## Example

Here I assume you're familiar with the Horner scheme:

5 0 -2051 5 5 -200

5 10

5

--------------------------------------

5 10 -200 step1 5 15 -185

5 20

5

--------------------------------------

5 20 -185 step1 5 25 -160

5 30

5

--------------------------------------

5 30 -160 step1 5 35 -125

5 40

5

--------------------------------------

5 40 -125 step1 5 45 -80

5 50

5

--------------------------------------

5 50 -80 step1 5 55 -25

5 60

5

--------------------------------------

5 60 -25 step1 5 65 40 here we turn the wheel back

5 600 -2500 and zoom

From now on I've chosen a shorter format:

5 610 -1895 stepNow Cochran's trick becomes evident: In the second column appears the result 6.40312.

5 620 -1280 step

5 630 -655 step

5 640 -20 step

5 650 625 back

5 6400 -2000 zoom

5 6410 4405 back

5 64000 -200000 zoom

5 64010 -135995 step

5 64020 -71980 step

5 64030 -7955 step

5 64040 56080 back

5 640300 -795500 zoom

5 640310 -155195 step

5 640320 485120 back

5 6403100 -15519500 zoom

5 6403110 -9116395 step

5 6403120 -2713280 step

5 6403130 3689845 back

5 64031200 -271328000 zoom

We could have also used a separate counter but it's not necessary.

## What are we actually doing?

We move our coordinate system step by step to the right until we step over the root. Then we go one step back and zoom. Thus our unit becomes one tenth of what it was before. Then we continue ...

In pseudocode:

for (1 .. 12):

while c <= 0:

step

back

zoom

The same algorithm could be used to solve the cubic root or x^{2} = x + 1. Unfortunately Cochran's trick won't work in these cases.

Personally I consider this algorithm a beautiful pearl. It's quiet amazing that the same algorithm was used in all these calculators over the years with only minor changes.

## Links