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;
}
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;
}
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);
}
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;
}
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");
}
Aggregations