3
$\begingroup$

As taught in High School Mathematics:

$$\begin{array}{ccl} \left\{ {(x-3)(x+3)\over 5(x+3)} : \ x\ne -3 \right\} & \ne & \left\{ {x-3\over 5} : \ x\in\mathbb{R} \right\} \\ \left\{ {(x-3)(x+3)\over 5(x+3)} : \ x\ne -3 \right\} & = & \left\{ {x-3\over 5} : \ x\ne -3 \right\} \end{array}$$

In order to truly say one rational expression is "equal" to another, when canceling variables in the denominator, we need to retain the conditions that make the domains equivalent as well.

Though from what I can tell Mathematica seems to have no problem with the potential for Zero in the Denominator.

For example I would have expected the following to give a conditional output where $x\ne -3$, but they don't:

In[]:= Cancel[((x - 3) (x + 3))/(5 (x + 3))]
Out[]= 1/5 (-3 + x)

In[]:= Reduce[((x - 3) (x + 3))/(5 (x + 3)) == (x - 3)/5, x]
Out[]= True

In[]:= Resolve[ForAll[{x}, ((x - 3) (x + 3))/(5 (x + 3)) == (x - 3)/5]]
Out[]= True

In[46]:= FunctionDomain[((x - 3) (x + 3))/(5 (x + 3)), x, Reals]
Out[46]= True

Etc.

On a practical level I can just manually add the assumptions. But I'd like to increase my familiarity with Mathematica and understand why this behavior arises in the first place.

$\endgroup$
  • 2
    $\begingroup$ You don't even need Reduce/Cancel/Resolve, etc because ((x - 3) (x + 3))/(5 (x + 3)) automatically simplifies to 1/5 (-3 + x) before any of these functions are called. $\endgroup$ – bill s Feb 24 '15 at 19:24
  • $\begingroup$ I missed this day in high school mathematics. If we follow this logic, then even $\frac{x}{x}$ would have a point where it is undefined. But surely, the limit as x goes to zero of that function is still 1? Any mathematician here to chime in? $\endgroup$ – Jason B. Dec 11 '15 at 9:18
  • $\begingroup$ So, it skips removable singularities… why do you need to keep them? $\endgroup$ – J. M. will be back soon Dec 11 '15 at 9:20
  • 1
    $\begingroup$ Related: mathematica.stackexchange.com/questions/89990/… $\endgroup$ – Patrick Stevens Dec 11 '15 at 9:47
  • $\begingroup$ A bit late for commenting, but I'll mention that a conditional result from Cancel and related functions would be, for practical purposes, useless. Also it would not be correct in the sense of working over fields of rational functions. $\endgroup$ – Daniel Lichtblau Dec 11 '15 at 15:34
5
$\begingroup$

As noted in comment by bill s, given rational expression automatically simplifies even without using Cancel, Reduce, etc.:

((x - 3) (x + 3))/(5 (x + 3))
(* 1/5 (-3 + x) *)

If you want to restrict "domain of expression" in Mathematica you can do it manually using ConditionalExpression. Quoting from its documentation:

ConditionalExpression is automatically propagated from the arguments of mathematical functions, equations and inequalities, and Boolean operators

So you can use it in your equation:

ConditionalExpression[((x - 3) (x + 3))/(5 (x + 3)), x != -3] == (x - 3)/5
% /. x -> 5
%% /. x -> -3
(* ConditionalExpression[True, x != -3] *)
(* True *)
(* Undefined *)

If you want to automatically restrict expression domain you could use FunctionDomain, but since discussed rational expression automatically evaluates to expression which has larger domain, we need to wrap original expression with Unevaluated when passing it to FunctionDomain.

FunctionDomain[Unevaluated[((x - 3) (x + 3))/(5 (x + 3))], x]
(* x < -3 || x > -3 *)

Output of FunctionDomain can be passed as second argument of ConditionalExpression. Automation of this process was implemented in RestrictDomain function from Domains` package. Using it we get:

RestrictDomain[((x - 3) (x + 3))/(5 (x + 3)), x]
(* ConditionalExpression[1/5 (-3 + x), x > -3 || x < -3] *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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