cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

Is it an error in Mathcad Prime?

ValeryOchkov
24-Ruby IV

Is it an error in Mathcad Prime?

NotComplex.png

And secons.

I see C, R and Z in help but C, R,Z and Q in the list of symbols.

1 ACCEPTED SOLUTION

Accepted Solutions

Sorry,

for a lot of Engineers (Mathcad users):

1 - real number

sqrt(-1) - imaginary number

1+sqrt(-1) - complex number

Now I see my error

Absolutely accurate and absolutely useless operator/

View solution in original post

19 REPLIES 19
athurin
4-Participant
(To:ValeryOchkov)

sqrt(1) is a real number, and C is a superset of R, so sqrt(1) is complex. If you want to know if sqrt(1) is imaginary, you can test Im(sqrt(1)) not equal to 0.

Only a not complex number is a not complex number

NotComplexNumber.png

athurin
4-Participant
(To:ValeryOchkov)

What is it you want to test exactly ?

My understanding of your question was that you were confusing "complex" and "not real". sqrt(1) is complex, because any real is complex. But it is true that it is not "not real", and if you want to test this condition, you have to do it differently. Like this, for instance:

Untitled.png

Now the real strange part is that Mathcad doesn't acknoledge that any real is complex in a "formal" way, although I suspect that if you ask the question for individual numbers, you will get the right answer.

Untitled.png

OK!

One simple question.

1 is complex?

athurin
4-Participant
(To:ValeryOchkov)

Yes. 1 E C is mathematically correct. And therefore, Mathcad is right.

Valery Ochkov wrote:

OK!

One simple question.

1 is complex?

Yes!

1 is a member of the set of natuaral numbers (N)

1 is a member of the set of integers (Z)

1 is a member of the set of rational numbers (Q)

1 is a member of the set of real numbers (R)

1 is a member of the set of complex numbers (C)

1 is NOT a member of the set of irrational numbers (I)

athurin
4-Participant
(To:Werner_E)

Is there a particular reason why R "IsElement" C returns 0 ? Not that it matters in every day life, since I expect it works when testing numbers, but mathematically, R "IsElement" C should return 1...

Adrien Thurin wrote:

Is there a particular reason why R "IsElement" C returns 0 ? Not that it matters in every day life, since I expect it works when testing numbers, but mathematically, R "IsElement" C should return 1...

No!! R is NOT an element of the set of of complex numbers - its a subset. And Mathcad provides no way to check for super- or subsets. We have the symbol for subset but no operator which will yield true or false like "element of".

1.png

Now the real strange part is that Mathcad doesn't acknoledge that any real is complex in a "formal" way, although I suspect that if you ask the question for individual numbers, you will get the right answer.

Untitled.png

This is correct, too!

R is not a member of the set of complex numbers - its a subset!

athurin
4-Participant
(To:Werner_E)

If you present it this way, it is true.

The confusing part is that "Is Element" uses the mathematical symbol for "is included in", which also works for a subset. Again, not that it matters much for every day Mathcad usage.

It would be more worrying if Mathcad could handle lists and/or sets of numbers (can it ? I haven't seen it, but I didn't look for it either). If it did, one would definitely want "Is Element" to work with subsets !

Adrien Thurin wrote:

If you present it this way, it is true.

The confusing part is that "Is Element" uses the mathematical symbol for "is included in", which also works for a subset. Again, not that it matters much for every day Mathcad usage.

Not sure if I understand correct. "is element of", "is included in", "is member of" means all the same and Prime has even an oparator for it which can be evaluated 1.png.

In contrary to this the symbol for subset 2.pngis just a symbol, a character, in Prime, not an operator which could be evaluated. Probably this is not necessary anyway as Prime unfortunately does not support sets or lists.

If it did, one would definitely want "Is Element" to work with subsets !

NO! Not the "is Elelement" operator - thats for checking if something is a member of a set. We would need a separate subset operator which should look like the normal mathematical subset symbol shown above.

athurin
4-Participant
(To:Werner_E)

I don't really agree. If it was possible, I would want one unique operator for "Is Element" and "Is Subset". In some cases, you might end up with a subset made of one element, and you don't want your whole algorithm to blow up because you used the wrong operator !

Either way, Mathcad doesn't handle this type of data, so there is not much point arguing about this

Adrien Thurin wrote:

I don't really agree. If it was possible, I would want one unique operator for "Is Element" and "Is Subset". In some cases, you might end up with a subset made of one element, and you don't want your whole algorithm to blow up because you used the wrong operator !

But you should! There is definitely a difference between the number 5 and the set consisting of just that number. So we must use the correct operator - convenient or not. And you dont have to change anything in your algorithm - if you end up with a subset of just 1 element you can and should use the subset operator (if it would exist) as with larger sets. The subset consisting just of that one element is a set and should not be confused with the element itself.

athurin
4-Participant
(To:Werner_E)

In which case, Mathcad needs to be consistant in the way it works. I remember finding a situation where the result of an algorithm would be either a number (if only 1 value returned), or a matrix (if several values returned), which caused one hell of a mess.

To be precise, I was looking for the poles and zeros of a transfer function.

Multiple zeros, returns a matrix :

Untitled.png

Single zero, returns a number :

Untitled.png

And that is not trivial to manage ! Give me at least a result in a consistent form, so that I can have a sheet that doesn't blow up in some cases !

And this is why I want a unique operator that works of "Is Element" and "Is Subset" (ie a "Is included" operator) : if subsets were managed in Mathcad like matrix are, there would be some painful cases to manage !

Adrien Thurin wrote:

In which case, Mathcad needs to be consistant in the way it works. I remember finding a situation where the result of an algorithm would be either a number (if only 1 value returned), or a matrix (if several values returned), which caused one hell of a mess.

To be precise, I was looking for the poles and zeros of a transfer function.

Multiple zeros, returns a matrix :

Single zero, returns a number :

First, thats the symbolics and thats a different breed in Mathcad anyway and should be handled with care. Contrary to Mathcad you can't use symbolic evaluations inside a self written program in Prime anyway. In the context of a program routine you could use Y <-- stack (Y) or Y <-- stack(Y^T)^T (in case of the 1xn matrix the symbolics will yield). The point is - you have to know your tools. And returning a scalar and not a 1x1 matrix if only one solution is found may make much sense and can be very convenient in other cases fo other people even if you consider it inconsistent.

Give me at least a result in a consistent form, so that I can have a sheet that doesn't blow up in some cases !

Again, its you who has to deal with special cases (as every programmer in any program). A good example of how confusing it can be if PTC inplements things the way you demand are the various lookup() and match() functions. Continuously I see here in this forum question from confused users with broken worksheets who simply do not realize that the result of those function is a matrix, even if only one match is found. So what seems to be a good implementation for one persn, cann be the hell for the next and its hard to decide unbiased which is the better one, less alaone the "correct" one.

And this is why I want a unique operator that works of "Is Element" and "Is Subset" (ie a "Is included" operator) : if subsets were managed in Mathcad like matrix are, there would be some painful cases to manage !

Again NO! Thats like jumping from the frying pan into the fire. "Is Element" and "Is Subset" are two absolutely different mathematical operators and it would be simply wrong to use one for both - thats sure not an option even if some may find it convenient. One way could be to wish that Prime should treat a 1x1 matrix as a scalar in some situations when it is clear (?) that the user wants that to happen. Something like the automatic vectorization which is applied if it is clear that the user has that intention (because the expression does not make sense when used with vectors). So if a and be are vectors, we get (per vectorization) a vector result if we evaluate a/b but a scalar when we evaluate a*b. Automatic vectorization is a convenient mechanism sometimes but also can lead tu much confusion as we see here ever so often.

But again - thats hypothetical as "Is subset" is not implemented anyway and "Is Eelement" is not of much help in everyday life to say the least.We could demand an "is subset" operator but given Prime with its many flaws and missing features compared to old Mathcad I guess this demand will be right at the end of the wish list.

athurin
4-Participant
(To:Werner_E)

I understand you point. Like you say, everyone has different expectations and usages, and there is no "absolute" right implementation.

In my particular case, is there a way to force the result into a 1x1 matrix when there is only one answer, and leave it as-is if there are more ?

In my particular case, is there a way to force the result into a 1x1 matrix when there is only one answer, and leave it as-is if there are more ?

Yes, there is. But I just noticed that it can't be done with stack as I had suggested above. The reason is that you need symbolic evaluation and strange enough stack produces different results whether you evaluate it numerically or symbolically. This sure is not as it should be but we have to live with that flaw. With symbolical evaluation we get a nested matrix which we can't use for our purpose.

1.png

So we can do it using the if function. It would be more natural to use IsArray() or IsScalar() in the following routine, but unfortunately they won't work with symbolics.

2.png

If you think its more convenient you may also create a utility function make_Matrix() to do the job:

3.png

In Mathcad 15 we can create an even more useful function which does it all in one step, but unfortunatley this utilizes to use symbolic evaluation inside of a program and this does not work in Prime as they have broken it.

4.png

Sorry,

for a lot of Engineers (Mathcad users):

1 - real number

sqrt(-1) - imaginary number

1+sqrt(-1) - complex number

Now I see my error

Absolutely accurate and absolutely useless operator/

Valery Ochkov wrote:

Sorry,

for a lot of Engineers (Mathcad users):

1 - real number

sqrt(-1) - imaginary number

1+sqrt(-1) - complex number

And thats absolutely correct. But 1 can be called a complex number, too.

BTW, 1 is NOT an imaginary number as this term is usually used for complex numbers z with Re(z)=0 and Im(z) not equal 0.

Absolutely accurate and absolutely useless operator/

Agreed on!

Top Tags