3
$\begingroup$

Say I want to ask Mathematica whether $|x| = x$ for all $x > 0$.

Obviously, if I try TrueQ[Abs[x] == x], I get False, because I haven't specified that I'm talking only about the case where $x > 0$. How would I go about doing that?

$\endgroup$
7
  • 2
    $\begingroup$ Assuming[x > 0, TrueQ[Refine[Abs[x] == x]]] ? $\endgroup$ Commented Oct 22, 2015 at 1:35
  • $\begingroup$ I like this method, it's very readable and intuitive. Thanks. $\endgroup$ Commented Oct 22, 2015 at 1:43
  • 2
    $\begingroup$ Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory tour now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. $\endgroup$ Commented Oct 22, 2015 at 1:44
  • 2
    $\begingroup$ Resolve[ForAll[x, x > 0, Abs[x] == x]] $\endgroup$ Commented Oct 22, 2015 at 1:44
  • 1
    $\begingroup$ Simplify[Abs[x] == x, x > 0] or Assuming[x > 0, Abs[x] == x // Simplify] $\endgroup$ Commented Oct 22, 2015 at 5:19

1 Answer 1

7
$\begingroup$

Posting this here as community wiki because we answers should not stay only as comments.


You have many options

Using Resolve and ForAll

Resolve[ForAll[x, x > 0, Abs[x] == x]] 

Using Refine

Assuming[x > 0, TrueQ[Refine[Abs[x] == x]]] 

But assumptions can be placed inside Refine, as in

Refine[Abs[x] == x, x > 0] 

Using Simplify

Simplify[Abs[x] == x, x > 0] 

Other

Actually almost any other function that accept assumptions will do the job.

PiecewiseExpand[Abs[x], x > 0] == x 
$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.