Function log()
📝 Description
The log function returns the logarithm of a given number with a specified base. It answers the question: "To what power must the base be raised to produce this number?"
Note: Both arguments must be positive numbers. The base must not be
1.
💻 Syntax
💡 Examples
1. Base 2 (Binary Logarithm):
2. Base 10 (Common Logarithm):
3. Scaling Calculation (Real-world scenario):
Imagine you want to calculate how many "layers" of infrastructure you need based on the number of nodes, where each layer can handle 4 times more nodes than the previous one:
⚠️ Common Errors
| Input | Result | Why? |
|---|---|---|
log(-10, 2) |
Error | The number must be positive. |
log(10, 1) |
Error | The base cannot be 1. |
log(10, -2) |
Error | The base must be positive. |
🔗 Related Functions
-
[[pow]] — The inverse of
log: raises a number to a power. -
[[ceil]] — Use this with
logto get a whole number of "layers" (e.g.,ceil(log(50, 4))).