use of org.matheclipse.core.interfaces.IAST in project symja_android_library by axkr.
the class RubiIntegrationTest method testRubi001.
public void testRubi001() {
IAST ast;
ast = LinearQ(Times(2, x), x);
check(ast, "True");
// ???
ast = LinearQ(C2, x);
check(ast, "False");
}
use of org.matheclipse.core.interfaces.IAST in project symja_android_library by axkr.
the class RubiIntegrationTest method testRubi005.
public void testRubi005() {
IAST ast;
// SimpFixFactor[(a_.*Complex[0,c_] + b_.*Complex[0,d_])^p_.,x_]
ast = SimpFixFactor(Power(Plus(Times(a, Complex(C0, c)), Times(b, Complex(C0, f))), -1), x);
check(ast, "-I/(a*c+b*f)");
ast = SimpFixFactor(Power(Plus(Times(a, I), Times(b, Complex(C0, f))), -1), x);
check(ast, "-I/(a+b*f)");
}
use of org.matheclipse.core.interfaces.IAST in project symja_android_library by axkr.
the class RubiIntegrationTest method testRubi002.
public void testRubi002() {
IAST ast;
ast = ExpandToSum(Times(x, Plus(a, b)), x);
check(ast, "(a+b)*x");
}
use of org.matheclipse.core.interfaces.IAST in project symja_android_library by axkr.
the class BigIntegerSym method divisors.
/**
* Return the divisors of this integer number.
*
* <pre>
* divisors(24) ==> {1,2,3,4,6,8,12,24}
* </pre>
*/
@Override
public IAST divisors() {
if (isOne() || isMinusOne()) {
return F.List(F.C1);
}
Set<IInteger> set = new TreeSet<IInteger>();
final IAST primeFactorsList = factorize(F.List());
int len = primeFactorsList.size() - 1;
// build the k-subsets from the primeFactorsList
for (int k = 1; k < len; k++) {
final KSubsetsList iter = Subsets.createKSubsets(primeFactorsList, k, F.List(), 1);
for (IAST subset : iter) {
if (subset == null) {
break;
}
// create the product of all integers in the k-subset
IInteger factor = F.C1;
for (int j = 1; j < subset.size(); j++) {
factor = factor.multiply((IInteger) subset.get(j));
}
// add this divisor to the set collection
set.add(factor);
}
}
// build the final divisors list from the tree set
final IAST resultList = List(F.C1);
for (IInteger entry : set) {
resultList.append(entry);
}
resultList.append(this);
return resultList;
}
use of org.matheclipse.core.interfaces.IAST in project symja_android_library by axkr.
the class BigIntegerSym method eulerPhi.
public static BigInteger eulerPhi(BigInteger value) throws ArithmeticException {
if (value.equals(BigInteger.ZERO)) {
return BigInteger.ZERO;
}
if (value.equals(BigInteger.ONE)) {
return BigInteger.ONE;
}
IAST ast = AbstractIntegerSym.valueOf(value).factorInteger();
IInteger phi = AbstractIntegerSym.valueOf(1);
for (int i = 1; i < ast.size(); i++) {
IAST element = (IAST) ast.get(i);
IInteger q = (IInteger) element.arg1();
int c = ((IInteger) element.arg2()).toInt();
if (c == 1) {
phi = phi.multiply(q.subtract(AbstractIntegerSym.valueOf(1)));
} else {
phi = phi.multiply(q.subtract(AbstractIntegerSym.valueOf(1)).multiply(q.pow(c - 1)));
}
}
return phi.toBigNumerator();
}
Aggregations