Reference · Vectors

vec.exp

signature
vec.exp(list) -> list

What it does

e raised to each item, as a list of floats. It undoes vec.log, up to float rounding.

Examples

print(vec.exp([0, 1, 2]))print(vec.exp(vec.log([2, 10])))
output
[1.0, 2.718281828459045, 7.38905609893065][2.0, 10.000000000000002]

Edge cases

print(vec.exp([1000, -1000]))print(vec.exp([]), vec.exp(null))
output
[inf, 0.0][] []

Errors

An item that is not an int or a float, or an argument that is not a list, is a runtime error, not an error value.

this one fails
print(vec.exp([1, true]))
output
line 1: `vec.exp` expects a list of numbers, but item 1 is bool

Chaining

A softmax: exponentials scaled to sum to 1.

let z = [1, 2, 3]let e = z | vec.sub(max(z)) | vec.expprint(e | vec.div(sum(e)) | vec.round(3))
output
[0.09, 0.245, 0.665]

See also

vec.log, vec.pow, math.exp

Thread
6Useful? Like it, or add to its thread below.

Thread 0 posts

On vec.exp(): questions, tips, corrections, and code that uses it.

No posts yet. The first one opens the thread.

    Edit this page on GitHub · every example's output was made by running it (tools/refcheck.mjs) · questions on Discord or r/quillo