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
- :
- polyroots + units = error?

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

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

10-19-2014
02:04 AM

Labels:

1 ACCEPTED SOLUTION

Accepted Solutions

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

10-19-2014
09:10 AM

10-19-2014
09:10 AM

!!!!!!!!!!!!!!!!!!!!!!!!!!!

Shame on me, praise for PTC!

Forget (most) of what I had written above.

polyroots() is fully unit aware and works intuitiv as expected - you just have to take care and use the correct units all over. And as Prime has dynamic unit checking you also have to supply the correct unit for a zero value.

That was the failure in your sheet. In your first attempt you supplied no unit at all and in your second the wrong unit. The correct unit for the coefficient of the linear element is length. If you supply km (or m, it doesn't matter) you get the correct result.

Even the eror message makes sense (though it wasn't helpful in your case). Mathcad can't tell the desired unit of the resulting variable unless you provide units for the first two elements of the vector. You can provide ANY units for those first two values, but the third (and all following for polynomial of higher order) have to be consistent. So you will never get an error that element 0 or element 1 should have a different dimension.

9 REPLIES 9

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

10-19-2014
06:13 AM

10-19-2014
06:13 AM

Re: polyroots + units = error?

So you found yet another function in Prime which still will not work as expected when used with units 😞

The error message itself is a confusing (not necessarily wrong. It will always tell you that "Element 2 of this vector must have units: ...." no matter which of the first three elelements has the wrong unit (and disregarding the setting of ORIGIN).

But if you use polyroot with a vector of more than three elements and the wrong unit is in the fourth or higher element it will give you the appropriate element count (no matter what ORIGIN is set to, the first element is always "Element 0").

polyroot(v) will always solve so that the scalar product of v with the vector of powers of x is dimensionless

So you have a couple of choices to get polyroot to work.

The obvious and most natural one is to strip all units

Another approach is to make all elements the very same unit

Both ways above of course will give you a dimensionless solution. If you want solutions with correct units, you will have to adapt the units in the vector accordingly (which does not feel natural on first sight). The rule is to make the second element (the coefficient of the linear element) show the reciproke of the unit you want to see for the result. If the dimensions of the rest are OK this will work. In your case the dimension of the coefficient of the linear element is length (the zero reults from L-L). So we have to divide the whole vector by length and multiply by 1/velocity. Chosing the correct units might be tricky.

Of course you always can get one numerical solution with correct units if you use either root or a solve block

P.S.: Using your pseudounits as you did at the end of the new sheet you attached is dangerous as you loose most of the benefits the usage of units in Mathcad has.

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

10-19-2014
07:44 AM

10-19-2014
07:44 AM

Re: polyroots + units = error?

It is one more bug.

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

10-19-2014
07:59 AM

10-19-2014
07:59 AM

Re: polyroots + units = error?

You did it again, but thats not the correct answer

Its not a bug, just a missing feature.

EDIT: Wrong! The feature is not missing, you just have to use it correctly. See my answer below.

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

10-19-2014
07:53 AM

10-19-2014
07:53 AM

Re: polyroots + units = error?

The correct solution of this problem is:

but I would liki to show using for this root, find and... polyroots functions.

The polyroot is with a bug - for this collection http://communities.ptc.com/groups/mathcad-paradoxes

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

10-19-2014
08:07 AM

10-19-2014
08:07 AM

Re: polyroots + units = error?

The polyroot is with a bug - for this collection http://communities.ptc.com/groups/mathcad-paradoxes

No, its not a bug. Once you understand how it works there is a perfect logic. But it sure would help if the help clearly states how polyroot works, what it needs and what kind of result you can expect.

And of course it would be nice if polyroot would be implented differently so we could use it more intuitive.

At the time being you simply have to divide the vector by the unit of the result.

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

10-19-2014
08:37 AM

10-19-2014
08:37 AM

Re: polyroots + units = error?

The polyroots-function with units is without bugs but for this collection http://communities.ptc.com/groups/mathcad-paradoxes

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

10-19-2014
08:57 AM

10-19-2014
08:57 AM

Re: polyroots + units = error?

Valery Ochkov wrote:

No, I won't say its a paradox (its doesn't imply a contradiction). Its just a liitle bit more difficult to understand when used with units. And Prime users sure would be happy if PTC decides to implement it in a more user/unit friendly way.

EDIT: Again - see my answer below. It IS already implemented the way it should be.

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

10-19-2014
09:10 AM

10-19-2014
09:10 AM

!!!!!!!!!!!!!!!!!!!!!!!!!!!

Shame on me, praise for PTC!

Forget (most) of what I had written above.

polyroots() is fully unit aware and works intuitiv as expected - you just have to take care and use the correct units all over. And as Prime has dynamic unit checking you also have to supply the correct unit for a zero value.

That was the failure in your sheet. In your first attempt you supplied no unit at all and in your second the wrong unit. The correct unit for the coefficient of the linear element is length. If you supply km (or m, it doesn't matter) you get the correct result.

Even the eror message makes sense (though it wasn't helpful in your case). Mathcad can't tell the desired unit of the resulting variable unless you provide units for the first two elements of the vector. You can provide ANY units for those first two values, but the third (and all following for polynomial of higher order) have to be consistent. So you will never get an error that element 0 or element 1 should have a different dimension.

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

10-19-2014
10:31 AM

10-19-2014
10:31 AM

Re: polyroots + units = error?

Werner Exinger wrote:

.... If you supply km (or m, it doesn't matter) you get the correct result.

Better is a nanotechnology!:

or a supernanotechnology - not 1 nm but 0 nm :