Site Logo
RanAwaySuccessfully's Website

Easily calculating Logarithms and Square Roots

Well, it's an easier method either way. There's quite a few methods to calculate square roots while only on pen and paper, but I don't hear many talk about the same using logarithms. In either case, both use very interesting methods that are probably going to be useless, unless you're in a situation in which you need to use only basic arithmetic.

The Logic - Square Roots

The logic for calculating Square Roots is simple. Let's say we want to calculate the Square Root of 25. First, we'll need a random number for y. I suggest the number 2, but to speed things up a bit you can just use the number that you think is close enough to the result you want. Then, we'll do the following proceedings:

  1. Divide 25 by y, the result will be x.
  2. Add y and x, then divide the result by 2, the result will be y.
  3. Repeat steps 1 and 2 until you think you have an approximate enough result in y.

For example, if we want to find the square root of 25:

Of course, this process will take a bit longer for numbers that aren't perfect squares, but the process will still work given enough steps. For example, we'll try calculating the square root of 50. In order to speed things up a bit, we'll try to get an approximate number right off the bat. We know that 7² is 49, so we'll start with y = 7:

Tip: you know you reached the result when x and y end up being the same number. If you try doing the next step in this case, you'll get "50 / 7.07 = 7.07..." which basically means 7.07² (7.07 * 7.07) is approximately 50.

You'd only need to use this about five times to get an decent result if you're only aiming for a number with two decimal places, and more times for more decimal places.

The Logic - Logarithms

For logarithms it's a bit more complicated and you'll probably need to do a small table in order to help. For every step you make, create a new row on the table. Say, you want to calculate the logarithm of a with base b, or "logb(a) = c" in more technical terms, you'd do the following steps:

  1. Set c to 0 and e to 1.
  2. While a is higher than b, do the following loop:
    • Grab a and divide it by b.
    • Add the value of e (which is 1) to c.
  3. While e is higher than the acceptable error margin, do the following loop:
    • Set b to the square root of itself.
    • Divide e by 2.
    • If a is higher than b, do the following:
      • Grab a and divide it by b.
      • Add the value of e to c.

Reminder that e is not Euler's number in this case, it's just a variable. Let's try calculating the logarithm of 64 in base 2:

step a b c e
1 64 2 0 1
2 32 2 1 1
16 2 2 1
8 2 3 1
4 2 4 1
2 2 5 1
end 1 2 6 1

Once a is 1, you've reached the end of the algorithm since b won't go below 1. In this situation we run into a special case: If the number is a power of the base number, then a will reach 1 before you can begin step 3. Here's another example, the logarithm of 90 in base 10:

step a b c e
1 90 10 0 1
2 9 10 1 1
3 2.84605 3.162277 1.5 0.5
1.600452 1.778279 1.75 0.25
1.20017 1.333521 1.875 0.125
1.039304 1.154782 1.9375 0.0625
1.039304 1.074608 1.9375 0.03125
1.002577 1.036633 1.953125 0.015625
... ... ... ...

This gives us 1.95 as our approximate result. You can choose the amount of decimal places for a and b without too many issues but do not round the values of c and e. That will produce inaccurate results. Although not in this example, there are also cases where a starts lower than b, and in that case step 2 is skipped.

The Code

Here's an example of this algorithm done in JavaScript (feel free to use it however you like):

function easySquareRoots(n) {
  var x = 0;
  var y = 2;
  for (var t = 0; t < 50; t++) {
    x = n / y;
    y = (y + x) / 2;
  return y;
function easyLogarithms(a, b) {
  var c = 0;
  var e = 1;

  while (a > b) {
    a /= b;
    c += e;
  while (e > 0) {
    b = easySquareRoots(b); // alternatively: b = Math.sqrt(b);
    e /= 2;
    if (a > b) {
      a /= b;
      c += e;
  return c;

And here's a live demo of it.

The Source

I could absolutely not have figured this out by myself, so, I don't take credit for finding this algorithm. The idea behind this comes from this page:

Source: Calculating Logarithms with Pencil and Paper - Acessed on June 11, 2017