I've come across some weirdness in ReplaceAll. Replacement works fine outside of a module, but inside the module some replacements don't occur where one might expect them to.
In[2]:= f = ListInterpolation[{1, 2, 3, 5, 8, 5}]
Out[2]= InterpolatingFunction[{{1, 6}}, <>]
In[3]:= g = D[f[x], x]
Out[3]= InterpolatingFunction[{{1, 6}}, <>][x]
In[4]:= h[u_] := Module[{x, z}, x + u /. {x -> z}]
In[5]:= h[g]
Out[5]= z$6446 + InterpolatingFunction[{{1, 6}}, <>][x]
In[6]:= x + g /. x -> z
Out[6]= z + InterpolatingFunction[{{1, 6}}, <>][z]
Note that outside of the module x gets replaced by z in both places where it occurs in the expression. But inside the module the parameter x of the InterpolationFunction does not get replaced with z.
Can anybody explain this to me please?


