Simbody  3.8

y=square(x) returns the square of the argument for any numeric type.

y=square(x) returns the square of the argument for any numeric type.

We promise to evaluate x only once. We assume is is acceptable for the result type to be the same as the argument type; if it won't fit caller must cast argument to a wider type first. This is an inline routine which will run as fast as an explicit multiply (x*x) in optimized code, and somewhat faster for complex and conjugate types (5 flops instead of the usual 6).

Squaring a negated number loses the negator at no cost; squaring a conjugate number returns a complex result at no additional cost.