# Question:How to optimize with an interpolated function

## Question:How to optimize with an interpolated function

Maple 2018

Hi,

I want to optimize a function f(g(e(x),x))  where g(x) is interpolated and e(x) is not known when the interpolation object is created. I found the intpolation Methods of Maple 2018 very helpful to quickly change the inpterpolation method.

Unfotunately the optimization fails when the interpolation object receives an expression as input.

It works if I just use x. Do you know my the first approach fails?

Is there maybe a way to convert the interpolation object to a piecewise function?

 > # Optimize with Interpolation Object
 > points :=  <<0.4000|  10.0000>,             <0.7000|   10.0000>,             <1.0000|   10.0000>,             <0.3000|   30.0000>,             <0.4000|   30.0000>,             <0.5000|   30.0000>>; Data := <0617,0767,0220,0444,0692,0789>*0.001; intmethod := LinearInterpolation; g := Interpolation[intmethod](points(1..-1,1),Data):
 (1)
 > plot(g(x),x=0..1)
 > e := x/sqrt(2);
 (2)
 > f := 5+g(e)*x^2
 (3)
 > f_simple := 5+g(x)*x^2
 (4)
 > op_f := Optimization[Minimize](f(x),x=0 .. 1);
 > op_f_simple := Optimization[Minimize](f_simple(x),x=0 .. 1);
 (5)
 >