Log2[x]
gives the base-2 logarithm of x.
Log2
Log2[x]
gives the base-2 logarithm of x.
Details
- Mathematical function, suitable for both symbolic and numerical manipulation.
- Log2 gives exact integer or rational number results when possible.
- For certain special arguments, Log2 automatically evaluates to exact values.
- Log2 can be evaluated to arbitrary numerical precision.
- Log2 automatically threads over lists.
Examples
open all close allBasic Examples (5)
Log2 gives the logarithm to base 2:
Log2[2 ^ 10]Log2[1.4142]Log2[x]Plot over a subset of the reals:
Plot[Log2[x], {x, 0, 5}]Plot over a subset of the complexes:
ComplexPlot3D[Log2[z ^ 3], {z, -2 - 2I, 2 + 2I}, PlotLegends -> Automatic]Series expansion shifted from the origin:
Series[Log2[1 + x], {x, 0, 5}]Asymptotic expansion at a singular point:
Series[Log2[x], {x, -1, 3}, Assumptions -> Im[x] > 0]Scope (43)
Numerical Evaluation (7)
Log2[9.]N[Log2[45], 100]The precision of the output tracks the precision of the input:
Log2[5.211111111111111111]N[Log2[2 + I]]Evaluate efficiently at high precision:
Log2[1600`100]//TimingLog2[456`100000];//TimingLog2 can deal with real‐valued intervals:
Log2[Interval[{1 / 3, 2}]]Compute average-case statistical intervals using Around:
Log2[ Around[1 / 5, 0.01]]Compute the elementwise values of an array:
Log2[{{2, 1}, {0, 1 / 2}}]Or compute the matrix Log2 function using MatrixFunction:
MatrixFunction[Log2, {{2, 1}, {0, 1 / 2}}]//FullSimplifySpecific Values (6)
Values of Log2 at fixed points:
Table[Log2[n ], {n, {1, 2, 4, 8}}]Table[Log2[1 / n], {n, {1, 2, 4, 8}}]Log2[0]Log2[ComplexInfinity]Log2[Infinity]Zero argument gives a symbolic result:
Log2[0]Zero of Log2:
Log2[1]Find a value of x for which the Log2[x]=0.5:
xval = x /. FindRoot[Log2[x] == 0.5, {x, 0.1}]Plot[Log2[x], {x, 0, 2E}, Epilog -> Style[Point[{xval, Log2[xval]}], PointSize[Large], Red]]Visualization (3)
Plot the Log2 function:
Plot[Log2[x], {x, 0, 4}]ComplexContourPlot[Re[Log2[z]], {z, -2 - 2I, 2 + 2 I}, Contours -> 20]ComplexContourPlot[Im[Log2[z]], {z, -2 - 2I, 2 + 2 I}, Contours -> 20]PolarPlot[Log2[ϕ], {ϕ, 0, 12π}, Frame -> True]Function Properties (10)
Log2 is defined for all positive values:
FunctionDomain[Log2[x], x]Log2 is defined for all nonzero complex values:
FunctionDomain[Log2[x], x, Complexes]Function range of Log2:
FunctionRange[Log2[x], x, y]FunctionRange[Log2[x], x, y, Complexes]Log2 is not an analytic function:
FunctionAnalytic[Log2[x], x]FunctionMeromorphic[Log2[x], x]Log2 has a branch cut along the negative real axis:
Limit[Log2[-2 + ϵ I], ϵ -> 0, Direction -> "FromAbove"]Limit[Log2[-2 + ϵ I], ϵ -> 0, Direction -> "FromBelow"]Log2 is monotonic on the positive reals:
FunctionMonotonicity[Log2[x], x, PositiveReals]Log2 is injective:
FunctionInjective[Log2[x], x]Plot[{Log2[x], 1 / 2}, {x, 0, 5}]Log2 is surjective:
FunctionSurjective[Log2[x], x]Plot[{Log2[x], 5}, {x, 0, 200}]Log2 is neither non-negative nor non-positive:
FunctionSign[Log2[x], x]Log2 has both singularities and discontinuities for x≤0:
FunctionSingularities[Log2[x], x]FunctionDiscontinuities[Log2[x], x]Log2 is concave on the positive reals:
FunctionConvexity[{Log2[x], x > 0}, x]TraditionalForm formatting:
Log2[x]//HoldForm//TraditionalFormDifferentiation (3)
D[Log2[x], x]Table[D[Log2[x], {x, k}], {k, 1, 5}]Plot[%, {x, -10, 10}, PlotLegends -> {"First Derivative", "Second Derivative", "Third Derivative", "Fourth Derivative", "Fifth Derivative"}]D[Log2[x], {x, k}]Integration (3)
Compute the indefinite integral using Integrate:
Integrate[Log2[x], x]Definite integral of Log2:
Integrate[Log2[x], {x, 0, 1}]Integrate[Log10[x]Log2[x], x]//FullSimplifyIntegrate[Log2[z] ^ a, z]Integrate[t ^ (α - 1)Log2[t], {t, 0, 1}, Assumptions -> Re[α] > 0]Series Expansions (5)
Find the Taylor expansion using Series:
Series[Log2[x], {x, 2, 4}]Plots of the first three approximations around
:
terms = Normal@Table[Series[Log2[x], {x, 1, m}], {m, 1, 5, 2}];
Plot[{Log2[x], terms}, {x, 0, 5}]General term in the series expansion using SeriesCoefficient:
SeriesCoefficient[Log2[x], {x, 1, n}]FourierSeries[Log2[x], x, 1]// FullSimplifyAsymptotic expansions at the branch cut:
Series[Log2[x], {x, -2, 3}]Log2 can be applied to power series:
Log2[x + (x^2/2) + (x^3/3) + O[x]^4]Function Identities and Simplifications (6)
Basic identity for Log2:
2 ^ Log2[x]Logarithm of a power function simplification:
FunctionExpand[Log2[x^a], x > 0 && a∈Reals]Simplify logarithms with assumptions:
Log2[2 ^ n]Simplify[%, n > 0]FunctionExpand[Log2[x y], x > 0 && x + y ≥ 0]FullSimplify[Log2[x] == (Log[a, x]/Log[a, 2])]Expand assuming real variables x and y:
ComplexExpand[Log2[x + I y]]//FullSimplifyApplications (5)
Worst-case complexity of merge sort algorithm from its functional equation:
RSolve[w[n] == 2w[n / 2] + n - 1 && w[1] == 0, w[n], n]Best-case complexity of merge sort algorithm:
RSolve[b[2n] == 2 b[n] + n && b[1] == 0, b[n], n]Bubble sort is asymptotically worse than merge sort:
mComparisons[n_] := n Log2[n / 2] + 1bComparisons[n_] := n(n - 1) / 2Limit[mComparisons[n] / bComparisons[n], n -> Infinity]Find the age of a sample in units of its half-life time:
y[17.] /. RSolve[{y[t + 1] == y[t] / 2, y[0] == 3.5}, y, t]Log2[3.5 / %]Compute the number of bits needed to store a large integer:
Log2[BarnesG[500]]//NCeiling[%]BitLength[BarnesG[500]]Find the number of rounds for a single tournament, with two players or teams, to determine a winner. For that, you can determine how many times 2 can be multiplied by itself to get a number equal to or greater than the total number of participants/teams.
For example, a tournament of 4 players requires 2 rounds to determine the winner, while a tournament of 32 teams requires 5 rounds. To calculate, use Log2:
rounds = Log2[4]round2 = Log2[32]See Also
Log Log10 Power IntegerExponent IntegerLength IntegerDigits BitLength PowerRange
Function Repository: BinaryIteratedLog
Related Guides
Related Links
History
Text
Wolfram Research (2008), Log2, Wolfram Language function, https://reference.wolfram.com/language/ref/Log2.html.
CMS
Wolfram Language. 2008. "Log2." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Log2.html.
APA
Wolfram Language. (2008). Log2. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Log2.html
BibTeX
@misc{reference.wolfram_2026_log2, author="Wolfram Research", title="{Log2}", year="2008", howpublished="\url{https://reference.wolfram.com/language/ref/Log2.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_log2, organization={Wolfram Research}, title={Log2}, year={2008}, url={https://reference.wolfram.com/language/ref/Log2.html}, note=[Accessed: 12-June-2026]}