Search in sources :

Example 96 with ISymbol

use of org.matheclipse.core.interfaces.ISymbol in project symja_android_library by axkr.

the class Limit method substituteInfinity.

/**
	 * Try a substitution. <code>y = 1/x</code>. As <code>|x|</code> approaches <code>Infinity</code> or
	 * <code>-Infinity</code>, <code>y</code> approaches <code>0</code>.
	 * 
	 * @param arg1
	 * @param data
	 *            (the datas limit must be Infinity or -Infinity)
	 * @return <code>F.NIL</code> if the substitution didn't succeed.
	 */
private static IExpr substituteInfinity(final IAST arg1, LimitData data) {
    ISymbol x = data.getSymbol();
    // substituting by 1/x
    IExpr y = F.Power(x, F.CN1);
    IExpr temp = F.evalQuiet(F.subst(arg1, x, y));
    if (temp.isTimes()) {
        IExpr[] parts = Algebra.fractionalPartsTimesPower((IAST) temp, false, false, true, true);
        if (parts != null) {
            if (!parts[1].isOne()) {
                // denominator != 1
                LimitData ndData = new LimitData(x, F.C0, F.Rule(x, F.C0), data.getDirection());
                temp = numeratorDenominatorLimit(parts[0], parts[1], ndData);
                if (temp.isPresent()) {
                    return temp;
                }
            }
        }
    }
    return F.NIL;
}
Also used : ISymbol(org.matheclipse.core.interfaces.ISymbol) IExpr(org.matheclipse.core.interfaces.IExpr)

Example 97 with ISymbol

use of org.matheclipse.core.interfaces.ISymbol in project symja_android_library by axkr.

the class Limit method lHospitalesRule.

/**
	 * Try L'hospitales rule. See <a href="http://en.wikipedia.org/wiki/L%27H%C3%B4pital%27s_rule"> Wikipedia
	 * L'Hôpital's rule</a>
	 * 
	 * @param numerator
	 * @param denominator
	 * @param data
	 *            the limits data definition
	 * @return
	 */
private static IExpr lHospitalesRule(IExpr numerator, IExpr denominator, LimitData data) {
    EvalEngine engine = EvalEngine.get();
    ISymbol x = data.getSymbol();
    int recursionLimit = engine.getRecursionLimit();
    if (recursionLimit > 0) {
        IExpr expr = F.evalQuiet(F.Times(F.D(numerator, x), F.Power(F.D(denominator, x), F.CN1)));
        return evalLimit(expr, data, false);
    }
    try {
        if (recursionLimit <= 0) {
            // set recursion limit for using l'Hospitales rule
            engine.setRecursionLimit(128);
        }
        IExpr expr = F.evalQuiet(F.Times(F.D(numerator, x), F.Power(F.D(denominator, x), F.CN1)));
        return evalLimit(expr, data, false);
    } catch (RecursionLimitExceeded rle) {
        engine.setRecursionLimit(recursionLimit);
    } finally {
        engine.setRecursionLimit(recursionLimit);
    }
    return F.NIL;
}
Also used : RecursionLimitExceeded(org.matheclipse.core.eval.exception.RecursionLimitExceeded) ISymbol(org.matheclipse.core.interfaces.ISymbol) EvalEngine(org.matheclipse.core.eval.EvalEngine) IExpr(org.matheclipse.core.interfaces.IExpr)

Example 98 with ISymbol

use of org.matheclipse.core.interfaces.ISymbol in project symja_android_library by axkr.

the class Limit method plusLimit.

private static IExpr plusLimit(final IAST arg1, LimitData data) {
    // Limit[a_+b_+c_,sym->lim] ->
    // Limit[a,sym->lim]+Limit[b,sym->lim]+Limit[c,sym->lim]
    // IAST rule = data.getRule();
    IExpr limit = data.getLimitValue();
    if (limit.isInfinity() || limit.isNegativeInfinity()) {
        ISymbol symbol = data.getSymbol();
        try {
            ExprPolynomialRing ring = new ExprPolynomialRing(symbol);
            ExprPolynomial poly = ring.create(arg1);
            IExpr coeff = poly.leadingBaseCoefficient();
            long oddDegree = poly.degree() % 2;
            if (oddDegree == 1) {
                // odd degree
                return data.limit(F.Times(coeff, limit));
            }
            // even degree
            return data.limit(F.Times(coeff, F.CInfinity));
        } catch (RuntimeException e) {
            if (Config.DEBUG) {
                e.printStackTrace();
            }
        }
    }
    return data.mapLimit(arg1);
}
Also used : ExprPolynomialRing(org.matheclipse.core.polynomials.ExprPolynomialRing) ISymbol(org.matheclipse.core.interfaces.ISymbol) IExpr(org.matheclipse.core.interfaces.IExpr) ExprPolynomial(org.matheclipse.core.polynomials.ExprPolynomial)

Example 99 with ISymbol

use of org.matheclipse.core.interfaces.ISymbol in project symja_android_library by axkr.

the class Integrate method getRuleASTStatic.

public static IAST getRuleASTStatic() {
    F.Integrate.createRulesData(new int[] { 0, 100 });
    IAST ast = F.ast(F.List, 10000, false);
    CONST.getRuleASTRubi45(ast);
    // INT_FUNCTIONS.add(F.Times);
    // INT_FUNCTIONS.add(F.Power);
    INT_FUNCTIONS.add(F.Cos);
    INT_FUNCTIONS.add(F.Cot);
    INT_FUNCTIONS.add(F.Csc);
    INT_FUNCTIONS.add(F.Sec);
    INT_FUNCTIONS.add(F.Sin);
    INT_FUNCTIONS.add(F.Tan);
    INT_FUNCTIONS.add(F.ArcCos);
    INT_FUNCTIONS.add(F.ArcCot);
    INT_FUNCTIONS.add(F.ArcCsc);
    INT_FUNCTIONS.add(F.ArcSec);
    INT_FUNCTIONS.add(F.ArcSin);
    INT_FUNCTIONS.add(F.ArcTan);
    INT_FUNCTIONS.add(F.Cosh);
    INT_FUNCTIONS.add(F.Coth);
    INT_FUNCTIONS.add(F.Csch);
    INT_FUNCTIONS.add(F.Sech);
    INT_FUNCTIONS.add(F.Sinh);
    INT_FUNCTIONS.add(F.Tanh);
    INT_FUNCTIONS.add(F.ArcCosh);
    INT_FUNCTIONS.add(F.ArcCoth);
    INT_FUNCTIONS.add(F.ArcCsc);
    INT_FUNCTIONS.add(F.ArcSec);
    INT_FUNCTIONS.add(F.ArcSinh);
    INT_FUNCTIONS.add(F.ArcTanh);
    ISymbol[] rubiSymbols = { F.AppellF1, F.ArcCos, F.ArcCot, F.ArcCsc, F.ArcSec, F.ArcSin, F.ArcTan, F.ArcCosh, F.ArcCoth, F.ArcCsch, F.ArcSech, F.ArcSinh, F.ArcTanh, F.Cos, F.Cosh, F.CosIntegral, F.CoshIntegral, F.Cot, F.Coth, F.Csc, F.Csch, F.EllipticE, F.EllipticF, F.EllipticPi, F.Erf, F.Erfc, F.Erfi, F.Exp, F.ExpIntegralE, F.ExpIntegralEi, F.FresnelC, F.FresnelS, F.Gamma, F.HypergeometricPFQ, F.Hypergeometric2F1, F.HurwitzZeta, F.InverseErf, F.Log, F.LogGamma, F.LogIntegral, F.Piecewise, F.Plus, F.PolyGamma, F.PolyLog, F.Power, F.ProductLog, F.Sec, F.Sech, F.Sin, F.Sinc, F.Sinh, F.SinIntegral, F.SinhIntegral, F.Sqrt, F.Tan, F.Tanh, F.Times, F.Zeta };
    for (int i = 0; i < rubiSymbols.length; i++) {
        INT_RUBI_FUNCTIONS.add(rubiSymbols[i]);
    }
    return ast;
}
Also used : ISymbol(org.matheclipse.core.interfaces.ISymbol) IAST(org.matheclipse.core.interfaces.IAST)

Example 100 with ISymbol

use of org.matheclipse.core.interfaces.ISymbol in project symja_android_library by axkr.

the class CompareToTestCase method testIssue122b.

public void testIssue122b() {
    // x5_c <||> x3*x4_c => -1
    ISymbol b = F.$s("b");
    ISymbol c = F.$s("c");
    ISymbol x1 = F.$s("x1");
    ISymbol x3 = F.$s("x3");
    ISymbol x4 = F.$s("x4");
    ISymbol x5 = F.$s("x5");
    IPattern x1_c = F.$p(x1, c);
    IPattern x3_b = F.$p(x3, b);
    IPattern x3_c = F.$p(x3, c);
    IPattern x4_c = F.$p(x4, c);
    IPattern x5_c = F.$p(x5, c);
    IAST ast2 = F.Times(x3, x4_c);
    int res = x5_c.compareTo(ast2);
    assertEquals(1, res);
    res = ast2.compareTo(x5_c);
    assertEquals(-1, res);
    check("-Infinity+b+a", "-Infinity+a+b");
}
Also used : IPattern(org.matheclipse.core.interfaces.IPattern) ISymbol(org.matheclipse.core.interfaces.ISymbol) IAST(org.matheclipse.core.interfaces.IAST)

Aggregations

ISymbol (org.matheclipse.core.interfaces.ISymbol)117 IExpr (org.matheclipse.core.interfaces.IExpr)79 IAST (org.matheclipse.core.interfaces.IAST)76 IInteger (org.matheclipse.core.interfaces.IInteger)18 WrongArgumentType (org.matheclipse.core.eval.exception.WrongArgumentType)12 INum (org.matheclipse.core.interfaces.INum)10 ISignedNumber (org.matheclipse.core.interfaces.ISignedNumber)10 IFraction (org.matheclipse.core.interfaces.IFraction)9 IBuiltInSymbol (org.matheclipse.core.interfaces.IBuiltInSymbol)8 IComplex (org.matheclipse.core.interfaces.IComplex)7 IComplexNum (org.matheclipse.core.interfaces.IComplexNum)7 ArrayList (java.util.ArrayList)6 IPatternObject (org.matheclipse.core.interfaces.IPatternObject)6 HashSet (java.util.HashSet)5 EvalEngine (org.matheclipse.core.eval.EvalEngine)5 Num (org.matheclipse.core.expression.Num)5 GenPolynomial (edu.jas.poly.GenPolynomial)4 Options (org.matheclipse.core.eval.util.Options)4 ExprPolynomialRing (org.matheclipse.core.polynomials.ExprPolynomialRing)4 ExpVector (edu.jas.poly.ExpVector)3