Plot Sin (x) for - π or negative x-axis

Just use f(x) = cbrt(sin(x))^2 to compute the 2/3 power in a way that works for negative numbers (and is faster to boot). (Not sure why you have a dot here. If you want to apply f elementwise to a vector just do f.(x).)

That’s what the cbrt function is for, whereas converting to complex chooses a different branch cut that you may not want here:

julia> cbrt(-1)
-1.0

julia> complex(-1)^(1//3)
0.5 + 0.8660254037844386im

julia> cbrt(-1)^2
1.0

julia> complex(-1)^(2//3)
-0.4999999999999999 + 0.8660254037844387im
2 Likes