コード例 #1
0
ファイル: iterate_test.go プロジェクト: thecc4re/meeus
func ExampleFullPrecision_diverging() {
	// Example 5.c, p. 49.
	betterRoot := func() iterate.BetterFunc {
		return func(x float64) float64 {
			return (8 - math.Pow(x, 5)) / 3
		}
	}
	x, err := iterate.FullPrecision(betterRoot(), 0, 20)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Printf("%.9f\n", x)
	fmt.Println(x, "(full precision)")
	// Output:
	// Maximum iterations reached
}
コード例 #2
0
ファイル: iterate_test.go プロジェクト: thecc4re/meeus
func ExampleFullPrecision_converging() {
	// Example 5.d, p.49.
	betterRoot := func() iterate.BetterFunc {
		return func(x float64) float64 {
			return math.Pow(8-3*x, .2)
		}
	}
	x, err := iterate.FullPrecision(betterRoot(), 0, 30)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Printf("%.9f\n", x)
	fmt.Println(x, "(full precision)")
	// Output:
	// 1.321785627
	// 1.321785627117658 (full precision)
}
コード例 #3
0
ファイル: iterate_test.go プロジェクト: thecc4re/meeus
func ExampleFullPrecision() {
	// Example 5.b, p. 48.
	betterRoot := func() iterate.BetterFunc {
		return func(x float64) float64 {
			return (8 - math.Pow(x, 5)) / 17
		}
	}
	x, err := iterate.FullPrecision(betterRoot(), 0, 20)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Printf("%.9f\n", x)
	fmt.Println(x, "(full precision)")
	// Output:
	// 0.469249878
	// 0.4692498784547387 (full precision)
}