Search in sources :

Example 81 with IAST

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");
}
Also used : IAST(org.matheclipse.core.interfaces.IAST)

Example 82 with IAST

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)");
}
Also used : IAST(org.matheclipse.core.interfaces.IAST)

Example 83 with IAST

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");
}
Also used : IAST(org.matheclipse.core.interfaces.IAST)

Example 84 with IAST

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;
}
Also used : TreeSet(java.util.TreeSet) IInteger(org.matheclipse.core.interfaces.IInteger) IAST(org.matheclipse.core.interfaces.IAST) KSubsetsList(org.matheclipse.core.builtin.Combinatoric.Subsets.KSubsetsList)

Example 85 with IAST

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();
}
Also used : IInteger(org.matheclipse.core.interfaces.IInteger) IAST(org.matheclipse.core.interfaces.IAST)

Aggregations

IAST (org.matheclipse.core.interfaces.IAST)413 IExpr (org.matheclipse.core.interfaces.IExpr)248 ISymbol (org.matheclipse.core.interfaces.ISymbol)76 IInteger (org.matheclipse.core.interfaces.IInteger)34 WrongArgumentType (org.matheclipse.core.eval.exception.WrongArgumentType)30 ISignedNumber (org.matheclipse.core.interfaces.ISignedNumber)22 ExpVector (edu.jas.poly.ExpVector)15 ArrayList (java.util.ArrayList)14 BigRational (edu.jas.arith.BigRational)13 JASIExpr (org.matheclipse.core.convert.JASIExpr)13 VariablesSet (org.matheclipse.core.convert.VariablesSet)13 INum (org.matheclipse.core.interfaces.INum)13 ExprPolynomial (org.matheclipse.core.polynomials.ExprPolynomial)12 GenPolynomial (edu.jas.poly.GenPolynomial)11 JASConversionException (org.matheclipse.core.eval.exception.JASConversionException)11 IFraction (org.matheclipse.core.interfaces.IFraction)11 INumber (org.matheclipse.core.interfaces.INumber)11 IComplex (org.matheclipse.core.interfaces.IComplex)10 ModLong (edu.jas.arith.ModLong)9 ExprPolynomialRing (org.matheclipse.core.polynomials.ExprPolynomialRing)9