1
$\begingroup$

I have a problem plotting a multivariable interpolated function when projected into two-dimensions using Resolve and RegionPlot.

I found the interpolation for a 5-variable list of data, which I call F[x1, x2, x3, x4, x5] (the interpolation works fine), where the xi are my variables. I want to plot a region for F satisfying certain condition, i.e., between two numbers and then project onto a two-variable plane, say {x1, x2}. I can do this when I fix the value of the rest of the variables, but I want to project onto x1, x2 the valid region of F for all of the values admitted by the rest of my parameters. My code looks something like this:

  ImpReg = 
    ImplicitRegion[-1 < F[x1, x2, x3, x4, x5] < 1, 
      {{x1, 1, 200}, {x2, 500, 5000}, {x3, 1, 351}, {x4, 1000, 4000}, {x5, 1, 4}]
  graph = 
    RegionPlot[
      Resolve[Exists[{x3, x4, x5}, {x1, x2, x3, x4, x5} ∈ ImpReg], Reals],
      {x1, 1, 200}, {x2, 500, 5000}]

By the way, I followed the example given in Mathematica documentation for "Formula Region Projections" the only difference being that they do not use an interpolated function, but I do not see why this should be the problem.

$\endgroup$

1 Answer 1

2
$\begingroup$

The calculation fails, because Resolve cannot handle an InterpolatingFunction. To illustrate, consider the simple problem,

f[x1_, x2_, x3_] := x1^2 + x2^2 + x3^2
ImpReg = ImplicitRegion[f[x1, x2, x3] < 1, {{x1, -2, 2}, {x2, -2, 2}, {x3, -2, 2}}];
RegionPlot[Resolve[Exists[{x3}, {x1, x2, x3} \[Element] ImpReg], Reals], {x1, -2, 2}, {x2, -2, 2}]

enter image description here

Next, define an InterpolatingFunction.

g = FunctionInterpolation[f[x1, x2, x3], {x1, -2, 2}, {x2, -2, 2}, {x3, -2, 2}]

g is well behaved, as can be seen from a plot of it.

RegionPlot3D[ImpReg]

enter image description here

Yet, as the OP observed,

ImpReg = ImplicitRegion[g[x1, x2, x3] < 1, {{x1, -2, 2}, {x2, -2, 2}, {x3, -2, 2}}]
RegionPlot[Resolve[Exists[{x3}, {x1, x2, x3} \[Element] ImpReg], Reals], {x1, -2, 2}, {x2, -2, 2}]

produces an empty plot. To see why, evaluate Resolve for the definition of ImpReg using f.

Resolve[Exists[{x3}, {x1, x2, x3} \[Element] ImpReg], Reals]
(* x1 <= 2 && x1 >= -2 && x2 <= 2 && x2 >= -2 && x1^2 + x2^2 < 1 *)

while for the definition of ImpReg using g it returns unevaluated. To plot the projecton of g onto the {x,y} plane, it would be necessary to develop an appropriate projection function, because Resolve is not up to it.

Conceptually, such a projection operator would involve solving g[x1,x2,x3] numerically for, say, x2 as a function of {x1, x3}, maximizing and minimizing x2 over x3 as a function of x1, and then plotting the maximum and minimum values of x2 as functions of x1. Alternatively, one could take numerous constant x3 slices through g, constructing the RegionUnion of them, and generating a RegionPlot of the result. Either approach is slow in 2D and slower still in 5D.

Alternatively, if the surface of the numerically defined region is simple enough, it might be possible to fit an analytical function to it, which Resolve presumably could then handle.

$\endgroup$
1
  • $\begingroup$ Thanks!, I suspected ImplicitFunction was the one that could not handle interpolated functions, this is useful. $\endgroup$ Feb 26, 2015 at 23:33

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.