Hi all,

I have a question not pertaining solely to C nor Programming in general. Nevertheless, I think there is no better place to ask (even in maths forums) than here..

Suppose you have the following equation to solve:

If we had to put that into a calculator or programme like Mathematica, mathcad, octave, MatLab, would those programms calculate AS IS or will they first simplify the equation then numerically calculate?

In other Words, will these programmes actually perform a CPU intensive square root operation in the numerator and denominator and then carry on solving? Or, if these programmes are written smart enough, they could first look for grouping, distribution, cancellation of squares/roots, cancellation of numerators and denominators, which in this case, it would cancel the numerator and denominator and completely get away with square rooting.

If they dont do this, is there a reason? Im sure it saves on CPU time especially if the simplifying is large. Or maybe they dont do this because the very operation of searching for cancellation consumes significant CPU time. Although having said that, I think that the operation of searching is linearly intensive O(n) while the potential for cancellation of square root operations (for example) saves on potential loss of O(log n) operations. So Im sure that these maths programms employ this simplifying technique.