3
$\begingroup$

I have a number with certain uncertainty

a1 = Around[1, 0.1]

I try to plot a function with this number

Plot[a1*x, {x, 0, 1}]

However nothing happened.

I was looking for something similar to this (the colour is not necessary):

a = Plot[1.1*x, {x, 0, 1}, PlotStyle -> Red];
b = Plot[1*x, {x, 0, 1}, PlotStyle -> Black];
c = Plot[0.9*x, {x, 0, 1}, PlotStyle -> Blue];
Show[a, b, c]

enter image description here

Question 1

There is some way to make that the first plot appears? Or there is some more efficient method than plotting three times?

Question 2

If I have a1=Around[1,0.1] how can I get the Maximum value of a1? In this case is clear that is 1.1, however I have to obtain this value "manually"

$\endgroup$
2
  • 1
    $\begingroup$ For question 2: Plus @@ Thread@ a1[{"Value", "Uncertainty"}] or a1["Value"] + a1["Uncertainty"] will give you the value + the uncertainty. That, of course, may not be the maximum value of a1 if the uncertainty is e.g. a standard deviation, but that's up to you to interpret. You may also be interested in other properties that you can extract from Around objects (see the details section of its docs). $\endgroup$
    – MarcoB
    Commented Jul 1, 2020 at 15:18
  • $\begingroup$ Oh thank you, that was the solution for the question 2. $\endgroup$
    – No name
    Commented Jul 1, 2020 at 15:23

1 Answer 1

3
$\begingroup$

Here's a way to get the plot programmatically:

a1 = Around[1, -0.1];
Plot[
  Evaluate@{a1["Value"] x, Thread[a1["Interval"] x, Interval]},
  {x, 0, 1},
  PlotStyle -> {Black, Blue, Red}
]

plot with three lines


For question 2, either one of the following will give you the value + the uncertainty:

Plus @@ Thread@ a1[{"Value", "Uncertainty"}] 
a1["Value"] + a1["Uncertainty"] 

That, of course, may not be the maximum value of a1 if the uncertainty is e.g. a standard deviation, but that's up to you to interpret. You may also be interested in other properties that you can extract from Around objects (see the details section of its docs).

$\endgroup$

Your Answer

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

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