Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
How to complete the quadratic form quickly using symbolic computation

Subject: How to complete the quadratic form quickly using symbolic computation

From: Eminem

Date: 21 Sep, 2010 01:25:10

Message: 1 of 2

Hi:

I'm working with joint Gaussian distributions and need to complete squares quickly.
Input:
variable:x,y,z
quadratic form: Q(x,y,z)=Q(x^2...,xy,....x,...1)
Output:
symmetric matrix: M, constant:a,b,c,d,e,f,g
Q(x,y,z)=([ax-b,cy-d,ez-f]*M*[ax-b,cy-d,ez-f]'+g

So, how to complete the quadratic form quickly using symbolic computation?
Thanks
Alex

Subject: How to complete the quadratic form quickly using symbolic computation

From: Roger Stafford

Date: 21 Sep, 2010 07:26:08

Message: 2 of 2

"Eminem " <weiddoonngglai@tom.com> wrote in message <i791hm$oua$1@fred.mathworks.com>...
> Hi:
>
> I'm working with joint Gaussian distributions and need to complete squares quickly.
> Input:
> variable:x,y,z
> quadratic form: Q(x,y,z)=Q(x^2...,xy,....x,...1)
> Output:
> symmetric matrix: M, constant:a,b,c,d,e,f,g
> Q(x,y,z)=([ax-b,cy-d,ez-f]*M*[ax-b,cy-d,ez-f]'+g
>
> So, how to complete the quadratic form quickly using symbolic computation?
> Thanks
> Alex
- - - - - - - - -
  I will not give you the complete solution to your problem. I would rather that you carried that our yourself using the symbolic toolbox. However I will give a hint or two to give you a start.

  What you would apparently like to do is start with the ten (uppercase) coefficients in a quadratic form

 Q = A*x^2+B*y^2+C*z^2+D*y*z+E*z*x+F*x*y+G*x+H*y+I*z+J

and derive from it the corresponding ten (lowercase) coefficients in the form

Q = [x-g,y-h,z-i] * [a f e;f b d;e d c] * [x-g;y-h;z-i] + j

  My suggestion is to expand this latter form symbolically and collect like terms so as to be able to compare them with the first form. You will quickly find that you must have a = A, b = B, c = C, d = D/2, e = E/2, and f = F/2. Finding g, h, and i can be accomplished by solving three linear equations in g, h, and i for which you can use the symbolic function 'solve' to obtain symbolic solutions. The unknown j is probably best expressed in terms of the g, h, and i variables already determined rather than substituting in the formulas for these. Otherwise the formula for j would probably lead to an uncomfortably complicated expression.

  (Note: You may prefer to use some other symbols than i and j since these are usually considered equal to the square root of -1.)

  Finally, please don't post duplicate threads. It can cause a needless duplication of peoples' efforts.

Roger Stafford

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us