Advertisement
matbiz01

Untitled

Mar 24th, 2021
835
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | None | 0 0
  1. def makePyramid(basePoints):
  2.     xVals = [x for x,y in basePoints]
  3.     pyramid = []
  4.     pyramid.append(basePoints[0])
  5.     pyramid.append(basePoints[1])
  6.     pyramid[1].append((basePoints[1][1] - basePoints[0][1]) / (basePoints[1][0] - basePoints[0][0]))
  7.     for x in range(2, n):
  8.         pyramid.append(basePoints[x])
  9.         for y in range(x):
  10.             pyramid[x].append((pyramid[x][y + 1] - pyramid[x - 1][y + 1]) / (xVals[x] - xVals[x - (y + 1)]))
  11.     coefficients = []
  12.     for x in range(n):
  13.         coefficients.append(pyramid[x][x + 1])
  14.     return coefficients
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement