23
$\begingroup$

Around is a useful feature of Mathematica 12 to work with uncertain data.

x = Around[-1, {0.5, 1.5}]

$-1.0^{+1.5}_{-0.5}$

I'm curious how to get an absolute value of such uncertain data. When I use Abs directly I get an unexpected result:

Abs[x]

$1.0^{+1.5}_{-0.5}$

I have expected: $1.0^{+0.5}_{-1.0}$, because

Abs[x["Interval"]]

Interval[{0, 1.5}]

In total there are two issues:

  1. Upper and lower uncertainties are not interchanged when taking Abs.

  2. Crossing of zero is ignored.

Is this intended behaviour of Around or some sort of a bug?

How should I calculate absolute values of uncertain data points? For example, when I want to plot Abs of uncertain of data?

Update

Simple multiplication by a negative number gives incorrect result:

(-1)*x

$1.0^{+1.5}_{-0.5}$ (* Correct answer is $1.0^{+0.5}_{-1.5}$*)

$\endgroup$
5
  • 7
    $\begingroup$ That some for support. Around is pretty new and apparently very buggy. Or the two uf us haven't understood the deeper meaning of Around, yet. $\endgroup$ Aug 9, 2019 at 23:13
  • 2
    $\begingroup$ I guess @HenrikSchumacher's comment should begin That's one for support. ? $\endgroup$ Aug 10, 2019 at 16:33
  • 2
    $\begingroup$ I wouldn't call this "buggy", it just looks like Abs doesn't support Around in its initial implementation (unless it is documented to do so). But if you'd like it to, then yes, reach out to support and ask for it. $\endgroup$
    – ktm
    Aug 12, 2019 at 15:14
  • $\begingroup$ @user6014 There are better ways to implement unimplemented functions, for example, keep the original symbolic form. Since it evaluates to incorrect result without warnings I would call it a bug. BTW multiplication of Around by a number is documented but still produces incorrect result. $\endgroup$
    – Ray Shadow
    Aug 13, 2019 at 1:16
  • $\begingroup$ -Around[-1, {0.5, 1.5}] has similar problems. The behavior of About seems consistent with f[About[x, {a,b}]] being About[f[x], {Abs[f'[x]]*a, Abs[f'[x]]*b}]. $\endgroup$
    – Michael E2
    Aug 13, 2019 at 1:38

1 Answer 1

2
$\begingroup$

I don't know if this would be acceptable as an answer, for the sake of expediency (assuming you just want a quick answer!), here is what you could write to keep this working for you:

abs[val_, lBound_, uBound_] := 
  Around[Abs[val], 
   If[val > 0, {lBound, uBound}, Reverse@{lBound, uBound}]];
abs[-1, 0.5, 1.5]

I hope this helps.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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