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
- :
- Mathcad Precision problem

Options

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

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

Showing results for

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

04-24-2013
03:48 PM

04-24-2013
03:48 PM

Mathcad Precision problem

I have stumbled upon what seems to be a serious precision error with Mcad. As shown in the attached worksheet, I implemneted a function to calculate the stirling number of the second kind (S2). The stirling number of the second kind is the number of ways to partition a set of *n *objects into *k* non-empty subsets. When n=k the answer should be 1; so S2(10,10) = 1 and S2(100,100)=1. However, I found that I only get correct results for small values up to n = 25. Above that I get all kinds of errors. See the attached worksheet.

Labels:

17 REPLIES 17

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

04-24-2013
04:19 PM

04-24-2013
04:19 PM

Re: Mathcad Precision problem

Thats really bad looking and I like the way you investigated to trap the problem.

But numerical evaluations are afflicted with numerical inaccuracies by nature - while I wouldn't have believed it to be that bad, so I can understand you call it an error/bug, but probably it isn't.

Anyway - you get the correct results if you use the symbolic evaluation:

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

04-25-2013
02:38 PM

04-25-2013
02:38 PM

Re: Mathcad Precision problem

Thanks for the reply.

Yes, the symbolic evaluation can be used to get the correct answers; However, because of the limitations associated with the symbolic processor, it's not of much use for the problem I'm working on which requires manipulating and ploting 2D functions that have the sterling function incorporated within it.

It would be nice if Mathcad had an option that would increase the internal precision for numerical evaluations.

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

04-25-2013
03:22 PM

04-25-2013
03:22 PM

Re: Mathcad Precision problem

Look at the attached. This modified function S2 will not behave exactly like a normal numeric function in all situations, but maybe you can benefit from it nonetheless.

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

04-25-2013
03:49 PM

04-25-2013
03:49 PM

Re: Mathcad Precision problem

Your file has extension .xmcdz which doesn't open with Mathcad 14. Can you post it as .xmcd or as a PDF file.

Thanks in advance.

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

04-25-2013
05:16 PM

04-25-2013
05:16 PM

Re: Mathcad Precision problem

Hmm, there is no difference in file format between MC14 and MC15 AFAIK and MC14 should be able to open xmcdz-files.

Anyway, here it is in xmcd and MC11 mcd format.

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

04-25-2013
08:41 PM

04-25-2013
08:41 PM

Re: Mathcad Precision problem

I've written a program that calculates n! to whatever precision you need up to 400!

The attached program outlines the method that can be expanded to even larger factorials.

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

04-26-2013
02:32 AM

04-26-2013
02:32 AM

Re: Mathcad Precision problem

In (my) MathCad 11.2 the definition of S2() fails with an error message of: 'This variable of function is not defined above.'

It appears it cannot evaluate the combin() function symbolically, only numerically.

"combin(3,1)=3"

"combin(3,1)->" produces an 'Unknown error.'

S2_detail() fails to produce the table, it lacks a statement to return A.

When I add a 'return A' to that function, it produces a table, and then the expression following "producing the error" results in '1' (which IS equal to the required 1!, isn't it?). No sorry, it returns 0.999868247598799; is that close enough?

Luc

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

04-26-2013
04:07 AM

04-26-2013
04:07 AM

Re: Mathcad Precision problem

"combin(3,1)->" produces an 'Unknown error.'

You may try using numbcomb(3,1) instead or replace by the definition using factorials.

The problem with S2(), with its symbolic eval definition and problematic numeric representation reminds me of this thread: http://communities.ptc.com/message/197737#197737

Also the big differences between MC11 and newer versions seem to be covered there.

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

04-26-2013
04:09 AM

04-26-2013
04:09 AM

Re: Mathcad Precision problem

Interesting approach - didn't you post a similiar sheet for calculation of pi a while ago?

How would you apply that method here to construct a function S2 with enough precision which is numerically useable also for plotting (mine isn't) as the poster demanded?