The syntax for defining a function such as
is:
double f(double t) { if (cos(t) <= sin(t)) return sin(t); else return cos(t); }If there are more than two formulas in the definition, use an else if construction, as in
double max_10_f(double x) { if ( fabs(f(x)) < 10 ) // |f(x)| < 10 return f(x); else if ( f(x)>0 ) return 10; else return -10; }This truncates