Package jmathexpr

Examples of jmathexpr.Expression.evaluate()


        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


    public void testIntegerExpressions() {
        IntegerNumber ten = Z.create(10);
        IntegerNumber eleven = Z.create(11)
        Expression integerExpr = new Subtraction(ten, eleven);
       
        System.out.printf("%s = %s%n", integerExpr, integerExpr.evaluate());       
        assertEquals(integerExpr.evaluate(), Z.create(-1));
    }
   
    @Test
    public void testNaturalExpressions() {
View Full Code Here

        IntegerNumber ten = Z.create(10);
        IntegerNumber eleven = Z.create(11)
        Expression integerExpr = new Subtraction(ten, eleven);
       
        System.out.printf("%s = %s%n", integerExpr, integerExpr.evaluate());       
        assertEquals(integerExpr.evaluate(), Z.create(-1));
    }
   
    @Test
    public void testNaturalExpressions() {
        Expression evaluated;
View Full Code Here

        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();
View Full Code Here

        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();
View Full Code Here

        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();
View Full Code Here

        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();
View Full Code Here

        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

           
            ExpressionContext.getInstance().addExpression(new Equality(Numbers.variable("x", 1), x1));
            ExpressionContext.getInstance().addExpression(new Equality(Numbers.variable("x", 2), x2));
           
            x1 = x1.evaluate();
            x2 = x2.evaluate();
           
            ExpressionContext.getInstance().addExpression(new Equality(Numbers.variable("x", 1), x1));
            ExpressionContext.getInstance().addExpression(new Equality(Numbers.variable("x", 2), x2));
           
            return new FiniteSet(x1, x2);
View Full Code Here

        public Expression apply() {
            Expression dd = p.discriminant();
           
            ExpressionContext.getInstance().addExpression(new Equality(Numbers.constant("D"), dd));
           
            dd = dd.evaluate();
           
            ExpressionContext.getInstance().addExpression(new Equality(Numbers.constant("D"), dd));
           
            Expression a = p.getCoefficient(2);
            Expression b = p.getCoefficient(1);
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.