tapyu
1
That is a very basic question. In Matlab, we can pass a vector for the exp
function and it returns a vector with the exponential results.
In Julia, I can’t do that since exp
does not allow a vector as input. Plus, I can’t do e.^v
since the Euler’s number is not defined. How to solve it?
julia> exp.(rand(10))
10-element Vector{Float64}:
1.5873169230522923
1.7204554407302755
1.9840565297531094
2.7057478585870305
1.3102571943681591
1.9628991834318725
1.2499693417272832
1.7896481387376577
1.23080464883015
1.4771492869804266
2 Likes
For the record, Euler’s number is bound to ℯ
(i.e., \euler<TAB>
). So you can do
julia> ℯ.^[1,2,3]
3-element Vector{Float64}:
2.718281828459045
7.38905609893065
20.085536923187668
1 Like
See also this section of the manual and (for further background) this blog post.