0
$\begingroup$

I'm trying to get Mathematica to Simplify

Sqrt[x^2 + y^2] < 2

to

x^2 + y^2 < 4

Among other things I've tried based on other's questions and answers

FullSimplify[Sqrt[x^2 + y^2] < 2, {x, y} \[Element] Reals, ComplexityFunction -> LeafCount]
(* Sqrt[x^2 + y^2] < 2 *)

FullSimplify[Refine[Reduce[(Sqrt[x^2 + y^2] < 2), (x | y) \[Element] Reals]],ComplexityFunction -> LeafCount]
(* -Sqrt[4 - x^2] < y < Sqrt[4 - x^2] *)

Any suggestions? Thanks in advance.

$\endgroup$
2
  • $\begingroup$ One isn't necessarily more simple than the other. In fact, I would prefer the former as it shows an Euclidean relationship. So Simplify[] is unlikely to do this for you. $\endgroup$
    – Feyre
    Commented Oct 24, 2016 at 7:43
  • $\begingroup$ Since x and y are real, just square both sides: expr = Sqrt[x^2 + y^2] < 2; expr2 = #^2 & /@ expr $\endgroup$
    – Bob Hanlon
    Commented Oct 24, 2016 at 22:32

1 Answer 1

2
$\begingroup$

It appears the Mathematica doesn't have a function to automatically Simplify a relational expression by squaring both sides.

However, one can accomplish this by providing a TransformationFunction to Simplify.

For example:

tf1[a_ < b_] := a^2 < b^2
Simplify[Sqrt[x^2 + y^2] < 2, TransformationFunctions ->{tf1, Automatic}]
(* x^2 + y^2 < 4 *)

However, tf1 only works for a LessThan relation.

Simplify[Sqrt[x^2 + y^2] > 2, TransformationFunctions -> {tf1, Automatic}]
(* Sqrt[x^2 + y^2] > 2 *)

But this can be fixed by adding an Alternatives pattern of relations. (Learned from Simplify equations with pattern assumptions )

relationOperators = Equal | Unequal | Greater | Less | GreaterEqual | LessEqual

tf2[l_~(relOp : relationOperators)~r_] := (l^2)~relOp~(r^2)

Table[Simplify[Sqrt[x^2 + y^2]~op~ 2, TransformationFunctions -> {tf2, Automatic}], {op, Level[relationOperators, -1]}]

(* {x^2 + y^2 == 4, x^2 + y^2 != 4, x^2 + y^2 > 4, x^2 + y^2 < 4, x^2 + y^2 >= 4, x^2 + y^2 <= 4} *)

Additionally, TransformationFunction can be expanded to only apply under the Condition that operands are Reals or relation is Equal or Unequal. (Learned from How to select TransformationFunctions based on Assumptions made when using Simplify? )

tf3[l_~(relOp : relationOperators)~r_] /; Simplify[(l \[Element] Reals) && (r \[Element] Reals) || relOp == Equal || relOp == Unequal]  := (l^2)~relOp~(r^2)

Table[Simplify[Sqrt[x^2 + y^2]~i~ 2, TransformationFunctions -> {tf3, Automatic}], {i, Level[relationOperators, -1]}]
(* {x^2 + y^2 == 4, x^2 + y^2 != 4, Sqrt[x^2 + y^2] > 2, Sqrt[x^2 + y^2] < 2, Sqrt[x^2 + y^2] >= 2, Sqrt[x^2 + y^2] <= 2} *)

Assuming[{x, y} \[Element] Reals, Table[Simplify[Sqrt[x^2 + y^2]~i~ 2, TransformationFunctions -> {tf3, Automatic}], {i, Level[relationOperators, -1]}]]
(* {x^2 + y^2 == 4, x^2 + y^2 != 4, x^2 + y^2 > 4, x^2 + y^2 < 4, x^2 + y^2 >= 4, x^2 + y^2 <= 4} *)
$\endgroup$

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.