exp2

exp2(x)

Compute $2^x$.

Examples

  1. Calculate $2^x$ for a single value:

    julia> exp2(3)
    8.0

    This example calculates and returns the value of $2^3$, which is 8.

  2. Apply exp2 to an array of values:

    julia> arr = [1, 2, 3, 4, 5];
    julia> exp2.(arr)
    5-element Array{Float64,1}:
    2.0
    4.0
    8.0
    16.0
    32.0

    Here, the exp2. syntax allows us to apply the exp2 function element-wise to the array arr, resulting in a new array containing the exponential values.

  3. Handle negative exponents:
    julia> exp2(-2)
    0.25

    This example demonstrates that the exp2 function can handle negative exponents. Here, it calculates and returns the value of $2^{-2}$, which is 0.25.

Common mistake example:

julia> exp2("2")
ERROR: MethodError: no method matching exp2(::String)

In this example, the argument provided is a string instead of a numeric value. The exp2 function expects a numerical argument, so ensure that you pass a valid numeric value to avoid this error.

See Also

abs2, beta, binomial, ceil, cell, cross, ctranspose, ctranspose!, cummin, cumprod, cumprod!, cumsum, cumsum!, cumsum_kbn, div, divrem, eigfact, eigfact!, eigmin, eps, erf, erfc, erfcinv, erfcx, erfi, erfinv, exp, exp10, exp2, expm1, exponent, factor, factorial, factorize, floor, gcd, invmod, log, log10, log1p, log2, logspace, max, min, mod, mod1, modf, next, nextpow, nextprod, num, primes, primesmask, prod, realmin, sqrt, sum!, sumabs, sumabs!, sumabs2, sumabs2!,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: