Skip to content

Commit

Permalink
improve complex sin and cos. fixes JuliaLang#2889
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Apr 19, 2013
1 parent cfdf114 commit 20d1bdd
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions base/complex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -190,21 +190,13 @@ end
angle(z::Complex) = atan2(imag(z), real(z))

function sin(z::Complex)
u = exp(imag(z))
v = 1/u
rz = real(z)
u = (u+v)/2
v = u-v
complex(u*sin(rz), v*cos(rz))
r, i = reim(z)
complex(sin(r)*cosh(i), cos(r)*sinh(i))
end

function cos(z::Complex)
u = exp(imag(z))
v = 1/u
rz = real(z)
u = (u+v)/2
v = u-v
complex(u*cos(rz), -v*sin(rz))
r, i = reim(z)
complex(cos(r)*cosh(i),-sin(r)*sinh(i))
end

function log(z::Complex)
Expand Down

0 comments on commit 20d1bdd

Please sign in to comment.