MathGroup Archive 2001

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

Search the Archive

Re: Sum of Squares

  • To: mathgroup at smc.vnet.net
  • Subject: [mg26651] Re: [mg26587] Sum of Squares
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Sat, 13 Jan 2001 22:36:24 -0500 (EST)
  • References: <93knck$74q@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Bob,
We can used SolveAlways in your technique:

expr1 = 5 x^2 + 8 x y + 5 y^2 + 2 x z - 2 y z + 2 z^2;
expr2 = Plus @@ ((
            Partition[
                coef = Table[Unique[s], {2*Length[var]}],
                Length[var]
                ].var)^2);

soln = SolveAlways[expr1 == expr2, var];

ss = expr2 /. soln /. Thread[coef -> 1]

{(-x - 2*y + z)^2 + (2*x + y + z)^2,
  (-2*x - y - z)^2 + (-x - 2*y + z)^2,
  (-x - 2*y + z)^2 + (2*x + y + z)^2,
  (x + 2*y - z)^2 + (2*x + y + z)^2}
--
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565

<BobHanlon at aol.com> wrote in message news:93knck$74q at smc.vnet.net...
>
> Here is an approach
>
> var = {x, y, z};
>
> expr1 = 5 x^2 + 8 x y + 5 y^2 + 2 x z - 2 y z + 2 z^2;
>
> expr2 = Plus @@ ((Partition[coef = Table[Unique[s], {2*Length[var]}],
>                 Length[var]].var)^2);
>
> cl1 = Flatten[CoefficientList[expr1, var]];
>
> cl2 = Flatten[CoefficientList[expr2, var]];
>
> soln = Solve[Complement[Thread[cl1 == cl2],{True}], coef];
>
> There are multiple solutions
>
> ans = expr2 /. soln /. coef[[3]] -> 1
>
> {(-2*x - y - z)^2 + (-x - 2*y + z)^2,
>   (-x - 2*y + z)^2 + (2*x + y + z)^2,
>   (x + 2*y - z)^2 + (2*x + y + z)^2,
>   (-x - 2*y + z)^2 + (2*x + y + z)^2}
>
> And @@ ((expr1 == Expand[#])& /@ ans)
>
> True
>
>
> Bob Hanlon
>
> In a message dated 2001/1/9 2:28:14 AM, wself at msubillings.edu writes:
>
> >Is there, or could there be, a "sum of squares" function for
> >multivariate polynomials, which would rewrite an expression as a sum of
> >squares, when possible?
> >
> >It might work like this:
> >
> >SumOfSquares[5 x^2 + 8 x y + 5 y^2 + 2 x z - 2 y z + 2 z^2]
> >
> >--->
> >
> >(x + 2y - z)^2 + (2x + y + z)^2
> >
>




  • Prev by Date: RE: Fourier Transform and convolution.
  • Next by Date: Re: Sum of Squares
  • Previous by thread: Re: Sum of Squares
  • Next by thread: Re: Sum of Squares