YAMP.RootFunction.Function C# (CSharp) Method

Function() private method

private Function ( FunctionValue f, ScalarValue x ) : ScalarValue
f FunctionValue
x ScalarValue
return ScalarValue
        public ScalarValue Function(FunctionValue f, ScalarValue x)
        {
            var lambda = new Func<Double, Double>(t =>
            {
                var sv = f.Perform(Context, new ScalarValue(t));

                if (sv is ScalarValue == false)
                {
                    throw new YAMPArgumentInvalidException(Name, sv.Header, 1);
                }

                return ((ScalarValue)sv).Re;
            });

            var newton = new NewtonMethod(lambda, x.Re, 0.00001);
            return new ScalarValue(newton.Result[0, 0]);
        }