Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive

MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Sum of Products - Complete The Square

  • To: mathgroup at
  • Subject: [mg126746] Re: Sum of Products - Complete The Square
  • From: "djmpark" <djmpark at>
  • Date: Sun, 3 Jun 2012 05:03:11 -0400 (EDT)
  • Delivered-to:
  • References: <> <2175700.115495.1338632524920.JavaMail.root@m06>

You're correct. I got tricked by one example into thinking
SymmetricReduction might be an easy way to do complete the square.

Complete the square, whose purpose is to eliminate the linear term in a
quadratic expression, is just barely common enough (my Thomas & Finny
Calculus book has two references to it in the index and it is sometimes used
as an integration technique) and just barely messy enough (Thomas & Finny
devote a third of the front inside cover of their book to a detailed
exposition) that I often wondered why Mathematica doesn't have a
CompleteTheSquare routine.

I do have it in Presentations.

3 x^2 + y^2 + 6 x y;
CompleteTheSquare[%, x]

-2 y^2 + 3 (x + y)^2 

3 x^2 + y^2 + 6 x y;
CompleteTheSquare[%, y] 

-6 x^2 + (3 x + y)^2 

1/3 (3 x + Sqrt[3] y)^2 + x y (6 - 2 Sqrt[3]);
CompleteTheSquare[%, x] 

y^2 - 1/12 (2 Sqrt[3] y + (6 - 2 Sqrt[3]) y)^2 + 
 3 (x + 1/6 (2 Sqrt[3] y + (6 - 2 Sqrt[3]) y))^2

So what do most users do? Memorize the formula? Look it up somewhere? Derive
it quickly by hand? Program up a routine to effect the transformation or put
in the step by hand typing? All of these are somewhat error prone.

I thought maybe the reason CompleteTheSquare was missing in Mathematica was
that there was some other convenient method to do it.

David Park
djmpark at 

From: Andrzej Kozlowski [mailto:akozlowski at] 

On 31 May 2012, at 08:51, djmpark wrote:

> Thanks for introducing/reminding us of SymmetricPolynomial and the 
> associated SymmetricReduction. SymmetricReduction is the high tech 
> generalization of complete the square.
> 3 x^2 + y^2 + 6 x y;
> Total@SymmetricReduction[%, {x, y}]
> 2 y^2 + 3 (x + y)^2

1. This is not quite right:

3 x^2 + y^2 + 6 x y;
Total@SymmetricReduction[%, {x, y}]

 -2 y^2 + 3 (x + y)^2

2. I don't see why this a "generalisation of complete the square". In fact,
there is no well defined notion of completing the square for arbitrary
quadratic expressions in two variables, e.g. this is another

(1/3)*(3*x + Sqrt[3]*y)^2 + x*y*(6 - 2*Sqrt[3])

In any case, symmetric reduction is about symmetric polynomials and not
about squares and it is based not on anything "high tech" but in fact on an
extremely classical fact, (known as the fundamental theorem of symmetric
that gave rise to the subject of invariant theory, namely, that the ring of
invariants of the symmetric group on n symbols acting on polynomials in
n-variables is a polynomial ring in n-variables. These new variables are
known as the elementary symmetric functions.

The seeming relation with completing the square is quite incidental. The
only reason why it looks this way is that the first elementary polynomial is
the sum of the variables so if the expression is a quadratic you will get in
it (x+y+=85)^2. But:

Total[SymmetricReduction[(2 x + y)^2, {x, y}]]

-4 x y - 3 y^2 + 4 (x + y)^2

A complete square was turned in to an incomplete one. One would hardly want
to call this "completing the square" would one?

Andrzej Kozlowski

  • Prev by Date: Re: Memory Blowup Issues
  • Next by Date: Re: Using CountryData to Get US Population by State
  • Previous by thread: Re: Sum of Products - Complete The Square
  • Next by thread: Re: new functional operator