Get Help

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Community
- :
- PTC Mathcad
- :
- PTC Mathcad
- :
- cos(pi/2) does not equal 0...why?

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-30-2014
01:37 PM

09-30-2014
01:37 PM

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

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

Labels:

9 REPLIES 9

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-30-2014
01:42 PM

09-30-2014
01:42 PM

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

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

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-30-2014
01:55 PM

09-30-2014
01:55 PM

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

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.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-30-2014
02:07 PM

09-30-2014
02:07 PM

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

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

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-30-2014
02:21 PM

09-30-2014
02:21 PM

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

I see, thats normal roundoff errors.

Its easy to suppress that in Mathcad (15 and below) - in fact you won't see anything else than 0 there in the first place anyway.

But I fear there is no way to do what you want with the limited formatting capabilities of Prime other than using symbolic evaluation.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-30-2014
03:40 PM

09-30-2014
03:40 PM

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

I wrote this years ago, and it works in MC15 (although I forget now why I wrote it ). It works in Prime, but only if you turn off Approximate Equality under the calculation options, and that can lead to other problems.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-18-2018
11:37 PM

09-18-2018
11:37 PM

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

Set Math Formatting to Decimal

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-17-2018
07:59 AM

09-17-2018
07:59 AM

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

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.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-17-2018
09:29 AM

09-17-2018
09:29 AM

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

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:

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:

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

Success!

Luc

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-17-2018
09:54 AM

09-17-2018
09:54 AM

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

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