# Taylor expansion of two variable function without cross terms

I have the matrix symmetric matrix

g={{a[x],        b[x],        c[x],         d[x]},
{b[x],  1/(1-a[x]),           0,            0},
{c[x],           0,  1/(1-a[x]),            0},
{d[x],           0,           0,  1/(1-a[x])}}


And I want to make a function who returns the inverse matrix in Taylor expansion linear in $a,b,c,d$, without their cross terms. After a little search I made this

 InverseMatrix[g_] :=
Normal[Series[Simplify[Inverse[g]] /. {a[x] -> ε a[x], b[x] -> ε b[x],


c[x] -> ε c[x], d[x] -> ε d[x]}, {ε, 0, 1}]] /. [Epsilon] -> 1;

But doesn't work as I want.

• Is a(x) supposed to be a[x]? or why are there brackets? If you could give an example of the desired result, that might help clarify things. You probably want linearity in $a'$, $b'$ etc., right? In that case you just made a syntax mistake. – Jens Mar 30 '17 at 16:22
• Sorry I meant a[x], copied wrong. In my code I have it a[x]. The results I hope to get is linearity in the a,b,c,d. – Jon Snow Mar 30 '17 at 17:01

What you want is probably this:

InverseMatrix[g_] :=
Normal[Series[
Simplify[
Inverse[g]] /. {f_[x] :> ε f[x]}, {ε, 0,
1}]] /. ε -> 1;


The parameter ε is not meant to be introduced in front of the function argument x, but in front of the functions themselves, if you want to expand to a consistent order in all of them.

• I am so sorry. You are right I make it wrong again when I copy. Thank you so much! – Jon Snow Mar 30 '17 at 17:29
• And If I want one function not to be expand, lets say a[x]? – Jon Snow Mar 30 '17 at 18:51
• @JonSnow You could change the named pattern f_[x] to (f : Except[a])[x] Here f is still the label for the pattern representing a function of x, but using Except I now exclude a[x]. – Jens Mar 30 '17 at 19:52
• And Something last!!! If I want to expand a[x] up to second power, and keep the others only the linear terms? I am noob in mathematica, I will be happy if you could suggest me a good book to read – Jon Snow Mar 30 '17 at 21:14
• I'd recommend reading the help documentation under tutorial/PatternsOverview. And of course searching this site. You could append another replacement rule to the one I gave. I don't understand how you want to keep track of the different orders, so I can't be more specific. The rule would involve a[x]-> a[ε x]. – Jens Mar 30 '17 at 21:27