Package jmathexpr

Examples of jmathexpr.Expression.evaluate()


        Expression contains, evaluated;
        Interval interval = new Interval(true, N.create(0), N.create(1), true); // [0, 1]
        System.out.printf("%s%n", interval);

        contains = new ElementOf(R.create(-1), interval);
        evaluated = contains.evaluate();
        System.out.printf("  %s : %s%n", contains, evaluated);
        assertEquals(evaluated, TruthValue.False);
       
        contains = new ElementOf(R.create(0), interval);
        evaluated = contains.evaluate();       
View Full Code Here


        evaluated = contains.evaluate();
        System.out.printf("  %s : %s%n", contains, evaluated);
        assertEquals(evaluated, TruthValue.False);
       
        contains = new ElementOf(R.create(0), interval);
        evaluated = contains.evaluate();       
        System.out.printf("  %s : %s%n", contains, evaluated);
        assertEquals(evaluated, TruthValue.True);
       
        interval = new Interval(false, N.create(0), N.create(1), true); // (0, 1]
        System.out.printf("%s%n", interval);
View Full Code Here

       
        interval = new Interval(false, N.create(0), N.create(1), true); // (0, 1]
        System.out.printf("%s%n", interval);
       
        contains = new ElementOf(R.create(0), interval);
        evaluated = contains.evaluate();
        System.out.printf("  %s : %s%n", contains, evaluated);
        assertEquals(evaluated, TruthValue.False);
       
        contains = new ElementOf(Z.create(13), interval);
        evaluated = contains.evaluate();
View Full Code Here

        evaluated = contains.evaluate();
        System.out.printf("  %s : %s%n", contains, evaluated);
        assertEquals(evaluated, TruthValue.False);
       
        contains = new ElementOf(Z.create(13), interval);
        evaluated = contains.evaluate();
        System.out.printf("  %s : %s%n", contains, evaluated);
        assertEquals(evaluated, TruthValue.False);
       
        interval = new Interval(false, N.create(0), Infinity.PLUS_INFINITY, false); // (0, inf)
        System.out.printf("%s%n", interval);
View Full Code Here

       
        interval = new Interval(false, N.create(0), Infinity.PLUS_INFINITY, false); // (0, inf)
        System.out.printf("%s%n", interval);

        contains = new ElementOf(R.create(3.14), interval);
        evaluated = contains.evaluate();
        System.out.printf("  %s : %s%n", contains, evaluated);
        assertEquals(evaluated, TruthValue.True);
    }
   
    @Test(dependsOnMethods = { "testSum" })
View Full Code Here

       
        Variable x = Numbers.variable("x");
        x.setValue(parser.parse("(15 + sqrt(249)) / 4"));
        ExpressionContext.getInstance().addVariable(x);
        Expression quadratic = parser.parse("x^2 - 6x + 1");
        evaluated = quadratic.evaluate();
        System.out.printf("%s (%s = %s) = %s%n", quadratic, x.name(), x.evaluate(), evaluated);
       
        expected = parser.parse("(3 sqrt(249) + 65) / 8");
        assertEquals(evaluated, expected);
    }
View Full Code Here

        Division division = new Division(R.create(10.0), R.create(2.0));
        System.out.printf("Division domain: %s%n", division.domain());
       
        ExpressionParser parser = new ExpressionParser();
        Expression fraction = parser.parse("(6 sqrt(249) + 130) / 16");
        evaluated = fraction.evaluate();
        System.out.printf("%s : %s%n", fraction, evaluated);
       
        Expression expected = parser.parse("(3 sqrt(249) + 65) / 8");
        assertEquals(evaluated, expected);
    }
View Full Code Here

        Expression evaluated;
        RationalNumber oneHalf = new LongRationalNumber(1, 2);
        RationalNumber oneThird = new LongRationalNumber(1, 3);
        Expression sum = new Addition(oneHalf, oneThird);
       
        evaluated = sum.evaluate();
        System.out.printf("%s = %s%n", sum, evaluated);
        assertEquals(evaluated, new LongRationalNumber(5, 6));
       
        Expression difference = new Subtraction(oneHalf, oneThird);
        evaluated = difference.evaluate();
View Full Code Here

        evaluated = sum.evaluate();
        System.out.printf("%s = %s%n", sum, evaluated);
        assertEquals(evaluated, new LongRationalNumber(5, 6));
       
        Expression difference = new Subtraction(oneHalf, oneThird);
        evaluated = difference.evaluate();
        System.out.printf("%s = %s%n", difference, evaluated);
        assertEquals(evaluated, new LongRationalNumber(1, 6));
       
        RationalNumber sixEighth = new LongRationalNumber(6, 8);
        evaluated = sixEighth.evaluate();
View Full Code Here

        evaluated = sixEighth.evaluate();
        System.out.printf("%s = %s%n", sixEighth, evaluated);
        assertEquals(evaluated, new LongRationalNumber(3, 4));
       
        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);
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.