from math import * def f(x, y): return (x - x * x) * y def t1(x, y): return 3 - y - x def t2(x, y): return y - y * x def t3(x, y): return (y - y * y) * x def f1(x, u, v): return cos(u + 1.1 * v) + 2.1 def f2(x, u, v): return 1.1 / (x + 2.1 * u * u) + x + 1 def rut2(x0, y_past, h, n, f): print("ROOT2") for i in range(n): x_past = x0 + i * h x_now = x0 + (i + 1) * h f_past = f(x_past, y_past) y_now = y_past + (f_past + f(x_now, y_past + f_past * h)) * h / 2 print(x_now, y_now) y_past = y_now def rut2_sys(x0, u_past, v_past, h, n): print("ROOT2_SYS") for i in range(n): x_past = x0 + i * h x_now = x0 + (i + 1) * h fu = u_past + f1(x_past, u_past, v_past) * h fv = v_past + f2(x_past, u_past, v_past) * h u_now = u_past + (f1(x_past, u_past, v_past) + f1(x_now, fu, fv)) * h / 2 v_now = v_past + (f2(x_past, u_past, v_past) + f2(x_now, fu, fv)) * h / 2 print(x_now, u_now, v_now) u_past = u_now v_past = v_now def rut4(x0, y_past, h, n, f): print("ROOT4") for i in range(n): x_past = x0 + i * h x_now = x0 + (i + 1) * h k1 = h * f(x_past, y_past) k2 = h * f(x_past + h / 2, y_past + k1 / 2) k3 = h * f(x_past + h / 2, y_past + k2 / 2) k4 = h * f(x_past + h, y_past + k3) y_now = y_past + (k1 + 2 * k2 + 2 * k3 + k4) / 6 print(x_now, y_now) y_past = y_now def rut4_sys(x0, u_past, v_past, h, n): print("ROOT4_SYS") for i in range(n): x_past = x0 + i * h x_now = x0 + (i + 1) * h k1 = h * f1(x_past, u_past, v_past) l1 = h * f2(x_past, u_past, v_past) k2 = h * f1(x_past + h / 2, u_past + k1 / 2, v_past + l1 / 2) l2 = h * f2(x_past + h / 2, u_past + k1 / 2, v_past + l1 / 2) k3 = h * f1(x_past + h / 2, u_past + k2 / 2, v_past + l2 / 2) l3 = h * f2(x_past + h / 2, u_past + k2 / 2, v_past + l2 / 2) k4 = h * f1(x_past + h, u_past + k3, v_past + l3) l4 = h * f2(x_past + h, u_past + k3, v_past + l3) u_now = u_past + (k1 + 2 * k2 + 2 * k3 + k4) / 6 v_now = v_past + (l1 + 2 * l2 + 2 * l3 + l4) / 6 print(x_now, u_now, v_now) u_past = u_now v_past = v_now n = int(input()) a, b = map(int, input().split()) el = input() if (el == 'eq'): #-eq num = input() x0 = 0 y0 = 1 h = (b - a) / n if (num == '2'): rut2(x0, y0, h, n, f) if (num == '4'): rut4(x0, y0, h, n, f) if (el == 'sys'): #-sys num = input() x0 = 0 y10 = 1 y20 = 1 h = (b - a) / n if (num == '4'): rut4_sys(x0, y10, y20, h, n) if (num == '2'): rut2_sys(x0, y10, y20, h, n) if (el == 'test'): #-test h = (b - a) / n rut2(0, 0, h, n, t1) print("\n") rut4(0, 0, h, n, t1) print("\n") rut2(0, 5, h, n, t2) print("\n") rut4(0, 5, h, n, t2) print("\n") rut2(0, 3, h, n, t3) print("\n") rut4(0, 3, h, n, t3)