From e7d6b059fc68154dde96cafeac10f3c5265df115 Mon Sep 17 00:00:00 2001 From: siddharth ravikumar Date: Mon, 14 Nov 2022 00:42:13 -0500 Subject: lib: add `BigCubeRoot` --- lib/cbrt_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 lib/cbrt_test.go (limited to 'lib/cbrt_test.go') diff --git a/lib/cbrt_test.go b/lib/cbrt_test.go new file mode 100644 index 0000000..a5722c8 --- /dev/null +++ b/lib/cbrt_test.go @@ -0,0 +1,23 @@ +// Copyright © 2021 siddharth ravikumar +// SPDX-License-Identifier: ISC + +package lib + +import ( + "math/big" + "testing" +) + +func TestBigCubeRoot(t *testing.T) { + a := big.NewFloat(612) + acr := BigCubeRoot(a) + if acr == nil { + t.Errorf("Could not find cube root of %v\n", a) + return + } + expected := big.NewFloat(8.490184748) + if big.NewFloat(0).Sub(acr, expected).Cmp(bigCubeRootTolerance) != -1 { + t.Errorf("Could not find cube root of %v (%v)\n", a, acr) + return + } +} -- cgit v1.2.3