What about something like

sage: var('p,q,r,a')
(p, q, r, a)
sage: b = sqrt(1-a^2)
sage: eq = (p*a+r*b+q)^2
sage: eq = eq.expand(); eq
a^2*p^2 - a^2*r^2 + 2*sqrt(-a^2 + 1)*a*p*r + 2*a*p*q + 2*sqrt(-a^2 + 1)*q*r 
+ q^2 + r^2
sage: b = var('b')
sage: eq.subs({sqrt(1-a^2): b})
a^2*p^2 + 2*a*b*p*r - a^2*r^2 + 2*a*p*q + 2*b*q*r + q^2 + r^2

-- 
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.

Reply via email to