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

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

Issue with solving system of equations in mathcad prime 8

DSE514
10-Marble

Issue with solving system of equations in mathcad prime 8

Hi,

 

So I'm struggling to understand exactly what is the issue that is occurring that is stopping the system of equations below from solving. I know that it is solvable, I did it by hand, and I have the answers for verification. However, it is in the software claiming to be unsolvable. Am I entering it in improperly?

 

soe issue.PNG

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:Werner_E)

OK, I played around with this puzzle:

The solve block fails when using square roots and variables with units

Werner_E_0-1666351011454.png

Getting rid of the roots does not help

Werner_E_1-1666351038879.png

Getting rid of the units does not help, either

Werner_E_2-1666351068303.png

BUT .... getting rid of roots AND units does the trick

Werner_E_3-1666351108847.png

Because we squared we get also negative solutions which we can get rid of by using the modifier "Assume, ALL>0"

Of course we must add the correct units manually

 

Werner_E_8-1666351631046.png

 

I was curious and tried the old symbolic engine (muPad) which was included up to version Prime 6. Not surprisingly its a bit more capable than the new one. It still throws a strange error initially ("Cannot understand the syntax") but we get results by either removing the units OR removing the roots:

Werner_E_9-1666352111694.png

 

View solution in original post

25 REPLIES 25
LucMeekes
23-Emerald III
(To:DSE514)

This should not be a problem. Mathcad 11 gives:

LucMeekes_2-1666287415343.png

With Prime you might try:

LucMeekes_3-1666287549043.png

Apparently Prime doesn't like roots (it's not a rabbit).

 

Success!
Luc

 

 

Thanks, this got rid of the Error! Problem is, a new one popped up, and I have no idea what it is (I cannot find anything about it online). Any ideas?

 

new error.png

 

Werner_E
25-Diamond I
(To:DSE514)

My guess is that Prime's Symbolic is also unable to cope with the units assigned as it does not know anything about units. If you want to use the symbolic "solve", then better without numeric values at all, as shown by Luc.
But in the concrete case no symbolic solution is needed at all. A numeric solution block will do as well:

Werner_E_0-1666297109939.png

 

Strib
12-Amethyst
(To:Werner_E)

Prime may be confused by your subscripts, thinks they're a vector index.  I got the same thing. 

Without subscripts there's no problem:

LucMeekes
23-Emerald III
(To:Strib)

That wasn't the problem of the OP. This is:

LucMeekes_0-1666303647548.png

Luc

Strib
12-Amethyst
(To:LucMeekes)

You're right, Luc.  But his second posting using your reformulated expressions without radicals gave a different error.  I used the same without any subscripts and get no error. 

Not sure what was different - you got a clean result also even with the subscripts.

Werner_E
25-Diamond I
(To:Strib)

The problem are not the subscripts but rather the variable with values inclusive units assigned to them!

I again propose a numerical approach using "root" or a solve block as shown above.

Or use a pure symbolic approach and assign the result to a function with f.r, Q etc. as its arguments.

DSE514
10-Marble
(To:Werner_E)

Okay, so I would like to ask if I understand this correctly: Due to limits with the design of prime with how it interacts with units, the original way that I was trying to solve cannot be done? If so, okay, that's something I can just adjust for.

 

As far as the solutions given, I actually tried the solve block method prior. However, when I did so, I would get this error where the solution from the solve block could be seen by evaluating it, as you shown in your example. However, when I would try to use it later in a symbolic solver, it would not register the variable as being initialized. I can simply use block solves to get around this issue, but they take up a ton of space on the document. Is there any way of getting around this, or is this just a hard limit on the software?

Werner_E
25-Diamond I
(To:DSE514)

I may be wrong but it looks to me that Primes symbolics is not able to cope with your simple equations when the other variables already have assigned quantities with units. So you either use the symbolic solver before you assign values or you may clear.sym(...) to make the assigned values unavailable for the symbolic engine and add them later again to get a numeric result.

Something along these lines:

Werner_E_0-1666348129156.png

To avoid having to copy and paste the symbolic result to evaluate it symbolically later, I defined a function getC(..) and used this function to give the variable c the desired value.

 

According using a solve block result in later symbolic evaluations: On contrary to real Mathcad, Prime has lost the ability to symbolically evaluate a solve block. Thats the reason symbolic caculations using numeric result from a solve block fail.

You may trick Prime by writing something like L.r:=L.r= after the solve block. You redefine L.r as being L.r and follow the assignment by a numeric evaluation. This stops the symbolic from trying to evaluate the solve block.
Here is simple example:

Werner_E_1-1666348821586.png

 

 

Werner_E
25-Diamond I
(To:Werner_E)

OK, I played around with this puzzle:

The solve block fails when using square roots and variables with units

Werner_E_0-1666351011454.png

Getting rid of the roots does not help

Werner_E_1-1666351038879.png

Getting rid of the units does not help, either

Werner_E_2-1666351068303.png

BUT .... getting rid of roots AND units does the trick

Werner_E_3-1666351108847.png

Because we squared we get also negative solutions which we can get rid of by using the modifier "Assume, ALL>0"

Of course we must add the correct units manually

 

Werner_E_8-1666351631046.png

 

I was curious and tried the old symbolic engine (muPad) which was included up to version Prime 6. Not surprisingly its a bit more capable than the new one. It still throws a strange error initially ("Cannot understand the syntax") but we get results by either removing the units OR removing the roots:

Werner_E_9-1666352111694.png

 

Strib
12-Amethyst
(To:Werner_E)

Excellent - makes more sense.  Do miss the old symbolic engine.

Yeah... always beware when multiplying by the unknown variable(s)  - introduces additional solutions.

DSE514
10-Marble
(To:Werner_E)

So now I'm just straight up confused. When I opened your document, it loaded and worked perfectly. I literally copied the entirety of that symbolic solve without the assume modifier into my document, and regardless, I'm getting the factor error. It however, works perfectly in your document. 

 

I honestly do not understand what is the issue at hand, I'm so lost

Werner_E
25-Diamond I
(To:DSE514)

"factor error" ???

whats that?

 

All I could think of is that you copied the expressions at a position where one or both variables which are solve for had been assigned a value before. If thats the case you may try clear.sym(L.r,C.r) in front of the symbolic evaluation. But this could also be seen explained in the sheet I attached and so I guess its not the cause of the problem.

 

P.S.: My sheet was created in Prime 6 but using the new engine which is the same as in Prime 7 and 8 but it may have been improved/modified. Using Prime 6 enabled me to also test how the old engine (muPad) performs, but the sheet I attached was set up using the new engine. Does this sheet work OK, too, if you let it recalculate (F5)?

 

DSE514
10-Marble
(To:Werner_E)

So they were placed in the same approximate spot on the worksheet. The error in question is this one:Screenshot 2022-10-22 212722.pngScreenshot 2022-10-22 212806.png

 

It's the exact same error that I was originally seeing in the OP. The second image is from your sheet, where it's showing the same error, so I believe that the problem with that and whatever is going on stopping me in my worksheet is the same issue. The first image in your worksheet works as you shown however. As far as why it works in yours, but not in mine, I have zero idea. Maybe it's using prime 6 legacy code on yours?

Werner_E
25-Diamond I
(To:DSE514)

If you can you may post your worksheet and I'll have a look. But I can only "convert" it to Prime 6 format and try to open it there. The symbolic engine is the same in P6 and later versions, but it sure may be that they "improved" that engine and in doing so did brake things which were working in P6.

But then, if my worksheet is working OK when you open it in P8, then I guess that the problem is not Prime 8 but rather something which you may have defined in front of the position you inserted the expression OR it also may be that Primes auto-labelling bug has struck once again. Maybe the labelling of some variables was changed in the process of copying. Check, if ALL occurrences of L.r and C.r are still labelled "Variable" and not "-" (check also the variables after "solve").

Werner_E
25-Diamond I
(To:DSE514)

Ahhh, I guess I got it!

I forgot to advice you to turn on "Units/Constants in Symbolics" in the "Calculation Options"!

Its turned on in my sheet and probably not in yours.

When I turn it off I get that strange error as well!

Werner_E_0-1666492756970.png

 

 

DSE514
10-Marble
(To:Werner_E)

 I already actually had that on due to a prior tango with the symbolic solver. Turning it off didn't help sadly.

 

EDIT: So I actually played around with the solver again this morning. After trying to rework the variables, I then just added the modifier to see what would happen. I got a solution finally, this:

Screenshot 2022-10-23 094205.png

Trying to evaluate Lr and Cr results in nothing. So I tried to copy and paste your version, and it doesn't recognize Lr and Cr, so whatever is happening now, I think it's linked. 

Werner_E
25-Diamond I
(To:DSE514)

Its hard to say anything more without seeing the failing sheet.

As already written I could reproduce the "MULTFACT.." error message when I turned OFF the option "Units/Constants in Symbolic". Turning it ON again made the expression work OK once more.

When Lr and Cr are not recognized a reason may be that some of them are labelled differently - just a weak guess.

What I see in your picture is that the unit kHz was not cancelled and still appears in the result. This should not happen! Obviously f.r is not replaced by the value you assigned to it. Did you assign a value (in kHz) in your new sheet?

I further notices that you wrote "Solve" with a capital "S". AFAIK this should throw an error.

EDIT: I just played around and found that "Solve" actually is indeed not recognized keyword, but behaves strangely if used in combination with "assume,ALL>0".

Werner_E_1-1666534904922.png

But nonetheless it would replace variables with the values as can be seen with "a". So there seems additionally something wrong as in your pic f.r was not replaced!

DSE514
10-Marble
(To:Werner_E)

So I'll link the most up to date version of the sheet here in this reply. For the record, there's no updated value for kHz, it's just the stock one in prime.

 

I did try your suggestion of changing "Solve" to "solve", but that didn't change anything.

Werner_E
25-Diamond I
(To:DSE514)

The frequency f.r is NOT defined anywhere in your sheet!

That, as already suspected in a former post of mine, seems to be the difference between the sheet I posted where the expression worked OK and your sheet, where the copied expression does not work.

 

While I tend to second Luc's advice, I also realize that this may mean that you end up with a lot of functions with ahuge number of arguments which may make expressions quite unclear and unreadable. So it depends.
If numeric results are all you want I still suggest using numeric methods like the "root" function or a solve block. Unfortunately solving systems of equations is only possible to do with the ugly looking and space consuming solve blocks and providing suitable guess values can be demanding for some systems.

You equations really aren't too complicated and I don't understand why Primes symbolics has that much troubles dealing with them (even without f.r being defined it should be able to provide a symbolic result). But the capability of the symbolic engine is quite limited and its very likely that sooner or later you end up with equations (maybe of higher order or where the variable is inside a log function and outside, too)  the symbolic isn't able to solve symbolically and you are forced to numeric methods anyway.

 

LucMeekes
23-Emerald III
(To:DSE514)

My advice in general is that, if you want to work symbolically, then work with symbols only. So in your case: First solve the problem symbolically:

LucMeekes_0-1666539600515.png

Then define your inputs, and use units as you please:

LucMeekes_1-1666539631150.png

With that you can calculate the results:

LucMeekes_2-1666539655270.png

 

Success!
Luc

So I actually figured out what was stopping my setup! I did not realize it, but I forgot that I renamed Fr above in the sheet, and that is what was causing the problems. Once I fixed that, it solved. I tried your method as well, and it had the same issue when I had it incorrectly labeled, but when I fixed it, it solved all the same.

 

I will keep this advice in mind though. This symbolic solver seems to be very finicky, even when everything is labeled correctly. Thanks!

Werner_E
25-Diamond I
(To:Strib)


@Strib wrote:

Prime may be confused by your subscripts, thinks they're a vector index.  I got the same thing. 

Without subscripts there's no problem:


No, sure not. Prime is mediocre but not that much 😉

You have to assign the values inclusive the very same units as seen in the original sheet and see you approach failing as well.

Strib
12-Amethyst
(To:Werner_E)

Ah...  my bad for not downloading and looking at OP's entire mcdx model and the assigned units.

ttokoro
20-Turquoise
(To:DSE514)

Assume, ALL>0 does not work. The one way that we want to get.

 

image.pngimage.pngimage.pngimage.png

Announcements

Top Tags