Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2007

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

Search the Archive

Re: express a quadratic, in the form (x+a)^2 + b

  • To: mathgroup at smc.vnet.net
  • Subject: [mg84337] Re: express a quadratic, in the form (x+a)^2 + b
  • From: "C.O." <costerhoudt at gmail.com>
  • Date: Wed, 19 Dec 2007 23:55:57 -0500 (EST)
  • References: <fkan3b$d6k$1@smc.vnet.net>

Something like

transform[equation_] :=
 Module[{coeffs = CoefficientList[equation, x]},
     {c, b, a} = coeffs; (x + b/(2*a))^2 + (c/a - (b/(2*a))^2)]

In[28]:= transform[x^2 + 4*x + 7]

Out[28]= 3 + (2 + x)^2
?


Note that this does not exactly return what you want, as the result is
not sorted in descending polynomial order.

            Hope that helps a bit!
                     C.O.



On Dec 19, 2:08 am, "Joseph Fagan" <noemailple... at nowhere.ru> wrote:
> I'm a Mathematica beginner.
> I wish to express a quadratic, in the form (x+a)^2 + b
> eg to express x^2 + 4x + 7 as (x+2)^2 + 3
> Is there an easy way?
> Thanks
> Joe



  • Prev by Date: Re: express a quadratic, in the form (x+a)^2 + b
  • Next by Date: Re: express a quadratic, in the form (x+a)^2 + b
  • Previous by thread: Re: express a quadratic, in the form (x+a)^2 + b
  • Next by thread: Re: express a quadratic, in the form (x+a)^2 + b