Message Boards Message Boards

0
|
5284 Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:
GROUPS:

How to find the max of an interpolating function?

Posted 10 years ago

Hi,

I have a triangular domain,

tri2 = Triangle[{{-1/2, 0}, {1/2, 0}, {0, Sqrt[3]/2}}];

over which I've used NDSolve on a PDE. This gives me an interpolating function nudifference[x,y]. It seems to be working:

In[56]:= nudifference[0, .3]

Out[56]= -14.7

I'd like to find the maximum value of this interpolating function, nudifference, on my triangular domain, tri2. I tried it this way:

In[57]:= FindMaxValue[{nudifference[x, y], {x, y} \[Element] 
   tri2}, {x, y}]

During evaluation of In[57]:= InterpolatingFunction::dmval: Input value {1.,1.} lies outside the range of data in the interpolating function. Extrapolation will be used. >>

During evaluation of In[57]:= InterpolatingFunction::dmval: Input value {1.,1.} lies outside the range of data in the interpolating function. Extrapolation will be used. >>

During evaluation of In[57]:= InterpolatingFunction::dmval: Input value {1.,1.} lies outside the range of data in the interpolating function. Extrapolation will be used. >>

During evaluation of In[57]:= General::stop: Further output of InterpolatingFunction::dmval will be suppressed during this calculation. >>

Out[57]= -4.42683*10^-8

What am I doing wrong to get these errors?

Thanks,

Bentley

POSTED BY: Bentley Bana

Hi,

as I don't have your interpolated function I will have to make up my own. I generate data points:

x = Flatten[Table[{x, y, Cos[x^2 + y^2]*Exp[-0.1 (x^2 + y^2)]}, {x, -6, 6, 0.5}, {y, -6, 6, 0.5}], 1];

and build my interpolation function:

f = Interpolation[x, InterpolationOrder -> 2]

which I then can plot

Plot3D[f[x, y], {x, -6, 6}, {y, -6, 6}, PlotRange -> All]

enter image description here

I can plot/consider this on a circular region only if I want:

Plot3D[f[x, y], {x, y} \[Element] Disk[{0, 0}, 6], PlotRange -> All]

enter image description here

I can then find the maximum:

NMaximize[{f[a, b]}, {a, b} \[Element] Disk[{0, 0}, 6], Method -> "DifferentialEvolution"]
(*{1.05071, {a -> 0.169378, b -> 0.169378}}*)

which is reasonable. Note that I needed to use a non-standard method for this; the standard method only found a local maximum.

Cheers,

Marco

POSTED BY: Marco Thiel
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract