Examples of Multiplication


Examples of eas.users.lukas.tnt.arithmetic.Multiplication

   
    @SuppressWarnings(value = { "all" })
    public static void main(String[] args) throws CloneNotSupportedException {
        Variable a = new Variable(0), b = new Variable(1), c = new Variable(2);
        Variable d = new Variable(3), e = new Variable(4), f = new Variable(5);
        Statement s1 = new Negation(new Exists(new Exists(new Exists(new Equality(new Multiplication(new Multiplication(a, a), a), new Addition(new Multiplication(new Multiplication(new Addition(b, new Number(1)), new Addition(b, new Number(1))), new Addition(b, new Number(1))), new Multiplication(new Multiplication(new Addition(c, new Number(1)), new Addition(c, new Number(1))), new Addition(c, new Number(1))))), c), b), a));
        Statement s2 = s1.clone();
        s1 = new Disjunction(new Conjunction(s1.clone(), s1.clone()), s1.clone());
        Statement s3 = s2.clone();
        renameVarConsistently(s3, a.clone(), d.clone());
        renameVarConsistently(s3, b.clone(), e.clone());
View Full Code Here

Examples of jmathexpr.arithmetic.op.Multiplication

        difference = new Subtraction(new LongRationalNumber(2, 3), new LongRationalNumber(1, 6));
        evaluated = difference.evaluate();
        System.out.printf("%s = %s%n", difference, evaluated);
        assertEquals(evaluated, new LongRationalNumber(1, 2));
       
        Expression product = new Multiplication(new LongRationalNumber(2, 3), new LongRationalNumber(9, 2));
        ElementOf isNatural = new ElementOf(product, N);
        evaluated = isNatural.evaluate();
        System.out.printf("%s = %s : %s%n", product.evaluate(), isNatural, evaluated);
        assertEquals(evaluated, TruthValue.True);
       
        System.out.println(Q.create("-3.750"));
    }
View Full Code Here

Examples of jmathexpr.arithmetic.op.Multiplication

    }
   
    @Test(dependsOnMethods = { "testIntegerExpressions" })
    public void testVariables() {
        NaturalNumber two = N.create(2);
        Variable x = Numbers.variable("x"), a = new Variable("a", new Multiplication(two, x));
             
        for (int i = 1; i < 4; i++) {
            x.setValue(N.create(i));
            System.out.printf("  %s = %s%n", a, a.evaluate());
        }
View Full Code Here

Examples of jmathexpr.arithmetic.op.Multiplication

        Expression evaluated;
        NaturalNumber five = N.create(5);
        NaturalNumber two = N.create(2);
        Addition seven = new Addition(five, two);
        NaturalNumber six = N.create("6");
        Expression naturalExpr = new Multiplication(six, seven);
       
        evaluated = naturalExpr.evaluate();
        System.out.printf("%s = %s%n", naturalExpr, evaluated);       
        assertEquals(evaluated, N.create(42));
       
        Expression equality = new Equality(naturalExpr, N.create(42));
        evaluated = equality.evaluate();
        System.out.printf("%s : %s%n", equality, evaluated);
        assertEquals(evaluated, TruthValue.True);
               
        Expression elementOf = new ElementOf(naturalExpr, N);
        evaluated = elementOf.evaluate();
        System.out.printf("%s : %s%n", elementOf, evaluated);
        assertEquals(evaluated, TruthValue.True);
       
        elementOf = new ElementOf(six, N);
        evaluated = elementOf.evaluate();
        System.out.printf("%s : %s%n", elementOf, evaluated);
        assertEquals(evaluated, TruthValue.True);
       
        Expression sqrt = new Sqrt(N.create(45));
        evaluated = sqrt.evaluate();
        System.out.printf("%s = %s%n", sqrt, evaluated);
        assertEquals(evaluated, new Multiplication(N.create(3), new Sqrt(N.create(5))));
    }
View Full Code Here

Examples of jmathexpr.arithmetic.op.Multiplication

       
        @Override
        public boolean matches(Expression expr) {
            target = expr;
           
            Expression ax = new Multiplication(a, x);

            boolean matches = new Equality(ax, b).matches(expr) || new Equality(b, ax).matches(expr);
           
            // Don't match the case x = b (a = 1)
            matches = matches && !a.hit().equals(Naturals.one());
View Full Code Here

Examples of jmathexpr.arithmetic.op.Multiplication

            ANumber coef = ca.lt(cc) ? ca : cc;

            if (coef.isNegative()) {
                coef = coef.negate();
               
                Expression cx = coef.isOne() ? x.evaluate() : new Multiplication(coef, x.evaluate());
               
                return new Equality(Sum.add(((Equality) target).lhs(), cx),
                    Sum.add(((Equality) target).rhs(), cx));
            } else {
                Expression cx = coef.isOne() ? x.evaluate() : new Multiplication(coef, x.evaluate());
               
                return new Equality(Sum.subtract(((Equality) target).lhs(), cx),
                    Sum.subtract(((Equality) target).rhs(), cx));
            }
        }
View Full Code Here

Examples of jmathexpr.arithmetic.op.Multiplication

        if (s == 1) { // perfect square
            return new LongNaturalNumber(a);
        } else if (a == 1) {
            return new Sqrt(n);
        } else { // sqrt(n) = a * sqrt(s)
            return new Multiplication(new LongNaturalNumber(a), new Sqrt(new LongNaturalNumber(s)));
        }
    }
View Full Code Here

Examples of jmathexpr.arithmetic.op.Multiplication

        Expression sum = null;
        Expression c, term;
       
        for (NaturalNumber n : coeffs.descendingKeySet()) {
            c = coeffs.get(n).evaluate();
            term = new Multiplication(c, new Exponentiation(xvalue, n));
           
            if (sum == null) {
                sum = new Sum(term);
            } else {
                sum = Sum.add(sum, term);
View Full Code Here

Examples of jmathexpr.arithmetic.op.Multiplication

            Expression a = coeffs.get(two);
            Expression b = coeffs.get(ONE);
            Expression c = coeffs.get(ZERO);
           
            return new Subtraction(new Exponentiation(b, two),
                    new Multiplication(four, new Multiplication(a, c)));
        } else {
            throw new UnsupportedOperationException("Cannot compute discriminant: " + this);
        }
    }
View Full Code Here

Examples of jmathexpr.arithmetic.op.Multiplication

       
        if (c != null) {
            if (degree.equals(ZERO)) {
                return c;
            } else if (degree.equals(ONE)) {
                return new Multiplication(c, x);
            } else {
                return new Multiplication(c, new Exponentiation(x, degree));
            }
        } else {
            return ZERO;
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.