# Exponentiation in Julia

**URL:** <https://discourse.julialang.org/t/exponentiation-in-julia/40299>\
**Category:** New to Julia\
**Tags:** question, math\
**Created:** [May 27, 2020, 11:06pm UTC](https://discourse.julialang.org/t/exponentiation-in-julia/40299 "2020-05-27T23:06:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vettukal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vettukal/32/15226_2.png) [@vettukal](https://discourse.julialang.org/u/vettukal)\
**Post date:** [May 27, 2020, 11:06pm UTC](https://discourse.julialang.org/t/exponentiation-in-julia/40299/1 "2020-05-27T23:06:59Z")

</div>

Hi Julia community,  
I am a new Julia user. Like what I see till now but with sometimes its head twisting.  
For example today I saw something and I wanted to know the difference between

> (-(0.5/1))^1.5

vs

> -(0.5/1)^1.5

First one gives me error:

```julia
ERROR: DomainError with -0.5:
Exponentiation yielding a complex result requires a complex argument.
Replace x^y with (x+0im)^y, Complex(x)^y, or similar.
Stacktrace:
 [1] throw_exp_domainerror(::Float64) at .\math.jl:37
 [2] ^(::Float64, ::Float64) at .\math.jl:872
 [3] top-level scope at REPL[9]:1

```

and the second code gives me answer: `-0.35355339059327373`

I was wondering what I am doing wrong in the first example of `(-(0.5/1))^1.5` that its expecting a complex number?

---

<div class="post-metadata">

**Author:** ![tbeason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbeason/32/15898_2.png) [@tbeason](https://discourse.julialang.org/u/tbeason)\
**Post date:** [May 27, 2020, 11:13pm UTC](https://discourse.julialang.org/t/exponentiation-in-julia/40299/2 "2020-05-27T23:13:07Z")

</div>

You are raising a negative number to the power 3/2, and that’s just not something you can do without complex numbers. It is the same as trying to take the square root of a negative number.

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [May 27, 2020, 11:19pm UTC](https://discourse.julialang.org/t/exponentiation-in-julia/40299/3 "2020-05-27T23:19:01Z")

</div>

And the second one was calculating `-(0.5^1.5)`

---

<div class="post-metadata">

**Author:** ![vettukal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vettukal/32/15226_2.png) [@vettukal](https://discourse.julialang.org/u/vettukal)\
**Post date:** [May 27, 2020, 11:41pm UTC](https://discourse.julialang.org/t/exponentiation-in-julia/40299/4 "2020-05-27T23:41:47Z")

</div>

Thanks everyone for answering. Searching around the forum I also found this thread which is useful.

[Complex numbers](https://discourse.julialang.org/t/1-1-2-is-complex-1-1-2-1-0-0-0im/32776)
