# Plotting a function containing a $\pm$ sign

Is there any command in Mathematica to plot an expression: $$f(x,y)=\exp^{x\pm y}$$. As far as I know, it is not possible as the expression will vary differently with the sign. I have seen such plots in some of the research articles without mentioning that they have been plotted for a single sign, so I want to know if there is any possibility.

• Is there a reason why you can't do Plot3D[{Exp[x+y],Exp[x-y]},{x,-2,2},{y,-2,2},PlotRange->All] ? Note that PlusMinus[x,y] is for display only and will not generate the same plot. i.e. Plot3D[Exp[PlusMinus[x,y]],{x,-2,2},{y,-2,2},PlotRange->All] will not work Commented Apr 28 at 5:03
• @Nasser Thank you
– Rag
Commented May 1 at 8:22

Define: ( because I can )

rule = {{PlusMinus :> Plus}, {PlusMinus :> Subtract}};

Plot3D[Evaluate[Exp[x ± y] /. rule]
, {x, -2, 2}, {y, -2, 2}
, PlotRange -> All
, PlotStyle -> {Red, Cyan}
, Exclusions -> None
, PlotLegends -> "Expressions"
]


Another experiment, perhaps to show envelopes:

Plot3D[Evaluate@{Exp[x ± y] /. rule // MinMax}
, {x, -2, 2}, {y, -2, 2}
, PlotRange -> All
, PlotStyle -> {White, Orange}
, Exclusions -> None
, PlotLegends -> "Expressions"
]


• To handle expressions with mixed $\pm$ and $\mp$, such as $\exp (x\pm y)(1\mp x)$, just extend the rule to rule = {{PlusMinus :> Plus, MinusPlus :> Subtract}, {PlusMinus :> Subtract, MinusPlus :> Plus}}. Commented Apr 29 at 13:33

If it won't interfere with the rest of your work, you can define

PlusMinus[a_, b_] := {a + b, a - b}


and then

f[x_, y_] := Exp[x \[PlusMinus] y]
f[a, b] (* {E^(a+b),E^(a-b)} *)

Plot3D[
Evaluate@f[x, y],
{x, -2, 2}, {y, -2, 2}, PlotRange -> All,
PlotStyle -> {Red, Cyan}, Exclusions -> None,
PlotLegends -> "Expressions"
]


Produces a plot like in @Syed's answer.

• Sometimes people write expressions like (a±b) (c±d) where the ±s are correlated with one another, both + or both – but not mixed. Both @Syed's rule and this trick implements the correlation correctly. If you need independent ±s (in this simple example, 4 results) something else is needed. Commented Apr 28 at 13:42