
Re: Optimizing the floating point or excluding singular points
PhilipOakley Apr 16, 2011 4:29 AM (in response to yeet)Yigit,
There is a misunderstanding here.
Mathcad is doing "what it says on the tin". It just isn't doing what you thought would happen.
We, as humans, can quickly abstract the essence of a problem and jump over minor inconveniences to get to the 'right' answer. These include knowing that we can have a term that looks like infinity divided by (the same) infinity and 'know' that the answer will be unity (one). Mathcad (and especially its numeric engine calculations, which are limited to double precision floating point) doesn't know that.
in your case you have asked for the sine of a complex number. When you use sin(x) = (exp(ix)  exp(ix))/(2i) see http://en.wikipedia.org/wiki/List_of_trigonometric_identities you should be able to see that if you have a large imaginary component to 'x' then you get an extra real exp(Imaginary_term) added onto your magnitude. Thus the sine becomes much greater than unity. In your case the multiplier is so large that it is bigger than the maximum number that can be represented by a floating point number  hence the (correct for mathcad) error report.
You should have a look at the effect of passing imaginary terms into the sin function. if the term is a pure imaginary (real part is zero), then you are simply asking for the sinh() hyperbolic function to be evaluated which ,as as you may know, zooms off to infinity.
The tan() function works because it (the mathcad implementation) has already taken care of the ratio between the sin/cos and evaluates it 'nicely'
Philip

Re: Optimizing the floating point or excluding singular points
yeet Apr 16, 2011 5:20 AM (in response to PhilipOakley)Yes tanh seems to be evaluating but when used in recursive and dependence functions it generates the error.Individually tanh(expression) evaluates but not in the case I mentioned above.Please see the attachement.

why.xmcd.zip 93.1 K

Re: Optimizing the floating point or excluding singular points
A.Non Apr 16, 2011 6:10 AM (in response to yeet)See the attached.
The way you are handling the matrix operations is very dangerous. Do you want element by element operations, or matrix operations? When you do a lot of vectorization on complicated expressions you have to be very careful that it is doing what you actually want it to do.

why3.xmcdz.zip 134.1 K




Re: Optimizing the floating point or excluding singular points
FredKohlhepp Apr 16, 2011 4:48 AM (in response to yeet)I can't help answer your question, but
You don't need to define j as the square root of 1. Mathcad will recognise imaginary numbers. You get an imaginary number by typing 1j (or 1i) with no multiplier between them.
The complex number 4 + 5i
is entered by typing 4 (plus) 5 (times) 1j [(plus) is + and (times) is *]
The real answer to your question is somewhere in the mathematics or the implimentation of the algorithms.
THis is one of the times when we should all wish Tom Gutman hadn't given up on this forum.

Re: Optimizing the floating point or excluding singular points
A.Non Apr 16, 2011 6:07 AM (in response to yeet)Some expressions in my sheet generate floating point errors and I would like to take as many floated decimals it can till it gets to "floating point error",
The problem is not the number of digits, it's the magnitude of the number. The numbers are larger than the floating point processor can handle.