Код: Выделить всё
import sympy as sp
# Define the symbolic variable
x = sp.symbols('x')
# Define f(x)
f = ((x**2 - 2)**2 - 2)**2 - 2
# Solve the equation f(x) = 0
solutions = sp.solve(f, x)
# Filter only the positive solutions
positive_solutions = [sol for sol in solutions if sol.is_real and sol > 0]
# Print the positive solutions
print("The positive solutions of the equation f(x) = 0 are:")
for sol in positive_solutions:
print(sol)

и я могу получить положительные решения. Однако решения возвращаются с вложенными квадратными корнями таким образом, что внутренние корни появляются слева, например:
Код: Выделить всё
sqrt(2 - sqrt(2 - sqrt(2)))
sqrt(2 - sqrt(sqrt(2) + 2))
sqrt(sqrt(2 - sqrt(2)) + 2)
sqrt(sqrt(sqrt(2) + 2) + 2)
Код: Выделить всё
sqrt(2 - sqrt(2 - sqrt(2)))
sqrt(2 - sqrt(sqrt(2) + 2))
sqrt(2 + sqrt(2 - sqrt(2)))
sqrt(2 + sqrt(sqrt(2) + 2))
Подробнее здесь: https://stackoverflow.com/questions/791 ... s-in-sympy
Мобильная версия