Package jmathexpr.arithmetic.func

Examples of jmathexpr.arithmetic.func.Sqrt


        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


        }
       
        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

     * @param equality the equality to test
     * @param x the unknown in the equation
     * @return true if the equality is a radical equation
     */
    public static boolean isA(Equality equality, Variable x) {
        return equality.contains(new Sqrt(new FunctionPattern(x)));
    }
View Full Code Here

       
        @Override
        public boolean matches(Expression expr) {
            target = expr;
           
            return expr.contains(new Sqrt(new FunctionPattern(x)));
        }
View Full Code Here

            return fraction.matches(expr) && pattern.matches(fraction.denominator());
        }

        @Override
        public Expression apply() {
            Expression sqrt = new Sqrt(arg.hit());
           
            return new Division(new Multiplication(fraction.numerator(), sqrt),
                       new Multiplication(fraction.denominator(), sqrt));
        }
View Full Code Here

        public boolean matches(Expression expr) {
            p = (Polynomial) ((Equality) expr).lhs();
           
            Expression a = p.leadCoefficient();

            return new Sqrt(arg).matches(a);
        }
View Full Code Here

            return new Sqrt(arg).matches(a);
        }

        @Override
        public Expression apply() {
            return new Equality(new Multiplication(p, new Sqrt(arg.hit())), Naturals.zero());
        }
View Full Code Here

                } else if (!((ANumber) c).isNegative()) {
                    return new EmptySet();
                }
            }
           
            Expression x1 = new Sqrt(new Division(new Negation(c), a));
            Expression x2 = new Negation(x1);
           
            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));
           
View Full Code Here

                    return new FiniteSet(new Division(new Negation(b),
                            new Multiplication(two, a)).evaluate());
                }
            }
           
            Expression sd = new Sqrt(dd);
            Expression x1 = new Division(
                    new Addition(new Negation(b), sd),
                    new Multiplication(two, a));
            Expression x2 = new Division(
                    new Subtraction(new Negation(b), sd),
View Full Code Here

        if (l.equals(r)) { // a * a = a^2
            return new Exponentiation(l, Naturals.getInstance().create(2)).evaluate();
        }
       
        if (l instanceof Sqrt && r instanceof Sqrt) {
            return new Sqrt(new Multiplication(((Sqrt) l).argument(), ((Sqrt) r).argument())).evaluate();
        }
       
        return new Multiplication(l, r);
    }
View Full Code Here

TOP

Related Classes of jmathexpr.arithmetic.func.Sqrt

Copyright © 2018 www.massapicom. 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.