在Java和Clojure的数学库中,您通常可以找到幂(或指数)函数.在java.lang.Math
它是exp
.但是我找不到用于查找任何根的泛型函数.在java.lang.Math
你可以得到的平方根sqrt
,并与立方根cbrt
.如果我想找到第4个根怎么办?我正在寻找一个实现或公式.
你可以通过获得相互的权力来获得根.
;; 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)
归档时间: |
|
查看次数: |
296 次 |
最近记录: |