One idea is to use the function MatrixD from my answer to question det simplification that takes scalar derivatives of functions of matrices:
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]
]
]
Here are your expressions:
f[e_] := df*(IdentityMatrix[d] e^1 + c2 e^2 + c3 e^3 + c4 e^4 + c5 e^5);
fe = f[e];
f1e = f'[e];
I added the IdentityMatrix
and assumed that df
is just a scalar. Then:
MatrixD[Inverse[f1e], e] /. e->0
-Inverse[df IdentityMatrix[d]].(2 c2 df).Inverse[df IdentityMatrix[d]]
In order to make progress, we need to include assumptions about the coefficients:
$Assumptions = (c2 | c3 | c4 | c5) ∈ Matrices[{d, d}] && df ∈ Complexes;
The first few derivatives of Inverse[f1e]
tensor expanded using the above assumptions:
TensorExpand[MatrixD[df Inverse[f1e], e] /. e->0]
TensorExpand[MatrixD[df Inverse[f1e], e, e] /. e->0]
TensorExpand[MatrixD[df Inverse[f1e], e, e, e] /. e->0]
-2 c2
-6 c3 + 8 MatrixPower[c2, 2]
-24 c4 + 36 c2.c3 + 36 c3.c2 - 48 MatrixPower[c2, 3]
So, the series expansion is:
TensorExpand[
(df Inverse[f1e] /. e->0) +
(MatrixD[df Inverse[f1e], e] /. e->0) e +
(MatrixD[df Inverse[f1e], e, e] /. e->0) e^2/2! +
(MatrixD[df Inverse[f1e], e, e, e] /. e->0) e^3/3! +
(MatrixD[df Inverse[f1e], e, e, e, e] /. e->0) e^4/4!
] + O[e]^5 //TeXForm
$\operatorname{IdentityMatrix}[d]-2 \operatorname{c2} e+e^2 (4
\operatorname{MatrixPower}[\operatorname{c2},2]-3 \operatorname{c3})+e^3 (-8
\operatorname{MatrixPower}[\operatorname{c2},3]+6
\operatorname{c2}.\operatorname{c3}+6 \operatorname{c3}.\operatorname{c2}-4
\operatorname{c4})+e^4 (-12
\operatorname{c3}.\operatorname{MatrixPower}[\operatorname{c2},2]-12
\operatorname{MatrixPower}[\operatorname{c2},2].\operatorname{c3}+16
\operatorname{MatrixPower}[\operatorname{c2},4]+9
\operatorname{MatrixPower}[\operatorname{c3},2]-12
\operatorname{c2}.\operatorname{c3}.\operatorname{c2}+8
\operatorname{c2}.\operatorname{c4}+8 \operatorname{c4}.\operatorname{c2}-5
\operatorname{c5})+O\left(e^5\right)$
which is in basic agreement with your inverse computation. A similar computation can be done for Inverse[f1e] . fe
. However, I will instead present an approach teaching Series
to use MatrixD
for matrix functions. The internal function used by Series
is System`Private`InternalSeries
, so we teach this internal function about Dot
and Inverse
:
Unprotect[System`Private`InternalSeries];
System`Private`InternalSeries[a_Inverse|a_Dot, {e_,e0_,n_}] := SeriesData[
e,
e0,
TensorReduce[TensorExpand[NestList[MatrixD[#,e]&,a,n]/.e->e0]]/Range[0,n]!,
0,
n+1,
1
]
Now, we can use Series
directly:
Series[df Inverse[f1e], {e, 0, 4}] //TeXForm
$\operatorname{IdentityMatrix}[d]-2 \operatorname{c2} e+e^2 (4
\operatorname{MatrixPower}[\operatorname{c2},2]-3 \operatorname{c3})+e^3 (-8
\operatorname{MatrixPower}[\operatorname{c2},3]+6
\operatorname{c2}.\operatorname{c3}+6 \operatorname{c3}.\operatorname{c2}-4
\operatorname{c4})+e^4 (-12
\operatorname{c3}.\operatorname{MatrixPower}[\operatorname{c2},2]-12
\operatorname{MatrixPower}[\operatorname{c2},2].\operatorname{c3}+16
\operatorname{MatrixPower}[\operatorname{c2},4]+9
\operatorname{MatrixPower}[\operatorname{c3},2]-12
\operatorname{c2}.\operatorname{c3}.\operatorname{c2}+8
\operatorname{c2}.\operatorname{c4}+8 \operatorname{c4}.\operatorname{c2}-5
\operatorname{c5})+O\left(e^5\right)$
in agreement with the previous result. Finally:
Series[Inverse[f1e] . fe, {e, 0, 4}] - e IdentityMatrix[d] //TeXForm
$-\operatorname{c2} e^2-2 e^3
(\operatorname{c3}-\operatorname{MatrixPower}[\operatorname{c2},2])+e^4 (-4
\operatorname{MatrixPower}[\operatorname{c2},3]+4
\operatorname{c2}.\operatorname{c3}+3 \operatorname{c3}.\operatorname{c2}-3
\operatorname{c4})+O\left(e^5\right)$
in agreement with your result.