Пример #1
0
        public static double solve(Expr expr, string varName)
        {
            Expr v = Expr.Variable(varName);

            expr = expr.RationalSimplify(v).Numerator().Expand();

            Expr[] coeff = expr.Coefficients(v);
            Console.WriteLine(coeff.Length);
            switch (coeff.Length)
            {
            case 1: return(0.0);   //Expr.Zero.Equals(coeff[0]) ? v : Expr.Undefined;

            case 2: return((-coeff[0] / coeff[1]).Expand().RationalSimplify(v).RealNumberValue);

            default: return(0.0);   //Expr.Undefined.RealNumberValue;
            }
        }