```Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: solving a system of multi-variable polynomial equations in mupad
Date: Tue, 9 Oct 2012 02:28:08 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 51
Message-ID: <k5023o\$mvg\$1@newscl01ah.mathworks.com>
References: <k4ib2c\$eel\$1@newscl01ah.mathworks.com> <k4l3c0\$2ed\$1@newscl01ah.mathworks.com> <k4n7o4\$1hf\$1@newscl01ah.mathworks.com> <k4nprj\$9rg\$1@newscl01ah.mathworks.com> <k4vg5t\$nss\$1@newscl01ah.mathworks.com>
NNTP-Posting-Host: www-05-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1349749688 23536 172.30.248.37 (9 Oct 2012 02:28:08 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 9 Oct 2012 02:28:08 +0000 (UTC)
Xref: news.mathworks.com comp.soft-sys.matlab:780188

"Daniel" wrote in message <k4vg5t\$nss\$1@newscl01ah.mathworks.com>...
> This is the derivation you state requires "healthy manipulation"! I understand that the purpose of the transformation is to eliminate the xy term, and in so doing produce a specific example of an equation of a conic, in terms of X and Y now, whose axes are parellel to the coordinate axes. Using your transformation
>
> x = X*cos(theta) - Y*sin(theta)
> y = X*sin(theta) + Y*cos(theta)
>
> and with a little help from matlab I get the resulting coefficient for XY which we set to zero and solve for theta;
>
> (C-A)*cos(theta)*sin(theta) + B*(cos^2(theta) - sin^2(theta)) = 0,
>
> or equivalently
>
> B*tan^2(theta) + (A-C)*tan(theta) - B = 0,
>
> which is solved with the quadratic formula;
>
> tan(theta) = [(C-A) +/- sqrt( (C-A)^2 + 4*B^2)] / 2*B.
>
> From this solution how do you get the following results
>
> sin(2*theta) =   2*B/sqrt(4*B^2+(A-C)^2)
> cos(2*theta) = (A-C)/sqrt(4*B^2+(A-C)^2)?
- - - - - - - - - - - -
Hello Daniel.

If we multiply by 2 in your equation

(C-A)*cos(theta)*sin(theta) + B*(cos^2(theta) - sin^2(theta)) = 0 ,

and use the double angle formulas for sine and cosine, it leads to

(A-C)*sin(2*theta) = 2*B*cos(2*theta) .

Now let k = sin(2*theta)/(2*B) and we then have

sin(2*theta) = k*(2*B) and cos(2*theta) = k*(A-C)

but since the sum of the squares of the left sides is 1, this forces k to be either

1/sqrt(4*B^2+(A-C)^2)

or its negative.  We can choose either one for our desired rotation and we choose the positive case which gives

sin(2*theta) =   2*B/sqrt(4*B^2+(A-C)^2)
cos(2*theta) = (A-C)/sqrt(4*B^2+(A-C)^2)

You will find it desirable to express the coefficients of X^2 and Y^2 also in terms of 2*theta and you can then replace the sin(2*theta) and cos(2*theta) by these last expressions.  This will lead you directly to the "magic equation" (after the smoke clears away.)  The same kind of manipulation will also lead you to the other magic formula

(A+C+sqrt(4*B^2+(A-C)^2))/2*X1*X2+(A+C-sqrt(4*B^2+(A-C)^2))/2*Y1*Y2 = 0.

Roger Stafford
```