# How to power-series expand determinants?

Say $g$ is a matrix which is given as, $g = g_0 + xg_2 + x^2 g_4 .. +x^{d/2 -1}g_{d-2}+ x^{d/2}(g_d + h_d(\log (x)))$ where $d$ is an even number and each $g_i$ is a matrix (same dimension as $g$) and $h_d$ is another matrix.

• For such a set of arbitrary matrices, how can one power-series expand $\sqrt {\det(g)}$ in $x$?
• use MatrixPower to evaluate g, then find its determinant using Det then take the square root of the result using Sqrt then use Series on the result. Jun 24, 2014 at 9:19
• @Nasser I want a general expression for the coefficients of $x$ in $\sqrt{det (g)}$ in terms of the matrices $g_i$ and $h_d$. I want to do this for arbitrary matrices $g_i$ and $h_d$ Jun 24, 2014 at 9:21
• @user6818: I would suggest to approach the problem by first simplifying it drastically. Put g = g0 + x g1 and study the cases of 2 and 3 dimensions. Also consider the determinant itself instaed of ist Sqrt. Use Series and look at the structure of the coefficients you obtain. The results can then be cautiously generalized. MMA gives you the desired development for any concrete case. Very clumsy epressions might result. Jul 16, 2014 at 8:38
• @Dr.WolfgangHintze I think it is safe to say that very clumsy expressions will result...
– acl
Jul 16, 2014 at 10:46

You can use my function MatrixD from the question det simplification:

MatrixD[expr_, x__] := With[
{old = OptionValue[SystemOptions[], "DifferentiationOptions"->"ExcludedFunctions"]},

InternalWithLocalSettings[
SetSystemOptions["DifferentiationOptions"->"ExcludedFunctions"->Join[old, {Det, Inverse, Tr}]];

Unprotect[D];
(* handle list derivatives *)
D[h:((Det|Tr|Inverse)[m_]), {z_, n_Integer}] := Nest[D[#, Replace[z, _List :> {z}]]&, h, n];
D[h:((Det|Tr|Inverse)[m_]), {z_List}] := D[h, #]& /@ z;
D[h:((Det|Tr|Inverse)[m_]), z_, y___] := D[D[h, z], y];

(* define derivatives for Det, Tr, and Inverse *)
D[Det[m_], z:Except[_List]] := Det[m] Tr[Inverse[m] . D[m,z]];
D[Tr[m_], z:Except[_List]] := Tr[D[m,z]];
D[Inverse[m_], z:Except[_List]] := -Inverse[m] . D[m, z] . Inverse[m],

D[expr, x],

SetSystemOptions["DifferentiationOptions"->"ExcludedFunctions"->old];
Clear[D];
Protect[D]
]
]


g[x_] := g0 + x g2 + x^2 g4 + x^3 g6 + x^3 hd Log[x];


Then:

coeffs = Table[
MatrixD[Sqrt[Det[g[x]]] /. Log[x]->u, {x, n}]/n! /. {x->0, u->Log[x]},
{n, 0, 3}
];
Print @* TeXForm /@ coeffs;


$\sqrt{\left| \operatorname{g0}\right| }$

$\frac{1}{2} \sqrt{\left| \operatorname{g0}\right| } \operatorname{Tr}\left[\operatorname{g0}^{-1}.\operatorname{g2}\right]$

$\frac{1}{2} \left(\frac{1}{2} \sqrt{\left| \operatorname{g0}\right| } \operatorname{Tr}\left[\left(-\operatorname{g0}^{-1}.\operatorname{g2}.\operatorname{g0}^{-1}\right).\operatorname{g2}+\operatorname{g0}^{-1}.(2 \operatorname{g4})\right]+\frac{1}{4} \sqrt{\left| \operatorname{g0}\right| } \operatorname{Tr}\left[\operatorname{g0}^{-1}.\operatorname{g2}\right]^2\right)$

$\frac{1}{6} \left(\frac{1}{2} \sqrt{\left| \operatorname{g0}\right| } \operatorname{Tr}\left[2 \left(-\operatorname{g0}^{-1}.\operatorname{g2}.\operatorname{g0}^{-1}\right).(2 \operatorname{g4})+\left(-\left(-\operatorname{g0}^{-1}.\operatorname{g2}.\operatorname{g0}^{-1}\right).\operatorname{g2}.\operatorname{g0}^{-1}-\operatorname{g0}^{-1}.\operatorname{g2}.\left(-\operatorname{g0}^{-1}.\operatorname{g2}.\operatorname{g0}^{-1}\right)-\operatorname{g0}^{-1}.(2 \operatorname{g4}).\operatorname{g0}^{-1}\right).\operatorname{g2}+\operatorname{g0}^{-1}.(6 \operatorname{g6}+6 \operatorname{hd} \log (x))\right]+\frac{3}{4} \sqrt{\left| \operatorname{g0}\right| } \operatorname{Tr}\left[\operatorname{g0}^{-1}.\operatorname{g2}\right] \operatorname{Tr}\left[\left(-\operatorname{g0}^{-1}.\operatorname{g2}.\operatorname{g0}^{-1}\right).\operatorname{g2}+\operatorname{g0}^{-1}.(2 \operatorname{g4})\right]+\frac{1}{8} \sqrt{\left| \operatorname{g0}\right| } \operatorname{Tr}\left[\operatorname{g0}^{-1}.\operatorname{g2}\right]^3\right)$

Let's evaluate the first few terms of the series using an explicit set of matrices:

SeedRandom[2];
rules = Thread[{g0, g2, g4, g6, hd} -> RandomReal[1,{5,3,3}]]


{g0 -> {{0.72224, 0.109449, 0.470703}, {0.535582, 0.583178, 0.293942}, {0.165154, 0.601258, 0.754218}}, g2 -> {{0.771123, 0.778574, 0.0236104}, {0.922757, 0.992454, 0.350409}, {0.0450047, 0.501359, 0.633756}}, g4 -> {{0.642208, 0.389875, 0.664971}, {0.843882, 0.56904, 0.398212}, {0.238652, 0.673513, 0.419507}}, g6 -> {{0.587398, 0.00833523, 0.942441}, {0.771263, 0.147503, 0.964774}, {0.898747, 0.332963, 0.204548}}, hd -> {{0.839035, 0.250388, 0.238638}, {0.616616, 0.879303, 0.404504}, {0.402517, 0.516192, 0.292009}}}

And the comparison:

N @ CoefficientList[Series[Sqrt[Det[g[x]]] /. rules, {x, 0, 3}], x]

coeffs /. rules //Expand


{0.507317, 0.663253, 0.436586, 0.0826776 + 0.572028 Log[x]}

{0.507317, 0.663253, 0.436586, 0.0826776 + 0.572028 Log[x]}

For any square matrix M which is the sum of two similar matrices M = A + B the determinant can be written as a sum of determinants as follows (example for two dimensions):

det(M) = det( ( A11 + B11, A12 + B12), (A21 + B21, A22 + B22) )

= det( ( A11 + 0, A12 + 0),  (A21 + B21, A22 + B22) )
+ det( ( 0 + B11, 0 + B12),  (A21 + B21, A22 + B22) )


and, expanding the lower row similarly,

= det( ( A11 + 0, A12 + 0),  (A21 + 0, A22 + 0) )
+ det( ( A11 + 0, A12 + 0),  (0 + B21, 0 + B22) )

+ det( ( 0 + B11, 0 + B12),  (A21 + 0, A22 + 0) )
+ det( ( 0 + B11, 0 + B12),  (0 + B21, 0 + B22) )

= det( ( A11, A12),  (A21, A22) )
+ det( ( A11, A12),  (B21, B22) )
+ det( ( B11, B12),  (A21, A22) )
+ det( ( B11, B12),  (B21, B22) )


Letting B = x C gives then the expansion

det(M) =
= det( ( A11, A12),  (A21, A22) )
+ x det( ( A11, A12),  (C21, C22) )
+ x det( ( C11, C12),  (A21, A22) )
+ x^2 det( ( C11, C12),  (C21, C22) )
`

Here we recognise det(A) and det(C) but also determinants of matrices mixed between A and C, more exactly, with replacement of rows.

This procedure obviously generalizes to your problem. You might wish to write it down in MMA terms.

Regards, Wolfgang

• Dr. Wolfgang Hintze, I just read your profile. Welcome aboard, and I hope you find this "home" to your liking. By the way, you should read Markdown Editing Help -- it'll help you make your posts look spiffy. Jul 16, 2014 at 10:39
• @Mr. Wizard, yes, I do like it, thanks. I read your profile as well and found you very active in the old group. Surprisingly, we had no topic in common there ... Jul 16, 2014 at 17:22