Skip to main content
 Web开发网 » 编程语言 » Python语言

如何运用Python代码求解f(x) = (x?

2021年11月26日6110百度已收录

deff(x):return(x3)**3’定义f(x)(x3)**3deffd(x):return3*((x3)**2)’定义f(x)3*((x3)**2)defnewtonMethod(n,assum):timenxassumNext0Af(x)Bfd(x)print(A+str(A)+,B+str(B)+,time+str(time))iff(x)0.0:returntime,xelse:NextxA/Bprint(Nextx+str(Next))ifAf(Next):print(Meetf(x)0,x+str(Next))’设置迭代跳出条件,同时输出满足f(x)0的x值else:returnnewtonMethod(n+1,Next)newtonMethod(0,4.0)’设置从0开始计数,x04.01.牛顿法.维基百科 这是我的看法,请采纳。

评论列表暂无评论
发表评论
微信