From ab2c7ffbc718ec2714e40a344cbe38d2d9dfc1ed Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Sat, 25 Mar 2023 09:48:33 +0100 Subject: Added root function --- bc.library | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/bc.library b/bc.library index 6b94a01..76a2722 100644 --- 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 -- cgit v1.3