# -*- coding: utf-8 -*-
"""
Created on Mon Nov 1 20:20:05 2021
@author: Machi
"""
from scipy.optimize import root
from math import cos
def f(x):
return x + cos(x+4)
myroot = root(f, 0)
print(myroot.x)
# 查看更多信息
print(myroot)
[0.35232971]
fjac: array([[-1.]])
fun: array([-2.77555756e-16])
message: ‘The solution converged.’
nfev: 7
qtf: array([-2.21917706e-10])
r: array([-1.93587568])
status: 1
success: True
x: array([0.35232971])