How to Calculate Antilog of Values in Python

Renesh Bedre    2 minute read

The antilogarithm (antilog) refers to the inverse operation of a logarithmic (log) number. The antilog is used for finding the original number from the log number.

For example, the antilog of the log with a base 10 (log10) value can be found by raising the base value (10) to the power of the log value. If log10(x) = z then the antilog of z is 10z.

The following examples illustrates for how to find antilog of various log bases,

Base Log Antilog
10 log10(5) = 0.6989 100.6989 = 5
2 log2(5) = 2.3219 22.3219 = 5
e log(5) = 1.6094 2.71821.6094 = 5

In Python, you can use the 10**x, 2**x, or np.exp(x) functions to calculate the antilogs, depending on the base you want to use.

Example 1: Calculate the antilog of the log10 value

Suppose you have a value of log10 as follows:

# import package
import numpy as np

# calculate log10 value
log_val = np.log10(5)

# see log value
log_val
0.6989700043360189

Now, calculate the antilog of log10 value (0.6989) to get the original value of 5.

# raise base value 10 to the power of the log10 value
10**log_val
# output
5.0

By taking the antilog of log10 value, we obtained the original value of 5.

Example 1: Calculate the antilog of the log2 value

Suppose you have a value of log2 as follows:

# import package
import numpy as np

# calculate log10 value
log_val = np.log2(5)

# see log value
log_val
2.321928094887362

Now, calculate the antilog of log2 value (2.3219) to get the original value of 5.

# raise base value 2 to the power of the log2 value
2**log_val
# output
5.0

By taking the antilog of log2 value, we obtained the original value of 5.

Example 3: Calculate the antilog of natural log

Suppose you have a value of natural log as follows:

# import package
import numpy as np

# calculate log10 value
log_val = np.log(5)

# see log value
log_val
1.6094379124341003

Now, calculate the antilog of natural log value (2.3219) to get the original value of 5.

You can use np.exp() function to calculate the antilog of natural log value.

# import package
import numpy as np

# calculate antilog
np.exp(log_val)

# output
5.0

By taking the antilog of natural log value, we obtained the original value of 5.

Related: How to Calculate Antilog of Values in R

Enhance your skills with courses on Statistics and Python




This work is licensed under a Creative Commons Attribution 4.0 International License

Some of the links on this page may be affiliate links, which means we may get an affiliate commission on a valid purchase. The retailer will pay the commission at no additional cost to you.