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

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

Error messages in Solve Blocks

0 Kudos

Error messages in Solve Blocks

Hi all,

I'm investigating improving error messages in solve blocks. I've been gathering examples of solve block issues from examples posted in the Community pages. If you have examples of solve blocks with unclear messages, please post them here or email them to me directly at -.

I know the most common error message is "undefined variable." What I'm trying to pull together is common situations that cause errors so we can write more helpful messages.

I have noted that some common issues include:

  • using matrix indices instead of literal subscripts
  • missing constraint equations
  • incompatible units
  • missing definitions
  • defining guess values with Ctr+= instead of :=

Thanks,

Mona

7 Comments
RichardJ
19-Tanzanite

I know the most common error message is "undefined variable."

It's the only error message!

What I'm trying to pull together is common situations that cause errors so we can write more helpful messages.

Does anyone at PTC still have access to the code for version 11 or earlier? The error messages were not great even then, but there were a lot more of them than just "undefined variable". If someone has access to that code they could fish the error messages from there.

In many cases it would be simple to return a more meaningful error message. It is frequently the case that if I simply evaluate an expression that is inside the solve block I get a useful error message. For example, I might have

Given

a=b+c

Find c=

where b and c have incompatible units. The solve block gives the error "undefined variable", but if you simply evaluate the expression

a=b+c=

You get the correct message. So many of the error messages are already available; someone just has to write the code to trap the error in the right way. The only error messages you should have to worry about are ones specific to solve blocks:

Failed to converge

Not enough equations for the number of unknowns

Too many equations for the number of unknowns (in the case of find)

Equations are not independent

etc

And, in Prime please make assignments inside solve blocks illegal again, as they used to be. Allowing this has lead to nothing but confusion, and I see no benefit to it.

mzeftel
1-Newbie

Hi Richard,

We know about the old error messages. I'm looking for examples of solve blocks that fail, so we can build improved error messages.

I'm not clear on what you mean about how assignments have changed in solve blocks. I'm aware that we made the definitions inside solve blocks be local assignments only. That doesn't sound like what you mean. This is the first I've heard of this issue, so can you provide an example.

Thanks,

Mona

RichardJ
19-Tanzanite

We know about the old error messages. I'm looking for examples of solve blocks that fail, so we can build improved error messages.

Sorry. Not the sort of thing I keep

I'm not clear on what you mean about how assignments have changed in solve blocks. I'm aware that we made the definitions inside solve blocks be local assignments only. That doesn't sound like what you mean. This is the first I've heard of this issue, so can you provide an example.

Definitions (i.e. what you get with ":") did not used to be allowed in solve blocks. If you put one in you got an error message (on the definition, not the terminating expression of the solve block) saying "This is not allowed inside a solve block,. For example, definitions are not allowed in a solve block". At some point, I forget exactly when, that was changed, so now they are allowed. The problem is, they do not have any effect on the solve block whatsoever (as far as I can tell, anyway). It's exactly the same as putting the definitions before the solve block. Many examples have been posted where people do not realize this though. They either put definitions where they should put = (i.e Boolean equals), or they put both, assuming that the definitions are evaluated at every iteration of the solver and therefore have some effect on the answer. They are not, and they don't. I don't know why the decision was made to allow definitions inside solve blocks, because it has not made solve blocks any more powerful, but it has lead to a great deal of confusion.

mzeftel
1-Newbie

Richard,

The definitions that are allowed inside the solve blocks in Mathcad Prime are guess values. They can also fall before the solve block. We added the labels to clarify for people what each part of the solve block contains. In going through old posts about solve block errors, I found that many people in older versions of Mathcad used the Boolean equals instead of definitions for guess values.

I plan for us to design error messages that are smart enough to catch that situation and other mismatches of contraints.

As you know the solve block need a guess value to know where to begin so I'm not sure what you are proposing.

Mona

RichardJ
19-Tanzanite

Hopefully this will clarify the problem.

The second solve block in the Mathcad 15 file was not always permitted, and in my opinion should never have been permitted. It is extremely misleading!

None of the solve blocks in the Prime worksheet should be allowed as written. The guess values should be above the equalities. The assignment of x:=y^2/4 does nothing except change the guess values, and is misleading. The solver does NOT take the y from the first equality and use it to calculate a new x for the second equality! It behaves as if the definition were above both equalities, and that is the only form that should be permitted. The third solve block is the same as in he MC15 worksheet, but Prime compounds the Mathcad 15 problem by restricting the scope of the second definition of z(x,y) to the solve block. If the function definition is permitted at all in a solve block (and I would argue it should not be permitted) then it should not be allowed between the equalities. It, along with the guess values, should only be permitted above the equalities.

mzeftel
1-Newbie

Thanks Richard,

We'll discuss these examples.

It's always helpful to have specifics.

Mona

olivierlp
Community Manager
Status changed to: Archived

Hello,

We are archiving your idea as part of a general review. This action is based on the age of your idea and the total number of votes received, as per this announcement.

You can always post a new idea with all the details required in the form.

Thank you for your participation.