verifying matrix identity with Mathematica
- To: mathgroup at smc.vnet.net
- Subject: [mg66487] verifying matrix identity with Mathematica
- From: "Yaroslav Bulatov" <yaroslavvb at gmail.com>
- Date: Mon, 15 May 2006 23:49:44 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Hi, I'm trying to check the following identity numerically
\forall B \in M \exists x s.t. argmin_{A \in M} NormK(ABA)+Norm2(A^-1)
= xI
where
M is the space of dxd symmetric positive definite matrices over reals
NormK is the Ky Fan norm (sum of eigenvalues)
Norm2 is the spectral norm
I is the identity matrix.
I wonder if there's a way to do this efficiently in Mathematica, for
instance, for 3d matrices, my straightforward approach (attached
notebook), takes over 30 seconds per matrix, and also has quite large
error
(************** Content-type: application/mathematica **************
CreatedBy='Mathematica 5.2'
Mathematica-Compatible Notebook
This notebook can be used with any Mathematica-compatible
application, such as Mathematica, MathReader or Publicon. The data
for the notebook starts with the line containing stars above.
To get the notebook into a Mathematica-compatible application, do
one of the following:
* Save the data starting with the line of stars above into a file
with a name ending in .nb, then open the file inside the
application;
* Copy the data starting with the line of stars above to the
clipboard, then use the Paste menu command inside the application.
Data for notebooks contains only printable 7-bit ASCII and can be
sent directly in email or through ftp in text mode. Newlines can be
CR, LF or CRLF (Unix, Macintosh or MS-DOS style).
NOTE: If you modify the data for this notebook not in a Mathematica-
compatible application, you must delete the line below containing
the word CacheID, otherwise Mathematica-compatible applications may
try to use invalid cache data.
For more information on notebooks and Mathematica-compatible
applications, contact Wolfram Research:
web: http://www.wolfram.com
email: info at wolfram.com
phone: +1-217-398-0700 (U.S.)
Notebook reader applications are available free of charge from
Wolfram Research.
*******************************************************************)
(*CacheID: 232*)
(*NotebookFileLineBreakTest
NotebookFileLineBreakTest*)
(*NotebookOptionsPosition[ 6599, 194]*)
(*NotebookOutlinePosition[ 7245, 216]*)
(* CellTagsIndexPosition[ 7201, 212]*)
(*WindowFrame->Normal*)
Notebook[{
Cell[CellGroupData[{
Cell["2d case", "Section"],
Cell[BoxData[
\(\(m2[t1_, t2_, t3_] = {{t1, t2}, {t2, t3}};\)\)], "Input"],
Cell[CellGroupData[{
Cell[BoxData[
\(posdef2 = {t1 >= 0, t1*t3 >= t2*t2}\)], "Input"],
Cell[BoxData[
\({t1 \[GreaterEqual] 0, t1\ t3 \[GreaterEqual] t2\^2}\)],
"Output"]
}, Open ]],
Cell[BoxData[
\(\(func2[A_, B_] :=
Plus @@ Eigenvalues[A . B . A] + Norm[Inverse[A]];\)\)],
"Input"],
Cell[BoxData[
\(Off[Norm::symb]\)], "Input"],
Cell[CellGroupData[{
Cell[BoxData[
\(B = {{2, 1}, {1, 2}};
NMinimize[{func[m2[t1, t2, t3], B], posdef2}, {t1, t2, t3}]\)],
"Input"],
Cell[BoxData[
\({3.000000002437493`, {t1 \[Rule] 0.5000094973913588`,
t2 \[Rule] \(-6.728653435021618`*^-10\),
t3 \[Rule] 0.5000094972781227`}}\)], "Output"]
}, Open ]],
Cell[CellGroupData[{
Cell[BoxData[
\(Timing[\(\(NMinimize[{func[m2[t1, t2, t3], #], posdef2}, {t1, t2,
t3}] &\) @@ {1/
2 \((# + Transpose[#] + IdentityMatrix[2])\)} &\) /@
Table[Random[], {2}, {2}, {2}]]\)], "Input"],
Cell[BoxData[
\({3.843999999999994`\ Second, {{2.4488559169567234`, {t1 \[Rule]
0.6114625232242126`, t2 \[Rule]
\(-3.802061059063895`*^-9\),
t3 \[Rule]
0.6114625251084623`}}, {2.0952781020631153`, {t1 \[Rule]
0.7158908861734735`, t2 \[Rule]
\(-2.079528218812988`*^-8\),
t3 \[Rule] 0.7158908750221485`}}}}\)], "Output"]
}, Open ]],
Cell[CellGroupData[{
Cell[BoxData[
\(Timing[\(m2[t1, t2, t3] -
t1\ IdentityMatrix[
2] /. \((\(NMinimize[{func[m2[t1, t2, t3], #],
posdef2}, {t1, t2, t3}] &\) @@ {1/
2 \((# + Transpose[#] +
IdentityMatrix[2])\)})\)[\([2]\)] &\) /@
Table[Random[], {10}, {2}, {2}]]\)], "Input"],
Cell[BoxData[
\({19.234999999999985`\ Second, {{{0, \(-5.639817819379918`*^-9\)},
\
{\(-5.639817819379918`*^-9\), 5.8423288429310105`*^-9}}, {{0,
1.101856965316137`*^-9}, {1.101856965316137`*^-9, \
\(-4.686124821517978`*^-10\)}}, {{0, \(-2.7270479320962677`*^-9\)}, \
{\(-2.7270479320962677`*^-9\),
1.2332745935594858`*^-10}}, {{0,
\(-6.6687295501042395`*^-9\)}, {\
\(-6.6687295501042395`*^-9\), 3.6256997404393587`*^-9}}, {{0,
5.62453019327729`*^-9}, {5.62453019327729`*^-9, \
\(-2.3182533670507155`*^-10\)}}, {{0, \(-4.265259592946679`*^-9\)}, \
{\(-4.265259592946679`*^-9\),
6.032556343349427`*^-9}}, {{0,
\(-6.108822095519977`*^-10\)}, \
{\(-6.108822095519977`*^-10\),
5.345884845908699`*^-10}}, {{0,
\(-7.404789099279999`*^-10\)}, \
{\(-7.404789099279999`*^-10\),
1.0306013820127191`*^-9}}, {{0,
\(-1.8714576506332886`*^-8\)}, \
{\(-1.8714576506332886`*^-8\), \(-2.3335073207064738`*^-8\)}}, {{0,
3.854917910261621`*^-9}, {3.854917910261621`*^-9, \
\(-1.525910398036956`*^-9\)}}}}\)], "Output"]
}, Open ]],
Cell[CellGroupData[{
Cell[BoxData[
\(Chop[%, 10^\(-5\)]\)], "Input"],
Cell[BoxData[
\({19.234999999999985`\ Second, {{{0, 0}, {0, 0}}, {{0, 0}, {0,
0}}, {{0,
0}, {0, 0}}, {{0, 0}, {0, 0}}, {{0, 0}, {0, 0}}, {{0, 0},
{0,
0}}, {{0, 0}, {0, 0}}, {{0, 0}, {0, 0}}, {{0, 0}, {0, 0}},
{{0,
0}, {0, 0}}}}\)], "Output"]
}, Open ]]
}, Open ]],
Cell[CellGroupData[{
Cell["3d case", "Section"],
Cell[BoxData[
\(\(m3[t1_, t2_, t3_, t4_, t5_,
t6_] = {{t1, t2, t3}, {t2, t4, t5}, {t3, t5, t6}};\)\)],
"Input"],
Cell[CellGroupData[{
Cell[BoxData[
\(posdef3 = {t1 >= 0,
t1\ t4 - t2\ t2 \[GreaterEqual]
0, \(-t3\^2\)\ t4 + 2\ t2\ t3\ t5 - t1\ t5\^2 - t2\^2\ t6 +
t1\ t4\ t6 >= 0}\)], "Input"],
Cell[BoxData[
\({t1 \[GreaterEqual] 0, \(-t2\^2\) + t1\ t4 \[GreaterEqual]
0, \(-t3\^2\)\ t4 + 2\ t2\ t3\ t5 - t1\ t5\^2 - t2\^2\ t6 +
t1\ t4\ t6 \[GreaterEqual] 0}\)], "Output"]
}, Open ]],
Cell[BoxData[
\(\(func3[A_, B_] :=
Plus @@ Eigenvalues[A . B . A] + Norm[Inverse[A]];\)\)],
"Input"],
Cell[CellGroupData[{
Cell[BoxData[
\(Timing[\(\(NMinimize[{func[m3[t1, t2, t3, t4, t5, t6], #],
posdef3}, {t1, t2, t3, t4, t5, t6}] &\) @@ {1/
2 \((# + Transpose[#] + IdentityMatrix[3])\)} &\) /@
Table[Random[], {1}, {3}, {3}]]\)], "Input"],
Cell[BoxData[
\({39.547`\ Second, {{2.6600710434730166`, {t1 \[Rule]
0.564425943484209`, t2 \[Rule]
\(-0.0003674085515258834`\),
t3 \[Rule] 0.00009561604546767761`,
t4 \[Rule] 0.5654156125784714`,
t5 \[Rule] \(-0.0002891716370465523`\),
t6 \[Rule] 0.5643797133749252`}}}}\)], "Output"]
}, Open ]],
Cell[BoxData[""], "Input"]
}, Open ]]
},
FrontEndVersion->"5.2 for Microsoft Windows",
ScreenRectangle->{{0, 1152}, {0, 777}},
WindowSize->{1017, 653},
WindowMargins->{{24, Automatic}, {Automatic, 30}}
]
(*******************************************************************
Cached data follows. If you edit this Notebook file directly, not
using Mathematica, you must remove the line containing CacheID at
the top of the file. The cache data will then be recreated when
you save this file from within Mathematica.
*******************************************************************)
(*CellTagsOutline
CellTagsIndex->{}
*)
(*CellTagsIndex
CellTagsIndex->{}
*)
(*NotebookFileOutline
Notebook[{
Cell[CellGroupData[{
Cell[1776, 53, 26, 0, 73, "Section"],
Cell[1805, 55, 78, 1, 30, "Input"],
Cell[CellGroupData[{
Cell[1908, 60, 68, 1, 30, "Input"],
Cell[1979, 63, 86, 1, 29, "Output"]
}, Open ]],
Cell[2080, 67, 113, 2, 30, "Input"],
Cell[2196, 71, 48, 1, 30, "Input"],
Cell[CellGroupData[{
Cell[2269, 76, 119, 2, 30, "Input"],
Cell[2391, 80, 179, 3, 29, "Output"]
}, Open ]],
Cell[CellGroupData[{
Cell[2607, 88, 245, 4, 50, "Input"],
Cell[2855, 94, 393, 6, 48, "Output"]
}, Open ]],
Cell[CellGroupData[{
Cell[3285, 105, 376, 7, 90, "Input"],
Cell[3664, 114, 1094, 18, 105, "Output"]
}, Open ]],
Cell[CellGroupData[{
Cell[4795, 137, 51, 1, 30, "Input"],
Cell[4849, 140, 284, 4, 48, "Output"]
}, Open ]]
}, Open ]],
Cell[CellGroupData[{
Cell[5182, 150, 26, 0, 73, "Section"],
Cell[5211, 152, 126, 2, 30, "Input"],
Cell[CellGroupData[{
Cell[5362, 158, 194, 4, 31, "Input"],
Cell[5559, 164, 202, 3, 29, "Output"]
}, Open ]],
Cell[5776, 170, 113, 2, 30, "Input"],
Cell[CellGroupData[{
Cell[5914, 176, 269, 4, 70, "Input"],
Cell[6186, 182, 356, 6, 29, "Output"]
}, Open ]],
Cell[6557, 191, 26, 0, 30, "Input"]
}, Open ]]
}
]
*)
(*******************************************************************
End of Mathematica Notebook file.
*******************************************************************)