freeCodeCamp/guide/english/mathematics/intro-to-logarithms/index.md

2.3 KiB

title
Intro to Logarithms

Intro to Logarithms

Logarithms are mathematical functions used to find what power a base is raised to in order to receive a specific output.

log diagram

Here in the example variable b is the base whereas variable a is the desired output and variable c is the exponent.

Logs are used in various things in the real world. They are used in the pH scale, the measuring of the intensity of earthquakes (the Richter Scale) and many other things.

Example of logs in python:

import math

# math.log(value, base) - outputs exponent
math.log(100, 10) #outputs 2
math.log(2, 2) #outputs 1

Definition of logarithm

The logarithm of a number x, written log(x), usually means the number you have to use as power over 10 to get x. Let's say you wanna find log(10). This means you wanna find the number you have to raise 10 to to get 10. This gives us an equation: log(10) = x.

We can use this and apply it as a power of 10 on both sides. This changes the equation to: 10log(10) = 10x

The 10log(x), where x is any number, will return x, as 10log cancels out. This means our equation is now 10 = 10x

Given that 10x is equal to 10 times itself x times, it means that 10 needs to be multiplied with itself enough times to be exactly 10, and x is therefore 1. This is because 101 = 10

Definition of the natural logarithm

This is strictly the same as the definition of logarithm, except what numbers are used. In the normal logarithm, the base number is usually 10, wheras in the natural logarithm, often written ln, uses e, euler's number as base. This means that ln(e) = 1, instead of log(10) = 1. So, we are instead finding the power you need to raise e to in ln(x).

More Information