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

The community will undergo maintenance on October 16th at 10:00 PM PDT and will be unavailable for up to one hour.

lsove - error?

ValeryOchkov
24-Ruby IV

lsove - error?

This system has not solution. The lsolve must return an error message, not solution!

What do you think about this?

mxv.png

ACCEPTED SOLUTION

Accepted Solutions


@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!

View solution in original post

14 REPLIES 14
LucMeekes
23-Emerald III
(To:ValeryOchkov)

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

 

Sorry, Luc!

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

Read please your error message!

 

For those of us with Express that require pseudo inverses of non-square matrices.

LucMeekes
23-Emerald III
(To:Fred_Kohlhepp)

I read the P7 online help info on lsolve (thanks Werner). It appears that the geninv() function is not premium, so the implementation of lsolve for Prime Express can be done with:

LucMeekes_0-1634137165744.png

Then:

LucMeekes_1-1634137185572.png

QED.

 

Luc

Если нельзя, но очень хочется, то можно!

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

 

 

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


@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!

OK! The error is in word solve in the function lsolve name! Better is the LMinErr name!

Как корабль назовешь - так он и поплывет!
It is a name the chapter 23 of my book!
2⁵ Problems for STEM Education - 1st Edition - Valery Ochkov - Rout (routledge.com)

LucMeekes
23-Emerald III
(To:Werner_E)

The Mathcad 11 handbook says:

LucMeekes_1-1634129305262.png

The phrasing: "Returns a solution vector x such that M*x=v." leaves no room for approximations.

As of Mathcad 12 the overview table of functions has disappeared from the manual. And as shown by you, they've changed the functionality.

 

Luc

 

Werner_E
25-Diamond I
(To:LucMeekes)


The phrasing: "Returns a solution vector x such that M*x=v." leaves no room for approximations.

That depends on how you'd like to define "solution" in case of a non-consistent system and if you'd like to accept a least square solution as being a "solution".

But I, too, think that "lsolve" is a somewhat misleading name for a function which may return just a least square fit.

LucMeekes
23-Emerald III
(To:Werner_E)

It's not so much the definition of 'solution'. If the problem is: "Give the closest value of x such that M*x approximates v." then an approximated x can be a good solution to that problem.

It's the fact that x must be such that M*x = v. That's an 'equals' not 'approximates'.

 

Luc

The lsolve function must work as a Find function!

mxv-Find.png


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

 

Announcements

Top Tags