sqrt,cbrt - 如果不想要平方根或立方根,但任何根?

Chr*_*phy 2 java clojure

在Java和Clojure的数学库中,您通常可以找到幂(或指数)函数.在java.lang.Math它是exp.但是我找不到用于查找任何根的泛型函数.在java.lang.Math你可以得到的平方根sqrt,并与立方根cbrt.如果我想找到第4个根怎么办?我正在寻找一个实现或公式.

noi*_*ith 7

你可以通过获得相互的权力来获得根.

;; Clojure shorthand to get the reciprocal
+user=> (/ 6)
1/6

;; 6th root
+user=> (Math/pow 42 (/ 6))
1.8644105355008191

;; verifying the identity
+user=> (Math/pow (Math/pow 42 (/ 6)) 6)
42.00000000000005
Run Code Online (Sandbox Code Playgroud)