Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- import numpy as np
- import matplotlib.pyplot as plt
- def func(t, y):
- return 2 * t * y
- t = 0
- print("Введите шаг h")
- h = float(input())
- n = int(1 / h)
- y = np.zeros(n+2)
- y[0] = 1
- for i in range(0, n + 1):
- y[i+1] = y[i] + h * func(t, y[i])
- #y[i + 1] = y[i] + h / 2 * (func(t, y[i]) + func(t + h, y[i] + h * func(t, y[i])));
- #y[i + 1] = y[i] + h * func(t + h / 2, y[i] + h / 2 * (func(t, y[i])));
- t = t + h;
- print(y[i])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement