作者mafiataiki (辉 ^.< 啾咪)
看板NCHU-ENVE102
标题[讨论] 计概 11/15
时间Mon Nov 15 14:36:15 2010
f2=function(a,b,c,d,e,x1,x2)
{
left=x1
right=x2
repeat{
mid=(left+right)/2
if( (a*mid^4+b*mid^3+c*mid^2+d*mid+e) * (a*left^4+b*left^3+c*left^2+d*left+e) >0) {
left =mid
right=right
}
else if ((a*mid^4+b*mid^3+c*mid^2+d*mid+e) * (a*right^4+b*right^3+c*right^2+d*right+e) >0)
{
left=left
right=mid
}
if( abs(a*mid^4+b*mid^3+c*mid^2+d*mid+e)<0.0000001)break
}
cat("the root",mid,"\n")
}
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.120.151.170