%mathpiper,def="IsEvenFunction"

IsEvenFunction(f,x):= (f = Eval(Subst(x,-x)f));

%/mathpiper



%mathpiper_docs,name="IsEvenFunction",categories="User Functions;Predicates"
*CMD IsEvenFunction --- Return true if function is an even function (False otherwise)

*STD
*CALL
	IsEvenFunction(expression,variable)

*PARMS

{expression} -- mathematical expression
{variable} -- variable

*DESC

This function returns True if MathPiper can determine that the
function is even. Even functions are
defined to be functions that have the property:

$$ f(x) = f(-x) $$

{Cos(x)} is an example of an even function.

As a side note, one can decompose a function into an
even and an odd part:

$$ f(x) = f_even(x) + f_odd(x) $$

Where 

$$ f_even(x) = (f(x)+f(-x))/2 $$

and

$$ f_odd(x) = (f(x)-f(-x))/2 $$

*E.G.

In> IsEvenFunction(Cos(b*x),x)
Result: True
In> IsEvenFunction(Sin(b*x),x)
Result: False
In> IsEvenFunction(1/x^2,x)
Result: True
In> IsEvenFunction(1/x,x)
Result: False

*SEE IsOddFunction, Sin, Cos
%/mathpiper_docs