Here's a two command script defining L1, Der1 (which compute the first Lyapunov exponent of an ODE):
Subscript[L, 1] =
Subscript[F, 3, 0] + Subscript[F, 1, 2] + Subscript[G, 0, 3] +
Subscript[G, 2, 1] +
1/\[Omega] (Subscript[F, 1,
1] (Subscript[F, 2, 0] + Subscript[F, 0, 2]) -
Subscript[G, 1, 1] (Subscript[G, 2, 0] + Subscript[G, 0, 2]) +
Subscript[F, 0, 2] Subscript[G, 0, 2] -
Subscript[F, 2, 0] Subscript[G, 2, 0]);
Der1[fg_, equilibrium_ : {}] :=
Module[{J, xyshift, T, Tinvuv, FG, derivatives, a, b, u, v, i, j},
J = Simplify[D[fg, {{x, y}}] /. equilibrium];
xyshift = {x -> x + (x /. equilibrium), y -> y + (y /. equilibrium)};
T = {{1, 0}, {-a/\[Omega], -b/\[Omega]}};
Tinvuv = Inverse[T] . {u, v};
FG = (T . fg /. xyshift) /. {x -> Tinvuv[[1]],
y -> Tinvuv[[2]]} /. {a -> J[[1, 1]], b -> J[[1, 2]]};
derivatives = {};
For[i = 0, i <= 3, i++, For[j = 0, j <= 3 - i, j++,
derivatives =
Join[derivatives, {Subscript[F, i,
j] -> (D[FG[[1]], {u, i}, {v, j}] /. {u -> 0, v -> 0}),
Subscript[G, i,
j] -> (D[FG[[2]], {u, i}, {v, j}] /. {u -> 0, v -> 0})}]]];
derivatives];
It works fine:
fg = Subscript[\[Kappa], 1] x^2 {1, 0} +
Subscript[\[Kappa], 2] x y {-1, 1} +
Subscript[\[Kappa], 3] y {0, -1} + Subscript[\[Kappa], 4] y {1, -1};
derivatives = Simplify[Der1[fg]]
L1 = Simplify[Subscript[L, 1] /. derivatives]
Then I copied Der1, but not L1, into a package util, after Begin["Private"], I only changed its name to DerS, and the same commands don't work anymore. The derivatives yield now
{Subscript[util`Private`F, 0, 0] ->
x^2 Subscript[\[Kappa], 1] +
y (-x Subscript[\[Kappa], 2] + Subscript[\[Kappa], 3]),
Subscript[util`Private`G, 0, 0] -> 0
... and are not subsituted in L1 at all (the input formula of L1 is offered as answer, with no substitution). I could still try to include the L1 formula to the script in the package, but first I'm curious if this can be avoided.