(1) I have expressions like curl*H - c^(-1)*d_t*D, where curl and d_t express derivatives. In the process of conversion, sage switches the order and outputs:H*curl - D*d_t/c
I thought of defining a free algebra over a symbolic ring, but this turns out to have problems. Apparently expand and simplify are not defined for expressions in a free algebra. Sage chokes on the following code.var('c, pi, c, mu_0,epsilon_0')F.<curl,H,d_t,D,J> = FreeAlgebra(SR,5,'curl,H,d_t,D,J')eqCGS = curl*H - c^(-1)*d_t*D ### CGS expression on this line ###eq = eqCGS * (1/2)*mu_0^(-1/2)*pi^(-1/2) ### Multiplicative factor on this line ###assume(c>0,mu_0>0,epsilon_0>0)eq = eq.subs({c == mu_0^(-1/2)*epsilon_0^(-1/2)})
eq = eq.subs({H:2*H})
eq = eq.subs({D : 2*pi^(1/2)*epsilon_0^(-1/2)*D})
eq = eq.subs({J : (1/2)*pi^(-1/2)*epsilon_0^(-1/2)*J})
eq = eq.expand()eq = eq.simplify()
Furthermore, the code does not substitute for c.
Any guidance would be appreciated
This works beautifully, thanks.I have another small issue: I can't do substitutions in equality expressions with terms in the free algebra. For instance, Sage tells me "Not iterable"var('c, pi, c, mu_0,epsilon_0,epsilon,mu,q,Q,e')F.<curl,div,grad,d_t,d_x,d_y,d_z,J,I,K,P,p,E,V,Phi,D,B,A,H,M,m,rho,sigma,C,R,Z,L> = FreeAlgebra(SR,27,'curl,div,grad,d_t,d_x,d_y,d_z,J,I,K,P,p,E,V,Phi,D,B,A,H,M,m,rho,sigma,C,R,Z,L')eqCGS = curl*H - (1/c)*d_t*D == 4*pi/c*K ### CGS expression on this line ###
eq =eqCGS* (1/2)*mu_0^(-1/2)*pi^(-1/2) ### Multiplicative factor on this line ###
assume(mu_0>0,epsilon_0>0,pi>0,c>0,e>0)eq = sum(b.subs(c == mu_0^(-1/2)*epsilon_0^(-1/2))*F(a) for a,b in eq)