Contents:

Python Basics: A Free Course for All Skill Levels Get to know 4 exciting projects for your portfolio Opportunity to communicate live with an expert and share experiences
Learn moreBefore moving on to the discussion, let's refresh our knowledge and solve a few typical problems.
- What is log3 81?
- And lg 2 × lb 10?
- First, let's use the property of logarithms, which allows us to add logarithms with the same base. We can write:
log₂₁₆ 2 + log₂₁₆ 3 = log₂₁₆ (2 * 3) = log₂₁₆ 6.
Now we need to find the value of log₂₁₆ 6. Since 16 can be expressed as 2 to the power of 4, we can rewrite the logarithm as follows:
log₂₁₆ 6 = log₂ (6) / log₂ (16).
Now we calculate log₂ (16). Since 16 = 2^4, then log₂ (16) = 4.
Now let's substitute this value into the equation:
log₂₁₆ 6 = log₂ (6) / 4.
Thus, the sum of log₂₁₆ 2 + log₂₁₆ 3 is equal to log₂ (6) / 4.
If you managed to easily solve all three problems in your head, without using a calculator, you can safely move on to the final part. And for those who have forgotten their school lessons a little, we offer a short five-minute educational program.
What is a logarithm?
In essence, a logarithm can be considered as the inverse action of raising to a power. For example, let's take the equation 2^3 = 8. In this equation:
- Two is the base.
- Three is the value of the exponent.
- Eight is the result of raising a number to a power.
The process of raising a number to a power has two inverse actions. The first is related to determining the base, which is done by extracting the root, and the second is related to finding the exponent, which is done using logarithms.
Therefore, the equation 23 = 8 can be transformed into logarithmic form, obtaining log2 8 = 3.
Let's consolidate the acquired knowledge: a logarithm is a number to which the base 2 must be raised to obtain 8 as a result.
The notation may seem non-obvious, and at first it is easy to confuse the base and the power. To prevent such errors, it is worth using the following rule:
In a logarithm, the base is located at the bottom, similar to how it happens in cases of raising to a power.
To more effectively understand the format of the entry, pay attention to the following phrases and try to understand their meaning:
- log3 9 = 2
- log4 64 = 3
- log5 625 = 4
- log7 343 = 3
- log10 100 = 2
- log2 128 = 7
- log2 0.25 = −2
- log625 125 = 0.75
In general, the notation logAB is interpreted as the logarithm of a number B with base A.
Definition of the natural logarithm: what is it?
The main element of any logarithm is its base. It is due to the presence of a common base for different logarithmic functions that it is possible to perform a variety of operations with them.
Euler's number, denoted by the letter e, is the base of the natural logarithm. It is an irrational number that is approximately equal to 2.71828.
First, let's clarify what irrational numbers are. These numbers cannot be expressed as a simple fraction, where both the numerator and denominator are integers, and the denominator must be different from zero.
For example, 0.333… is a rational number, since it can be represented as a fraction 1/3. In contrast, numbers such as pi or the square root of 2 are considered irrational.
Because natural logarithms are widely used, a special notation was developed to represent them: ln x is equivalent to loge x.
Let's assume we have a crystal weighing 1 kg, which grows by 100% annually. At first glance, one might assume that after a year its mass will be 2 kg, but reality turns out to be different.
Each new part of the crystal will initiate its own growth process. When the crystal reaches 1.1 kg in mass, it will grow at a rate of 1.1 kg per year, and when it reaches 1.5 kg, it will grow at the same rate of 1.5 kg per year. According to mathematicians' calculations, after a year the crystal's weight will be e, which is approximately 2.71828 kg.

This type of growth is called exponential. It is according to this model that bacteria reproduce, populations increase, incomes rise, snowballs accumulate, radioactive substances decay, and drinks cool.
To determine the mass of a crystal after three, five, or ten years, it is necessary to raise the number e to the appropriate power of time.
e3 ≈ 20.0855 kg
e5 ≈ 148.4132 kg
e10 ≈ 22,026.4658 kg
How can we determine the moment when the mass of the crystal reaches one ton? To do this, we need to formulate an equation:
ex = 1000
We have the value of the base of the degree and the result of raising to the power - now we need to determine the exponent. This evokes certain associations, doesn't it? In essence, this is the logarithm: x = loge 1000! Or, in shortened form, it can be written as x = ln 1000.
If you run the calculations in a calculator, you can find that x is approximately equal to 6.9. This will be the time required for the crystal to reach a mass of one ton.
Variety of logarithmic systems: decimal and binary logarithms
The decimal logarithm is the logarithm whose base is 10. It is usually denoted as lg x. This type of logarithm is especially convenient because it allows you to easily perform calculations with round numbers.

The binary logarithm is a logarithm with a base of 2. It is denoted as lb x and is widely used among programmers, since computers process and store information in the binary number system.

Basic characteristics and equations of the logarithmic function
The list of operations available for working with logarithms is not that large. Once you've mastered all the basic rules and learned how to apply them, you'll be able to solve logarithmic problems as easily as cracking sunflower seeds.
Logarithms have certain limitations. The argument and base of the logarithm must be positive numbers, and the base must not be equal to one. In mathematical terminology, this is formulated as follows:

Let's look at the properties of logarithms. They function in both directions, which allows them to be used on both the left and right sides.
The logarithm of one, regardless of its base, is always zero.

For example, the logarithm to the base 17 of 1 is 0.
The logarithm in which the number and the base coincide is always equal to one.

For example, the logarithm of the number 17 to the base 17 is equal to 1.
The fundamental logarithmic identity states that the logarithm of a number to a base is equal to the power to which that base must be raised to obtain that number. This is expressed by the formula: if a is a base, b is a number, then log_a(b) = c, where c is the power that must be taken so that a^c = b.

For example, the logarithm to the base 17 of 175 is 5.
The logarithm of the product of two numbers is equivalent to the sum of the logarithms of these numbers.

For example: log5 12.5 + log5 10 can be converted to log5 (12.5 × 10), which is equal to log5 125, which in turn is equal to 3.
The logarithm of the ratio of two numbers can be expressed as the difference between the logarithms of the numerator and the denominator.

For example, you can write the following expression: log3 63 minus log3 7. This equals log3 (63 divided by 7), which simplifies to log3 9, which equals 2.
6. When the base or argument is in the power, they can be conveniently taken outside the logarithm:

From the two equations given, the following conclusions can be drawn:

For example: log23 49 can be expressed as 9/3 multiplied by log2 4, which is equal to 3 multiplied by 2, and as a result we get 6.
7. If the base of the logarithm causes difficulties, it can be replaced with a more convenient one.

For example, the expression log25 125 can be transformed as follows: log5 125 divided by log5 25. As a result, we get 3/2, which is equal to 1.5.
From this formula, we can conclude that the base and argument can be swapped as follows:

For example: log16 4 can be represented as 1/log4 16, which in turn is equal to 1/2, which ultimately gives 0.5.
Methods for independently solving logarithmic equations
Now we again turn to the problems that were presented at the beginning of the article.
Example 1
Remember that 81 is equal to 92. And 9 is equal to 32. Therefore:
log3 81 = log3 92 = log3 (32 + 2) = log3 34
Now logarithms are no longer a problem. Let's apply the property of powers and isolate the four.
log₃ 34 = 4 × log₃ 3 = 4 × 1 = 4
Answer: 4.
Example 2
Let's transform the abbreviated notations into their full expression:
The equation lg 2 × lb 10 = log10 2 × log2 10 can be rewritten using the properties of logarithms.
First, let's remember that lg and log10 refer to the same logarithm, the one with base 10, and that lb refers to the logarithm with base 2.
So, we can express the equation in more familiar terms:
log10(2) × log2(10) = log10(2) × log2(10).
Thus, both sides of the equation are equal, and this equality is true because of the properties of logarithms and their relationship.
Let's convert both logarithms to the same base.
log10 2 times log2 10 is 1, since it can be thought of as 1 divided by log2 10 multiplied by log2 10. This is also equal to log2 10 divided by log2 10, which ultimately gives 1.
Answer: 1.
Example 3
Let's apply the property of addition.
log₂₁₆ 2 + log₂₁₆ 3 can be combined using the properties of logarithms. This expression is equivalent to log₂₁₆ (2 × 3), which is log₂₁₆ 6.
Let's represent 216 as a power of 6 and use the properties of powers to simplify it.
log₂₁₆ 6 is log₆₃ 6, which is 1/3 times log₆ 6, which is 1/3 times 1, which is 1/3.
Answer: 1/3.
Methods for Calculating Logarithms in Python
In order to perform operations with logarithmic expressions in Python, you first need to include the math module.
Now we can calculate log2 8 using the math.log(b, a) function:
Note two key aspects. First, we pass the argument to the function, and then specify the base. Second, regardless of whether the result is an integer, the function always returns a float.
When the base is not specified when calling the function, the logarithm is assumed to be the natural logarithm by default.
There are unique approaches for calculating both common and binary logarithms.
Python has a special method that increments the passed argument by one and then calculates the natural logarithm of the resulting value.
In situations where the value of x tends to zero, this approach provides higher accuracy compared to the math.log(1+x) function. Compare:
These are the key tools for manipulating logarithms in Python.
Read also:
- Math Basics for Beginners: What to Refresh Your Memory Before a Data Science Interview.
- Test: How Deeply Do You Know the Structure of the Internet?
- An ML developer is a specialist who creates and implements machine learning algorithms. Their work involves analyzing data, developing models, and testing and optimizing them to solve various problems.
The main responsibilities of an ML developer include preprocessing data, selecting appropriate models and algorithms, training them, and evaluating their performance. These specialists often collaborate with other teams, such as data analysts and engineers, to integrate solutions into existing systems.
As for earnings, the income level of ML developers varies depending on the region, experience, and company. On average, specialists in this field can expect a high salary, which often exceeds the average for the IT sector, due to the high demand for their skills and knowledge.

