The exercise has two square roots and some extra stuff.
To solve by hand, one would
- isolate one square root on one side of the equation,
to get something like
a = b + c
where a
and b
are square roots and c
is not - square both sides (this can lose information so we'll have to check,
among all solutions of this new equation, which ones are
solutions of the original equation)
- this gets rid of one of the square roots, the other one survives
in the double product of (b + c)^2, as (2bc)
- isolate the square root one one side of the equation
- square both sides again
- finally solve the equation with no square roots
(a polynomial equation of degree four)
- check which solutions satisfy the original equation
We can follow this method with Sage too, guiding it through the calculations.
It's a bit tedious but it saves us from doing the computations by hand.
Set constants:
sage: n = 4/3
sage: h1 = 1
sage: h2 = 1
Two variables in the symbolic ring and an equation:
sage: x, y = SR.var('x, y')
sage: g = sqrt(x^2 + y^2) + n * sqrt(x^2 + (h1 + h2 - y)^2) - (h1 + n * h2) == 0
sage: g
4/3*sqrt(x^2 + (y - 2)^2) + sqrt(x^2 + y^2) - 7/3 == 0
Solve does not help much:
sage: solve(g.subs({x: 1/5}), y)
[sqrt(25*y^2 - 100*y + 101) == -3/4*sqrt(25*y^2 + 1) + 35/4]
Substitute:
sage: h = g.subs({x: 1/5})
sage: h
4/15*sqrt(25*(y - 2)^2 + 1) + 1/5*sqrt(25*y^2 + 1) - 7/3 == 0
Get rid of denominators:
sage: hh = 15 * h
sage: hh
4*sqrt(25*(y - 2)^2 + 1) + 3*sqrt(25*y^2 + 1) - 35 == 0
Give names to the three summands:
sage: a, b, c = hh.lhs().operands()
sage: a, b, c
(4*sqrt(25*(y - 2)^2 + 1), 3*sqrt(25*y^2 + 1), -35)
Isolate one and square both sides:
sage: j = a^2 == (b + c)^2
sage: j
400*(y - 2)^2 + 16 == (3*sqrt(25*y^2 + 1) - 35)^2
Expand:
sage: jj = j.expand()
sage: jj
400*y^2 - 1600*y + 1616 == 225*y^2 - 210*sqrt(25*y^2 + 1) + 1234
Compute the difference of both sides (that should be zero):
sage: k = jj.lhs() - jj.rhs()
sage: k
175*y^2 - 1600*y + 210*sqrt(25*y^2 + 1) + 382
Give names to the four summands:
sage: aa, bb, cc, dd = k.operands()
sage: aa, bb, cc, dd
(175*y^2, -1600*y, 210*sqrt(25*y^2 + 1), 382)
If the sum is zero, then the difference of squares must be zero:
sage: m = (aa + bb + dd)^2 - (cc)^2
sage: m
(175*y^2 - 1600*y + 382)^2 - 1102500*y^2 - 44100
Expand:
sage: mm = m.expand()
sage: mm
30625*y^4 - 560000*y^3 + 1591200*y^2 - 1222400*y + 101824
Move from the symbolic ring to a proper polynomial ring:
sage: R.<y> = QQ[]
sage: p = R(mm)
sage: p
30625*y^4 - 560000*y^3 + 1591200*y^2 - 1222400*y + 101824
Find the roots as algebraic numbers:
sage: rr = p.roots(QQbar, multiplicities=False)
sage: rr
[0.09455004564983336?,
1.144286167075680?,
2.049032178063518?,
14.99784589492526?]
Substitute in the original equation to know which give zero:
sage: ss = [h.subs({y: r}).lhs() for r in rr]
sage: ss
[4/15*sqrt(91.76848821332630?) + 1/5*sqrt(1.223492778309640?) - 7/3,
1/5*sqrt(33.73477080401876?) + 4/15*sqrt(19.30615409645079?) - 7/3,
1/5*sqrt(105.9633216684931?) + 4/15*sqrt(1.060103862141313?) - 7/3,
1/5*sqrt(5624.384537198158?) + 4/15*sqrt(4224.599947705633?) - 7/3]
The symbolic ring keeps things too symbolic, move to algebraic numbers:
sage: tt = [QQbar(s) for s in ss]
sage: tt
[0.4424464312541602?, 0.?e-16, 0.?e-16, 29.99835872096514?]
Exactify to make sure things that look like zero are actually zero:
sage: _ = [t.exactify() for t in tt]
sage: tt
[0.4424464312541602?, 0, 0, 29.99835872096514?]
Select the roots of the transformed equation that are actually roots
of the original equation:
sage: zz = [r for i, r in enumerate(rr) if tt[i].is_zero()]
sage: zz
[1.144286167075680?, 2.049032178063518?]
These are algebraic numbers:
sage: za, zb = zz
sage: za.minpoly()
x^4 - 128/7*x^3 + 63648/1225*x^2 - 48896/1225*x + 101824/30625
sage: zb.minpoly()
x^4 - 128/7*x^3 + 63648/1225*x^2 - 48896/1225*x + 101824/30625
Since their minimal polynomial is of degree four,
they can be expressed with radicals, although the
radical expression is not particularly illuminating.
sage: za.radical_expression()
-1/2450*sqrt((1500625*(12288/42875*I*sqrt(2776173) - 6128672768/1838265625)^(2/3) + 73460800*(12288/42875*I*sqrt(2776173) - 6128672768/1838265625)^(1/3) + 91681024)/(12288/42875*I*sqrt(2776173) - 6128672768/1838265625)^(1/3)) + 1/2*sqrt(-(12288/42875*I*sqrt(2776173) - 6128672768/1838265625)^(1/3) - 91681024/1500625/(12288/42875*I*sqrt(2776173) - 6128672768/1838265625)^(1/3) - 806400/sqrt((1500625*(12288/42875*I*sqrt(2776173) - 6128672768/1838265625)^(2/3) + 73460800*(12288/42875*I*sqrt(2776173) - 6128672768/1838265625)^(1/3) + 91681024)/(12288/42875*I*sqrt(2776173) - 6128672768/1838265625)^(1/3)) + 119936/1225) + 32/7
sage: zb.radical_expression()
1/2450*sqrt((1500625*(12288/42875*I*sqrt(2776173) - 6128672768/1838265625)^(2/3) + 73460800*(12288/42875*I*sqrt(2776173) - 6128672768/1838265625)^(1/3) + 91681024)/(12288/42875*I*sqrt(2776173) - 6128672768/1838265625)^(1/3)) - 1/2*sqrt(-(12288/42875*I*sqrt(2776173) - 6128672768/1838265625)^(1/3) - 91681024/1500625/(12288/42875*I*sqrt(2776173) - 6128672768/1838265625)^(1/3) + 806400/sqrt((1500625*(12288/42875*I*sqrt(2776173) - 6128672768/1838265625)^(2/3) + 73460800*(12288/42875*I*sqrt(2776173) - 6128672768/1838265625)^(1/3) + 91681024)/(12288/42875*I*sqrt(2776173) - 6128672768/1838265625)^(1/3)) + 119936/1225) + 32/7
Welcome to Ask Sage! Thank you for your question!
Note: no need to declare
h1
,h2
,n
as symbolic variables before assigning values to them.Only declaring
x
andy
is useful, as they will be used asx
andy
.