From 31a077702c3107a0a939b0002594353c8151f6c7 Mon Sep 17 00:00:00 2001 From: Pratik Mota Date: Sun, 26 May 2024 15:40:46 +0530 Subject: [PATCH] Adding erfc math function --- evaldo/builtins_math.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/evaldo/builtins_math.go b/evaldo/builtins_math.go index 5f98441c..532cbeb3 100644 --- a/evaldo/builtins_math.go +++ b/evaldo/builtins_math.go @@ -412,6 +412,20 @@ var Builtins_math = map[string]*env.Builtin{ } }, }, + "erfc": { + Argsn: 1, + Doc: "Returns the complementary error function of value.", + Fn: func(ps *env.ProgramState, arg0 env.Object, arg1 env.Object, arg2 env.Object, arg3 env.Object, arg4 env.Object) env.Object { + switch val := arg0.(type) { + case env.Integer: + return *env.NewDecimal(math.Erfc(float64(val.Value))) + case env.Decimal: + return *env.NewDecimal(math.Erfc(val.Value)) + default: + return MakeArgError(ps, 1, []env.Type{env.IntegerType, env.DecimalType}, "erfc") + } + }, + }, "pi": { Argsn: 0, Doc: "Return Pi constant.",