Skip to main content
Best answer by Werner_E

@ValeryOchkov wrote:

I think it is an error! Wrong answer is more badly as an error message!


Its not an error, its just a function which behaves differently than you expected.

You won't call an answer given by "MinErr" as being wrong. You don't do this, because you know that "minerr" is not necessarily returning an exact solution to a problem but does its best to give you a "close solution".

The same is true with "lsolve". The difference only is, that you did not know that it also may give you just a close solution and not an exact one.

 

Of course you are free to think that a function with the word "solve" in its name should not be allowed to return an inexact (wrong?) least-square solution but rather should return an error in case of an inconsistent system. This may be a matter of personal taste and you can always open a case with PTC support and wait for them to change the algorithm behind "lsolve" - Good luck! 🙂 👿

 

I wouldn't get upset myself. I can live with the fact that the documentation clearly describes that "lsolve" may also provide approximate solutions and can remember that (well, hopefully I can remember that) and use the function accordingly.
My point was: Its not a bug, its not wrong, its not an error -  it works as specified!

3 replies

23-Emerald IV
October 13, 2021

It's a BUG in Prime!

Mathcad 11/Maple agrees with you:

LucMeekes_1-1634118994034.png

In Prime Express the lsolve function is a Premium function, so not available.

That can be amended with:

LucMeekes_2-1634119273682.png

And that gives:

LucMeekes_3-1634119322525.png

Much better than an expensive full license...

 

Success!
Luc

 

24-Ruby IV
October 13, 2021

Sorry, Luc!

We can not have an inverse matrix from not square matrix!

Read please your error message!

 

25-Diamond I
October 13, 2021

IMHO its not a bug and lsolve just works as expected!

According to the help its not necessary for M to be square and in case of an inconsistent system lsolve switches to a least-square solution (similar to geninv). Given Luc's screenshot of MC11 it looks like implementation has changed somewhere on the way from MC11 to MC14.
For more information about the usage and algorithm used you may look it up in "Numerical Recipes" and study the Mathcad E-Book "Inside Mathcad: Solving" (not available for Prime, of course).

Link to P7 help "lsolve" 

 

Playing around with MC15:

Werner_E_1-1634122761760.png

 

From MC15's help:

Werner_E_0-1634123655753.png

 

 

24-Ruby IV
October 13, 2021

I think it is an error! Wrong answer is more badly as an error message!

Werner_E25-Diamond IAnswer
25-Diamond I
October 13, 2021

@ValeryOchkov wrote:

I think it is an error! Wrong answer is more badly as an error message!


Its not an error, its just a function which behaves differently than you expected.

You won't call an answer given by "MinErr" as being wrong. You don't do this, because you know that "minerr" is not necessarily returning an exact solution to a problem but does its best to give you a "close solution".

The same is true with "lsolve". The difference only is, that you did not know that it also may give you just a close solution and not an exact one.

 

Of course you are free to think that a function with the word "solve" in its name should not be allowed to return an inexact (wrong?) least-square solution but rather should return an error in case of an inconsistent system. This may be a matter of personal taste and you can always open a case with PTC support and wait for them to change the algorithm behind "lsolve" - Good luck! 🙂 👿

 

I wouldn't get upset myself. I can live with the fact that the documentation clearly describes that "lsolve" may also provide approximate solutions and can remember that (well, hopefully I can remember that) and use the function accordingly.
My point was: Its not a bug, its not wrong, its not an error -  it works as specified!

24-Ruby IV
October 13, 2021

The lsolve function must work as a Find function!

mxv-Find.png

25-Diamond I
October 13, 2021

@ValeryOchkov wrote:

The lsolve function must work as a Find function!

 


This may be your opinion which is to be respected.
But the developers of Mathcad (after V11) had a different opinion and implemented a more generic algorithm.
So, as already written above, lsolve works like MinErr on purpose and can be used that way for inconsistent systems, too.

So the function works as intended and specified.