Rob*_*b N 8 interpolation wolfram-mathematica
[下面的截图]
我正在使用ListPlot在一些数据点上绘制一条平滑的线.但我希望能够使用绘图的第一和第二衍生物,所以我想我会使用插值创建一个实际的"函数".但正如你在图片中看到的那样,它并不顺畅.当我进行Plot [Interpolation [...] ...]时,会出现一些奇怪的峰值.我想知道ListPlot如何得到它的插值函数,以及如何使用Interpolation []或其他方法得到相同的东西.
谢谢,
罗布
这是复制/粘贴的一些文本:
myPoints = {{0.,3.87},{1.21,4.05},{2.6,4.25},{4.62,4.48},{7.24,4.73},{9.66,4.93},
{12.48,5.14},{14.87,5.33},{17.34,5.55},{19.31,5.78},{20.78,6.01},{22.08,6.34},
{22.82,6.7},{23.2,7.06},{23.41,7.54},{23.52,8.78},{23.59,9.59},{23.62,9.93},
{23.72,10.24},{23.88,10.56},{24.14,10.85},{24.46,11.05},{24.81,11.2},
{25.73,11.44},{27.15,11.63}}
ListPlot[myPoints, Joined -> True, Mesh -> Full]
Plot[Interpolation[myPoints][x], {x, 0, 27.2}]
Run Code Online (Sandbox Code Playgroud)
最后一个有尖峰.
编辑...
Gleno pointed out that my List plot is linear. But what about when both have
InterpolationOrder -> 3?
ListPlot[myPoints, Joined -> True, Mesh -> Full, InterpolationOrder -> 3]
Plot[Interpolation[myPoints, InterpolationOrder -> 3][x], {x, 0, 27.2}]
Run Code Online (Sandbox Code Playgroud)

也许更容易:
interp = Interpolation[myPoints, InterpolationOrder -> 2, Method -> "Spline"]
(*Now let's plot the function and its derivative*)
Show[ListPlot@myPoints,
Plot[{interp'[x], interp[x]},
{x, Min[First /@ myPoints], Max[First /@ myPoints]}, PlotRange -> All]]
Run Code Online (Sandbox Code Playgroud)

在"感兴趣的区域":
Show[Plot[{interp'[x], interp[x]}, {x, 23, 24}], ListPlot@myPoints]
Run Code Online (Sandbox Code Playgroud)

如果你想要一个连续的二阶导数,只需像这样增加插值顺序:
interp = Interpolation[myPoints, InterpolationOrder -> 3, Method -> "Spline"];
Show[Plot[{interp'[x], interp[x]}, {x, 23, 24}], ListPlot@myPoints]
Run Code Online (Sandbox Code Playgroud)

我相信 for 插值所使用的方法ListPlot是将每个坐标插值为列表索引的函数。类似下面的内容看起来很像以下的输出ListPlot[...,InterpolationOrder->3]:
With[{
xyInterpolation=Interpolation[#,InterpolationOrder->3]&/@Transpose[myPoints]},
ParametricPlot[Through[xyInterpolation[i]],{i,1,Length[myPoints]}]
]
Run Code Online (Sandbox Code Playgroud)
从这样的插值中,您应该能够通过隐式微分获取导数,例如 dx/dy == (dx/dt)/(dy/dt)。很高兴在一个可能会让一些数学家呕吐的地方炫耀这个符号:)