# Best response from calculator for uncomputable expression

What should be the best response from a calculator or computer algebra system when it can't evaluate given expression ? Some examples:

``````LibreCalc         : =๐รท๐คฃ  โ Err:501
Ubuntu Calculator : ๐รท๐คฃ   โ Malformed expression
Wolfram Alpha     : ๐รท๐คฃ   โ Wolfram|Alpha doesn't understand your query
Maxima            : maxima --very-quiet -r '๐รท๐คฃ;' โ ๐รท๐คฃ
``````

Now my personal impressions about these responses:

Err:501

Some cryptic error code which doesn't say anything about issue at hand. You must then read manuals to understand what's going on. And from version-to-version this error code can change.

Malformed expression

This tries to argue that my given expression is somewhat BAD. But you can't be sure about it. It may be bad OR simply calculator engine don't have an internal knowledge how to compute that expression. So this response is too categorical.

This is much, much better. Shows that computation engine can't parse requested expression. Of course if I would get such answer from a human, I would ask "What you don't understand exactly ?" So still not 100% right.

๐รท๐คฃ

I choose this as a winner. This program tries to be mathematically correct in each and every way. Every man on the world knows that expression is equal to itself : `x=x`. So if you can't evaluate given expression - at least output to the user original expression. It respects my feeling
"Do something !". And it does (at least what it can)

What do you think ?

• I, for one, have no idea what you mean by this: "Every man on the world knows that expression is equal to itself : x=x". Your assumption there is already wrong. Oct 23, 2018 at 8:13
• You can output original (un-evaluated) expression as an answer. And technically it would be a valid answer, albeit not calculated Oct 23, 2018 at 8:43
• Ah, now I see what you mean there. It could make sense to an advanced calculator user. You could enrich the question with some details about the typical user of your system? Oct 23, 2018 at 8:50

A calculator is a tool intended to be useful for humans. If the human entered an expression that the calculator couldn't process, they deserve to have a response that indicates what went wrong. This will hopefully give them the information they need to help them fix their input and get a more useful response.

Just returning the expression that you were unable to evaluate might be smugly "correct" on some mathematical level, but it certainly does not make the tool more useful to the humans using it.

• Agree to some level. But problem is with "what went wrong". Not in all cases is easy to say what was wrong. In practice almost reverse situation happens - what exactly went wrong is unclear or there may be multiple/alternative wrong causes - in that case what program should choose ? This is too ambiguous, so program in principle can't help the user to fix their input. Oct 24, 2018 at 9:04
• @AgniusVasiliauskas Not a problem at all with "what went wrong". A programm code inside calculator knows what's gong wrong because it detected and processed error. So I agree with Franchesca that more useful will be error description. If there are several possible errors simply start with the first one. This is not too ambiguous, but driving user step by step to correct expression. If calculator can't interpret correct expression due to it's functional restrictions, user will be informed about this and choose another one.
– Serg
Oct 24, 2018 at 9:23
• @AgniusVasiliauskas One cannot always explain what exactly went wrong. I have implemented expression parsing a number of times, and in practice I have found that we usually have a long expression that was mostly parse-able, but with one section that didn't make sense. Often just highlighting which part of the expression we couldn't parse is sufficient for the user to notice the typo they made. Oct 24, 2018 at 9:23
• +1 And even if you cannot give useful information about what is wrong with an expression, the fact that you get an error message will make the user stop and think. One problem with just echoing an expression that cannot be computed (either because it's un-parseable, or because it's too complex), is that -- it seems to me -- to be too easy for the user not to notice it wasn't fully understood (especially if this were in a script of operations). Oct 24, 2018 at 15:20

I would vote for "Malformed expression" as it is the most recognizable and familiar expression amongst the options. System feedback should always use natural language and phrases. This way you not only decrease the learning curve but also discard confusion.

I have almost nominal knowledge of Programming/Dev, out of all the options, the only one clear enough was 2nd.

In fact, I would make it simpler and natural like "Oops, this is tough!". Probably not go with that exact sentence but something on similar lines.

Hope this helps!

• Imagine user tries expression `!45`, maybe instead of showing "Malformed expression" is better to show `Available options : 45! ,...` ? Oct 24, 2018 at 9:09
• Yes, that would be useful. Maybe you can also frame it as how Google does it "Did you mean : 45! I would still show a message stating that there has been an error in the user input though. Oct 24, 2018 at 10:32
• @AgniusVasiliauskas By all means build in knowledge of "obvious" typos, if you can... but to do that well probably requires scanning an enormous amount of malformed input (something Google can easily do; most others less so). And even then, some typos won't suggest "obvious" corrections. Start with a clear error ("Malformed expression") and potentially augment it when easy to do. (Noting, that many users will quickly spot their own errors when brought to their attention). Oct 24, 2018 at 15:25