Skip navigation
2305 Views 5 Replies Latest reply: Apr 16, 2011 6:10 AM by A.Non RSS
yeet Bronze 26 posts since
Mar 7, 2011
Currently Being Moderated

Apr 16, 2011 3:42 AM

Optimizing the floating point or excluding singular points

Hi,

 

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", precision will be less for sure but to reach the approximate analytical results I need to get pass this issue. When the floating point error generating expression is in the denominator of the expression this is percieved as a "found a singularity.." error by Mathcad. Also it would be coould if I could just tell Mathcad to exclude points which cause the singularity of the expression.

 

cos(expression) returns floating point error

sin(expression) returns floating point error

but tanh(expression) doesn't give any error and converges to a result. Does it make sense ?

 

It would do the trick for me if Mathcad performs calculations to the point it returns an error based on the hardware/architecture.I can sacrifice some precision that will not be a problem.

 

Thanks

Attachments:
  • PhilipOakley Silver 2,084 posts since
    Feb 20, 2007

    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

  • FredKohlhepp Platinum 1,706 posts since
    Nov 28, 2006

    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.

  • A.Non Diamond 10,255 posts since
    May 11, 2010
    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.

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • Correct Answers - 3 points
  • Helpful Answers - 1 points