2
$\begingroup$

Following this post (which is nearly what I need):

I want to plot the function a + bx, but the parameters a and b have an "uncertainty" in such a way that they can only be in a particular region, say:

2D region for parameters a and b

If parameters have independent uncertainties, then the answer to this post is ok:

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

With a succesful output:

enter image description here

However, I need to modify the With so that a and b are not in independent intervals, but inside the region specified by Reg (see image). This is, for every x I want to plot the maximum and the minimum of a complicated function whose parameters should be in a particular region.

I've tried something similar to {a, b} = Reg or {a, b} ∈ Reg but doesn't work. Any ideas?

$\endgroup$
4
  • $\begingroup$ Need more information to help - try to post a minimal working example that shows what you want to do. But take a look at RegionFunction $\endgroup$
    – Jason B.
    Aug 9, 2016 at 14:32
  • $\begingroup$ Please, post code and try to format your question as to present a clear, self-contained entity. $\endgroup$
    – user9660
    Aug 9, 2016 at 14:33
  • $\begingroup$ Let me edit the question to make it clearer $\endgroup$
    – Salva
    Aug 9, 2016 at 14:36
  • $\begingroup$ Without knowing the "complicated function" you want to minimize, I think the approach used by m_goldberg is the right way to go: MinValue[{< my function of x, a, and b >, 1/4 < a^2 + b^2 && a^2 + b^2 < 1}, {a, b}] and MaxValue[{< my function of x, a, and b >, 1/4 < a^2 + b^2 && a^2 + b^2 < 1}, {a, b}] $\endgroup$
    – Jason B.
    Aug 9, 2016 at 15:53

2 Answers 2

2
$\begingroup$

Your question seems to be asking for a mathematical impossibility. The linear function 1.01 + .92 x does not stay in the parameter space you wish to impose on it.

The parameter space looks like this.

paramSpace = 
  With[{r = ImplicitRegion[a^2 + b^2 < 1, {{a, -1, 1}, {b, -1, 1}}]},
    Plot[
      {Evaluate @ MinValue[a + b*x, {a, b} ∈ r], 
       Evaluate @ MaxValue[a + b*x, {a, b} ∈ r]}, 
      {x, -5, 5},
      Filling -> {1 -> {2}},
      FillingStyle -> Darker]]

params

However, 1.01 + .92 x does not stay within it.

Show[
  paramSpace,
  Plot[1.01 + .92 x, {x, -5, 5}, PlotStyle -> Red]]

plot

Note: the lower bound of 1/4 does not have any effect on the problem and so I have omitted it.

$\endgroup$
2
  • $\begingroup$ Beat me to it - also, is good to point out that MinValue[{a x + b, 1/4 < a^2 + b^2 && a^2 + b^2 < 1}, {a, b}] gives an analytic solution, as does MaxValue. But I think the line 1.01 + .92 x is unrelated here. The OP says they want to minimize "a complicated function" so I don't know if it's linear at all - but it's hard to help without knowing what is asked. $\endgroup$
    – Jason B.
    Aug 9, 2016 at 15:51
  • $\begingroup$ @JasonB. Ah. I should have looked at output of MinValue, and not just thrown it into the plot. It speeds up the plot quite a bit to use the analytic solution. I have made an edit. Thanks for the tip. $\endgroup$
    – m_goldberg
    Aug 9, 2016 at 16:04
1
$\begingroup$

You can obtain intervals for a and b with the help of Reduce.

Reduce[a^2 + b^2 < 1 && a^2 + b^2 > (1/2)^2, b]

I don't know how to transform the reduced solutions elegantly into Interval expressions. But plugging in the first interval pair by hand:

Module[{a, b, min, max},
 a = Interval[{-1, -(1/2)}];
 b = Interval[{-Sqrt[1 - a^2], Sqrt[1 - a^2]}];
 min[e_] := MapAt[Min, e, Position[e, Interval[_]]];
 max[e_] := MapAt[Max, e, Position[e, Interval[_]]];
 Plot[{min[a + b x], max[a + b x]}, {x, -5, 5},
  Filling -> {1 -> {2}},
  ImageSize -> Small]]

enter image description here

$\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.