|
"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
|