import math f = lambda x, a, b, c, d: a / (1 + math.exp(-b - c * x - d * x**2)) def calc_and_save(a, b, c, d, filename="results.txt"): if a <= 0 or b <= 0 or c <= 0 or d <= 0: raise ValueError("Все параметры должны быть положительными") xs = list(range(-20, 21, 2)) values = [f(x, a, b, c, d) for x in xs] with open(filename, "w", encoding="utf-8") as file: for i in range(0, len(values), 3): chunk = values[i:i+3] line = " ".join(f"{v:.6f}" for v in chunk) file.write(line + "\n") return xs, values