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

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

Roots of polynomial #3 and How to find unique values into a vector/matrice?

Cornel
19-Tanzanite

Roots of polynomial #3 and How to find unique values into a vector/matrice?

Hi,

How to find all roots of this equation:

Cornel_0-1727076079588.png

ACCEPTED SOLUTION

Accepted Solutions
ttokoro
20-Turquoise
(To:Cornel)

image.png

Depend on TOL. So need UniqueP function to select 4.

image.pngimage.pngimage.pngimage.png

View solution in original post

9 REPLIES 9
Cornel
19-Tanzanite
(To:Cornel)

Hm...I think I found a way:

Cornel_0-1727076572586.png

 

We can see that only these 4 values (roots) are repeated: -0.439-1.077i, 0.584-0.431i, 0.274+0.784i, and -0.648+0.852i.

Now I am interested in how to extract/retain only those unique 4 values?

Cornel_2-1727076785580.png

ttokoro
20-Turquoise
(To:Cornel)

image.png

Depend on TOL. So need UniqueP function to select 4.

image.pngimage.pngimage.pngimage.png

Cornel
19-Tanzanite
(To:ttokoro)

A(x) is not an array?

I do not know how to think at the differences between the two. I see that when defining x as not integer values (0.1, 0.2, 0.3, etc), then I cannot use like Cx and also I cannot use further UniqueP function. On the other hand when defining range variable as y (1,2,3, etc, integer values), then I can use UniqueP function but only when defining with matrix index as B. Maybe someone can explain a little bit this function UniqueP, and also why I cannot use A(x) with UniqueP function.

Cornel_2-1727161703325.png

StuartBruff
23-Emerald III
(To:Cornel)

You cannot, I repeat cannot, use a non-integer range definition to index a Mathcad array.  You can only use integers in the range ORIGIN .. 2^31-2 to index a Mathcad array.

 

Consequently, Cx fails because x is a real () range variable.  By succeeds because y is an integer () range variable.  The first element of B is zero because you didn't define it (your ORIGIN = 0, but y starts at 1; all undefined elements with valid indices have the default value of zero).

 

A range variable is NOT a vector; it is a separate data type. Consequently, it is that rare beast that may look like a duck and even walk like a duck occasionally but is most definitely not a duck. 

 

When Mathcad sees a range variable on the left hand side of an evaluation or definition operator it treats the range variable as an iterator over the implied sequence given by the range definition (range operator with values).  When you evaluate A(x) and D(y), Mathcad iterates over x and y and applies A and D to those values individually and writes the result to the screen individually. 

 

What you then see on the worksheet looks very much like a vector but is actually best thought of as a list of separate values stacked on top of each other. So,, when  you try to apply UniqueP to A(x), what's really happening is that Mathcad is trying to apply UniqueP to A(x) for each single value of x in turn; as A(x) returns a scalar and UniqueP expects to see an array (to take the row of), Mathcad raises an error. 

 

Now, B really is a duck, sorry vector, so UniqueP is happy with it and returns the expected value.

 

Range Variables - confusing Mathcadders for over 30 years.

 

Stuart

 

LucMeekes
23-Emerald III
(To:Cornel)

LucMeekes_0-1727113676435.png

LucMeekes_1-1727113691494.png

LucMeekes_2-1727113735783.png

Success!
Luc

 

Werner_E
25-Diamond I
(To:LucMeekes)

Interesting!

Needless to say that the symbolic solve does not work that way in non-MC11 versions.
The symbolic would switch to float mode and returns just one solution.

Based on the graphic, it is difficult to say whether the four spikes only 'touch' the floor plan at one point (just four solutions), or whether they penetrate it and the solution consists of four circle-like shapes. In the latter case, however, there would be an infinite number of solutions, not just 43... Can you plot the solutions in the Gauß-plane?

Werner_E_0-1727122883973.png

 

LucMeekes
23-Emerald III
(To:Werner_E)

I guess you want to see this:

LucMeekes_0-1727130223029.png

or (sorted on angle) like:

LucMeekes_1-1727130262777.png

 

Success!
Luc

 

Werner_E
25-Diamond I
(To:LucMeekes)

Thanks.

What I had in mind was an xy-plot Im(sroots) over Re(sroots). Just unconnected points.
Guess thats basically what your second plot shows.

Interesting that it seems to not correspond with the 3D plot I made.

I also used uno's implicitplot2D to plot the zeros of the absolute values of f(z). But it did not find any, probably because of numerical inaccuracies. but when I look for complex arguments with |f|=0.5, I get a result which corresponds perfectly with the four (and only four) solutions found:

Werner_E_0-1727152679067.png

 

Werner_E_1-1727145734136.png

Complex-Roots.gif

I also plotted the zeros of Re(f) and Im(f) and it indicates, too, that there are only four solutions.

Werner_E_2-1727145923101.png

Worksheet in Mathcad 11 format attached

 

What do you thing that the many solutions which the symbolics in MC11 had found stem from?
Did you check the function values of your solutions vector?

 

 

 

LucMeekes
23-Emerald III
(To:Werner_E)

Good point, I forgot to check the roots. As it appears of that long list, only the last four seem to come close to 0:

LucMeekes_0-1727197800163.png

that makes the four roots to be:

LucMeekes_1-1727197960197.png

LucMeekes_2-1727198075789.png

or, in the total picture:

LucMeekes_3-1727198192342.png

I think Mathcad/Maple used the polyroots function on the polynome:

LucMeekes_4-1727198341935.png

And this was caused by the fact that I set the function up with all integers (writing 16/10 instead of 1.6 etc.)

Considering that the undocumented trick using solve as a symbolic function gives:

LucMeekes_5-1727198366459.png

Now I see where 43 roots came from.

Ok, with the function defined with fractional exponents (1.6, -2.7) I get only a single root:

LucMeekes_6-1727198604363.png

Which is just the first (!) of the long list, and not a root at all.

Conclusion: Care must be taken with such expressions.

 

Success!
Luc

Announcements

Top Tags