Skip to main content
Best answer by Werner_E

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

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.7.png

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.

8.png

2 replies

25-Diamond I
October 19, 2014

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").

5.png

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

00.png

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

The obvious and most natural one is to strip all units

1.png

Another approach is to make all elements the very same unit

2.png

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.

000.png

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

3.png

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.

24-Ruby IV
October 19, 2014

It is one more bug.

25-Diamond I
October 19, 2014

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.

Werner_E25-Diamond IAnswer
25-Diamond I
October 19, 2014

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

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.7.png

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.

8.png

24-Ruby IV
October 19, 2014

Werner Exinger wrote:

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

Better is a nanotechnology!:

nt.png

or a supernanotechnology - not 1 nm but 0 nm :