Re: integrate an interpolated function
- To: mathgroup at smc.vnet.net
- Subject: [mg70320] Re: integrate an interpolated function
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Fri, 13 Oct 2006 01:29:59 -0400 (EDT)
- Organization: The Open University, Milton Keynes, UK
- References: <egl2qh$4o3$1@smc.vnet.net>
wtplasar at ehu.es wrote: > Hi, > > I have defined numerical derivatives of functions by interpolation, > because for some complicated numerical functions I was getting > convergence problems using ND. > > I have defined the second derivative of a 2 variable function by > interpolating the function in a square region with the point where I > want to evaluate the function at its center. I do it here for Sin[x*y] > as an example. > > yyder[om_?NumericQ, > w_?NumericQ, h_?NumericQ] := D[FunctionInterpolation[Sin[x*y], > {x, om - \ > h, om + h}, {y, w - h, w + h}][x, y], {y, 2}] /. x -> om /. y -> w > > Then I want to perform an operation on this function which involves > integrating it over one of the variables (multiplying it by another > function, but that does not matter). > > So I do > > fun[w_?NumericQ, h_?NumericQ] := NIntegrate[yyder[om, w, h], {om, 0, > 1}] > > and I get a series of errors like: > > FunctionInterpolation::range: Argument {x, om - 0.3, om + 0.3} is not > in the > form of a range specification, {x, xmin, xmax}. > > FunctionInterpolation::range: Argument {#2, #3, #4} is not in the form > of a > range specification, {x, xmin, xmax} > > and so on. > > Can you help me? Thanks, > > Ruth > Hi Ruth, Have you try your functions with a fresh kernel? Could you provide MathGroup an example of a call to the function fun that does produce the error messages you reported. It works correctly on my system: In[1]:= yyder[(om_)?NumericQ, (w_)?NumericQ, (h_)?NumericQ] := D[FunctionInterpolation[Sin[x*y], {x, om - h, om + h}, {y, w - h, w + h}][x, y], {y, 2}] /. x -> om /. y -> w In[2]:= fun[(w_)?NumericQ, (h_)?NumericQ] := NIntegrate[yyder[om, w, h], {om, 0, 1}] In[3]:= fun[1, 2] Out[3]= -0.221297 In[4]:= $Version Out[4]= "5.2 for Microsoft Windows (June 20, 2005)" Regards, Jean-Marc