1
$\begingroup$

How can I automatically identify the term containing a radical (Sqrt[x^2 + (2 + y)^2]) in an equation and move it to the right side:

1 + 2 y + Sqrt[x^2 + (2 + y)^2] == 0

1 + 2 y == -Sqrt[x^2 + (2 + y)^2]

If the equation contains two radical terms, only one of them should be moved to the right:

Sqrt[x^2 + (-2 + y)^2] + Sqrt[x^2 + (2 + y)^2] == 6

Sqrt[x^2 + (-2 + y)^2] == 6-Sqrt[x^2 + (2 + y)^2]


If the equation contains two roots, simply move any of them to the right side of the equation. The purpose is to have one radical on each side of the equation.

$\endgroup$
3
  • 2
    $\begingroup$ In future, please do not significantly change the question when you already got answers to the initial question. $\endgroup$
    – Domen
    Apr 19, 2023 at 12:03
  • $\begingroup$ When running such code, new problems arise when trying various practical application scenarios $\endgroup$
    – csn899
    Apr 19, 2023 at 14:13
  • 1
    $\begingroup$ Well, of course, but then either explore your problem a bit more thoroughly in the first place before asking the question, or ask a new question :) $\endgroup$
    – Domen
    Apr 19, 2023 at 14:20

1 Answer 1

4
$\begingroup$
eq = 1 + 2 y + Sqrt[x^2 + (2 + y)^2] == 0;
SubtractSides[eq, FirstCase[List @@ First@eq, Sqrt[__]]]
(* 1 + 2 y == -Sqrt[x^2 + (2 + y)^2] *)

eq = Sqrt[x^2 + (-2 + y)^2] + Sqrt[x^2 + (2 + y)^2] == 6;
SubtractSides[eq, FirstCase[List @@ First@eq, Sqrt[__]]]
(* Sqrt[x^2 + (2 + y)^2] == 6 - Sqrt[x^2 + (-2 + y)^2] *)
$\endgroup$
6
  • $\begingroup$ 5 (-5 + Sqrt[x^2 + (-2 + y)^2]) + 2 y == 0If there are coefficients before the radical, how can we move such a radical to the right side of the equation? $\endgroup$
    – csn899
    Apr 19, 2023 at 14:12
  • 2
    $\begingroup$ @csn899, I don't want to come off as snarky, but if you want to learn Mathematica, you should try understanding the answers we give you and grasp the main concepts. For example, in FirstCase, the second argument is a pattern. Have you tried learning them? Then you will see that you can modify Sqrt[__] to k_*Sqrt[__] to match also radicals with a coefficient. However, you will also need to Expand your equation beforehand. $\endgroup$
    – Domen
    Apr 19, 2023 at 14:33
  • $\begingroup$ Clear["Global`*"] expr = EuclideanDistance[{0, 2}, {x, y}] + EuclideanDistance[{0, -2}, {x, y}] == 10 eq1 = Refine[Simplify[expr], Assumptions -> {x \[Element] Reals, y \[Element] Reals}] // FullSimplify eq2 = SubtractSides[eq1, FirstCase[List @@ First@eq1, Sqrt[__]]] eq3 = ApplySides[#^2 &, eq2] // Expand eq4 = Apply[Subtract, eq3] == 0 eq5 = SubtractSides[eq4, FirstCase[List @@ First@eq4, k_*Sqrt[__]]] eq6 = ApplySides[#^2 &, eq5] // Simplify $\endgroup$
    – csn899
    Apr 19, 2023 at 14:44
  • $\begingroup$ Why use K_* The form of Sqrt [__] cannot shift terms when the coefficient before the radical is 1. Is there any way to unify and transfer terms for all coefficients before the radical that are one? $\endgroup$
    – csn899
    Apr 19, 2023 at 15:01
  • $\begingroup$ @csn899, again, try learning patterns. There is a way to make part of a pattern Optional: k_.*Sqrt[__] $\endgroup$
    – Domen
    Apr 19, 2023 at 15:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.