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
- :
- Divide by zero only in a range variable

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

11-14-2011
02:13 PM

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

11-14-2011
02:13 PM

Divide by zero only in a range variable

I'm attaching a Prime 1.0 worksheet that demonstrates a problem I'm having. I'm defining a function with a program which tests for a zero input. This works fine when you invoke the function with a constant or a simple variable of zero, but not when the argument is a range variable including a zero value. Am I doing something wrong, or is there a workaround to this?

Thanks,

Gerrit

11 REPLIES 11

11-14-2011
04:31 PM

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

11-14-2011
04:31 PM

Have a look at the attached if you can open it. There does seem to be a problem when units are involved.

Mike

11-14-2011
04:34 PM

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

11-14-2011
04:34 PM

Just incase you can't open the above file I save included an image for you to follow. Sorry, my Mathcad Prime 1.0 is off at the moment.

Mike

11-14-2011
04:41 PM

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

11-14-2011
04:41 PM

If I vectorize my call to H(f) like you've done it works fine too, even with units. Thank you, Mike! Are you with PTC? Can I consider that this little insect has been reported?

11-14-2011
05:00 PM

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

11-14-2011
05:00 PM

If I vectorize my call to H(f) like you've done it works fine too, even with units. Thank you, Mike!

No problem at all. It works for me with units, but when I see a problem I always strip the units away and start from scratch.

Are you with PTC?

No I'm not with PTC

Can I consider that this little insect has been reported?

It's actually not a bug. The way to created your range requires the Vectorize function.

Mike

11-14-2011
05:01 PM

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

11-14-2011
05:01 PM

Against my old argument, see below. Mathcad 15 which doesn't need the vectorize function.

Mike

11-14-2011
05:36 PM

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

11-14-2011
05:36 PM

I didn't recall that it did either. In fact, I've done similar things in Prime without having to vectorize. My general philosophy has always been "if it doesn't work, try vectorizing", which I didn't follow this time, alas.

I do think Prime is not quite up to snuff yet. I've seen a number of unexplainable errors, which disappear if you delete part of the equation and then re-enter the identical thing, for example. It's so nice in other ways I'm sticking with it, but it's been really difficult this morning.

Gerrit

11-14-2011
05:38 PM

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

11-14-2011
05:38 PM

I would stick with it Gerrit. Future releases will be a massive improvement.

Mike

11-14-2011
05:44 PM

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

11-14-2011
05:44 PM

Mike's Mathcad 15 example works the same in Mathcad Prime as well.

I was looking at the problem with Gerrit's worksheet, and it appears that the issue is that f is defined as 0 in the program, but f is a vector. So you can't test for 0 this way.

Mona

11-14-2011
05:51 PM

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

11-14-2011
05:51 PM

Hi Mona,

I don't see where f is defined as zero in the program (that is, in the definition of H()). There is a *test *for the argument being passed being zero. The definition of H as it is should accept a vector f_sub_i and return a vector of the same size, shouldn't it? And if an element of the vector is zero, the test on the first line should catch it. Or am I misunderstanding?

Gerrit

11-14-2011
06:02 PM

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

11-14-2011
06:02 PM

Mike's Mathcad 15 example works the same in Mathcad Prime as well.

Mona,

Mathcad 15 works without using the vectorize function and just using the subscript i. Mathcad Prime will not allow this. Are you getting this problem?

Mike

11-14-2011
05:45 PM

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

11-14-2011
05:45 PM

I agree! I'm looking forward to it.

Thanks again for your help,

Gerrit