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

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

Meaningful Error Messages

Efried
1-Newbie

Meaningful Error Messages

Hello,

allow me to explore if Mathcad V15 will bring me some relief in cosntrast to V14 M020.

I'm struggling with a 4p long code (programm). It had started to claim that units were different that they should be. After killing the (correct) expression and replacing it by "1", the complete code turned red....

So I'm searching for an imprveenet of the situation, which might be caused by sheer size of the program or list of variables and functions handed over?

Attached the version I started from and got deeper into trouble...

thanks

1 ACCEPTED SOLUTION

Accepted Solutions

Does Mathcad ignore the units because the numerical value is zero?

That's exactly why it does it. When Mathcad sees 0*anything, it doesn't bother to check what "anything" is, and just returns 0. I was told, many years ago, that this was because 0*anything is always 0, and so not calculating "anything" (which could be a complicated expression), saves time. I wouldn't argue about the time savings, but 0*anything is not always 0. The example above is only one nasty side effect. Consider this function (name chosen quite deliberately!)

BS(x):=x/x

evaluate that for x=0, and you get the answer 0, which is wrong (it is of course undefined).

View solution in original post

52 REPLIES 52
RichardJ
19-Tanzanite
(To:Efried)

The size of the program shouldn't make any difference. It's hard to say anything based on a pdf with most of the worksheet erased.

You have a large number of return variables at the end. Does it work if you remove all but one of them?

Hi,

many thanks for your endevour.

Sorry neither solutions worked

- complying to the error mesages turned the whole code into red finally

- deleting output variables

- reducing output vestor by one row

uploading the file alone will not help since there are other mathcad files embedded.

Interestingly the calling code says variable not existing meaning the function, so the programm itself is rotten...

best regrads

RichardJ
19-Tanzanite
(To:Efried)

- complying to the error mesages turned the whole code into red finally

Sorry, but I don't know what you mean.

- deleting output variables

- reducing output vestor by one row

Did you try deleting all of them except for one? i.e. replace the vector with only, for example, W.Sp.

Interestingly the calling code says variable not existing

You mean "Variable Undefined"? You said in your first post that the error was about units.

Sorry I'm working with the German version so translating might confuse...

Richard Jackson schrieb:

- complying to the error mesages turned the whole code into red finally

Sorry, but I don't know what you mean.

I removed all the stuff Mathcad was complaining radically about and suddenly the whole program was red

By

- deleting output variables

- reducing output vestor by one row

Did you try deleting all of them except for one? i.e. replace the vector with only, for example, W.Sp.

Yes I did, without any change.

Interestingly the calling code says variable not existing

You mean "Variable Undefined"? You said in your first post that the error was about units.

Yes it seems so but the calling code identifies the programm function as unknown.

RichardJ
19-Tanzanite
(To:Efried)

What happens if you replace the statement

if (W.Spnn+DeltaW) < W.ED

with

if 1 < 2

?

I played this game replacing every complaint by 100% acceptable code - after replacing all equations where W.ED is included, the complete programm turns red....

Gerfried

RichardJ
19-Tanzanite
(To:Efried)

Then sorry, but without the worksheet I don't think there is anything else I can do. The problem (or problems) could be anywhere in the program, or even somewhere else in the worksheet above. It's not possible for me to find it with just that pdf to work from.

may I send you the file(s) in an email?

thanks

MikeArmstrong
5-Regular Member
(To:Efried)

may I send you the file(s) in an email?

thanks

I'm sorry for the rant, but this thread is worthless. If you wanted to go down the route of getting help privately, why didn't you contact one of the experienced users directly and requested help?


Mike

RichardJ
19-Tanzanite
(To:Efried)

Sorry, but I answer questions in emails only for friends any paying clients. The reason for that is simple: I have no obligation to answer a question posted to the forum, and can drop out of the discussion at any time, even if I have already said something. There are also other contributors to share the work. If the question is in an e-mail the burden is on me only, and I do not necessarily have the time to deal with it.

Efried
1-Newbie
(To:Efried)

Sad story.

I asked whether V15 will bring relief and I tried it out now. The answer is no - the differences between V15 and V14 are zero in this respect.

I can only give advice to programmes NOT to use mathcad, because the debugging support is so limited. Error messages almost meaningless.

You are lucky if Mathcad does not freeze - at least the behaviour is odd turning totally red....

RichardJ
19-Tanzanite
(To:Efried)

The problem is not Mathcad, it's a bug in your program. That is not going to go away just because you switched from 14 to 15. And although Mathcad's debugging features are not that great, they do exist. I agree the error messages in Mathcad are often either useless or misleading, but that only makes finding the bug slightly harder. It doesn't mean the bug can't be found.

Post an image of the "all red" program, and tell us what the error message is.

I'm sorry there is no error message - just the complete programm block is red.

It seems that the error messages concerning units are wrong, tht's no helpful at least.

I have to think about a reverse debugging strategy building the programm from scratch again and checking out when troube starts...

regards

RichardJ
19-Tanzanite
(To:Efried)

Go through the program and make a list of every variable that is either passed as an argument to the program or that the program picks up from the worksheet (variables that are locally defined in the worksheet do not matter). Evaluate all of those variables directly above the program. Copy and paste the results of the evaluations (with any units!) into new variable assignments with the same names, directly above the program.. Now copy and paste all of those assignments and the program to a new worksheet. Post the worksheet.

RichardJ
19-Tanzanite
(To:RichardJ)

(variables that are locally defined in the worksheet do not matter).

Duh! In case you didn't already guess, that should read "(variables that are locally defined in the program do not matter).

http://communities.ptc.com/servlet/JiveServlet/showImage/38-1286-6353/Duh.gif

MikeArmstrong
5-Regular Member
(To:Efried)

No worksheet = No help

Mike

Thanks for offering help- the programm is that complex that I would have to pay you for wading through it 😉

MikeArmstrong
5-Regular Member
(To:Efried)

Thanks for offering help- the programm is that complex that I would have to pay you for wading through it 😉

Shame.


The thing is, if a worksheet would have been posted in the first place a solution might have been found.


Mike

Hi there,

I took the freedom opening the xml in an editor and found the caues of the dilemma I think:

Mathcad incorporated some unit errors- what is stored as >tonne< in the variable list, reads "ti" in the worksheet.

I think I deserve a correct working Mathcad version!

<region region-id="7893" left="1692" top="11067" width="827.4" height="635.4" align-x="2383.8" align-y="11076" show-border="false" show-highlight="false" is-protected="true" z-order="0" background-color="inherit" tag="">
<math optimize="false" disable-calc="false">
<ml:define xmlns:ml="http://schemas.mathsoft.com/math30">
<ml:function>
<ml:id xml:space="preserve">Steuerung</ml:id>
<ml:boundVars>
<ml:id xml:space="preserve" subscript="max">n</ml:id>
<ml:id xml:space="preserve" subscript="nEA_m">P</ml:id>
<ml:id xml:space="preserve" subscript="MotGen">η</ml:id>
<ml:id xml:space="preserve" subscript="Mot">η</ml:id>
<ml:id xml:space="preserve" subscript="EArel">n</ml:id>
<ml:id xml:space="preserve" subscript="nEA">U</ml:id>
<ml:id xml:space="preserve" subscript="nED">U</ml:id>
<ml:id xml:space="preserve" subscript="nGenS">U</ml:id>
<ml:id xml:space="preserve" subscript="BB">eff</ml:id>
<ml:id xml:space="preserve" subscript="antr_m">P</ml:id>
<ml:id xml:space="preserve" subscript="frei">W</ml:id>
<ml:id xml:space="preserve" subscript="erf">W</ml:id>
<ml:id xml:space="preserve">tonne</ml:id>
<ml:id xml:space="preserve" subscript="nGenS_e">P</ml:id>
<ml:id xml:space="preserve" subscript="ED">W</ml:id>
<ml:id xml:space="preserve" subscript="ED">C</ml:id>
<ml:id xml:space="preserve">ESR</ml:id>
<ml:id xml:space="preserve" subscript="l">I</ml:id>
<ml:id xml:space="preserve" subscript="start">W</ml:id>
<ml:id xml:space="preserve" subscript="Soc">f</ml:id>
<ml:id xml:space="preserve" subscript="SocZH">f</ml:id>
<ml:id xml:space="preserve" subscript="ZH">a</ml:id>
<ml:id xml:space="preserve">GenSBer</ml:id>
</ml:boundVars>
</ml:function>
<ml:program>

RichardJ
19-Tanzanite
(To:Efried)

If you evaluate "t" directly above the program, what do you see?

t was defined as time- but I chande this and omitted to use t - I'm using t.x instead.

I'm insiting that the error messages are random - if I remove part of the code other odd messages pop up and in the end everthing turns red...

As saif it si not easy to allow you insight into the code- since they are many interconnnected files.

Gerfried

RichardJ
19-Tanzanite
(To:Efried)

t was defined as time- but I chande this and omitted to use t - I'm using t.x instead.

You are using t.x above the program, in the worksheet, or in the program? The only version of the program you have shown uses t. The XML you showed is for a program that uses t.

I'm insiting that the error messages are random - if I remove part of the code other odd messages pop up and in the end everthing turns red...

They are not random. They might be wrong (although I am not convinced of that), but they are not random.

As saif it si not easy to allow you insight into the code- since they are many interconnnected files.

I explained how to deal with that.

And I would still like to know what you see if you evaluate t directly above the program (the program that contains t, and for which the XML shows tonne). Helping you with no worksheet is hard. Helping you if you will not answer the questions is impossible.

MikeArmstrong
5-Regular Member
(To:Efried)

We now have over twenty posts in this thread and no worksheet.

The thread is detailed as 'Answered', but the answer is not shown.

Mike

The thread is detailed as 'Answered', but the answer is not shown.

It's a weirdity of the forums. The thread gets marked as answered even if the only answer was a "helpful" one, rather than a "correct" one.

Hello,

the thing is:

The programm needs two include files some data files and has 8MB alone...

How to handle that in this forum context?

Gerfried

RichardJ
19-Tanzanite
(To:Efried)

Do what I suggested. Evaluate the relevant variables directly above the program, and copy and paste the answers into new variable definitions. Then everything above the program is no longer required.

sorry I'm handing over functions to the programm and lately the programm without calling it reporst errors so I can post it.

thanks in advance

RichardJ
19-Tanzanite
(To:Efried)

It is indeed a units problem. Two of them in fact.

You are returning a large vector of values at the end of the program, and the static unit checking is picking up on the fact that it is not possible for the units in that return vector to all be the same, You can't mix units in matrices or vectors. Although the root problem here is really just a single problem, it appears to be many, because the only way to fix it in the body of the program is to fix it for one variable, but doing so then screws up the units for another variable! The whole problem looks especially complicated because you have many if statements, and the final units for a given variable must be the same for all possible paths through the program. Consequently, if you fix the units for one variable in one path, it may now conflict with the units in another path! You can put the return vector back at the end, but you must divide each entry by the correct units, so that the program just returns a vector of numeric values. Then after the program you will have to put the units back on again. Sorry, but there is no way around this problem. On the upside, this problem does not exist in Prime, because it allows mixed units in matrices (so we do sometimes get what we ask for, even if it does take ten years of begging!).

Once that problem is fixed you have one other unit issue, which I fixed and flagged.

I have no way to know if the program now actually returns the values you think it should, but at least the unit errors are resolved.

hello,

thats really nice to step into my problem.

But I have to reject the allegations with regards to unit handling 😉

1) the return vector is corrected as you may see so all variables have "J" as unit

2) if you don't remove the unit W but exchange TOL by 0 in the P.antr_m[nn]<-TOL W the same healing of the programm occurs (after removing the return block)

3) there is another comparison of P.antr_m[nn] some lines before using 0 W

Tomorrow morning I will give your hint a new trial, may be I have hidden errors in my code which worked before but I applied to many changes at once...

best regards and thanks again

Gerfried

Top Tags