0
$\begingroup$

Note: The following questions are from the 21th question of the 2010 Chinese Graduate Mathematical Entrance Examination (first set):

It is known that the canonical form of the quadratic form $f\left(x_{1}, x_{2}, x_{3}\right)=x^{T} A x $ under the orthogonal transformation $x=Qy$ is $ y_{1}^{2}+y_{2}^{2}$, and the third column of Q is $\left(\frac{\sqrt{2}}{2}, 0, \frac{\sqrt{2}}{2}\right)^{T}$.Now I need to find the matrices A and Q.

I use the following code to calculate this problem, hoping to find a set of solutions that meet the requirements. But the following code runs all the time:

Q = {{x1, x2, Sqrt[2]/2}, {x3, x4, 0}, {x5, x6, Sqrt[2]/2}}; 
A = Array[x, {3, 3}]; 
FindInstance[
 Thread[Transpose[Q] . A . Q == {{1, 0, 0}, {0, 1, 0}, {0, 0, 0}}], 
   Join[{x1, x2, x3, x4, x5, x6}, Flatten[A]], Reals]

How can I improve this code to quickly find a set of solutions that meet the requirements?

The reference answer is $Q=\left(\begin{array}{ccc} \frac{\sqrt{2}}{2} & 0 & \frac{\sqrt{2}}{2} \\ 0 & 1 & 0 \\ -\frac{\sqrt{2}}{2} & 0 & \frac{\sqrt{2}}{2} \end{array}\right)$, $A=Q\left(\begin{array}{lll} 1 & & \\ & 1 & \\ & & 0 \end{array}\right) Q^{T}=\frac{1}{2}\left(\begin{array}{ccc} 1 & 0 & -1 \\ 0 & 2 & 0 \\ -1 & 0 & 1 \end{array}\right)$.

$\endgroup$
3
  • $\begingroup$ Your reference answer doesn't satisfy Transpose[Q] . A . Q == {{1, 0, 0}, {0, 1, 0}, {0, 0, 0}} ! $\endgroup$ – Ulrich Neumann Aug 12 '20 at 8:32
  • $\begingroup$ @UlrichNeumann Note that the reference answer is $Q.A.Q^{T}$. if $Q=\left(\begin{array}{ccc} \frac{\sqrt{2}}{2} & 0 & \frac{\sqrt{2}}{2} \\ 0 & 1 & 0 \\ -\frac{\sqrt{2}}{2} & 0 & \frac{\sqrt{2}}{2} \end{array}\right)^{T}$, the answer is still correct $\endgroup$ – A little mouse on the pampas Aug 12 '20 at 8:55
  • 1
    $\begingroup$ I agree, my fault. But right Q as given in your question without transposition! $\endgroup$ – Ulrich Neumann Aug 12 '20 at 9:06
1
$\begingroup$

NMinimize evaluates quite fast:

mini = NMinimize[{#.# &[Flatten[Transpose[Q].A.Q - {{1, 0, 0}, {0, 1, 0}, {0, 0, 0}} ]] + 10^10 #.# &[ Flatten[IdentityMatrix[3] - Transpose[Q].Q]  ]}, 
Join[{x1, x2, x3, x4, x5, x6}, Flatten[A]], WorkingPrecision -> 15]


 Transpose[Q].A.Q - {{1, 0, 0}, {0, 1, 0}, {0, 0, 0}} /. mini[[2]]
 (*{{0.*10^-15, 0.*10^-15, 0.*10^-15}, {0.*10^-15, 0.*10^-15,0.*10^-15}, {0.*10^-16, 0.*10^-16, 0.*10^-15}}*)

The result for matrix A matches the reference answer

 A /. mini[[2]] // Chop // Rationalize
 (* {{1/2, 0, -(1/2)}, {0, 1, 0}, {-(1/2), 0, 1/2}} *)

but Q doesn't match the reference.

$\endgroup$
6
  • $\begingroup$ Thank you very much. I hope to find a set of exact solutions rather than numerical solutions quickly. $\endgroup$ – A little mouse on the pampas Aug 12 '20 at 7:43
  • $\begingroup$ @Montevideo Ok you could try Minimize? Thereby you should add a constraint Q^T.Q==Identity[3] $\endgroup$ – Ulrich Neumann Aug 12 '20 at 9:09
  • $\begingroup$ After I added the constraint Q^T.Q==IdentityMatrix[3], it still runs without returning results. $\endgroup$ – A little mouse on the pampas Aug 12 '20 at 9:52
  • 1
    $\begingroup$ @Montevidoe I modified my answer. Minimize version doesn't evaluate... $\endgroup$ – Ulrich Neumann Aug 12 '20 at 10:14
  • 1
    $\begingroup$ @Montevideo What a simple trick. Solve instead of FindInstance fgives 8 solutions quite fast. $\endgroup$ – Ulrich Neumann Aug 13 '20 at 7:21
1
$\begingroup$

I will leave the rigorous proof of the following to the interested reader:

v = {Sqrt[1/2], 0, Sqrt[1/2]};
qq = Transpose[Simplify[TrigExpand[Append[RotationMatrix[2 ArcTan[u]].
                                          (Normalize /@ NullSpace[{#}]), #] &[v]]]]
   {{(-1 + u^2)/(Sqrt[2] (1 + u^2)), -((Sqrt[2] u)/(1 + u^2)), 1/Sqrt[2]},
    {-((2 u)/(1 + u^2)), (1 - u^2)/(1 + u^2), 0},
    {-((-1 + u^2)/(Sqrt[2] (1 + u^2))), (Sqrt[2] u)/(1 + u^2), 1/Sqrt[2]}}

aa = FullSimplify[qq.{{1, 0, 0}, {0, 1, 0}, {0, 0, 0}}.Transpose[qq]]
   {{1/2, 0, -1/2}, {0, 1, 0}, {-1/2, 0, 1/2}}
$\endgroup$
1
  • $\begingroup$ This answer is great, but I don’t yet know its mathematical principles. $\endgroup$ – A little mouse on the pampas Aug 15 '20 at 5:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.