Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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) )
- = 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) )
- 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) )
- MatrixD[expr_, x__] := With[
- {old = OptionValue[SystemOptions[], "DifferentiationOptions"->"ExcludedFunctions"]},
- Internal`WithLocalSettings[
- 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];
- coeffs = Table[
- MatrixD[Sqrt[Det[g[x]]] /. Log[x]->u, {x, n}]/n! /. {x->0, u->Log[x]},
- {n, 0, 3}
- ];
- Print @* TeXForm /@ coeffs;
- SeedRandom[2];
- rules = Thread[{g0, g2, g4, g6, hd} -> RandomReal[1,{5,3,3}]]
- N @ CoefficientList[Series[Sqrt[Det[g[x]]] /. rules, {x, 0, 3}], x]
- coeffs /. rules //Expand
Add Comment
Please, Sign In to add comment