Now that exp. and sqrt. exist, will expm and sqrtm be deprecated and replaced by exp and sqrt on matrices? Is the answer no because it would be too error-prone?

# Status of exp and sqrt

**jkbest2**#2

The `expm`

and `sqrtm`

functions are matrix operations, not elementwise operations. I expect theyâll be sticking around.

Edit: Below is likely not what OP meant.

To be explicit:

```
julia> A = rand(2,2)
2Ă2 Array{Float64,2}:
0.0692582 0.167208
0.223925 0.360005
julia> expm(A'A)
2Ă2 Array{Float64,2}:
1.06113 0.10272
0.10272 1.17547
julia> exp.(A'A)
2Ă2 Array{Float64,2}:
1.05648 1.09658
1.09658 1.17065
julia> expm(A'A) â exp.(A'A)
false
```

**cdsousa**#4

But having `exp.`

to mean elementwise operations, wouldnât it be correct for `exp`

to mean matrix exponentiation (although possibly against all other languages)?

Ah, that makes more sense. Hm, I think that would perhaps be error prone. On the other hand, it might enable generic code that will both work with matrices and scalars?

**mbauman**#6

Some prior discussion here: https://github.com/JuliaLang/julia/issues/5840#issuecomment-237077416

Yes, exponential integrators, integration factor methods, and exponential time differencing methods would be nicer to write with this. You can get around this with a simple `if <: AbstractArray`

, but if `exp`

âjust workedâ then the code would be much nicer. So thereâs at least a use case in DiffEqs (that I ran into quite recently).

**cortner**#9

It sounds tempting, but then what about fast vectorised versions of `exp`

etc, see e.g. AppleAccelerate.jl

Also note that `expm`

and `sqrtm`

can be applied to scalars, so the canonical way to write exponential integrators would probably be to use `expm`

from the start?

**andyferris**#13

I think all these types of functions should work on matrices, on the guiding principal that if a Taylor (or similar) expansion works for both `Number`

and square `Matrix`

, then why *wouldnât* the same function apply to both?? Julia is meant to support generic mathematical programming, after allâŚ

**cossio**#16

@cortner If the element-wise `exp([1., 2.])`

becomes deprecated, then `expm`

will be a superset of `exp`

.

**cortner**#17

I guess you are right then - I am still thinking 0.5; maybe another argument in favour deprecating `expm`

**nalimilan**#18

IMHO it would be confusing for new users. People will frequently expect `exp(::AbstractMatrix)`

to apply `exp`

to each entry in the matrix. Better keep separate functions.

**Tamas_Papp**#19

At least while only a subset of functions have a âproperâ matrix version, distinguishing the latter is a reasonable alternative, even if it comes at the cost of elegance.

Conversely, `expm`

should only be merged to `exp`

when `cos(::AbstractMatrix)`

and similar throw an error.