Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Let's assume I want to plot the function $f(x)=a + bx+ cx^{2}$, where experimentally known values of parameters $a, b$ and, $c$ are as follows:

$a=1.01 \pm 0.18$

$b=0.92 \pm 0.11$

$c=2.2 \pm 0.2$

In the absence of uncertainties, we should have a thin curve which is trivial to plot. However, the thickness of the curve will increase depending on the amount of uncertainties. Is there any way to plot such a function with the corresponding "confidence bands" in Mathematica 8.0?

share|improve this question
3  
Try Plot[With[{w = Interval[1.01 + 0.18 {-1, 1}] + x (Interval[0.92 + 0.11 {-1, 1}] + x Interval[2.2 + 0.2 {-1, 1}])}, {Min[w], Max[w]}], {x, -5, 5}] and report back. – J. M. May 21 at 7:12
    
Thanks, J.M. This is good. – Benjamin May 22 at 17:40
up vote 5 down vote accepted

This does what I think you're after, fiddle with options as desired:

With[{a = Interval[1.01 + .18 {-1, 1}], 
  b = Interval[.92 + .11 {-1, 1}], c = Interval[2.2 + .2 {-1, 1}]}, 
 Plot[{Min[a + b*x + c*x^2], 1.01 + .92 x + 2.2 x^2, 
   Max[a + b*x + c*x^2]}, {x, -5, 5}, Filling -> {1 -> {3}}, 
  FillingStyle -> Darker, PlotStyle -> {None, Red, None}]]

enter image description here

share|improve this answer
    
Thanks dear Ciao, this is wonderful. I truly appreciate that. Even though I am able to reproduce this but it gives me a minor error message, "Darker is not a Graphics primitive or directive." Do you know what is wrong with the Graphics chosen? What else should I choose in order to not receive this error messages? I just chose "Orange" so that the "red" you had chosen would be visible in it and that is working. Just curious to know why "Darker" is not recognized in my 8.0 version. – Benjamin May 22 at 17:39
    
Also, what if there are more than one such function that needs to be plotted in the same graph? The "None" option of the PlotStyle is not recognized anymore in such cases! – Benjamin May 22 at 18:48
    
@Benjamin: I don't have 8.0 installed any more - I'm sure Darker was available in 8, but can't test to explain. Glad you worked around that. As for two or more curves - depends on what you want to do with the confidence bands. Might deserve its own question... – ciao May 22 at 21:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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