Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import matplotlib.pyplot as plt
- c = [1,2,3]
- x = [0, 2, 4, 8]
- def polynomial():
- for i in range(len(x)):
- ans = 0
- for n,a in enumerate(c): #uzycie enumarate
- ans = sum((a*x[i]**n, ans)) #uzycie sum
- yield ans
- p = (list(polynomial()))
- print(p) #wynik sie zgadza
- #2
- import matplotlib.pyplot as plt
- c = [1,2,3]
- x = [0, 2, 4, 8]
- def polynomial():
- for i in range(len(x)):
- ans = 0
- for n,a in enumerate(c): #uzycie enumarate
- ans = sum((a*x[i]**n, ans)) #uzycie sum
- yield ans
- p = (list(polynomial()))
- print(p) #wynik sie zgadza
- n = 100
- xd = [8*x/100 for x in range(0,100)]
- y = [xd**2 for xd in xd]
- plt.plot(x,p)
- plt.plot(xd,y)
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement