Billy Logan Billy Logan - 1 month ago 23
Pascal Question

How to interpret equation in Pascal?

How can I write the following equation in Pascal?

enter image description here

Does it equal to

pow(x, 2) / (pow(pow(16 - x*x, 1/2)), 3)
?

Answer

You don't mention the dialect, so I'll assume something still in active use like Lazarus/FPC/Delphi

Squared has a separate function sqr(), as does square root, sqrt(). For other values math.power is used (add math to your uses clause).

So that makes sqr(x)/power(sqrt(16-sqr(x)),3);

As a rule of thumb, the simplest expression gives the best precision.