kigubkur.elfun.exp

Elementary Function: exponential function.

(require '[kigubkur.elfun [exp :refer [exp]]])

Examples

Exponent of a number

=> (exp 1)
2.718281828459045

Exponent of a vector

=> (def r [[1 2 3 4]])
=> (def c [[1][2][3][4]])
=> (view r)
[1 2 3 4]
Order -> 1 x 4
=> (exp r)
[[2.718281828459045 7.38905609893065 20.085536923187668 54.598150033144236]]
=> (view c)
[1]
[2]
[3]
[4]
Order -> 4 x 1
=> (exp c)
[[2.718281828459045] [7.38905609893065] [20.085536923187668] [54.598150033144236]]

Exponent of a matrix

=> (def M [[1 2 3 4 5] [1 2 3 4 5] [1 2 3 4 5] [1 2 3 4 5]])
=> (view M)
[1 2 3 4 5]
[1 2 3 4 5]
[1 2 3 4 5]
[1 2 3 4 5]
Order -> 4 x 5
=> (view (exp M))
[2.718281828459045 7.38905609893065 20.085536923187668 54.598150033144236 148.4131591025766]
[2.718281828459045 7.38905609893065 20.085536923187668 54.598150033144236 148.4131591025766]
[2.718281828459045 7.38905609893065 20.085536923187668 54.598150033144236 148.4131591025766]
[2.718281828459045 7.38905609893065 20.085536923187668 54.598150033144236 148.4131591025766]
Order -> 4 x 5

Exponent of a block

(require '[kigubkur.construct [blocking :refer [block]]])
=> (def L [[1 2 3 4 5 6 7 8 9 10]
           [1 2 3 4 5 6 7 8 9 10]
           [1 2 3 4 5 6 7 8 9 10]
           [1 2 3 4 5 6 7 8 9 10]
           [1 2 3 4 5 6 7 8 9 10]
           [1 2 3 4 5 6 7 8 9 10]
           [1 2 3 4 5 6 7 8 9 10]])
=> (def B (block L 5))
=> (pprint B)
[[{:A11 [[1 2 3 4 5]
         [1 2 3 4 5]
         [1 2 3 4 5]
         [1 2 3 4 5]
         [1 2 3 4 5]],
   :A12 [[6 7 8 9 10]
         [6 7 8 9 10]
         [6 7 8 9 10]
         [6 7 8 9 10]
         [6 7 8 9 10]]}]
 [{:A22 [[6 7 8 9 10]
         [6 7 8 9 10]],
   :A21 [[1 2 3 4 5]
         [1 2 3 4 5]]}]]
=> (pprint (exp B))
[[{:A11 [[2.718281828459045 7.38905609893065 20.085536923187668 54.598150033144236 148.4131591025766]
         [2.718281828459045 7.38905609893065 20.085536923187668 54.598150033144236 148.4131591025766]
         [2.718281828459045 7.38905609893065 20.085536923187668 54.598150033144236 148.4131591025766]
         [2.718281828459045 7.38905609893065 20.085536923187668 54.598150033144236 148.4131591025766]
         [2.718281828459045 7.38905609893065 20.085536923187668 54.598150033144236 148.4131591025766]],
   :A12 [[403.4287934927351 1096.6331584284585 2980.9579870417283 8103.083927575384 22026.465794806718]
         [403.4287934927351 1096.6331584284585 2980.9579870417283 8103.083927575384 22026.465794806718]
         [403.4287934927351 1096.6331584284585 2980.9579870417283 8103.083927575384 22026.465794806718]
         [403.4287934927351 1096.6331584284585 2980.9579870417283 8103.083927575384 22026.465794806718]
         [403.4287934927351 1096.6331584284585 2980.9579870417283 8103.083927575384 22026.465794806718]]}]
 [{:A22 [[403.4287934927351 1096.6331584284585 2980.9579870417283 8103.083927575384 22026.465794806718]
         [403.4287934927351 1096.6331584284585 2980.9579870417283 8103.083927575384 22026.465794806718]],
   :A21 [[2.718281828459045 7.38905609893065 20.085536923187668 54.598150033144236 148.4131591025766]
         [2.718281828459045 7.38905609893065 20.085536923187668 54.598150033144236 148.4131591025766]]}]]

exp

(exp X)

Calculate the exponential of a number or every element of a matrix or a block (i.e. element-wise exponential).

Syntax: (exp X) s.t X is a scalar or a kigubkur© matrix (or both blocks)

Note that exponential of 1 is equal to Euler’s number and

if x ∈ {##NaN, ##Inf, ##-Inf}, returns ##NaN,

otherwise, returns expx.