0
|
4706 Views
|
|
0 Total Likes
View groups...
Share
GROUPS:

# How to find the max of an interpolating function?

Posted 9 years ago
 Hi, I have a triangular domain, tri2 = Triangle[{{-1/2, 0}, {1/2, 0}, {0, Sqrt/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:= nudifference[0, .3] Out= -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:= FindMaxValue[{nudifference[x, y], {x, y} \[Element] tri2}, {x, y}] During evaluation of In:= InterpolatingFunction::dmval: Input value {1.,1.} lies outside the range of data in the interpolating function. Extrapolation will be used. >> During evaluation of In:= InterpolatingFunction::dmval: Input value {1.,1.} lies outside the range of data in the interpolating function. Extrapolation will be used. >> During evaluation of In:= InterpolatingFunction::dmval: Input value {1.,1.} lies outside the range of data in the interpolating function. Extrapolation will be used. >> During evaluation of In:= General::stop: Further output of InterpolatingFunction::dmval will be suppressed during this calculation. >> Out= -4.42683*10^-8  What am I doing wrong to get these errors? Thanks, Bentley
 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] 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] 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