A Grumpy Computer Scientist
1 min readOct 25, 2021

--

Apart from the fact that your code is wrong as it doesn't account for sign (the result could be minus infinity).....

You are missing the larger picture: double.infinity is NOT infinity.

If your objective is to execute the code and get the correct result, even sqrt(2) is a problem. The result of that expression is mathematically wrong because of computers having no *reals* only floating point arithmentic https://en.wikipedia.org/wiki/Floating-point_arithmetic

Even remaining in the discrete world, that every expression can be represented by a computable program that can be run is banally negated by computability theory and Rice-Shapiro theorem. Google "non-computable functions".

Perhaps the original author was making the point that pseudocode can be used as a _notation_ to *represent* any expression, which is probably true, but also underwhelming: expressions are just operands and operators and if you are willing to substitute operands with symbols (constants and variables) and operators with named functions, any expression can be expressed as a composition of function calls. All you have done is to change the shape of the symbols that you used to write the expression.

In any case the code version quickly ends up being uglier, more convoluted, and ultimately less understandable than its counterpart.

--

--

A Grumpy Computer Scientist

UK-based AI professor interested in AI, mind, science, rationality, digital culture and innovation. Hobbies: incessantly fighting nonsense.