Skip to main content
1-Visitor
December 11, 2014
Question

Mathcad v14 trig functions calculate incorrectly

  • December 11, 2014
  • 2 replies
  • 4873 views

Does anybody know if this error has been corrected in subsequent versions? Mathcad v14 does not calculate sin(180 deg) or cos(90 deg) as 0. There is a value out to ~16 decimal places, which would not normally be an issue, but I have a 0/0 division calculation that returns an error because of this. Using radians rather than degrees does not change the value calculated. I have created a kludge workaround, but I shouldn't have to. Is there a program fix for this? And does PTC know?

2 replies

25-Diamond I
December 11, 2014

I wouldn't call this an error. Mathcad is a numeric number cruncher and the results are within its numeric accuracy.

If you need something better you might consider using the symbolic evaluation. The screenshot below was made in the current release of Mathcad 15 and I guess it would be similar in Prime, too. I am just too lazy to fire up that uncomfortable slow horse.

1.png

23-Emerald V
December 11, 2014

And just for comparison with another mainstream maths application, here are the Matlab 2014a results for the same calculation:

Trial>> sin(pi)

ans =

1.224646799147353e-16

Trial>> cos(pi/2)

ans =

6.123233995736766e-17

Trial>> sin(3*pi)

ans =

3.673940397442059e-16

Trial>> cos(101*pi/2)

ans =

4.408109496293883e-15

Trial>>

Very similar and for the same reason - standard fixed-width floating point roundoff.

Stuart

23-Emerald V
December 11, 2014

And, for forms sake, here's Excel's take on it ...

1.2251484549086E-16
6.1257422745431E-17
3.6754453647259E-16
4.4106428578883E-15

So, unfortunately, you'll find this behaviour is common to many, industry-standard numeric applications.

Stuart

19-Tanzanite
December 11, 2014

Roundoff error is the nature of numeric processing. This has come up before, more than once. See here:

http://communities.ptc.com/message/70317#70317

http://communities.ptc.com/message/258037#258037

Maybe the worksheet I posted in the second thread would be a solution for you.