Function Repository Resource:

QuadraticFunctionQ

Source Notebook

Determine whether an expression represents a quadratic function of a given set of variables

Contributed by: Paco Jain (Wolfram Research)

ResourceFunction["QuadraticFunctionQ"][expr,var]

returns True if expr is a quadratic function of the symbol var, and returns False otherwise.

ResourceFunction["QuadraticFunctionQ"][expr,{var1,var2, }]

returns True if expr is a quadratic function of each of the symbols vari, considered together, and returns False otherwise.

Details and Options

If expr is of the form lhs==rhs, ResourceFunction["QuadraticFunctionQ"][expr, ] is equivalent to ResourceFunction["QuadraticFunctionQ"][lhs - rhs, ]
An expression is determined to be quadratic if and only if it is a PolynomialQ in the variable(s) of the second argument, has at least one term of cumulative order 2 and has no terms of cumulative order greater than 2.

Examples

Basic Examples (2) 

Test whether an expression represents a quadratic function of a given variable:

In[1]:=
ResourceFunction["QuadraticFunctionQ"][a x^2 + b x + c, x]
Out[1]=
In[2]:=
ResourceFunction["QuadraticFunctionQ"][4 x - Pi == 0, x]
Out[2]=

Test whether a given expression represents a quadratic function of a list of variables:

In[3]:=
ResourceFunction["QuadraticFunctionQ"][(x^2 + 1) Log[y], {x}]
Out[3]=
In[4]:=
ResourceFunction["QuadraticFunctionQ"][(x^2 + 1) Log[y], {x, y}]
Out[4]=
In[5]:=
ResourceFunction["QuadraticFunctionQ"][
 a x^2 + b x + c x y + d y^2, {x, y}]
Out[5]=

Properties and Relations (3) 

Variables listed in the second argument are considered together:

In[6]:=
ResourceFunction["QuadraticFunctionQ"][x y, {x, y} ]
Out[6]=
In[7]:=
ResourceFunction["QuadraticFunctionQ"][x^2 y, {x, y} ]
Out[7]=

If high-order terms in expr do not explicitly vanish, QuadraticFunctionQ[expr, ] returns False:

In[8]:=
ResourceFunction["QuadraticFunctionQ"][
 a x^2 + b x + c x y + d y^2 + r x^2 y + s x y^2 + t x^2 y^2, {x, y}]
Out[8]=

Explicitly taking the cubic and quartic coefficients of the previous input to be zero yields True:

In[9]:=
With[{r = 0, s = 0, t = 0},
 ResourceFunction["QuadraticFunctionQ"][
  a x^2 + b x + c x y + d y^2 + r x^2 y + s x y^2 + t x^2 y^2, {x, y}]
 ]
Out[9]=

Expressions that lack an explicit quadratic term are not considered to be QuadraticFunctionQ:

In[10]:=
ResourceFunction["QuadraticFunctionQ"][4 + y, y]
Out[10]=

Requirements

Wolfram Language 11.3 (March 2018) or above

Version History

  • 1.0.0 – 20 March 2019

Related Resources

License Information