Converting large symbolic Jacobian to LaTeX

461 Views Asked by At

I have generated an 8x8 Jacobian, containing a few variables and several zeros as elements. I would like to translate this to LaTeX code. How can I first simplify what I have, to make it tractable?

Here is the Maple code:

eq_1 := Lambda-mu*S-(beta*(H+C+C1+C2)*S+tau*(T+C)*S)/(S+T+H+C+C1+C2+C1M+C2M);
eq_2 := (-beta*(H+C+C1+C2)*T+tau*(T+C)*S)/(S+T+H+C+C1+C2+C1M+C2M)-(mu+mu[T])*T;
eq_3 := (beta*(H+C+C1+C2)*S-tau*(T+C)*H)/(S+T+H+C+C1+C2+C1M+C2M)-(mu+mu[A])*H;
eq_4 := (beta*(H+C+C1+C2)*T+tau*(T+C)*H)/(S+T+H+C+C1+C2+C1M+C2M)-(mu+mu[T]+mu[A]+lambda[T])*C;
eq_5 := lambda[T]*C-(mu+mu[A]+rho[1]+eta[1])*C1;
eq_6 := rho[1]*C1-(mu+mu[A]+rho[2]+eta[2])*C2;
eq_7 := eta[1]*C1-(mu+rho[1]+gamma)*C1M;
eq_8 := eta[2]*C2+rho[1]*C1M-(mu+rho[2]+gamma*rho[1]/(rho[1]+rho[2]))*C2M;
J := VectorCalculus:-Jacobian([eq_1, eq_2, eq_3, eq_4, eq_5, eq_6, eq_7, eq_8], [S, T, H, C, C1, C2, C1M, C2M]);

JQDFE := eval(J, [S = Lambda/(beta-mu[A]), T = 0, H = Lambda*(beta/(mu+mu[A])-1)/(beta-mu[A]), C = 0, C1 = 0, C2 = 0, C1M = 0, C2M = 0]);

Thanks.

1

There are 1 best solutions below

0
On BEST ANSWER

The Maple command simplify, with its size option supplied, reduces the length of the Matrix considerably.

You can also "factor" out a diagonal Matrix (scalars, from each row), and make a simple substitution of a sum of two variables, to get the length down by half again. That produces two Matrix factors f1 and f2 such that f1.f2=Q after resubstitution of R=mu+mu[A]. You might find that Matrices f1 and f2 prints ok. I'm not sure how "tractable" you need it.

restart:
eq_1 := Lambda-mu*S
        -(beta*(H+C+C1+C2)*S+tau*(T+C)*S)/(S+T+H+C+C1+C2+C1M+C2M):
eq_2 := (-beta*(H+C+C1+C2)*T+tau*(T+C)*S)/(S+T+H+C+C1+C2+C1M+C2M)
        -(mu+mu[T])*T:
eq_3 := (beta*(H+C+C1+C2)*S-tau*(T+C)*H)/(S+T+H+C+C1+C2+C1M+C2M)
        -(mu+mu[A])*H:
eq_4 := (beta*(H+C+C1+C2)*T+tau*(T+C)*H)/(S+T+H+C+C1+C2+C1M+C2M)
        -(mu+mu[T]+mu[A]+lambda[T])*C:
eq_5 := lambda[T]*C-(mu+mu[A]+rho[1]+eta[1])*C1:
eq_6 := rho[1]*C1-(mu+mu[A]+rho[2]+eta[2])*C2:
eq_7 := eta[1]*C1-(mu+rho[1]+gamma)*C1M:
eq_8 := eta[2]*C2+rho[1]*C1M
        -(mu+rho[2]+gamma*rho[1]/(rho[1]+rho[2]))*C2M:

J := VectorCalculus:-Jacobian([eq_1,eq_2,eq_3,eq_4,eq_5,eq_6,eq_7,eq_8],
                              [S, T, H, C, C1, C2, C1M, C2M]):
JQDFE := eval(J, [S = Lambda/(beta-mu[A]), T = 0,
                  H = Lambda*(beta/(mu+mu[A])-1)/(beta-mu[A]),
                  C = 0, C1 = 0, C2 = 0, C1M = 0, C2M = 0]):

length(JQDFE);
                                6483

Q:=simplify(JQDFE,size):

length(Q);
                                1421

F := Matrix(8,scan=diagonal,[beta/(mu+mu[A]),beta/(mu+mu[A]),
                             beta/((mu+mu[A]-beta)),beta,1$4]):

R = mu+mu[A];

f1:=map2( algsubs, (mu+muA) = R, subs(mu[A]=muA,F^(-1)) ):

f2:=simplify(subs(muA=mu[A], map2( algsubs, (mu+muA) = R,
                                   subs(mu[A]=muA,F.Q) )),size):

length(f2);

                                 781

LinearAlgebra:-Norm(simplify( subs( R=mu+mu[A], f1.f2 ) - Q ));
                                  0