10
$\begingroup$

So, I've been playing around with Mathematica lately, and I found an interesting (what I presume to be an) error. Trying to simplify (PlusMinus[a])^2 does not give a result of a^2. However, it is a fact that $(\pm a)^2 == a^2$.

Obviously, this is fairly easy to work around, but it does require splitting your work up into two (or more, depending on how many times you use PlusMinus) separate pieces.

So, am I missing something, or is this an error on Mathematica's part?

$\endgroup$
1

1 Answer 1

25
$\begingroup$

From the documentation:

PlusMinus[a] displays as $\pm x$.

I believe it is purely a formatting function. It is not literally interpreted as $\pm x$. However, per the documentation, you can assign values to it.

You can assign a rule that mimics the behavior you want by assigning an UpValue to PlusMinus:

PlusMinus /: PlusMinus[a_]^2 := a^2

Then:

UpValues@PlusMinus
(* { HoldPattern[(\[PlusMinus]a_)^2] :> a^2 } *)

and

PlusMinus[5]^2
(* 25 *)

As pointed out by Lou in a comment, PlusMinus is one of the Operators without Built-in Meanings, which means that

PlusMinus[x,y,[Ellipsis]]

doesn't evaluate, it just displays.

$\endgroup$

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