Add to Chrome
✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
def lagrange_interpolation(x, y, x_val):
result = 0
for i in range(len(x)):
term = y[i]
for j in range(len(x)):
if i != j:
term /= (x[i] - x[j])
result += term
return result
term *= (x_val - x[j]) / (x[i] - x[j])
term *= (x_val - x[i]) / (x[j] - x[i])
if i == j:
Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!