Skip to main content
1-Visitor
September 30, 2014
Question

cos(pi/2) does not equal 0...why?

  • September 30, 2014
  • 2 replies
  • 11893 views

I am performing some martrix algebra.

When I ask Mathcad what cos(pi/2) equals it says "6.123X10^-17". How do I get this value to revert to 0, which is the true value?

Thank you

Jamie

2 replies

1-Visitor
September 30, 2014

I was able to change the formatting from general to decimal which fixed the formatting of zero; however my large numbers now have 5-6 zeroes beyond the significant digits.

Is there a way to get 73680000 to show as 7.37X10^7 and zero to show as 0, not 2.8X10^-9?

Thank you

25-Diamond I
September 30, 2014

Jamie Skovron wrote:

I was able to change the formatting from general to decimal which fixed the formatting of zero; however my large numbers now have 5-6 zeroes beyond the significant digits.

Is there a way to get 73680000 to show as 7.37X10^7 and zero to show as 0, not 2.8X10^-9?

Change formatting back to General or Scientific. You may play araound with the value of the Zero Threshold (by default 15, you may try to lower it to 8).

If the calculated value IS 2.8X10^-9 I would like it to show up as 2.8X10^-9 and not as zero.

rather recheck the ways you do your calculations and see if you can achieve a better precision without big roundoff errors.

And in Mathcad cos(pi/2) definitely is shown as 0 and not anything else.

You'll have to show your worksheet for further help.

1-Visitor
September 30, 2014

MathcadHelp.png

As you can see, it is calculating cos^2-sin^2 as 2.22X10^-16 rather than zero.

1-Visitor
September 17, 2018

I met the same in calculations of attack angle of wind on elements of my structure. I was very surprised.

So, as I understood I have to round my velocity vectors to get right angles.

23-Emerald IV
September 17, 2018

You have to realize that (unless you work fully symbolically) Mathcad uses numerical approximation. So you may get results close to, but not exactly, zero on occasions.  cos(pi/2) is one such occasion:

LM_20180917_CosHalfPi1.png

In (real) Mathcad, it is possible to set the zero threshold, which will cause numerical resuls to show as 0 when they are close to zero within that threshold. The default for the zero threshold is '15' which sets that any value within -10^-15 to 10^-15 will be shown as zero. 'Shown as'....! it will not be set to 0. If you multiply such a result with 10^15, it will come up as non-zero. See here:

LM_20180917_CosHalfPi2.png

So what you could do is wrap the cos function into a function that detects small results, and sets them to 0. Like:

LM_20180917_CosHalfPi3.png

 

Success!

Luc

 

1-Visitor
September 17, 2018

Thanks, I used round(cos(),8)