# Plot when parameters are in a region

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: 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: 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?

• 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 – Jason B. Aug 9 '16 at 14:32
• Please, post code and try to format your question as to present a clear, self-contained entity. – user9660 Aug 9 '16 at 14:33
• Let me edit the question to make it clearer – Salva Aug 9 '16 at 14:36
• 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}] – Jason B. Aug 9 '16 at 15:53

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]] However, 1.01 + .92 x does not stay within it.

Show[
paramSpace,
Plot[1.01 + .92 x, {x, -5, 5}, PlotStyle -> Red]] Note: the lower bound of 1/4 does not have any effect on the problem and so I have omitted it.

• 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. – Jason B. Aug 9 '16 at 15:51
• @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. – m_goldberg Aug 9 '16 at 16:04

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]] 