作者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