Skip to main content
1-Visitor
April 14, 2011
Solved

Yet Another Floating Point Error

  • April 14, 2011
  • 1 reply
  • 3961 views

Hi all,

There occured a problem in my work and I traced back the error, because of the dependencies it was hard to spot but once done, it seems like a really simple problem but can not explain why. Hopefully experienced users can help me get over this.

Have a nice day

Best answer by RichardJ

It's not a bug at all. Im(exp(i*x)) is only equal to sin(x) for real x.

You have numbers with large imaginary parts. The sin of such numbers have both real and imaginary parts that are outside the range of the floating point processor. So you get a floating point error.

1 reply

19-Tanzanite
April 15, 2011

You can get a result by taking the imaginary part of e^ix, where x is the argument you pass to the sin function. It is zero to within the numerical precision of Mathcad. Don't know why the sin function itself doesn't like it - some peculiarity of its algorithm I guess. See attached.

Alan

yeet1-VisitorAuthor
1-Visitor
April 15, 2011

Is this a confirmed bug or am I missing something ? There seems to be no reason to get floating point error in this case.

RichardJ19-TanzaniteAnswer
19-Tanzanite
April 15, 2011

It's not a bug at all. Im(exp(i*x)) is only equal to sin(x) for real x.

You have numbers with large imaginary parts. The sin of such numbers have both real and imaginary parts that are outside the range of the floating point processor. So you get a floating point error.