In the following example I would like to make Sage realize that (p,q,r) are constants and (a,b) are variables so in the end everything should be expressed as a polynomial in a,b. In particular b^2 should be rewritten as 1-a^2 (b and a are actually sin and cosine of something) but b should not be rewritten as sqrt(1-a^2). And, in the end the terms should be grouped so we see explicitly the coefficients of a,b,1, and a^2. Of course this example is simple enough to do by hand, but I want to know how to control Sage enough to get this to happen in Sage. I tried various simplification functions. I suppose I could start over, not using "symbolic expressions" but declaring K to be a suitable field or ring, maybe a quadratic extension of the field of rational functions in a. That is probably the "right" way to do it. But I wish there were a simpler way. I'm writing a paper with little snippets of Sage code with which the reader, who will be a mathematician probably unfamiliar with SageMath, can check the computations, or see how the computations can be checked. So the code should be readable to such a person, ruling out the introduction of new fields. The code below is perfectly readable in that sense, but it doesn't quite do the job.
def mar11b(): var('p,q,r,a,b') b = sqrt(1-a^2) lam = p*a + r*b + q mu = r*a - p*b lam = sqrt(N/2) eq = lam^2 - (p*a+r*b+q)^2 eq = eq.expand() print(eq) -- 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 https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.