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 a list, data, where the elements data[[i]] range over i from -N to N. I want to define a function interpolating this list at every point except for i=0.

Is there a way to do this?

share|improve this question
3  
How about f = Interpolation[Complement[data, {0}]]? –  RunnyKine Nov 22 '13 at 16:23
1  
Is your list a simple list, or does it have some structure? –  m_goldberg Nov 22 '13 at 18:12
1  
Data[i] as you write it is probably not a list. You meant data[[i]], right? –  Sjoerd C. de Vries Nov 22 '13 at 18:25
    
@SjoerdC.deVries "defined on values of i which go from -N to N." –  belisarius Nov 22 '13 at 23:08
    
@m_goldberg a simple list! –  usumdelphini Nov 23 '13 at 12:19
add comment

closed as unclear what you're asking by RunnyKine, Artes, ssch, Yves Klett, belisarius Nov 24 '13 at 23:30

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

2 Answers

up vote 0 down vote accepted

Select[] preserves the order and may be a more general solution, e.g.

Select[Range[-5, 5], # != 0 &]

{-5, -4, -3, -2, -1, 1, 2, 3, 4, 5}
share|improve this answer
add comment

Given a simple list of values $\{ y_{-n},\; \ldots,\; y_n\}$, perhaps something like this will do.

makeData[n_Integer] := Quiet@Table[Abs[1/i], {i, -n, n, 1}]
data = makeData[5]
{1/5, 1/4, 1/3, 1/2, 1, ∞, 1, 1/2, 1/3, 1/4, 1/5}

The above is just to make some data with a singularity at $y_0$. Here is the function that will make interpolating functions for the kind of data being considered.

makeInterpF[data_List] /; OddQ@Length@data :=
  Module[{n, x, y},
    n = (Length[data] - 1)/2;
    x = Delete[Range[-n, n], n + 1];
    y = Delete[data, n + 1];
    Interpolation[Transpose[{x, y}]]]

Now let's see what f looks like

f = makeInterpF[data];
Plot[f[x], {x, -5, 5}, PlotRange -> {0, Automatic}]

plot.png

and check that it maintains the original data points, except for $y_0$.

f /@ Range[-5, 5]
{1/5, 1/4, 1/3, 1/2, 1, 7/6, 1, 1/2, 1/3, 1/4, 1/5}
share|improve this answer
add comment

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