Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have 2d list which is upper triangular. I would like to interpolate it, but I cannot unless I set the interpolation order to 1. I tried making the list rectangular by filling the bottom half with Null. This does allow me to interpolate with higher order. However, the interpolation function ends too early; that is, it does not return values when the distance from the boundary (the diagonal elements of the list) is relatively small. I would like to have a full interpolation up to (or very close to) the boundary. any advice?

Here is the list that I would like to interpolate.

{{0.103974, 0.103971, 0.103953, 0.103899, 0.103786, 0.103597, 
  0.103316, 0.102925, 0.102414, 0.10177, 0.100988, 0.100062, 
  0.0989872, 0.0977656, 0.0963984, 0.09489, 0.0932473, 0.0914792, 
  0.089597, 0.0876143, 0.0855483, 0.0834163, 0.0812392, 0.0790409, 
  0.0768409, 0.0746749, 0.0725479, 0.0703533, 0.068163, 
  0.0666494}, {0.10394, 0.103939, 0.103922, 0.103868, 0.103755, 
  0.103567, 0.103285, 0.102896, 0.102385, 0.101742, 0.10096, 0.100033,
   0.0989584, 0.0977364, 0.0963682, 0.0948584, 0.093214, 0.0914444, 
  0.0895606, 0.087576, 0.0855068, 0.0833692, 0.0811831, 0.0789712, 
  0.0767541, 0.0745556, 0.0723645, 0.0701298, 0.0680141}, {0.10387, 
  0.103868, 0.10385, 0.103795, 0.103683, 0.103495, 0.103214, 0.102825,
   0.102314, 0.10167, 0.100887, 0.0999592, 0.0988834, 0.0976591, 
  0.0962884, 0.0947757, 0.0931276, 0.091353, 0.0894624, 0.0874687, 
  0.0853863, 0.0832311, 0.0810217, 0.0787762, 0.076513, 0.0742205, 
  0.0718546, 0.0695221}, {0.103748, 0.103745, 0.103724, 0.103669, 
  0.103558, 0.103371, 0.10309, 0.102699, 0.102187, 0.101542, 0.100757,
   0.0998263, 0.0987467, 0.0975176, 0.0961414, 0.0946217, 0.0929642, 
  0.0911773, 0.089271, 0.0872567, 0.0851463, 0.0829572, 0.0807012, 
  0.0783843, 0.0760088, 0.0734579, 0.0706321}, {0.103554, 0.103551, 
  0.103531, 0.103476, 0.103366, 0.103178, 0.102896, 0.102504, 
  0.101989, 0.101341, 0.100553, 0.099617, 0.0985308, 0.0972933, 
  0.0959062, 0.0943723, 0.0926975, 0.0908894, 0.0889562, 0.0869069, 
  0.0847519, 0.0825056, 0.0801589, 0.0777, 0.0750337, 
  0.0716811}, {0.103276, 0.103275, 0.103256, 0.103202, 0.10309, 
  0.102901, 0.102618, 0.102223, 0.101704, 0.101052, 0.100256, 
  0.0993117, 0.0982145, 0.0969632, 0.0955586, 0.0940032, 0.092303, 
  0.0904624, 0.0884869, 0.0863832, 0.0841579, 0.081807, 0.0792933, 
  0.0765284, 0.0728391}, {0.102903, 0.102902, 0.102884, 0.10283, 
  0.102718, 0.102528, 0.102241, 0.101843, 0.101318, 0.100658, 
  0.0998522, 0.0988945, 0.0977811, 0.0965098, 0.0950807, 0.0934955, 
  0.0917577, 0.0898677, 0.0878288, 0.0856427, 0.0832993, 0.0807647, 
  0.0779256, 0.0740117}, {0.102422, 0.102422, 0.102405, 0.10235, 
  0.102237, 0.102044, 0.101754, 0.101349, 0.100817, 0.100146, 
  0.0993255, 0.09835, 0.0972144, 0.0959158, 0.0944531, 0.0928257, 
  0.091033, 0.089073, 0.0869434, 0.0846283, 0.0820913, 0.0792068, 
  0.0751356}, {0.101822, 0.101823, 0.101806, 0.101752, 0.101637, 
  0.10144, 0.101144, 0.100732, 0.100188, 0.099502, 0.0986628, 
  0.097664, 0.0964989, 0.0951639, 0.0936555, 0.0919695, 0.090102, 
  0.0880447, 0.0857767, 0.083259, 0.0803534, 0.0761756}, {0.101097, 
  0.101098, 0.101081, 0.101026, 0.100909, 0.100708, 0.100405, 
  0.0999814, 0.0994228, 0.0987171, 0.0978542, 0.0968249, 0.0956215, 
  0.0942383, 0.0926684, 0.090904, 0.0889336, 0.0867302, 0.0842497, 
  0.0813519, 0.0771066}, {0.100239, 0.10024, 0.100224, 0.100167, 
  0.100048, 0.0998402, 0.0995268, 0.0990894, 0.0985123, 0.0977829, 
  0.0968891, 0.0958205, 0.0945678, 0.0931211, 0.0914701, 0.0895987, 
  0.0874762, 0.0850528, 0.0821852, 0.0779089}, {0.0992445, 0.0992461, 
  0.0992294, 0.0991719, 0.099048, 0.0988324, 0.0985062, 0.0980515, 
  0.0974514, 0.0966918, 0.0957588, 0.0946403, 0.0933235, 0.0917941, 
  0.0900337, 0.0880059, 0.0856582, 0.0828417, 0.0785649}, {0.0981125, 
  0.0981144, 0.0980973, 0.0980374, 0.0979076, 0.0976814, 0.09734, 
  0.096864, 0.0962348, 0.0954372, 0.0944552, 0.093273, 0.0918731, 
  0.0902326, 0.0883131, 0.0860581, 0.0833127, 0.0790662}, {0.0968426, 
  0.0968454, 0.096828, 0.0967645, 0.0966264, 0.0963876, 0.0960279, 
  0.0955252, 0.0948597, 0.0940148, 0.0929701, 0.0917054, 0.0901945, 
  0.0883946, 0.0862476, 0.0835918, 0.079405}, {0.0954383, 0.0954419, 
  0.095424, 0.0953556, 0.0952077, 0.0949537, 0.0945706, 0.0940344, 
  0.0933241, 0.0924188, 0.0912934, 0.0899197, 0.0882514, 0.0862242, 
  0.083675, 0.0795756}, {0.0939058, 0.0939098, 0.09389, 0.0938154, 
  0.0936557, 0.093382, 0.092969, 0.0923913, 0.0916245, 0.0906417, 
  0.0894103, 0.0878829, 0.0859885, 0.0835615, 0.0795752}, {0.0922516, 
  0.0922556, 0.0922334, 0.092151, 0.0919761, 0.0916776, 0.0912276, 
  0.0905977, 0.0897577, 0.088673, 0.0872931, 0.0855428, 0.0832538, 
  0.0794039}, {0.0904849, 0.0904886, 0.0904629, 0.0903703, 0.090176, 
  0.0898463, 0.0893496, 0.0886522, 0.0877159, 0.0864893, 0.0848929, 
  0.0827551, 0.0790643}, {0.0886172, 0.0886199, 0.0885891, 0.0884833, 
  0.0882643, 0.0878948, 0.0873377, 0.0865514, 0.0854815, 0.0840469, 
  0.0820716, 0.078562}, {0.08666, 0.086662, 0.0866252, 0.086502, 
  0.0862506, 0.0858294, 0.0851927, 0.0842826, 0.0830158, 0.0812123, 
  0.0779048}, {0.0846302, 0.0846316, 0.0845855, 0.0844381, 0.084145, 
  0.0836566, 0.0829073, 0.0818115, 0.0801893, 0.0771012}, {0.0825462, 
  0.0825452, 0.082486, 0.0823086, 0.0819616, 0.081374, 0.0804515, 
  0.0790206, 0.0761684}, {0.0804289, 0.0804223, 0.0803448, 0.0801253, 
  0.0796932, 0.0789504, 0.0777197, 0.0751256}, {0.0783023, 0.078285, 
  0.0781783, 0.0778938, 0.0773324, 0.0763055, 0.0739972}, {0.0761874, 
  0.0761545, 0.0760065, 0.0756224, 0.074797, 0.0728167}, {0.0741274, 
  0.0740638, 0.0738307, 0.0732125, 0.0716426}, {0.0721374, 0.0720111, 
  0.071612, 0.0705599}, {0.0701032, 0.0699286, 0.0694193}, {0.0680611,
   0.0679384}, {0.0666374}}

and here is the code I am using

temp1 = ConstantArray[Null, {30, 30}]; 
Table[temp1[[ixa, ixb]] = data[[ixa, ixb]], {ixa, Range[1, 30]}, {ixb, 30 - ixa + 1}]; 
F = ListInterpolation[temp1, {{0, 1}, {0, 1}}]
share|improve this question
    
I'd like to see your interpolation code –  belisarius Apr 6 '13 at 3:02
    
temp1 = ConstantArray[Null, {30, 30}]; Table[ temp1[[ixa, ixb]] = data[[ixa, ixb]] , {ixa, Range[1, 30]}, {ixb, 30 - ixa + 1}]; F = ListInterpolation[temp1, {{0, 1}, {0, 1}}] –  gino Apr 6 '13 at 3:35
    
Please do not convey your code in a comment. Always add to your question by editing the question. Because this is first post, I have done it for you. –  m_goldberg Apr 6 '13 at 4:42
add comment

2 Answers

You're getting numerical problems with polynomial interpolation because of the effectively discontinuous jump in function values at the diagonal, if you insist on padding the missing triangle with zeros.

To get a good interpolation, you should simply pad the matrix in such a way as to avoid a numerical discontinuity. Here is how I would do that:

Call the list in your example a, then define

b = PadLeft[#, Length[First[a]], First[#]] & /@ a;
ListPlot3D[b]

3d plot

Now the diagonal has a continuous transition. The above plot is already an interpolation. To get the interpolation explicitly, we do this:

interpol = ListInterpolation[b, {{0, 1}, {0, 1}}];

ContourPlot[interpol[x, y], {x, 0, 1}, {y, 0, 1}]

interp

The region near the diagonal is smoothly interpolated.

share|improve this answer
    
It works perfectly. I just had to change PadLeft to PadRight. Thank you. –  gino Apr 6 '13 at 5:14
add comment

Here are the interpolation along row N°10 of your table :

enter image description here

One see on the first graphic that the end of data are at position 21.

On the other graphics, one see that if you use InterpolationOrder superior to 1, the interpolation is smooth until 20.

To go beyond 20 with InterpolationOrder superior to 1, you must make some further hypotheses about the behaviour of the data >21 (value different from 0) or about the derivative of the function at 21 .

If there no such very accurate hypothesis, I think that linear interpolation is the best choice for values between 20 and 21.

Note : Here, it's a interpolation 2D of the full table (not interpolation 1D along row 10 of the table).

share|improve this answer
    
I have done a smooth interpolation of order superior to 1, and at the end, there was not difference. –  andre Apr 6 '13 at 7:23
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.