MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: problem with integrating an interpolated list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg102982] Re: problem with integrating an interpolated list
  • From: dh <dh at metrohm.com>
  • Date: Thu, 3 Sep 2009 07:09:40 -0400 (EDT)
  • References: <h7b04r$d8$1@smc.vnet.net>


Hi Tobias,

Integrate is built to deal with symbolic expressions and accurate 

numbers. However, an interpolating function deals with inaccurate 

numbers. NIntegrate is built to deal with such objects.  Integrate 

should actually call NIntegrate if it is fed with machine numbers. Why 

this does not happen, I can not say. But you can call NIntegrate directly.

Daniel



Tobias Baumann wrote:

> Hi

> 

> I've an problem with integrating an interpolated list. I use Mathematica 

> 7 and I'm a pretty newbie.

> 

> I generate a list of lists like this

> 

> List2D = {{0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 5,

>      1, 0, 0}, {0, 0, 1, 4, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0,

>      0}};

> 

> With MatrixForm it looks like

> 

> 000000

> 000000

> 005100

> 001400

> 000000

> 000000

> 

> Now i make a ListInterpolation first order

> 

> 

> MyFunction = ListInterpolation[List2D, {{0, 6}, {0, 6}}, 

> InterpolationOrder -> 1];

> 

> 

> After this I norm the new Function to value 1. So I integrate

> 

> 

> NormFactor = Integrate[MyFunction[x, y], {x, 0, 6}, {y, 0, 6}]

> 

> 

> This works very well, the result is 396/25. For the next step, I prepare 

> a new function, to make shure that outside of the interpolaten range the 

> function is 0. In this step I also normalize "MyFunction":

> 

> 

> NewFunction[xy_List] := 0 /; xy[[1]] < 2

> NewFunction[xy_List] := 0 /; xy[[2]] < 2

> NewFunction[xy_List] := 0 /; xy[[1]] > MaxResolution - 2

> NewFunction[xy_List] := 0 /; xy[[2]] > MaxResolution - 2

> NewFunction[xy_List] := MyFunction [xy[[1]], xy[[2]]]/NormFactor

> 

> 

> Now, if I make an integration of "NewFunction" ist works really good if 

> I try

> 

> 

> Output = Integrate[NewFunction[{x, y}], {x, -10, 10}, {y, -10, 10}];

> Output

> 

> Out = 1

> 

> 

> But I can't integrate something like this

> 

> 

> Output = Integrate[NewFunction[{x+2, y+2}], {x, -10, 10}, {y, -10, 10}];

> Output

> 

> Out = 25/396 Integrate[InterpolatingFunction[{{0,6}, {0,6}}, <>][2 + x, 

> 2 + y],{x,-10, 10}, {y,-10,10}]

> 

> 

> In this case the Output is no numerical result. I allways get the 

> inputstring back (in a bit more graphical way). The problem is that I 

> need to transform the x and y coordinate.

> 

> Numerical integration is also no option. I get the right solution, but 

> with the message

> 

> "NIntegrate::slwcon: Numerical integration converging too slowly; 

> suspect one of the following: singularity, value of the integration is 

> 0, highly oscillatory integrand, or WorkingPrecision too small. >>"

> 

> It's also too slow for my project.

> 

> I hope someone has any ideas.

> 

> 

> Thanks a lot,

> Tobias

> 

> Complete Code for trying at home

> 

> List2D = {{0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 5, 1, 0,

>      0}, {0, 0, 1, 4, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}};

> 

> List2D // MatrixForm

> 

> MaxResolution = Length[List2D];

> 

> MyFunction =

>    ListInterpolation[List2D, {{0, MaxResolution}, {0, MaxResolution}},

>     InterpolationOrder -> 1];

> 

> NormFactor = Integrate[MyFunction[x, y], {x, 0, 6}, {y, 0, 6}]

> 

> NewFunction[xy_List] := 0 /; xy[[1]] < 2

> NewFunction[xy_List] := 0 /; xy[[2]] < 2

> NewFunction[xy_List] := 0 /; xy[[1]] > MaxResolution - 2

> NewFunction[xy_List] := 0 /; xy[[2]] > MaxResolution - 2

> NewFunction[xy_List] := MyFunction [xy[[1]], xy[[2]]]/NormFactor

> 

> Output = Integrate[

>     NewFunction[{x + 2, y + 2}], {x, -10, 10}, {y, -10, 10}];

> Output

> 




  • Prev by Date: Re: re-grouping expressions in mathematica
  • Next by Date: how to solve the integer equation Abs[3^x-2^y]=1
  • Previous by thread: Re: Viewing .mx files (Question)
  • Next by thread: Re: problem with integrating an interpolated list