Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. import math
  2. import numpy as np
  3. import matplotlib.pyplot as plt
  4.  
  5.  
  6. def func(t, y):
  7.     return 2 * t * y
  8.  
  9.  
  10. t = 0
  11. print("Введите шаг h")
  12. h = float(input())
  13. n = int(1 / h)
  14. y = np.zeros(n+2)
  15. y[0] = 1
  16. for i in range(0, n + 1):
  17.     y[i+1] = y[i] + h * func(t, y[i])
  18.     #y[i + 1] = y[i] + h / 2 * (func(t, y[i]) + func(t + h, y[i] + h * func(t, y[i])));
  19.     #y[i + 1] = y[i] + h * func(t + h / 2, y[i] + h / 2 * (func(t, y[i])));
  20.     t = t + h;
  21.     print(y[i])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement