# Status of exp and sqrt

**URL:** <https://discourse.julialang.org/t/status-of-exp-and-sqrt/4092>\
**Category:** Internals & Design\
**Created:** [June 5, 2017, 2:04pm UTC](https://discourse.julialang.org/t/status-of-exp-and-sqrt/4092 "2017-06-05T14:04:37Z")\
**Posts on this page:** 11\
**Page:** 2

<div class="post-metadata">

**Author:** ![ExpandingMan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/expandingman/32/866_2.png) [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)\
**Post date:** [June 8, 2017, 2:51pm UTC](https://discourse.julialang.org/t/status-of-exp-and-sqrt/4092/21 "2017-06-08T14:51:42Z")

</div>

At the risk of sounding too academic, one of the distinguishing features of Julia is that it (mostly) retains universally recognized mathematical conventions except in cases where there is absolutely some sort of software concern that precludes this.

Every single person who reads e^A where A is a matrix in any context other than programming recognizes this as a matrix exponential, so if we make this something _other_ than a matrix exponential, we’d better have a damn good reason.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [June 8, 2017, 5:28pm UTC](https://discourse.julialang.org/t/status-of-exp-and-sqrt/4092/22 "2017-06-08T17:28:19Z")

</div>

> [@ExpandingMan](#):
>
> so if we make this something other than a matrix exponential, we’d better have a damn good reason.

The fact that `exp(A)` is elementwise in nearly every other widely used programming language oriented towards numerics (Matlab, Python/NumPy, R, Fortran, Scilab, and Julia itself prior to 0.7) is a pretty decent reason.

Now that we have `exp.(A)`, it is pretty reasonable to redefine `exp(A)` to `expm` (and deprecate the latter), but it’s important to recognize that there is a tradeoff here.

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [June 8, 2017, 5:34pm UTC](https://discourse.julialang.org/t/status-of-exp-and-sqrt/4092/23 "2017-06-08T17:34:40Z")

</div>

> [@stevengj](#):
>
> The fact that `exp(A)` is elementwise in nearly every other widely used programming language oriented towards numerics (Matlab, Python/NumPy, R, Fortran, Scilab, and Julia itself prior to 0.7) is a pretty decent reason.

But that applies to any other function as well, why should `exp` be different? Instead, it would be nice to have `exp` do the Right Thing™ based on the type of the input, which is probably the most Julian behavior.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [June 8, 2017, 5:40pm UTC](https://discourse.julialang.org/t/status-of-exp-and-sqrt/4092/24 "2017-06-08T17:40:04Z")

</div>

> [@giordano](#):
>
> But that applies to any other function as well, why should exp be different?

I’m not advocating that it should be different from anything? `exp(A)` will definitely not be elementwise in 0.7. The question is whether we define it at all. All I’m saying is that there is at least a reasonable argument for leaving it undefined when there are two competing definitions for a function (elementwise in technical programming languages vs matrix exponential in linear algebra). It’s not an overwhelming argument — I’m not opposed to choosing the matrix-exponential definition — but we should at least consider the tradeoff.

---

<div class="post-metadata">

**Author:** ![ExpandingMan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/expandingman/32/866_2.png) [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)\
**Post date:** [June 8, 2017, 5:46pm UTC](https://discourse.julialang.org/t/status-of-exp-and-sqrt/4092/25 "2017-06-08T17:46:50Z")

</div>

When the strengths of Julia allow us to transcend the shortcomings of other languages, we should do that.

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [June 8, 2017, 6:23pm UTC](https://discourse.julialang.org/t/status-of-exp-and-sqrt/4092/26 "2017-06-08T18:23:17Z")

</div>

I understand your concerns about tradeoff for people coming from other languages, but Julia has the opportunity to do something better, as @ExpandingMan said.

---

<div class="post-metadata">

**Author:** ![e3c6](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Post date:** [June 12, 2017, 1:19pm UTC](https://discourse.julialang.org/t/status-of-exp-and-sqrt/4092/27 "2017-06-12T13:19:55Z")

</div>

I think the notation `e^A` also needs to be discussed. In my opinion, both `exp(A)` and `e^A` are matrix exponentiation, while `e.^A` and `exp.(A)` are element-wise exponentiation. In any case, both `e^A` and `exp(A)` should mean exactly the same.

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [June 12, 2017, 2:13pm UTC](https://discourse.julialang.org/t/status-of-exp-and-sqrt/4092/28 "2017-06-12T14:13:44Z")

</div>

What would b^A mean for values of b that are not equal to e in that case?

---

<div class="post-metadata">

**Author:** ![e3c6](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Post date:** [June 12, 2017, 2:29pm UTC](https://discourse.julialang.org/t/status-of-exp-and-sqrt/4092/29 "2017-06-12T14:29:07Z")

</div>

`b^A = e^(ln b * A)`

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [June 12, 2017, 3:39pm UTC](https://discourse.julialang.org/t/status-of-exp-and-sqrt/4092/30 "2017-06-12T15:39:19Z")

</div>

Maybe you could make a Pull Request so people can try this out.

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [June 12, 2017, 3:49pm UTC](https://discourse.julialang.org/t/status-of-exp-and-sqrt/4092/31 "2017-06-12T15:49:30Z")

</div>

> [@e3c6](#):
>
> In any case, both `e^A` and `exp(A)` should mean exactly the same.

That’s already the case for numerical `A`, can be easily extended to matrices.

[Previous page](https://discourse.julialang.org/t/status-of-exp-and-sqrt/4092.md?page=1)
