[2022 Fall] Assignment7-3¶
Course: AP3021
Q7-3¶
Use Newton’s interpolating polynomials of order 1 to 4 to get f(4). Choose your base points to attain good accuracy.(Python) (繪圖、值)¶
In [1]:
Copied!
def f(m, n):
a = (y[m] - y[n]) / (x[m] - x[n])
return a
def f(m, n):
a = (y[m] - y[n]) / (x[m] - x[n])
return a
In [2]:
Copied!
x = [1, 2, 3, 5, 7, 8]
y = [3, 6, 19, 99, 291, 444]
a = 4
ans = y[2] + (a - x[2]) * f(3, 2)
print("Newton's interpolating polynomials f(4) =", ans)
x = [1, 2, 3, 5, 7, 8]
y = [3, 6, 19, 99, 291, 444]
a = 4
ans = y[2] + (a - x[2]) * f(3, 2)
print("Newton's interpolating polynomials f(4) =", ans)
Newton's interpolating polynomials f(4) = 59.0
Last update:
2024-04-27