public IExpr and(final IExpr that) { return F.And(this, that); }
default IExpr and(final IExpr that) { return F.And(this, that); }
public static IExpr and(IExpr a, Integer i) { return And(a, integer(i.longValue())); }
public static IExpr and(IExpr a, java.math.BigInteger i) { return And(a, integer(i)); }
public static IExpr and(java.math.BigInteger i, IExpr b) { return And(integer(i), b); }
public static IExpr and(Integer i, IExpr b) { return And(integer(i.longValue()), b); }
/** * Transform <code>Inequality()</code> AST to <code>And()</code> expression. * * @param ast * an Inequality AST with <code>size()>=4</code>. * @return */ public static IAST inequality2And(final IAST ast) { IASTAppendable result = F.And(); for (int i = 3; i < ast.size(); i += 2) { result.append(F.binaryAST2(ast.get(i - 1), ast.get(i - 2), ast.get(i))); } return result; }
private IAST createComparator(IAST matrix, int i, int j, int size) { if (i == 1) { // # < matrix[i+2, 1] return F.Less(F.Slot1, matrix.getPart(i + 2, 1)); } else { if (j < size) { // matrix[i+1, 1] <= # < matrix[i+2, 1] return F.And(F.LessEqual(matrix.getPart(i + 1, 1), F.Slot1), F.Less(F.Slot1, matrix.getPart(i + 2, 1))); } else { // # >= matrix[i+1, 1] return F.GreaterEqual(F.Slot1, matrix.getPart(i + 1, 1)); } } }
/** * Convert less or greater relations on input. Example: convert expressions like <code>a < b <= c</code> to * <code>Less[a,b]&&LessEqual[b,c]</code>. * * @param ast * @param compareHead * @return */ public static IExpr rewriteLessGreaterAST(final IASTMutable ast, ISymbol compareHead) { IExpr temp; boolean evaled = false; IASTAppendable andAST = F.And(); for (int i = 1; i < ast.size(); i++) { temp = ast.get(i); if (temp.isASTSizeGE(compareHead, 3)) { IAST lt = (IAST) temp; andAST.append(lt); ast.set(i, lt.last()); evaled = true; } } if (evaled) { andAST.append(ast); return andAST; } else { return ast; } }
public static IExpr tukeyWindow(IExpr x) { return // [$ Piecewise({{1, -(1/3) - 2*x <= 0 && -(1/3) + 2*x <= 0}, {(1/2)*(1 + Cos(3*Pi*(1/6 + x))), x >= -(1/2) && // -(1/3) - 2*x > 0}, {(1/2)*(1 + Cos(3*Pi*(-(1/6) + x))), -(1/3) + 2*x > 0 && x <= 1/2}}, 0) $] F.Piecewise(F.List( F.List(F.C1, F.And(F.LessEqual(F.Plus(F.CN1D3, F.Times(F.CN2, x)), F.C0), F.LessEqual(F.Plus(F.CN1D3, F.Times(F.C2, x)), F.C0))), F.List(F.Times(F.C1D2, F.Plus(F.C1, F.Cos(F.Times(F.C3, F.Pi, F.Plus(F.QQ(1L, 6L), x))))), F.And(F.GreaterEqual(x, F.CN1D2), F.Greater(F.Plus(F.CN1D3, F.Times(F.CN2, x)), F.C0))), F.List(F.Times(F.C1D2, F.Plus(F.C1, F.Cos(F.Times(F.C3, F.Pi, F.Plus(F.QQ(-1L, 6L), x))))), F.And(F.Greater(F.Plus(F.CN1D3, F.Times(F.C2, x)), F.C0), F.LessEqual(x, F.C1D2)))), F.C0); // $$; }
public static IExpr bartlettWindow(IExpr x) { return // [$ Piecewise({{1 - 2*x, 0 <= x <= 1/2}, {1 + 2*x, Inequality(-(1/2), LessEqual, x, Less, 0)}}, 0) // $] F.Piecewise(F.List(F.List(F.Plus(F.C1, F.Times(F.CN2, x)), F.LessEqual(F.C0, x, F.C1D2)), F.List(F.Plus(F.C1, F.Times(F.C2, x)), F.And(F.LessEqual(F.CN1D2, x), F.Less(x, F.C0)))), F.C0); // $$; }
public static IExpr parzenWindow(IExpr x) { return // [$ Piecewise({{-2*(-1 + 2*x)^3, Inequality(1/4, Less, x, LessEqual, 1/2)},{2*(1 + 2*x)^3, Inequality(-(1/2), // LessEqual, x, Less, -(1/4))},{1 - 24*x^2 - 48*x^3, Inequality(-(1/4), LessEqual, x, Less, 0)}, {1 - 24*x^2 + // 48*x^3, 0 <= x <= 1/4}}, 0) $] F.Piecewise(F.List( F.List(F.Times(F.CN2, F.Power(F.Plus(F.CN1, F.Times(F.C2, x)), 3)), F.And(F.Less(F.C1D4, x), F.LessEqual(x, F.C1D2))), F.List(F.Times(F.C2, F.Power(F.Plus(F.C1, F.Times(F.C2, x)), 3)), F.And(F.LessEqual(F.CN1D2, x), F.Less(x, F.CN1D4))), F.List(F.Plus(F.C1, F.Times(F.ZZ(-24L), F.Sqr(x)), F.Times(F.ZZ(-48L), F.Power(x, 3))), F.And(F.LessEqual(F.CN1D4, x), F.Less(x, F.C0))), F.List(F.Plus(F.C1, F.Times(F.ZZ(-24L), F.Sqr(x)), F.Times(F.ZZ(48L), F.Power(x, 3))), F.LessEqual(F.C0, x, F.C1D4))), F.C0); // $$; }
@Override public IExpr cdf(IAST dist, IExpr k) { if (dist.isAST1()) { IExpr p = dist.arg1(); IExpr function = // [$ (Piecewise({{0, # < 0}, {1 - p, 0<=#<1 }}, 1)) & $] F.Function( F.Piecewise( F.List(F.List(F.C0, F.Less(F.Slot1, F.C0)), F.List(F.Plus(F.C1, F.Negate(p)), F.And(F.LessEqual(F.C0, F.Slot1), F.Less(F.Slot1, F.C1)))), F.C1)); // $$; return callFunction(function, k); } return F.NIL; }
@Override public IExpr evaluate(final IAST ast, EvalEngine engine) { Validate.checkSize(ast, 3); final IExpr arg2 = engine.evaluate(ast.arg2()); if (arg2.isSymbol()) { final IExpr arg1 = engine.evaluate(ast.arg1()); if (arg1.isAST(F.Alternatives)) { IAST alternatives = (IAST) arg1; IASTAppendable andList = F.And(); for (int i = 1; i < alternatives.size(); i++) { andList.append(F.Not(F.Element(alternatives.get(i), (ISymbol) arg2))); } return andList; } return F.Not(F.Element(arg1, (ISymbol) arg2)); } return F.NIL; }
@Override public IExpr cdf(IAST dist, IExpr k) { IExpr[] minMax = minmax(dist); if (minMax != null) { IExpr a = minMax[0]; IExpr b = minMax[1]; IExpr function = // [$ (Piecewise({{(1 - a + Floor(#))/(1 - a + b), a<=#<b}, {1, # >= b}}, 0)) & $] F.Function(F.Piecewise(F.List( F.List(F.Times(F.Power(F.Plus(F.C1, F.Negate(a), b), -1), F.Plus(F.C1, F.Negate(a), F.Floor(F.Slot1))), F.And(F.LessEqual(a, F.Slot1), F.Less(F.Slot1, b))), F.List(F.C1, F.GreaterEqual(F.Slot1, b))), F.C0)); // $$; return callFunction(function, k); } return F.NIL; }
@Override public IExpr cdf(IAST dist, IExpr k) { if (dist.isAST2()) { IExpr n = dist.arg1(); IExpr m = dist.arg2(); IExpr function = // [$ (Piecewise({{BetaRegularized(1 - m, n - Floor(#), 1 + Floor(#)), 0<=#<n}, {1, # >= n}}, // 0)) & $] F.Function(F.Piecewise(F.List( F.List(F.BetaRegularized(F.Plus(F.C1, F.Negate(m)), F.Plus(n, F.Negate(F.Floor(F.Slot1))), F.Plus(F.C1, F.Floor(F.Slot1))), F.And(F.LessEqual(F.C0, F.Slot1), F.Less(F.Slot1, n))), F.List(F.C1, F.GreaterEqual(F.Slot1, n))), F.C0)); // $$; return callFunction(function, k); } return F.NIL; }
/** * <p> * Match <code>a_.*variable^n_+b_.*variable^m_</code> to * <code>E^(((-I)*Pi + Log(a) - Log(b))/(m - n)) /; FreeQ(a,x)&&FreeQ(b,x)&&FreeQ(n,x)&&FreeQ(m,x)</code> * </p> * * @param ast * @param x * @return */ private static IExpr matchSpecialExpressions(IAST ast, IExpr exprWithoutVariable, IExpr x) { if (exprWithoutVariable.isZero()) { final Matcher matcher = new Matcher(); // match a_.*variable^n_.+b_.*variable^m_ to E^(((-I)*Pi + Log(a) - Log(b))/(m - n)) matcher.caseOf( F.Plus(F.Times(F.b_DEFAULT, F.Power(x, F.m_)), F.Times(F.a_DEFAULT, F.Power(x, F.n_DEFAULT))), // F.Condition( F.Exp(F.Times(F.Power(F.Plus(F.m, F.Negate(F.n)), -1), F.Plus(F.Times(F.CNI, F.Pi), F.Log(F.a), F.Negate(F.Log(F.b))))), F.And(F.FreeQ(F.a, x), F.FreeQ(F.b, x), F.FreeQ(F.n, x), F.FreeQ(F.m, x)))); return matcher.replaceAll(ast); } return F.NIL; }
@Override public IExpr pdf(IAST dist, IExpr k) { if (dist.isAST3()) { IExpr n = dist.arg1(); IExpr ns = dist.arg2(); IExpr nt = dist.arg3(); IExpr function = // [$ (Piecewise({{(Binomial(ns, #)*Binomial(-ns + nt, -# + n))/Binomial(nt, n), 0 <= # <= n && // n + ns - nt <= # <= n && 0 <= # <= ns && n + ns - nt <= # <= ns}}, 0)) & $] F.Function( F.Piecewise( F.List(F.List( F.Times(F.Binomial(ns, F.Slot1), F.Power(F.Binomial(nt, n), -1), F.Binomial(F.Plus(F.Negate(ns), nt), F.Plus(F.Negate(F.Slot1), n))), F.And(F.LessEqual(F.C0, F.Slot1, n), F.LessEqual(F.Plus(n, ns, F.Negate(nt)), F.Slot1, n), F.LessEqual(F.C0, F.Slot1, ns), F.LessEqual(F.Plus(n, ns, F.Negate(nt)), F.Slot1, ns)))), F.C0)); // $$; return callFunction(function, k); } return F.NIL; }
@Override public void setUp(final ISymbol newSymbol) { newSymbol.setAttributes(ISymbol.HOLDALL); super.setUp(newSymbol); // if (Config.LOAD_SERIALIZED_RULES) { // initSerializedRules(symbol); // } // hack for TimeConstrained time limit: // F.ISet(F.$s("§timelimit"), F.integer(12)); F.ISet(F.$s("§simplifyflag"), F.False); F.ISet(F.$s("§$timelimit"), F.ZZ(Config.INTEGRATE_RUBI_TIMELIMIT)); F.ISet(F.$s("§$showsteps"), F.False); UtilityFunctionCtors.ReapList.setAttributes(ISymbol.HOLDFIRST); F.ISet(F.$s("§$trigfunctions"), F.List(F.Sin, F.Cos, F.Tan, F.Cot, F.Sec, F.Csc)); F.ISet(F.$s("§$hyperbolicfunctions"), F.List(F.Sinh, F.Cosh, F.Tanh, F.Coth, F.Sech, F.Csch)); F.ISet(F.$s("§$inversetrigfunctions"), F.List(F.ArcSin, F.ArcCos, F.ArcTan, F.ArcCot, F.ArcSec, F.ArcCsc)); F.ISet(F.$s("§$inversehyperbolicfunctions"), F.List(F.ArcSinh, F.ArcCosh, F.ArcTanh, F.ArcCoth, F.ArcSech, F.ArcCsch)); F.ISet(F.$s("§$calculusfunctions"), F.List(F.D, Integrate, F.Sum, F.Product, F.Integrate, F.$rubi("Unintegrable"), F.$rubi("CannotIntegrate"), F.$rubi("Dif"), F.$rubi("Subst"))); F.ISet(F.$s("§$stopfunctions"), F.List(F.Hold, F.HoldForm, F.Defer, F.Pattern, F.If, F.Integrate, F.$rubi("Unintegrable"), F.$rubi("CannotIntegrate"))); F.ISet(F.$s("§$heldfunctions"), F.List(F.Hold, F.HoldForm, F.Defer, F.Pattern)); F.ISet(UtilityFunctionCtors.IntegerPowerQ, // F.Function(F.And(F.SameQ(F.Head(F.Slot1), F.Power), F.IntegerQ(F.Part(F.Slot1, F.C2))))); F.ISet(UtilityFunctionCtors.FractionalPowerQ, // F.Function( F.And(F.SameQ(F.Head(F.Slot1), F.Power), F.SameQ(F.Head(F.Part(F.Slot1, F.C2)), F.Rational)))); }
if (argX.isPresent() && F.evalTrue(F.And(F.Less(F.CNPiHalf, argX), F.LessEqual(argX, F.CPiHalf)))) { return F.ArcTan(F.Divide(y, x));