Function definitions in C may be as simple as an algebraic formula,
or as complicated as an arbitrary finite ``rule''. Sums of finite
series are achieved with the following sort of definition, which
defines
:
double fourier9(double t) { int k; // summation index double y=0; // running total of the sum /* Run from k=1 to 9; increment k at each step */ for (k=1; k < 10; ++k) // Add (1/k)sin(kt) to the running total y += (1.0/k)*sin(k*t); return y; }The Weierstrass non-differentiable function sample file is an example.
Generally, a function definition may be specified by an arbitrary algorithm; see the definitions of gcd, sup, and inf in functions.cc for more examples. Of course, numerical error can become an issue if the algorithm is complicated.