✔ 最佳答案
[解法1] 待定係數法
f(x) = ax^3 + bx^2 + cx + d
1 = a + b + c + d
2 = 8a + 4b + 2c + d
-2 = 64a + 16b + 4c + d
5 = 125a + 25b + 5c + d
解 a, b, c, d 即得.
[解法2] 插值法, Lagrange.
f(x) = 1(x-2)(x-4)(x-5)/[(1-2)(1-4)(1-5)]
+ 2(x-1)(x-4)(x-5)/[(2-1)(2-4)(2-5)
- 2(x-1)(x-2)(x-5)/[(4-1)(4-2)(4-5)]
+5(x-1)(x-2)(x-4)/[(5-1)(5-2)(5-4)]
化簡之.
還有其他插值公式, 例如 Newton.
x_i y_i 第1階差商 第2階差商 第3階差商
1 1 1 -1 1
2 2 -2 3
4 -2 7
5 5
f(x) = 1 + 1(x-1) + (-1)(x-1)(x-2) + 1(x-1)(x-2)(x-4)
化簡即得.