Exemplo n.º 1
0
        public static double EvaluateUnaryToken(string token, double a)
        {
            switch (token)
            {
            case "!": return(MathPlus.Factorial(a));

            case "sin": return(Math.Sin(a));

            case "cos": return(Math.Cos(a));

            case "tg": return(Math.Tan(a));

            case "ctg": return(1.0 / Math.Tan(a));

            case "abs": return(Math.Abs(a));

            case "ln": return(Math.Log(a));

            case "sqrt": return(Math.Sqrt(a));

            case "exp": return(Math.Exp(a));

            default: throw new Exception("Unknown function/operator name.");
            }
        }
Exemplo n.º 2
0
        public Curve PlotFunction(double a, double b)
        {
            double[]  arguments = MathPlus.Interpolate(a, b, 300);
            Vector2[] nodes     = new Vector2[arguments.Length];

            for (int i = 0; i < arguments.Length; i++)
            {
                double  x    = arguments[i];
                double  y    = Evaluate(x);
                Vector2 node = new Vector2(x, y);
                nodes[i] = node;
            }

            return(new Curve(nodes));
        }