Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import matplotlib.pyplot as plt
- ans = 0
- h = 0.001
- g = 9.8
- k = 0.001
- v0 = 800
- def f(v):
- return v - (g + k * v * v) * h
- t = [0]
- v = [v0]
- while abs(v[-1]) > 0.005:
- ans += v[-1] * h
- t.append(t[-1] + h)
- v.append(f(v[-1]))
- tans = t[-1]
- print("Высота: ", ans)
- print("Время:", tans)
- fig, ax = plt.subplots(figsize=(5, 3))
- ax.plot(t, v, "g", linestyle='solid')
- ax.set_xlim(left=t[0], right=t[-1])
- fig.tight_layout()
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement