Base 10 (Common Log)
Base e (Natural Log – ln)
Base 2
Other Base
Result:
—
Understanding Logarithms
A logarithm answers the question: "To what power must we raise a base to get a certain number?"
Mathematically, if by = x, then logb(x) = y.
Here, 'b' is the base, 'x' is the number, and 'y' is the logarithm (or exponent).
Common Logarithms (Base 10)
The common logarithm, often written as log(x) or log10(x), uses a base of 10.
For example, log(100) = 2 because 102 = 100.
This calculator allows you to compute this directly.
Natural Logarithms (Base e)
The natural logarithm, written as ln(x) or loge(x), uses the mathematical constant 'e' (approximately 2.71828) as its base.
It's fundamental in calculus and many areas of science and engineering. For example, ln(e3) = 3.
This calculator computes the natural logarithm when 'Base e' is selected.
Other Bases
Logarithms can be calculated for any positive base (other than 1). For instance, log2(8) = 3 because 23 = 8.
Our calculator supports custom bases, allowing you to explore various logarithmic relationships.
Change of Base Formula
If your calculator or software doesn't directly support a specific base, you can use the change of base formula:
logb(x) = logk(x) / logk(b)
where 'k' can be any convenient base, such as 10 or 'e'.
For example, to find log3(27):
Using base 10: log(27) / log(3) ≈ 1.43136 / 0.47712 ≈ 3.
Using base e: ln(27) / ln(3) ≈ 3.29584 / 1.09861 ≈ 3.
Our calculator implements this logic internally when a custom base is chosen.
Finance: Calculating compound growth and analyzing financial models.
Engineering: Signal processing, control systems, and statistical analysis.
General Mathematics: Solving exponential equations, simplifying complex calculations.
var baseSelect = document.getElementById('baseSelect');
var otherBaseInputGroup = document.getElementById('otherBaseInputGroup');
var numberInput = document.getElementById('numberInput');
var otherBaseInput = document.getElementById('otherBaseInput');
var calculationResult = document.getElementById('calculationResult');
baseSelect.onchange = function() {
if (this.value === 'other') {
otherBaseInputGroup.style.display = 'flex';
} else {
otherBaseInputGroup.style.display = 'none';
otherBaseInput.value = "; // Clear custom base if not selected
}
};
function calculateLogarithm() {
var number = parseFloat(numberInput.value);
var baseType = baseSelect.value;
var customBase = parseFloat(otherBaseInput.value);
var result;
// Input validation
if (isNaN(number) || number <= 0) {
calculationResult.textContent = "Error: Number must be positive.";
calculationResult.style.color = "#dc3545"; // Red for error
return;
}
var effectiveBase;
if (baseType === 'other') {
if (isNaN(customBase) || customBase 0 and != 1
calculationResult.textContent = "Error: Invalid base.";
calculationResult.style.color = "#dc3545";
return;
}
result = ln_number / ln_base;
if (isNaN(result)) {
calculationResult.textContent = "Error: Calculation failed.";
calculationResult.style.color = "#dc3545";
} else {
calculationResult.textContent = result.toFixed(6); // Display with reasonable precision
calculationResult.style.color = "#28a745"; // Green for success
}
}