# Mentally computing common functions

This page shows how to roughly calculate functions that are common on scientific calculators—exponentials and logs, trig functions, roots—and one function that I believe should be more common on scientific calculator: the gamma function [1].

In general the approximations on this page are good to a couple significant figures. More details are given with each approximation.

## Logarithms

This section shows how to mentally calculate logarithms base 10, e, and 2.

For reasons explained here, you can reduce the problem of calculating the log of any number base 10 to the case of 0.3 ≤ x ≤ 3.

More generally, logs base b can be reduced to the case 1/√bx ≤ √b.

### Base 10

For 0.3 ≤ x ≤ 3.

log10 x ≈ (x − 1)/(x + 1).

This approximation has a maximum error of about 0.03, and is very accurate for x near 1.

### Base e

For 1/√ex ≤ √e,

loge x ≈ 2 (x – 1)/(x + 1).

This approximation has a maximum error of about 0.03, and is very accurate for x near 1.

More details here.

### Base 2

For 1/√2 ≤ x ≤ √2.

log2 x≈ 3(x – 1)/(x + 1).

This approximation has a maximum error of about 0.015, and is very accurate for x near 1.

More details here.

### All together

Incidentally,

log2 x ≈ loge x + log10 x.

More details here.

## Exponentials

This section shows how to mentally calculate 10x and  ex.

We only need to consider x between −0.5 and 0.5 because we can reduce the general case to this case.

### Base 10

For x between -0.5 and 0.5,

10x ≈ (1 + x)/(1 − x).

The maximum relative error is about 0.08. A simple variation can reduce this to 0.03. More details here.

### Base e

For x between −0.5 and 0.5,

ex ≈ (2 + x)/(2 − x).

This approximation has a maximum relative error of about 0.01. More details here.

### Base 2

Often when computing powers of 2, the exponent is an integer and you need an exact integer result, not an approximation. Therefore it is worth memorizing the numbers 2n for n integer up to 10.

Still, if you need to compute 2x for real x, between -0.5 and 0.5, the approximation

2x ≈ (3 + x)/(3 − x)

is good to within 0.015.

## Roots

This section gives a couple methods for mentally calculating roots. Note that you could also calculate roots using logarithms and exponentials with the tricks above.

### Square roots

To calculate the square root of a number x, take a guess g at the root and compute the average of g and x/g. You can get as much accuracy as you like by repeating this process enough times.

More details here.

### Higher roots

There is a way to compute higher order roots that is connected with the methods above for computing logs and exponentials.

See this post for details.

## Trig functions

For small angles (in radians), trig functions are easiest to compute from a one-term Taylor series. All the following approximations are accurate to within 1%.

• sin xx for |x| < 0.244.
• cos x ≈ 1 – x²/2 for |x| < 0.662.
• tan xx for |x| < 0.173.
• arcsin xx for |x| < 0.242.
• arccos x ≈ π/2 – x for |x| < 0.4.
• arctan xx for |x| < 0.173.

You can use trig identities to reduce the problem of computing any trig function of any angle to that of computing trig functions for angles between 0 and π/4 radians = 45°.

For angles in degrees, with x between 0 and 45, the following approximations hold:

The sine approximation is good to within about 0.02 and the cosine approximation to within about 0.005. The tan approximation error can be as big as 0.1, but taking the ratio of the sine and cosine approximations is more accurate. See this post for references and details.

The following approximation for cosine is good to within 0.001 for x between 0 and 40.

cos d° ≈ 1 – d(d + 1)/7000

See this post for references and details.

## Gamma function

You can reduce the problem of calculating the gamma function for any real argument to the problem of computing the gamma function over an interval of length 1.

For 2 ≤ x ≤ 3,

Γ(x) ≈ 2/(4 – x).

This approximation has a maximum relative error of about 0.009. See this post for details.

[1] It’s common for a calculator to have a factorial button. If that factorial will accept a non-integer argument, then presumably it’s computing Γ(x+1).