3
$\begingroup$

I want to simplify with Mathematica 11 the following algebraic expression under the assumptions $x<0$ and $y>0$:

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

A short calculation yields A = 1. But Mathematica seems not able to obtain that result when the following expression is evaluated:

FullSimplify[A,Assumptions->x<0&&y>0]

Is it possible to help Mathematica to solve this?

Thanks for your answer.

$\endgroup$
5
  • $\begingroup$ What is that "short calculation " that yields A = 1? $\endgroup$
    – rhermans
    Sep 22, 2017 at 13:16
  • 1
    $\begingroup$ You can complete the square in the denominator, explicitly: 2x^2 + y - 2 x Sqrt[x^2+y] = (-x + Sqrt[x^2 + y])^2 $\endgroup$
    – Flo
    Sep 22, 2017 at 13:20
  • $\begingroup$ Strange indeed. Simplify[A == 1, ...] and Simplify[A^2, ...] both work. You could use the latter to figure out that the result must be either 1 or -1, and the former to show that it is always 1. $\endgroup$
    – Szabolcs
    Sep 22, 2017 at 13:24
  • $\begingroup$ Even this works: Reduce[A == z, {x, y}, Reals]. $\endgroup$
    – Szabolcs
    Sep 22, 2017 at 13:26
  • 2
    $\begingroup$ Thanks for looking into it. My problem is that A is part of a much bigger expression and I rely on FullSimplify to correctly simplify it. And I want to avoid using replacement rules, which wouldn't be elegant. $\endgroup$
    – Flo
    Sep 22, 2017 at 13:28

1 Answer 1

3
$\begingroup$

One possibility is to add Reduce to the list of TransformationFunction rules. For example:

oneReduce[x_] := If[TrueQ @ !Reduce[{x != 1, $Assumptions}], 1, x]

If Reduce can determine that x != 1 is definitely False based on $Assumptions, then it transforms x to 1. Let's see this in action:

Assuming[x<0 && y>0, Simplify[A, TransformationFunctions->{Automatic, oneReduce}]]

1

Another useful transformation function is:

zeroReduce[x_] := If[TrueQ @ !Reduce[{x != 0, $Assumptions}], 0, x]

Perhaps this approach will work with more complicated expressions.

$\endgroup$
1
  • $\begingroup$ That's definitely an elegant and useful solution. In my case computationally too expensive though. $\endgroup$
    – Flo
    Sep 22, 2017 at 15:04

Your Answer

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

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