Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Well...

sage: var("a,b,d")
(a, b, d)
sage: E=1/(a-b*sqrt(d));E
-1/(b*sqrt(d) - a)
def cm(x):
    W=[SR.wild(u) for u in range(2)]
    def cm1(x):
        W=[SR.wild(u) for u in range(4)]
        return x.subs(W[0]/(W[1]+W[2]*sqrt(W[3]))==\
                      (W[0]*(W[1]-W[2]*sqrt(W[3])))/(W[1]^2-W[2]^2*W[3]))
    return x.subs(W[0]+W[1]==W[0]+cm1(W[1]))

This should do the job.

sage: cm(E)
-1/(b*sqrt(d) - a)

But be aware that recursing in subexpressions isn't especially Sage's forte.