From: Silvio Abruzzo on 11 Jul 2010 06:19 Dear Group, I have the following problem. I have a matrix of this form {{{9, 0.01, 1001, 269250000, 0.944218 - 12.6734 Sqrt[1/x] + 72.8455/x}, {10, 0.01, 1001, 269250000, 0.944134 - 13.1619 Sqrt[1/x] + 71.1457/x}, {11, 0.01, 1001, 269250000, 0.944054 - 13.6278 Sqrt[1/x] + 69.5111/x},.... where the first two numbers are parameters and the third and fourth number represent the bounds where the function in the last entries is usable. I would like to interpolate the first, second and last column in such a way that I have as result a function f[a_, b_, x_] were when a and b are fixed and corresponds to some value in the matrix above the function in the last column is used and when there is not the corresponding entry the interpolation is used. A method to achieve my goal is to calculate in some point between the min and the max the function in the last column in order that I have a tensor product structure and then to use the function Interpolation. Although this method should work enough well, I would like to know if there is a method to use all analytical information contained in the function in the last column in order to produce a better interpolation. Best regards, Silvio
From: Ingolf Dahl on 12 Jul 2010 01:04 Here is my suggestion: Restructure the data matrix in two steps data1 = Flatten[data, 1]; data2 = Table[{{data1[[i, 1]], data1[[i, 2]]}, {data1[[i, 3]], data1[[i, 4]], data1[[i, 5]]}}, {i, Length[data1]}]; The list data2 can be used for interpolation f[a_, b_, x_] := Simplify[Interpolation[data2][a, b]] f[10.45, 0.065, x] gives {1000.67,8.09232*10^7,0.731501-22.7918 Sqrt[1/x]+151.976/x} Was this what you were looking for? I suggest that instead of working with large x, you should work with small y, where x = 1/y^2. The limits will then be very small number instead of very large. It seems plausible that linear interpolation should be more exact for small numbers than for large. x := 1/y^2 data3 = Table[{{data1[[i, 1]], data1[[i, 2]]}, {Sqrt[1./data1[[i, 4]]], Sqrt[1./data1[[i, 3]]], data1[[i, 5]]}}, {i, Length[data1]}] /. {Sqrt[y^2] -> y}; Instead of f we might define g. The first two elements in the result are then the limits for y. g[a_, b_, y_] := Expand[Simplify[Interpolation[data3][a, b]]] g[9., 0.09, y] gives {0.000140028,0.031607,0.651531-21.3675 y+128.192 y^2} I guess that g gives a "better" interpolation than f Best regards Ingolf Dahl http://www.familydahl.se/mathematica > -----Original Message----- > From: Silvio Abruzzo [mailto:silvio.abruzzo(a)gmail.com] > Sent: den 11 juli 2010 12:20 > To: mathgroup(a)smc.vnet.net > Subject: multivariate interpolation > > Dear Group, > I have the following problem. I have a matrix of this form > {{{9, 0.01, 1001, 269250000, > 0.944218 - 12.6734 Sqrt[1/x] + 72.8455/x}, {10, 0.01, 1001, > 269250000, 0.944134 - 13.1619 Sqrt[1/x] + 71.1457/x}, {11, 0.01, > 1001, 269250000, 0.944054 - 13.6278 Sqrt[1/x] + 69.5111/x},.... > > where the first two numbers are parameters and the third and fourth > number represent the bounds where the function in the last entries is > usable. I would like to interpolate the first, second and last column > in such a way that I have as result a function f[a_, b_, x_] were when > a and b are fixed and corresponds to some value in the matrix above > the function in the last column is used and when there is not the > corresponding entry the interpolation is used. A method to achieve my > goal is to calculate in some point between the min and the max the > function in the last column in order that I have a tensor product > structure and then to use the function Interpolation. Although this > method should work enough well, I would like to know if there is a > method to use all analytical information contained in the function in > the last column in order to produce a better interpolation. > > > Best regards, > > Silvio
From: Silvio Abruzzo on 12 Jul 2010 07:21 Dear Ingolf Dahl, thank you very much. It is exactly what I was looking for. I tried with other data that I have and the interpolation with the small numbers works very good, better than the interpolation with the big numbers. Best regards, Silvio On Jul 12, 7:04 am, "Ingolf Dahl" <ingolf.d...(a)telia.com> wrote: > Here is my suggestion: > Restructure the data matrix in two steps > > data1 = Flatten[data, 1]; > > data2 = Table[{{data1[[i, 1]], data1[[i, 2]]}, {data1[[i, 3]], > data1[[i, 4]], data1[[i, 5]]}}, {i, Length[data1]}]; > > The list data2 can be used for interpolation > > f[a_, b_, x_] := Simplify[Interpolation[data2][a, b]] > > f[10.45, 0.065, x] > > gives > > {1000.67,8.09232*10^7,0.731501-22.7918 Sqrt[1/x]+151.976/x} > > Was this what you were looking for? > > I suggest that instead of working with large x, you should work with smal= l > y, where x = 1/y^2. The limits will then be very small number instead o= f > very large. It seems plausible that linear interpolation should be more > exact for small numbers than for large. > > x := 1/y^2 > > data3 = Table[{{data1[[i, 1]], > data1[[i, 2]]}, {Sqrt[1./data1[[i, 4]]], Sqrt[1./data1[[i, 3]]= ], > data1[[i, 5]]}}, {i, Length[data1]}] /. {Sqrt[y^2] -> y}; > > Instead of f we might define g. The first two elements in the result are > then the limits for y. > > g[a_, b_, y_] := Expand[Simplify[Interpolation[data3][a, b]]] > > g[9., 0.09, y] > > gives > > {0.000140028,0.031607,0.651531-21.3675 y+128.192 y^2} > > I guess that g gives a "better" interpolation than f > > Best regards > > Ingolf Dahlhttp://www.familydahl.se/mathematica > > > > > -----Original Message----- > > From: Silvio Abruzzo [mailto:silvio.abru...(a)gmail.com] > > Sent: den 11 juli 2010 12:20 > > To: mathgr...(a)smc.vnet.net > > Subject: multivariate interpolation > > > Dear Group, > > I have the following problem. I have a matrix of this form > > {{{9, 0.01, 1001, 269250000, > > 0.944218 - 12.6734 Sqrt[1/x] + 72.8455/x}, {10, 0.01, 1001, > > 269250000, 0.944134 - 13.1619 Sqrt[1/x] + 71.1457/x}, {11, 0.01, > > 1001, 269250000, 0.944054 - 13.6278 Sqrt[1/x] + 69.5111/x},.... > > > where the first two numbers are parameters and the third and fourth > > number represent the bounds where the function in the last entries is > > usable. I would like to interpolate the first, second and last column > > in such a way that I have as result a function f[a_, b_, x_] were when > > a and b are fixed and corresponds to some value in the matrix above > > the function in the last column is used and when there is not the > > corresponding entry the interpolation is used. A method to achieve my > > goal is to calculate in some point between the min and the max the > > function in the last column in order that I have a tensor product > > structure and then to use the function Interpolation. Although this > > method should work enough well, I would like to know if there is a > > method to use all analytical information contained in the function in > > the last column in order to produce a better interpolation. > > > Best regards, > > > Silvio
|
Pages: 1 Prev: Another 3D and Contour plots Rendering problem Next: Chi Square Areas (CORRECTION) |