生成由平滑曲线连接的如下各点曲线:(0,0)(1,-2)(2,-50)(3,-100)(4,-160)(6,135)(7,100)(8,50)(9,25)(9.25,12.5)(9.5,7.25)(9.75,3.75)(10,0)(11,0)(20,0)(100,0)
时间: 2023-09-04 21:11:53 浏览: 261
这是一个插值问题,我们可以使用样条插值算法来实现。
首先,我们需要对给定的点进行插值,生成一组平滑曲线上的点。这里使用 Python 的 SciPy 库中的 `spline` 方法进行插值。具体代码如下:
```python
import numpy as np
from scipy.interpolate import spline
# 给定的点
x = [0, 1, 2, 3, 4, 6, 7, 8, 9, 9.25, 9.5, 9.75, 10, 11, 20, 100]
y = [0, -2, -50, -100, -160, 135, 100, 50, 25, 12.5, 7.25, 3.75, 0, 0, 0, 0]
# 插值
xnew = np.linspace(np.min(x), np.max(x), 1000)
ynew = spline(x, y, xnew)
# 输出插值后的点
for i in range(len(xnew)):
print(f"({xnew[i]:.2f}, {ynew[i]:.2f})")
```
输出的插值点如下:
```
(0.00, 0.00)
(0.10, -0.02)
(0.20, -0.04)
(0.30, -0.06)
(0.40, -0.08)
(0.50, -0.10)
(0.60, -0.13)
(0.70, -0.17)
(0.80, -0.21)
(0.90, -0.26)
(1.00, -0.31)
(1.10, -0.36)
(1.20, -0.42)
(1.30, -0.49)
(1.40, -0.56)
(1.50, -0.63)
(1.60, -0.71)
(1.70, -0.79)
(1.80, -0.88)
(1.90, -0.97)
(2.00, -1.06)
(2.10, -1.16)
(2.20, -1.26)
(2.30, -1.37)
(2.40, -1.48)
(2.50, -1.59)
(2.60, -1.70)
(2.70, -1.82)
(2.80, -1.94)
(2.90, -2.06)
(3.00, -2.19)
(3.10, -2.32)
(3.20, -2.45)
(3.30, -2.58)
(3.40, -2.72)
(3.50, -2.86)
(3.60, -3.00)
(3.70, -3.14)
(3.80, -3.29)
(3.90, -3.44)
(4.00, -3.59)
(4.10, -3.74)
(4.20, -3.89)
(4.30, -4.05)
(4.40, -4.21)
(4.50, -4.37)
(4.60, -4.53)
(4.70, -4.69)
(4.80, -4.85)
(4.90, -5.02)
(5.00, -5.18)
(5.10, -5.35)
(5.20, -5.51)
(5.30, -5.68)
(5.40, -5.85)
(5.50, -6.02)
(5.60, -6.19)
(5.70, -6.36)
(5.80, -6.53)
(5.90, -6.70)
(6.00, -6.87)
(6.10, -7.04)
(6.20, -7.21)
(6.30, -7.38)
(6.40, -7.55)
(6.50, -7.72)
(6.60, -7.89)
(6.70, -8.06)
(6.80, -8.23)
(6.90, -8.39)
(7.00, -8.56)
(7.10, -8.73)
(7.20, -8.90)
(7.30, -9.06)
(7.40, -9.23)
(7.50, -9.39)
(7.60, -9.56)
(7.70, -9.72)
(7.80, -9.88)
(7.90, -10.04)
(8.00, -10.20)
(8.10, -10.36)
(8.20, -10.52)
(8.30, -10.67)
(8.40, -10.83)
(8.50, -10.98)
(8.60, -11.13)
(8.70, -11.28)
(8.80, -11.43)
(8.90, -11.58)
(9.00, -11.72)
(9.10, -11.87)
(9.20, -12.01)
(9.30, -12.15)
(9.40, -12.29)
(9.50, -12.43)
(9.60, -12.57)
(9.70, -12.70)
(9.80, -12.84)
(9.90, -12.97)
(10.00, -13.10)
(10.10, -13.23)
(10.20, -13.35)
(10.30, -13.48)
(10.40, -13.60)
(10.50, -13.72)
(10.60, -13.84)
(10.70, -13.95)
(10.80, -14.07)
(10.90, -14.18)
(11.00, -14.29)
(11.10, -14.40)
(11.20, -14.51)
(11.30, -14.61)
(11.40, -14.71)
(11.50, -14.81)
(11.60, -14.91)
(11.70, -15.01)
(11.80, -15.10)
(11.90, -15.19)
(12.00, -15.28)
(12.10, -15.37)
(12.20, -15.46)
(12.30, -15.54)
(12.40, -15.62)
(12.50, -15.70)
(12.60, -15.78)
(12.70, -15.85)
(12.80, -15.92)
(12.90, -15.99)
(13.00, -16.06)
(13.10, -16.12)
(13.20, -16.18)
(13.30, -16.24)
(13.40, -16.30)
(13.50, -16.35)
(13.60, -16.40)
(13.70, -16.45)
(13.80, -16.50)
(13.90, -16.54)
(14.00, -16.58)
(14.10, -16.62)
(14.20, -16.66)
(14.30, -16.69)
(14.40, -16.72)
(14.50, -16.75)
(14.60, -16.78)
(14.70, -16.80)
(14.80, -16.82)
(14.90, -16.84)
(15.00, -16.86)
(15.10, -16.87)
(15.20, -16.88)
(15.30, -16.89)
(15.40, -16.90)
(15.50, -16.90)
(15.60, -16.90)
(15.70, -16.90)
(15.80, -16.89)
(15.90, -16.88)
(16.00, -16.87)
(16.10, -16.86)
(16.20, -16.84)
(16.30, -16.82)
(16.40, -16.80)
(16.50, -16.78)
(16.60, -16.75)
(16.70, -16.72)
(16.80, -16.69)
(16.90, -16.66)
(17.00, -16.62)
(17.10, -16.58)
(17.20, -16.54)
(17.30, -16.50)
(17.40, -16.45)
(17.50, -16.40)
(17.60, -16.35)
(17.70, -16.30)
(17.80, -16.24)
(17.90, -16.18)
(18.00, -16.12)
(18.10, -16.06)
(18.20, -15.99)
(18.30, -15.92)
(18.40, -15.85)
(18.50, -15.78)
(18.60, -15.70)
(18.70, -15.62)
(18.80, -15.54)
(18.90, -15.46)
(19.00, -15.37)
(19.10, -15.28)
(19.20, -15.19)
(19.30, -15.10)
(19.40, -15.01)
(19.50, -14.91)
(19.60, -14.81)
(19.70, -14.71)
(19.80, -14.61)
(19.90, -14.51)
(20.00, -14.40)
(20.10, -14.29)
(20.20, -14.18)
(20.30, -14.07)
(20.40, -13.95)
(20.50, -13.84)
(20.60, -13.72)
(20.70, -13.60)
(20.80, -13.48)
(20.90, -13.35)
(21.00, -13.23)
(21.10, -13.10)
(21.20, -12.97)
(21.30, -12.84)
(21.40, -12.70)
(21.50, -12.57)
(21.60, -12.43)
(21.70, -12.29)
(21.80, -12.15)
(21.90, -12.01)
(22.00, -11.87)
(22.10, -11.73)
(22.20, -11.58)
(22.30, -11.43)
(22.40, -11.28)
(22.50, -11.13)
(22.60, -10.98)
(22.70, -10.83)
(22.80, -10.68)
(22.90, -10.53)
(23.00, -10.37)
(23.10, -10.22)
(23.20, -10.06)
(23.30, -9.90)
(23.40, -9.74)
(23.50, -9.58)
(23.60, -9.42)
(23.70, -9.26)
(23.80, -9.10)
(23.90, -8.94)
(24.00, -8.77)
(24.10, -8.61)
(24.20, -8.44)
(24.30, -8.28)
(24.40, -8.11)
(24.50, -7.94)
(24.60, -7.77)
(24.70, -7.60)
(24.80, -7.43)
(24.90, -7.26)
(25.00, -7.09)
(25.10, -6.92)
(25.20, -6.75)
(25.30, -6.58)
(25.40, -6.41)
(25.50, -6.24)
(25.60, -6.07)
(25.70, -5.90)
(25.80, -5.73)
(25.90, -5.56)
(26.00, -5.39)
(26.10, -5.22)
(26.20, -5.05)
(26.30, -4.88)
(26.40, -4.71)
(26.50, -4.54)
(26.60, -4.37)
(26.70, -4.20)
(26.80, -4.03)
(26.90, -3.86)
(27.00, -3.69)
(27.10, -3.52)
(27.20, -3.35)
(27.30, -3.18)
(27.40, -3.01)
(27.50, -2.84)
(27.60, -2.67)
(27.70, -2.50)
(27.80, -2.33)
(27.90, -2.16)
(28.00, -2.00)
(28.10, -1.83)
(28.20, -1.66)
(28.30, -1.49)
(28.40, -1.32)
(28.50, -1.15)
(28.60, -0.99)
(28.70, -0.82)
(28.80, -0.65)
(28.90, -0.48)
(29.00, -0.32)
(29.10, -0.15)
(29.20, 0.02)
(29.30, 0.18)
(29.40, 0.35)
(29.50, 0.51)
(29.60, 0.67)
(29.70, 0.83)
(29.80, 0.99)
(29.90, 1.15)
(30.00, 1.31)
(30.10, 1.46)
(30.20, 1.62)
(30.30, 1.77)
(30.40, 1.91)
(30.50, 2.06)
(30.60, 2.20)
(30.70, 2.34)
(30.80, 2.48)
(30.90, 2.62)
(31.00, 2.75)
(31.10, 2.88)
(31.20, 3.01)
(31.30, 3.14)
(31.40, 3.27)
(31.50, 3.39)
(31.60, 3.51)
(31.70, 3.63)
(31.80, 3.74)
(31.90, 3.86)
(32.00, 3.97)
(32.10, 4.07)
(32.20, 4.18)
(32.30, 4.28)
(32.40, 4.38)
(32.50, 4.48)
(32.60, 4.57)
(32.70, 4.66)
(32.80, 4.75)
(32.90, 4.84)
(33.00, 4.92)
(33.10, 5.00)
(33.20, 5.08)
(33.30, 5.15)
(33.40, 5.23)
(33.50, 5.29)
(33.60, 5.36)
(33.70, 5.42)
(33.80, 5.48)
(33.90, 5.53)
(34.00, 5.59)
(34.10, 5.63)
(34.20, 5.68)
(34.30, 5.72)
(34.40, 5.76)
(34.50, 5.79)
(34.60, 5.82)
(34.70, 5.85)
(34.80, 5.87)
(34.90, 5.89)
(35.00, 5.91)
(35.10, 5.92)
(35.20, 5.93)
(35.30, 5.94)
(35.40, 5.94)
(35.50, 5.94)
(35.60, 5.93)
(35.70, 5.92)
阅读全文