Ask Your Question
1

Conjugate multiplication of square root

asked 2019-09-27 21:34:51 +0200

Tommi gravatar image

Is there a simple way to simplify a formula using conjugate multiplication of the square roots? For example, when I perform

var('a,b,d')
exp = 1/(a+b*sqrt(d))
exp.full_simplify()

I would like to get

(b*sqrt(d) - a)/(b^2*d - a^2)

but what I actually get is just the form that I started with. Even if I specify the assumptions

assume(d,'real')
assume(d>0)

the conjugate multiplication does not happen automatically. I would like to be able to tell Sage, that I want the conjugate multiplication. In some cases that are relevant to me, the conjugate multiplication would simplify my expressions significantly.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-09-28 10:05:43 +0200

Emmanuel Charpentier gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-09-27 21:34:51 +0200

Seen: 214 times

Last updated: Sep 28 '19