# 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 allclose all

## Basic Examples(5)

Log2 gives the logarithm to base 2:

Plot over a subset of the reals:

Plot over a subset of the complexes:

Series expansion shifted from the origin:

Asymptotic expansion at a singular point:

## Scope(42)

### Numerical Evaluation(6)

Evaluate numerically:

Evaluate to high precision:

The precision of the output tracks the precision of the input:

Complex number inputs:

Evaluate efficiently at high precision:

Log2 can deal with realvalued intervals:

Log2 threads elementwise over lists and matrices:

### Specific Values(6)

Values of Log2 at fixed points:

Values at zero:

Values at infinity:

Zero argument gives a symbolic result:

Zero of Log2:

Find a value of x for which the Log2[x]=0.5:

### Visualization(3)

Plot the Log2 function:

Plot the real part of :

Plot the imaginary part of :

Polar plot with :

### Function Properties(10)

Log2 is defined for all positive values:

Log2 is defined for all nonzero complex values:

Function range of Log2:

Log2 is not an analytic function:

Nor is it meromorphic:

Log2 has a branch cut along the negative real axis:

Log2 is monotonic on the positive reals:

Log2 is injective:

Log2 is surjective:

Log2 is neither non-negative nor non-positive:

Log2 has both singularities and discontinuities for x0:

Log2 is concave on the positive reals:

### Differentiation(3)

First derivative:

Higher derivatives:

Plot the higher derivatives:

Formula for the  derivative:

### Integration(3)

Compute the indefinite integral using Integrate:

Definite integral of Log2:

More integrals:

### Series Expansions(5)

Find the Taylor expansion using Series:

Plots of the first three approximations around :

General term in the series expansion using SeriesCoefficient:

Asymptotic expansions at the branch cut:

Log2 can be applied to power series:

### Function Identities and Simplifications(6)

Basic identity for Log2:

Logarithm of a power function simplification:

Simplify logarithms with assumptions:

Logarithm of a product:

Change of base:

Expand assuming real variables x and y:

## Applications(4)

Worst-case complexity of merge sort algorithm from its functional equation:

Best-case complexity of merge sort algorithm:

Bubble sort is asymptotically worse than merge sort:

Find the age of a sample in units of its half-life time:

Compute the number of bits needed to store a large integer:

Compare to the exact result:

## Properties & Relations(2)

Number of bits used to represent the Wolfram Language's machine reals:

Simplification with assumptions: