Advertisement
myloyo

№2 интерполяционный многочлен в форме Лагранжа

Sep 26th, 2024 (edited)
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. dot = [0, 1, 2, 3]
  2. res = [8, 9, 16, 43]
  3. table = [[0, 0.5, 1, 1.5, 2, 2.5, 3], []]
  4. x_dots = [0, 0.5, 1, 1.5, 2, 2.5, 3]
  5.  
  6. for a in range(7):
  7.     Ln = 0
  8.     for n in range(4):
  9.         chisl = 1
  10.         znam = 1
  11.         for i in range(4):
  12.             if n != i:
  13.                 chisl *= x_dots[a] - dot[i]
  14.                 znam *= dot[n] - dot[i]
  15.         Ln += res[n] * (chisl / znam)
  16.     table[1].append(Ln)
  17.  
  18. for row in table:
  19.     print('| {:^6} | {:^6} | {:^6} | {:^6} | {:^6} | {:^6} | {:^6} |'.format(*row))
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement