文件名称:newtonmethod:牛顿法,求根
文件大小:2KB
文件格式:ZIP
更新时间:2024-07-24 10:02:57
Go
牛顿法 // find an approximate solution to `x^2=612` var ( ƒ = func ( x float64 ) float64 { return x * x } dƒ = func ( x float64 ) float64 { return 2 * x } value = 612.0 ) // iterate 5 times, start with approximation // of 10 approx := 10.0 iterate := 5 soln := Apply ( value , ƒ , dƒ , iterate , approx ) fmt . Printf ( "sqrt(%.1f)=%.4f" , value , truncateDigits ( soln , 4 )) // Out
【文件预览】:
newtonmethod-master
----newton.go(477B)
----newton_test.go(599B)
----README.md(436B)