1
$\begingroup$

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.

$\endgroup$
2
  • $\begingroup$ 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. $\endgroup$
    – Jens
    Commented Mar 30, 2017 at 16:22
  • $\begingroup$ 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. $\endgroup$
    – Jon Snow
    Commented Mar 30, 2017 at 17:01

1 Answer 1

1
$\begingroup$

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.

$\endgroup$
8
  • $\begingroup$ I am so sorry. You are right I make it wrong again when I copy. Thank you so much! $\endgroup$
    – Jon Snow
    Commented Mar 30, 2017 at 17:29
  • $\begingroup$ And If I want one function not to be expand, lets say a[x]? $\endgroup$
    – Jon Snow
    Commented Mar 30, 2017 at 18:51
  • $\begingroup$ @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]. $\endgroup$
    – Jens
    Commented Mar 30, 2017 at 19:52
  • $\begingroup$ 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 $\endgroup$
    – Jon Snow
    Commented Mar 30, 2017 at 21:14
  • $\begingroup$ 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]. $\endgroup$
    – Jens
    Commented Mar 30, 2017 at 21:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.