public IAST replaceAll(final IAST options) { if (fCurrentOptionsList != null) { return (IAST) fEngine.evaluate(ReplaceAll(options, fCurrentOptionsList)); } if (fDefaultOptionsList != null) { return (IAST) fEngine.evaluate(ReplaceAll(options, fDefaultOptionsList)); } return options; }
public IAST replaceAll(final IAST options) { IAST result = options.clone(); if (fCurrentOptionsList != null) { result = (IAST) F.eval(ReplaceAll(result, fCurrentOptionsList)); } if (fDefaultOptionsList != null) { result = (IAST) F.eval(ReplaceAll(result, fDefaultOptionsList)); } return result; }
@Override public IExpr evaluate(final IAST ast, EvalEngine engine) { if (ast.isAST2() && (ast.arg2().isVector() == 3)) { IAST list = (IAST) ast.arg2(); final int upperLimit = Validate.checkIntType(list, 3, 0); if (upperLimit < 0) { return F.NIL; } IASTAppendable fadd = F.PlusAlloc(upperLimit+2); fadd.append(F.ReplaceAll(ast.arg1(), F.Rule(list.arg1(), list.arg2()))); IExpr temp = ast.arg1(); IExpr factor = null; for (int i = 1; i <= upperLimit; i++) { temp = F.D(temp, list.arg1()); factor = F.Times(F.Power(F.Factorial(F.integer(i)), F.CN1), F.Power(F.Plus(list.arg1(), F.Times(F.CN1, list.arg2())), F .integer(i))); fadd.append(F.Times(F.ReplaceAll(temp, F.Rule(list.arg1(), list.arg2())), factor)); } return fadd; } return F.NIL; } }
@Override public IExpr evaluate(final IAST ast) { if (ast.size() == 3 && (ast.get(2).isVector() == 3)) { IAST list = (IAST) ast.get(2); final int lowerLimit = Validate.checkIntType(list, 2, Integer.MIN_VALUE); if (lowerLimit != 0) { // TODO support other cases than 0 return null; } final int upperLimit = Validate.checkIntType(list, 3, Integer.MIN_VALUE); if (upperLimit < 0) { return null; } IAST fadd = F.Plus(); fadd.add(F.ReplaceAll(ast.get(1), F.Rule(list.get(1), list.get(2)))); IExpr temp = ast.get(1); IExpr factor = null; for (int i = 1; i <= upperLimit; i++) { temp = F.D(temp, list.get(1)); factor = F.Times(F.Power(F.Factorial(F.integer(i)), F.CN1), F.Power(F.Plus(list.get(1), F.Times(F.CN1, list.get(2))), F .integer(i))); fadd.add(F.Times(F.ReplaceAll(temp, F.Rule(list.get(1), list.get(2))), factor)); } return fadd; } return null; } }
/** * Try using the <code>TrigReduce</code> function to get a <code>Plus(...)</code> expression which could be * integrated. * * @param timesAST * an IAST which is a <code>Times(...)</code> expression * @param arg2 * the symbol to get the indefinite integral for. * @return <code>F.NIL</code> if no trigonometric funtion could be found. */ private static IExpr integrateTimesTrigFunctions(final IAST timesAST, IExpr arg2) { Predicate<IExpr> isTrigFunction = Predicates.isAST(new ISymbol[] { F.Cos, F.Sin }); if (timesAST.has(isTrigFunction, false)) { // use a symbol which is not in the symbols map ISymbol pSymbol = new Symbol("$x$", Context.SYSTEM); IExpr fx = F.eval(F.TrigReduce(timesAST)); if (fx.isPlus()) { // Collect arguments for x // Sin(f_) -> Sin(Collect(f, arg2)) fx = F.eval(F.ReplaceAll(fx, F.List(F.Rule(F.Sin(F.$p(pSymbol)), F.Sin(F.Collect(pSymbol, arg2))), F.Rule(F.Cos(F.$p(pSymbol)), F.Cos(F.Collect(pSymbol, arg2)))))); // Integrate[a_+b_+...,x_] -> Integrate[a,x]+Integrate[b,x]+... return ((IAST) fx).mapThread(F.Integrate(null, arg2), 1); } } return F.NIL; }
@Override public IExpr evaluate(final IAST ast, EvalEngine engine) { Validate.checkSize(ast, 4); IExpr m = ast.arg1(); IExpr f = ast.arg2(); IExpr x = ast.arg3(); if (f.isList()) { if (x.isAtom()) { // DesignMatrix(m_, f_List, x_?AtomQ) := // DesignMatrix(m, {f}, ConstantArray(x, Length(f))) return F.DesignMatrix(m, F.List(f), F.ConstantArray(x, F.ZZ(((IAST) f).argSize()))); } else if (x.isList()) { // DesignMatrix(m_, f_List, x_List) := // Prepend(MapThread(Function({g, y, r}, g /. y -> r), {f, x, Most(#)}), 1)& /@ m return Map( Function(Prepend(MapThread(Function(List(F.g, F.y, F.r), ReplaceAll(F.g, Rule(F.y, F.r))), List(f, x, Most(Slot1))), C1)), m); } } else { if (x.isAtom()) { // DesignMatrix(m_, f_, x_?AtomQ) := DesignMatrix(m, {f}, {x}) return F.DesignMatrix(m, F.List(f), F.List(x)); } } return F.NIL; }
return F.ReplaceAll(function, F.Rule(x, x0)); return F.Times(F.Power(F.Factorial(n), F.CN1), F.ReplaceAll(derivedFunction, F.Rule(x, x0)));
IExpr derivedFunction = function; for (int i = 0; i <= n; i++) { IExpr functionPart = engine.evalQuiet(F.ReplaceAll(derivedFunction, F.Rule(x, x0))); if (functionPart.isIndeterminate()) { functionPart = engine.evalQuiet(F.Limit(derivedFunction, F.Rule(x, x0)));