       Re: Matrix Form of Quadratic Equations

• To: mathgroup at smc.vnet.net
• Subject: [mg114243] Re: Matrix Form of Quadratic Equations
• From: Simon <simonjtyler at gmail.com>
• Date: Sun, 28 Nov 2010 06:54:57 -0500 (EST)
• References: <ico2b2\$nq6\$1@smc.vnet.net>

```On Nov 26, 6:32 pm, Ari <ari... at finly.net> wrote:
> Hello,
>
> Could anyone guide me how to build a mathematica module to form a Matrix =
> For example, x^2 + y^2 - 2 x y will output
> {{1, -1}, {-1, 1}} ?
>
> Thanks

Hi there,

I was sure that you would be inundated with answers... but none
arrived.

In:= quad = a x^2+b x y+c y^2;

Then either calculate the Hessian (http://mathworld.wolfram.com/
Hessian.html)

Out= {{a,b/2},{b/2,c}}
Out= True

Or extract the coefficients using CoefficientList[]

Extract[%,1+{{2,0},{1,1},{0,2}}]
Out= {{0,0,c},{0,b,0},{a,0,0}}
Out= {a,b,c}
Out= True

In terms of how to "build a mathematica module to form a Matrix form
from a quadratic equations", it's probably good to use a general
approach like

Hessian[f_, x_List?VectorQ] := D[f, {x, 2}]
Hessian[f_, x_List?VectorQ, x0_List?VectorQ] /;
Length[x] === Length[x0] := Hessian[f, x] /. Thread[x -> x0]
Hessian[f_, x_List?VectorQ, x0_?NumericQ] :=
Hessian[f, x] /. Thread[x -> x0]

Simon

```

• Prev by Date: Re: How do I take every 3rd number from a text file?
• Next by Date: Creating rounded blobs in Mathematica 8