ArrayInterpolation can be calculated, but not integrated

lastcomm's picture

I have to create a n-dimensional interpolation to get function to use it in a numerically solved differential equation.

T:=(x,y)->ArrayInterpolation(Ranges,Img,[[x],[y]],method=linear)[1][1]:

T(3.3,4.1);
1.30999999999999983

int(T(3.3,x),x=0.0..1);
Error, (in CurveFitting:-ArrayInterpolation) invalid input: coordinates of xvalues must be of type numeric

I don't need to get the actual equation of surface. I just want to use the function without restrictions. If it can be evaluated in a point or plotted, so it should be a way to use it in a differential equation.

Give me some idea how to.

evalf/int and curry

I would probably try:

`evalf/int`(curry(T,3.3),0..1);

lastcomm's picture

I also used instead of curry

I also used instead of curry Q:=x->T(x,3.3):
but in any case it does not work.

It can not access T as a normal function, only calculation in a point is avalible.

acer's picture

more info

Please tell us what `Ranges` and `Img` are.

I am imagining that an efficient in-place solution using the container=V option may be possible. But it'd help to see the structure of Ranges and Img.

acer

lastcomm's picture

> restart; >

> restart;
> with(CurveFitting):
> with(LinearAlgebra):with(plots):
> Ranges := [[seq(1..5)],[seq(1..5)]]:
> Img := [[1,3,2,0,0],[1,2,1,3,3],[3,4,2,1,2],[0,1,2,2,0],[2,3,6,1,0]]:
> T:=(x,y)->ArrayInterpolation(Ranges,Img,[[x],[y]],method=spline)[1][1]:
> plot3d(T,1..5,1..5,shading=z,grid=[25,25]);
> Q:=x->T(x,2.4):
> plot(Q,1..5);
> T(2.3,4);

2.59687499999517968

> Q(3);

3.40228571428511728

So it can plot T and Q or eval them in points, but I can not use Q in a numerically solved differential equation or numerically integrate it.

evalf/Int

I believe your example will work if you use evalf(Int(Q, 0..1)).  You can look at the evalf/Int (Numerical Integration) help page for more examples.

Paulina Chin
Maplesoft

lastcomm's picture

evalf(Int(Q, 0..1)) really

evalf(Int(Q, 0..1)) really works! Thanks.

Now I need to solve differential equation: diff(diff(x(t),t),t)=T(x(t),diff(x(t),t)).

dsolve/numeric

For the differential equation, you'll want to use the numeric routines again. Try looking at the dsolve/numeric help page. There are examples showing how you can use operator form. "Operator form" refers to input that's in the form of a procedure rather than an expression, and this is the form used in the evalf(Int(Q, 0..,1)) call.

Paulina

lastcomm's picture

Yo! It works. Thank you.

Yo! It works. Thank you.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
}