Function Repository Resource:

FunctionParity

Source Notebook

Determine the parity of a function, even or odd, with respect to one or more variables

Contributed by: Wolfram|Alpha Math Team

ResourceFunction["FunctionParity"][expr,x]

gives an integer indicating the parity of expr with respect to x, or Undefined.

ResourceFunction["FunctionParity"][expr,{x1,x2,}]

gives the overall parity of expr with respect to multiple variables xi.

Details and Options

ResourceFunction["FunctionParity"] returns one of the following results:
-1expr is an odd function of x
1expr is an even function of x
0expr is both an even and an odd function of x
Undefinednone of the above is true
A function is considered even if for all x and is considered odd if .
For a function of multiple variables, parity is determined by its behavior under the transformation {x,y,..}{-x,-y,..}. It is considered even if it maintains its value under this transformation and odd if it changes sign.

Examples

Basic Examples (12) 

Find the parity of a basic power function:

In[1]:=
ResourceFunction[
 "FunctionParity", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][x^2, x]
Out[1]=

Test another power function:

In[2]:=
ResourceFunction[
 "FunctionParity", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][x^3, x]
Out[2]=

Show that a constant function has even parity:

In[3]:=
ResourceFunction[
 "FunctionParity", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][1, x]
Out[3]=

Find the parity of a rational function:

In[4]:=
ResourceFunction[
 "FunctionParity", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][x/(x^2 + 1), x]
Out[4]=

Find the parity of the absolute value function:

In[5]:=
ResourceFunction[
 "FunctionParity", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][Abs[x], x]
Out[5]=

Find the parity of a trigonometric function:

In[6]:=
ResourceFunction[
 "FunctionParity", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][Sin[x + Pi/4] + Cos[x + Pi/4], x]
Out[6]=

Find the parity of a Gaussian function:

In[7]:=
ResourceFunction[
 "FunctionParity", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][Exp[-x^2], x]
Out[7]=

Test a signed Gaussian function:

In[8]:=
ResourceFunction[
 "FunctionParity", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][Sign[x] Exp[-x^2], x]
Out[8]=

Find the parity of the hyperbolic tangent function:

In[9]:=
ResourceFunction[
 "FunctionParity", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][Tanh[x], x]
Out[9]=

Find the parity of the error function:

In[10]:=
ResourceFunction[
 "FunctionParity", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][Erf[x], x]
Out[10]=

Find the parity of a Fresnel integral:

In[11]:=
ResourceFunction[
 "FunctionParity", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][FresnelC[x], x]
Out[11]=

Find the parity of a shifted Fresnel integral:

In[12]:=
ResourceFunction[
 "FunctionParity", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][FresnelC[x] + 1, x]
Out[12]=

Scope (3) 

For a function of multiple variables, parity is determined based on the behavior of the function under the transformation {x,y,..}{-x,-y,..}. Find the parity of a function of two variables:

In[13]:=
ResourceFunction[
 "FunctionParity", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][Sinh[x + y], {x, y}]
Out[13]=

Find the parity of a function of three variables:

In[14]:=
ResourceFunction[
 "FunctionParity", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][Sin[x y z], {x, y, z}]
Out[14]=

Wrapping z in Abs converts this to an even function:

In[15]:=
ResourceFunction[
 "FunctionParity", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][Sin[x y Abs[z]], {x, y, z}]
Out[15]=

Show that an implicitly defined circle is even in both x and y:

In[16]:=
ResourceFunction[
 "FunctionParity", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][x^2 + y^2, {x, y}]
Out[16]=

Properties and Relations (2) 

FunctionParity returns Undefined for functions that are neither even nor odd:

In[17]:=
ResourceFunction[
 "FunctionParity", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][1 + x, x]
Out[17]=

The constant function f(x)=0 is both even and odd:

In[18]:=
ResourceFunction[
 "FunctionParity", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][0, x]
Out[18]=

Publisher

Wolfram|Alpha Math Team

Version History

  • 4.0.0 – 23 March 2023
  • 3.0.0 – 01 April 2020
  • 2.0.0 – 06 September 2019
  • 1.0.0 – 10 July 2019

Related Resources

License Information