## Squaring numbers with 5 at ends

In this post, I'll discuss some simple tricks I use to square numbers that begin or end with the digit 5. Let me illustrate each trick with two examples for 2-digit numbers. Later, in this post, I'll generalize the trick for n-digit numbers where n ≥ 2 after explaining why the tricks work using algebra.

Squaring a 2-digit number that ends with 5

I learnt this from a book when I was in 5th standard. For a 2-digit number that ends with 5, let us assume that the first digit is A. So, the number can be written as A5. The square is: A × (A + 1) followed by 25, i.e. the first few digits of the square is given by A × (A + 1) and the last two digits are 25. Let us try some examples.

252 = 625. (2 × 3 = 6.) 852 = 7225. (8 × 9 = 72.)

Squaring a 2-digit number that begins with 5

After learning that trick from the book, I wondered if I could make more tricks for myself. This is the first one I could come up with. If the first digit of a 2-digit number is 5 and the second digit is A, i.e. if the number is of the form 5A, the square is given by the sum of 25 and A followed by square of A. In other words, the first two digits of the square are obtained from 25 + A and the last two digits are obtained from A2. Let us try some examples.

522 = 2704. (25 + 2 = 27 and 22 = 4.) 572 = 3249. (25 + 7 = 32 and 72 = 49.)

Squaring an n-digit number that ends with 5

Let us represent all digits except the last one as A. So, the number is of the form A5 where A represents one or more digits. e.g. if the number is 115, A = 11.

So, we can say that the number of the form A5 can be algebraically expressed as 10A + 5. Now, (10A + 5)2 = 100A2 + 100A + 25 = 100A(A + 1) + 25. This amounts to writing A(A + 1) followed by 25.

Let us try some examples:

1152 = 13225. (11 × 12 = 132.) 99952 = 99900025. (999 × 1000 = 999000.)

Squaring an n-digit number that begins with 5.

Let us represent all digits except the first one as A. So the number is of the form 5A where A represents one or more digits. e.g. if the number is 512, A = 12.

So, we can say that the number of the form 5A can be algebraically expressed as 5 × 10n + A where n is the number of digits in A, i.e. the number of digits after the first digit which is 5. Now, (5 × 10n + A)2 = 25 × 102n + 10n + 1A + A2. This amounts to writing 25 as the first two digits followed by A2 as the last 2n digits and then adding A to it by placing it just below the second digit which is 5. Some examples follow.

5022

= 250004   (22 = 4.)
+02      (02 placed under 5.)
---------
252004
---------

5122
= 250144   (122 = 144.)
+12      (12 placed under 5.)
---------
262144
---------

Using both tricks together

51952

= 25038025 (1952 =
38025; 19 × 20 = 380.)
+195     (195 placed under 5.)
-----------
26988025
-----------

Note that in the problem above, we use the second trick to square 5195 because it begins with the digit 5. However, while doing so, we need to figure the square of 195 and we use the first trick to do this.

## π PM

For so long, I have been wishing "Happy Pi PM" to my friends and colleagues at 3:14 PM. However, this doesn't seem to be appropriate since 3:14 PM is not really 3.14 PM. In fact, 3:14 PM is 31460 PM which when expressed in decimal representation turns out to be 3.23333 PM, accurate up to 5 decimal places.

The value of π accurate up to 5 decimal places is 3.14159. Now, .14159 hour = 509.724 seconds ≈ 8 minutes and 30 seconds, or 8½ minutes.

So, π PM turns out be 3:08:30 PM or 8½ minutes past 3 PM.

## Clumsy equations

Yesterday, at work while calculating the most optimal parameters for a data structure, I arrived at this equation.

xe−x + (1 − e−x) ln (1 − e−x) = 0

This is a little clumsy to deal with. So, I cleaned it up by representing e−x as t. With e−x = t, we get

−t ln t + (1 − t) ln (1 − t) = 0
⇒ t ln t = (1 − t) ln (1 − t)

Obviously, t = 1 − t is one solution. Thus, t = ½. Are there more solutions? The answer turns out to be 'no'.

y = −t ln t + (1 − t) ln (1 − t)

x is real in this problem and so is t. ln t is undefined for t ≤ 0. Similarly, ln (1 − t) is undefined for t ≥ 0. So, we need to consider the open interval (0, 1) to see if there are any other solutions for t. Let us rewrite the equation in a neater form and see if we can somehow eliminate the possibility of other solutions in the open interval (0, 1).

t ln t = (1 − t) ln (1 − t)
⇒ ln tt = ln (1 − t)(1 − t)
⇒ tt = (1 − t)(1 − t)

For 0 < t < ½, t < (1 − t) ⇒ tt < (1 − t)t.
For ½ < t < 1, t > (1 − t) ⇒ tt > (1 − t)t.

So, we see that in the open interval (0, 1), except for ½ there is no other value for t such that tt = (1 − t)t. Hence, the solution to the equation is

t = ½
⇒ e−x = ½
⇒ −x = ln ½
⇒ x = ln 2

y = xe−x + (1 − e−x) ln (1 − e−x)

Two years ago, I once had to solve the following equation.

ln x − x0.03 = 0

There is no simple way to solve this equation. I had to resort to using the Lambert W function to solve this. To use this function, we need to bring our equation to w(x) ew(x) = k form where w(x) is a function of x. The solution of w(x) ew(x) = k is w(x) = W(k). Let us try it.

ln x − x0.03 = 0
⇒ ln x = e0.03 ln x
⇒ ln x ⋅ e−0.03 ln x = 1
⇒ −0.03 ln x ⋅ e−0.03 ln x = −0.03

So, if we have brought the equation in the w(x) ew(x) = k form with w(x) = −0.03 ln x and k = −0.03. Therefore, the solution is

−0.03 ln x = W(−0.03)
⇒ x = eW(−0.03) ⁄ 0.03

y = ln x − x0.03
The MacLaurin series for the Lambert W function is

W(k) = k − k2 + 32 ⋅ k383 ⋅ k4 + 1254 ⋅ k5 + …

Using this function, we get

x = e−0.03094 ⁄ 0.03 = 2.805 approximately

## Lost solutions

Let me start this post with a simple equation.

x(x − 2) = 3x

Let us solve it in a particular manner.

Dividing both sides by x we get

x − 2 = 3

Adding 2 to both sides we get

x = 5

Indeed, x = 5 is a solution to this equation. When we substitute x with 5 in the equation we get 15 on both sides. However, when we solved the equation in this manner, we lost one solution, x = 0. If we substitute x with 0, the equation still holds good as we get 0 on both sides.

Why did we lose this solution?

We lost this solution in the step where we divided both sides by x. In doing so, we made the wrong assumption that x ≠ 0. If the possibility of x = 0 is allowed, then we can not divide both sides by x since division by 0 is undefined in arithmetic.

We usually get around this problem by bringing all terms involving x to one side rather than dividing both sides by x.

x(x − 2) = 3x ⇔ x(x − 2) − 3x = 0 ⇔ x(x − 2 − 3) = 0 ⇔ x = 0 or x = 5

Often fallacies or spurious proofs of contradictions is formed by sneaking such a division by 0 into the proof. Here is one I could think of.

Let a = b. So,

a + b = 2a ⇔ a − b = 2a − 2b ⇔ (a − b) = 2(a − b)

Dividing both sides by a − b we get

1 = 2

We have learnt these things in our high school. However, I forgot this important lesson while solving differential equations and lost a solution. The differential equation I was trying to solve was

y' = x2y2

If we divide both sides by y2, the variables separate and solving it becomes a routine job.

y−2y' = x2 ⇔ −y−1y' = x33 + c' … (c' is constant of integration) ⇔ y = −3(x3 + c) … (c = 3c')

This is indeed a valid solution of the differential equation. However, we lost one solution while dividing both sides by y2. This solution is y = 0. It can be verified that with y = 0, we get 0 on both sides of the equation.

We lost this solution in the step where we divided both sides by y2. I couldn't find a way to get around this problem. So, whenever we need to divide both sides of the equation by y to separate the variables, we also need to perform an additional step of verifying whether y = 0 is a solution of the equation.

In general, when we need to divide both sides of the equation by f(y) to separate the variables, we need to perform an additional step of verifying whether f(y) = 0 is a solution of the equation.

## From a cup of cappuccino to paradoxes

After a long meeting, I went to the cafeteria with a friend to have a cup of cappuccino, my favourite drink at office. In the dialogue below, P is my friend and colleague, and S is me.

S: Hey, they have a 'Silence Please' board here. We can't talk.
P: Rules are made to be broken.
S: So, your rule is to break rules?
P: Yes.
S: This implies that you should break your rule of breaking rules and thus not break rules and be silent.
P: Umm… My rule is to break rules made by others.
S: Ah! You avoided a self-reference there. It makes sense now.

I could have still trapped her by making a rule that P breaks rules made by others but this didn't occur to me in the cafeteria.

Such self references often set up paradoxes in logic. One of the simplest ones is the liar paradox.

This statement is false.

Now, is this statement true? Is it false? Is it both true and false, or is it neither? This is discussed pretty nicely in the Wikipedia page for this paradox.

How do we avoid such paradoxes? Yes, one way is to avoid self-references by restricting a statement from talking about itself. But does it really solve the problem? Let us have a look at this.

The next statement is true. The previous statement is false.

Is the first statement true or false? Yes, we have set up a paradox again despite avoiding self-reference here. The correct way to prevent these paradoxes from happening is to categorize the statements into various levels and allow a statement to talk about statements belonging to a lower level only.

So, if we categorize the first statement "The next statement is true" as a level 1 statement, then the next statement automatically becomes a level 2 statement as it is talking about level 1 statement. But wait! This implies that the level 1 statement is talking about level 2 statement which is illegal as per our new restriction of not allowing a statement to talk about another statement at the same or higher level. So, we see that we can avoid such paradoxes with this additional restriction.

A friend of mine, shown as W below, often claims something strange.

W: I only ask questions in a debate. I don't take sides.
S: Ok. Let us debate this. Side 1: You take sides. Side 2: You don't take sides. Which side do you take?

Comic by Randall Munroe: http://xkcd.com/468/

Let me list down some of my favourite logical paradoxes.

Do go through Al Franken's advice.