On Sunday, September 7, 2014 10:28:02 AM UTC-7, Chris Thron wrote: > > HI, > I'm trying to write a program that converts electromagnetic equations from > CGS to MKS units. I've run into the following issues: > > (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 >
Are you sure it's swapping the order on d_t*D? I'm not seeing that on your example. For the other rewriting, it's documented that " Free algebras commute with their base ring." which is clumsily formulated but means that the base ring will be the centre of the free algebra.It will rewrite expressions to have the coefficients to the left of monomials in the free algebra generators. > 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. > Yes, those routines are specific to SR and do not automatically extend to free algebras over SR. There's nothing to do, really, since free algebra elements themselves will be expanded anyway. The substitutions you want to do are on the level of SR and FreeAlgebraElements can't just dispatch on coefficients (e.g. FreeAlgebra(ZZ,...) elements would have coefficients that don't have a subs method. You can take apart your expression, do the operations coefficient-wise, and assemble your expression yourself: sum([b.subs(c == mu_0^(-1/2)*epsilon_0^(-1/2))*F(a) for a,b in eq]) (note that your original ".subs(..)" syntax does not work). Also be aware that FreeAlgebra probably assumes that the base ring actually is a ring, and "SymbolicRing" isn't strictly a ring (there are too many things that can be stuffed into it). For your basic expressions it might be OK, though. -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.