Skip to content
Snippets Groups Projects
Commit c350688e authored by abivarma.kandiah's avatar abivarma.kandiah
Browse files

Lagrange don't work yet

parent 8c4e1d67
No related branches found
No related tags found
1 merge request!10Resolve "Create Lagrange method"
......@@ -5,8 +5,27 @@ def get_possibilities(l: list):
pass
def lagrange_compute(l: list) -> polynome:
pass
list_s = [0] * len(l)
list_p = [1] * 2 + [0] * (len(l)-2)
sum_poly = polynome(list_s)
product_poly = polynome(list_p)
for x_i, y_i in enumerate(l):
for x_j, y_j in enumerate(l):
if x_j != x_i:
product_poly = product_poly.mul(polynome([(y_i * (0-x_j)) /(x_i - x_j) , y_i / (x_i - x_j)]))
#product_poly.show()
sum_poly = sum_poly.add(product_poly)
#sum_poly.show()
product_poly = polynome(list_p)
return sum_poly
def check_nb_error(l: list, p: polynome) -> int:
pass
if __name__ == '__main__':
list_ = [1, 2, 3]
print(list_)
poly = lagrange_compute(list_)
poly.show()
#print(poly.evaluate(0))
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment