Skip to main content
10-Marble
November 19, 2025
Solved

Division by zero error

  • November 19, 2025
  • 1 reply
  • 537 views

Hi all, 

 

Can anyone suggest how to overcome the issue in the attached image. 

Currently using Mathcad Prime 10. 

 

Kind regards,

Iain 

Best answer by Werner_E

@IA_12699372 wrote:

Thank you, I don't have a copy of the Mathcad original sheet. Asking for a colleague. 


So he has to say what the outcome should be in which case and he may be able to provide a worksheet to play with.
He may also ask here himself which could make it easier for him and us. After all taking part in this forum is free anyway.

 

As I already wrote I see two ways to go. Either trap the error using "try..on error" or avoid the division by zero by adding an additional "if". In both cases we would have to know what the result should be and if we have to distinguish between 'nominator is zero as well" and "nominator is different from zero" or not.

 

EDIT: Here are two implementations. Both distinguish between 'nominator equals zero' or not in case of denominator is zero. If this is not necessary you may just replace the last "if" by the desired return text.
The second looks much smaller because I used the "if" function instead of the "if" program statement. Of course we could use either "if" in both versions.

As you can see I prefer using functions  as its more versatile and also makes it easier to demonstrate the various situations.

Werner_E_2-1763569830185.png

 

 

1 reply

25-Diamond I
November 19, 2025

You may use "try ... on error ..." to catch the division by zero.
Or you may use an additional "if" statement and ask if the denominator is zero.

In any case you will have to decide what the return value should be.

What is should be in case of  (0 kN) / (0 kN) as in your picture and what it should be in case of, lets say, (10 kN)/(0 kN).

 

In case you still have difficulties implementing either the "try ... on error" or he additional "if" I would suggest that you clearly state which outcomes you expect in which case and that you attach your worksheet so we can show how to do it.

10-Marble
November 19, 2025

Thank you, I don't have a copy of the Mathcad original sheet. Asking for a colleague. 

10-Marble
November 19, 2025

See attached issue in Mathcad.