# Exp() of nonsquare matrix

**URL:** <https://discourse.julialang.org/t/exp-of-nonsquare-matrix/25036>\
**Category:** General Usage\
**Created:** [June 7, 2019, 7:08am UTC](https://discourse.julialang.org/t/exp-of-nonsquare-matrix/25036 "2019-06-07T07:08:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hytonwons](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hytonwons/32/8787_2.png) [@hytonwons](https://discourse.julialang.org/u/hytonwons)\
**Post date:** [June 7, 2019, 7:08am UTC](https://discourse.julialang.org/t/exp-of-nonsquare-matrix/25036/1 "2019-06-07T07:08:19Z")

</div>

Hi,

I ran into an issue on exp() of a matrix.  
Here is a minimal reproducible example, and I’m using Julia 1.0.3:

```julia
using LinearAlgebra
exp(Matrix(1.0I, 2, 1))

```

The error I got is:

```julia
DimensionMismatch("matrix is not square: dimensions are (2, 1)")

```

I checked the source code, in both exp and exp!, it first checks whether the input matrix is square or not.  
However, Matlab does support exp of nonsquare matrix.  
Any idea? Any help is appreciated.

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [June 7, 2019, 7:12am UTC](https://discourse.julialang.org/t/exp-of-nonsquare-matrix/25036/2 "2019-06-07T07:12:08Z")

</div>

It’s because matlab calculates the elementwise exponential when you call `exp` on a matrix. To get that in Julia, do `exp.(M)`, notice the dot `.`.

Julia calculates the _matrix exponential_ when you ask for `exp(m::Matrix)`

---

<div class="post-metadata">

**Author:** ![hytonwons](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hytonwons/32/8787_2.png) [@hytonwons](https://discourse.julialang.org/u/hytonwons)\
**Post date:** [June 7, 2019, 7:56am UTC](https://discourse.julialang.org/t/exp-of-nonsquare-matrix/25036/3 "2019-06-07T07:56:25Z")

</div>

Thanks!

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [June 7, 2019, 8:02am UTC](https://discourse.julialang.org/t/exp-of-nonsquare-matrix/25036/4 "2019-06-07T08:02:46Z")

</div>

The dot is very powerful in julia and can be applied to _any_ function, including operators. See [broadcasting](https://docs.julialang.org/en/v1/manual/arrays/#Broadcasting-1) for documentation.
