@Override public IExpr pdf(IAST dist, IExpr k) { if (dist.isAST1()) { IExpr p = dist.arg1(); // IExpr function = // [$ Piecewise({{1 - p, # == 0}, {p, # == 1}}, 0) & $] F.Function(F.Piecewise(F.List(F.List(F.Plus(F.C1, F.Negate(p)), F.Equal(F.Slot1, F.C0)), F.List(p, F.Equal(F.Slot1, F.C1))), F.C0)); // $$; return callFunction(function, k); } return F.NIL; }
/** * Use the <code>Eliminate()</code> function to extract one variable. * * @param termsEqualZeroList * a list of expressions which equals zero. * @param variable * the variable which should be eliminated in the term * @return */ private static IExpr eliminateOneVariable(IAST termsEqualZeroList, IExpr variable, EvalEngine engine) { if (!termsEqualZeroList.arg1().isFree(t -> t.isIndeterminate() || t.isDirectedInfinity(), true)) { return F.NIL; } // copy the termsEqualZeroList back to a list of F.Equal(...) expressions // because Eliminate() operates on equations. IAST equalsASTList = termsEqualZeroList.mapThread(F.Equal(F.Null, F.C0), 1); IAST[] tempAST = Eliminate.eliminateOneVariable(equalsASTList, variable, engine); if (tempAST != null && tempAST[1] != null && tempAST[1].isRule() && tempAST[1].second().isTrue()) { return F.CEmptyList; } if (tempAST != null && tempAST[1] != null) { return F.List(F.List(tempAST[1])); } return F.NIL; }
@Override public IExpr evaluate(final IAST ast, EvalEngine engine) { Validate.checkSize(ast, 2); // ISymbol arg1 = Validate.checkSymbolType(ast, 1); IExpr arg1 = ast.arg1(); if (arg1.isFunction()) { IExpr f = arg1.first(); if (f.isAST()) { final int moduleCounter = engine.incModuleCounter(); final String varAppend = "$" + moduleCounter; ISymbol dummy = F.Dummy(varAppend); IAST[] arr = Eliminate.eliminateSlot(F.Equal((IAST) f, dummy), F.Slot1, engine); if (arr != null) { return F.Function(F.subst(arr[1].second(), F.Rule(dummy, F.Slot1))); } } } else if (arg1.isBuiltInSymbol()) { if (arg1.equals(F.Abs)) { engine.printMessage("InverseFunction: using of inverse functions may omit some values."); } IExpr temp = getUnaryInverseFunction((ISymbol) arg1); if (temp != null) { return temp; } return F.NIL; } return F.NIL; }
rules.append(F.List(engine.evaluate(plus), F.Equal(n, F.C0)));
return F.List(F.Equal(F.evalExpandAll(equalAST.arg1(), engine), F.evalExpandAll(equalAST.arg2(), engine)));
IExpr candidates = F.Solve.of(engine, F.Equal(first_derivative, F.C0), x, F.Reals); if (candidates.isFree(F.Solve)) { IExpr maxCandidate = F.NIL;
IExpr candidates = F.Solve.of(engine, F.Equal(first_derivative, F.C0), x, F.Reals); if (candidates.isFree(F.Solve)) { IExpr minCandidate = F.NIL;
if (boundaryCondition != null) { IExpr res = F.subst(temp, F.List(F.Rule(xVar, boundaryCondition[0]))); IExpr C1 = F.Roots.of(engine, F.Equal(res, boundaryCondition[1]), C_1); if (C1.isAST(F.Equal, 3, C_1)) { res = F.subst(temp, F.List(F.Rule(C_1, C1.second())));
IASTAppendable or = F.Or(); for (int i = 1; i < list.size(); i++) { or.append(F.Equal(variable, list.get(i)));
And(Positive(x), Equal(y, Power(x, CN1))));