Function Repository Resource:

ConstantTerm

Source Notebook

Determine the constant term in an expression

Contributed by: Dennis M Schneider

ResourceFunction["ConstantTerm"][expr,vars]

removes all terms in expr that involve vars.

Details and Options

Removing all terms in expr involving vars means that what's left does not depend on the vars and, in that sense, is constant.

Examples

Basic Examples (2) 

Return an expression that does not depend on x:

In[1]:=
ResourceFunction["ConstantTerm"][a + b x y + c x^2 + \[Pi] y^3, x]
Out[1]=

Return an expression that does not depend on x or y:

In[2]:=
ResourceFunction["ConstantTerm"][
 1 + \[Pi] + E^\[Pi] + a + x + y^2, {x, y}]
Out[2]=

Scope (2) 

Return all terms that do not depend on x or y:

In[3]:=
ResourceFunction["ConstantTerm"][
 a + b x y + c x^2 + \[Pi] y^3, {x, y}]
Out[3]=
In[4]:=
ResourceFunction["ConstantTerm"][
 x + x y + y z^3 + (x + z)^2 + Exp[z], {x, y}]
Out[4]=
In[5]:=
ResourceFunction["ConstantTerm"][
 x + x (y + z) + y z^3 + (x + z)^2, {x, y}]
Out[5]=

If every term in an expression involves all of its variables, then 0 is returned:

In[6]:=
ResourceFunction["ConstantTerm"][
 x + x y + y z^3 + (x + z)^2, {x, y, z}]
Out[6]=
In[7]:=
ResourceFunction["ConstantTerm"][x + Cos[x + z], {x}]
Out[7]=

Publisher

Dennis M Schneider

Version History

  • 1.0.0 – 06 August 2019

License Information