Search in sources :

Example 1 with PartialFractionGenerator

use of org.matheclipse.core.polynomials.PartialFractionGenerator in project symja_android_library by axkr.

the class Limit method timesLimit.

private static IExpr timesLimit(final IAST timesAST, LimitData data) {
    IAST isFreeResult = timesAST.partitionTimes(Predicates.isFree(data.getSymbol()), F.C1, F.C1, F.List);
    if (!isFreeResult.get(1).isOne()) {
        return F.Times(isFreeResult.get(1), data.limit(isFreeResult.get(2)));
    }
    IExpr[] parts = Algebra.fractionalPartsTimesPower(timesAST, false, false, true, true);
    if (parts != null) {
        IExpr numerator = parts[0];
        IExpr denominator = parts[1];
        IExpr limit = data.getLimitValue();
        ISymbol symbol = data.getSymbol();
        if (limit.isInfinity() || limit.isNegativeInfinity()) {
            try {
                ExprPolynomialRing ring = new ExprPolynomialRing(symbol);
                ExprPolynomial denominatorPoly = ring.create(denominator);
                ExprPolynomial numeratorPoly = ring.create(numerator);
                return limitsInfinityOfRationalFunctions(numeratorPoly, denominatorPoly, symbol, limit, data);
            } catch (RuntimeException e) {
                if (Config.DEBUG) {
                    e.printStackTrace();
                }
            }
        }
        IExpr plusResult = Algebra.partialFractionDecompositionRational(new PartialFractionGenerator(), parts, symbol);
        if (plusResult.isPlus()) {
            // if (plusResult.size() > 2) {
            return data.mapLimit((IAST) plusResult);
        // }
        }
        if (denominator.isOne()) {
            if (limit.isInfinity() || limit.isNegativeInfinity()) {
                IExpr temp = substituteInfinity(timesAST, data);
                if (temp.isPresent()) {
                    return temp;
                }
            }
        }
        IExpr temp = numeratorDenominatorLimit(numerator, denominator, data);
        if (temp.isPresent()) {
            return temp;
        }
    }
    return data.mapLimit(timesAST);
}
Also used : ExprPolynomialRing(org.matheclipse.core.polynomials.ExprPolynomialRing) ISymbol(org.matheclipse.core.interfaces.ISymbol) IAST(org.matheclipse.core.interfaces.IAST) IExpr(org.matheclipse.core.interfaces.IExpr) ExprPolynomial(org.matheclipse.core.polynomials.ExprPolynomial) PartialFractionGenerator(org.matheclipse.core.polynomials.PartialFractionGenerator)

Aggregations

IAST (org.matheclipse.core.interfaces.IAST)1 IExpr (org.matheclipse.core.interfaces.IExpr)1 ISymbol (org.matheclipse.core.interfaces.ISymbol)1 ExprPolynomial (org.matheclipse.core.polynomials.ExprPolynomial)1 ExprPolynomialRing (org.matheclipse.core.polynomials.ExprPolynomialRing)1 PartialFractionGenerator (org.matheclipse.core.polynomials.PartialFractionGenerator)1