commit ab2c7ffbc718ec2714e40a344cbe38d2d9dfc1ed
parent 894de25beb628716e1b7abe4fc35ca0255289160
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date: Sat, 25 Mar 2023 09:48:33 +0100
Added root function
Diffstat:
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/bc.library b/bc.library
@@ -5,7 +5,7 @@
* The following functions are available (aliases in parentheses):
* General utility: max, min, sgn, abs, floor, ceiling
* Arithmetic: factorial(fact), binomial(binom, bin), gcd, lcm, totient(phi)
- * Calculus: exp, log(ln), pow, sin, cos, tan, cosh, sinh, tanh
+ * Calculus: exp, log(ln), pow, root, sin, cos, tan, cosh, sinh, tanh
* atan, atan2, asin, acos, atanh, asinh, acosh
* Constants (as functions): e(), pi()
*
@@ -187,6 +187,14 @@ define pow(a, b) {
return a ^ b
}
+define root(a, b) {
+ auto res
+ scale += 5
+ res = pow(b, 1/a)
+ scale -= 5
+ return res / 1
+}
+
define trig(x, ii, in, id) {
auto i, n, d, series
scale += 10