# 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.