1
$\begingroup$

I want to let Simplify know the exact value of a symbol, to resolve logical statements, but don't want it to actually replace it. For instance, I would like something like

assumptions = x==4;  
Simplify[Sqrt[x^2], assumptions]

to output x and not 4 (or Abs[x]).

How can this, or something analogous, be done?

Edit: It wasn't clear enough that I understand that in this case an assumption like x>0 would output what I want -- however, this is not what I'm looking for. This is what I have been doing so far, but it is messy and needs focused attention. That is, I need to be sure that the eps that I set to define a range as

assumptions = (x > xValue - eps) && (x < xValue + eps)

is small enough for every independent simplification to be equivalent to that of

assumptions = x == xValue

Even if I could generaly chose a value exaggeratedly small such that this would be the case for all my problems, I'd still like to find a better alternative -- if there is one.

$\endgroup$
9
  • 2
    $\begingroup$ If instead of the exact value, you provide a range of values (for instance 3<x<5), the simplification will be done, but the values will not be substituted. $\endgroup$
    – yarchik
    Oct 15 at 20:00
  • $\begingroup$ @yarchik That is what I have been doing in this situation, but have always wondered if there isn't a more elegant and general solution. $\endgroup$
    – GaloisFan
    Oct 15 at 20:02
  • $\begingroup$ At the risk of pointing the obvious, these three examples are from the doc page on Simplify. $\endgroup$
    – Syed
    Oct 15 at 20:51
  • $\begingroup$ @Syed I understand that! It's just that it would be preferable to define the exact value because in very complicated scenarios, with a lot of variables, there is no direct way of defining a safe range for the variable in such a way that the expression is simplified to the max. $\endgroup$
    – GaloisFan
    Oct 15 at 21:03
  • 1
    $\begingroup$ Would x <=4 && x>=4 work for you? $\endgroup$
    – Michael E2
    Oct 15 at 22:45
5
$\begingroup$

One possibility is to mimic the behavior of symbolic constants like Pi, E, etc:

N[x, _] ^= 4;
NumericQ[x] ^= True;

Then:

Sqrt[x^2]

x

without even using Simplify.

$\endgroup$

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