MathGroup Archive 2010

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

Search the Archive

Re: coefficients of polynomial

  • To: mathgroup at smc.vnet.net
  • Subject: [mg107960] Re: coefficients of polynomial
  • From: "Nasser M. Abbasi" <nma at 12000.org>
  • Date: Thu, 4 Mar 2010 05:26:00 -0500 (EST)
  • References: <hmlf1q$jsd$1@smc.vnet.net>

"Jim Armstrong" <yusufenginn at yahoo.com> wrote in message 
news:hmlf1q$jsd$1 at smc.vnet.net...
> Hi,
>
> I am trying to find the coefficients d,e,f of this simple equating:
>
> ax^2+bxy+cy^2=d(x+y)^2+e(x-y)^2+f(x^2-y^2)
>
> I mean I am waiting for this type of solution:
>
> d=(a-b+c)/2
> e=b/2
> f=(a-c)/2
>
> so how can I get these constants?
>
> I searched it and tried to use Solve, Expand...but either they dont give 
> it or they solve it in terms of all terms (a,b,c,x,y).
>
> Thanks a lot
>

Do you have to automate this? unless you are writing a program, sometimes it 
is easier just to type a command and copy its output from the screen and use 
it.

So, here I collected terms in xy, then in x^2, then in y^2, and made up 3 
equations and solved for d,e,f.

expr = a*x^2 + b*x*y + c*y^2 == d*(x + y)^2 + e*(x - y)^2 + f*(x^2 - y^2)
Collect[expr, y*x];
eq1 = b == 2*d - 2*e;

Collect[expr, x^2];
eq2 = a == d + e + f;

Collect[expr, y^2];
eq3 = c == -f;

Solve[{eq1, eq2, eq3}, {d, e, f}]
Out[42]= a*x^2 + b*x*y + c*y^2 == d*x^2 + e*x^2 + f*x^2 + 2*d*x*y -
   2*e*x*y + d*y^2 + e*y^2 - f*y^2


Out[49]= {{d -> (1/4)*(2*a + b + 2*c), e -> (1/4)*(2*a - b + 2*c), f -> -c}}

Ofcourse this can be automated using Cases and patterns and such. But again, 
sometimes for a quick solution, one can just read the output of the last 
command and use it.

ps. I am getting slightly different result than what you have expected.

--Nasser




  • Prev by Date: Re: Developing C code with Workbench
  • Next by Date: Re: coefficients of polynomial
  • Previous by thread: Re: coefficients of polynomial
  • Next by thread: Re: coefficients of polynomial