Beispiel #1
0
        public override Algebraic Integrate(Variable v)
        {
            if (!den.Depends(v))
            {
                return(nom.Integrate(v) / den);
            }

            var quot = den.Derive(v) / nom;

            if (quot.Derive(v).Equals(Symbol.ZERO))
            {
                return(FunctionVariable.Create("log", den) / quot);
            }

            var q = new[] { nom, den };

            Poly.polydiv(q, v);

            if (q[0] != Symbol.ZERO && nom.IsRat(v) && den.IsRat(v))
            {
                return(q[0].Integrate(v) + (q[1] / den).Integrate(v));
            }

            if (IsRat(v))
            {
                Algebraic r = Symbol.ZERO;

                var h = Horowitz(nom, den, v);

                if (h[0] is Rational)
                {
                    r = r + h[0];
                }

                if (h[1] is Rational)
                {
                    r = r + new TrigInverseExpand().SymEval((( Rational )h[1]).intrat(v));
                }

                return(r);
            }

            throw new SymbolicException("Could not integrate Function " + this);
        }