@Test public void testIntegrals() throws Exception { assertEquals("50", Expression.valueOf("∫ab(x, x, 0, 10)").expand().numeric().toString()); assertEquals("1/2*a^2", Expression.valueOf("∫ab(x, x, 0, a)").expand().toString()); try { assertEquals("∫ab(x, x, 0)", Expression.valueOf("∫ab(x, x, 0)").expand().toString()); fail(); } catch (ParseException e) { } try { assertEquals("∫ab(x, x)", Expression.valueOf("∫ab(x, x)").expand().simplify().toString()); fail(); } catch (ParseException e) { } assertEquals("x^2/2", Expression.valueOf("∫(x, x)").expand().simplify().toString()); try { assertEquals("x^2/2", Expression.valueOf("∫(x, x)").expand().numeric().toString()); fail(); } catch (ArithmeticException e) { } assertEquals("x^2/2", Expression.valueOf("∫(x, x)").expand().simplify().toString()); assertEquals("ln(x)", Expression.valueOf("∫(1/x, x)").expand().simplify().toString()); try { JsclMathEngine.getInstance().setAngleUnits(AngleUnit.rad); assertEquals("2*ln(2)+ln(cosh(x))", Expression.valueOf("∫(tanh(x), x)").expand().simplify().toString()); assertEquals("2*ln(2)+ln(sin(x))", Expression.valueOf("∫(cot(x), x)").expand().simplify().toString()); assertEquals("-2*ln(2)-ln(cos(x))", Expression.valueOf("∫(tan(x), x)").expand().simplify().toString()); } finally { JsclMathEngine.getInstance().setAngleUnits(AngleUnit.deg); } }
@Nonnull public static Expression valueOf(@Nonnull Variable variable) { return valueOf(Literal.valueOf(variable)); }
Expression extends Generic { @Nonnull public static Expression valueOf(@Nonnull Variable variable) { return valueOf(Literal.valueOf(variable)); } }
Expression extends Generic { @Nonnull public static Expression valueOf(@Nonnull Variable variable) { return valueOf(Literal.valueOf(variable)); } Expression();   Expression(int size); }
Expression extends Generic { @Nonnull public static Expression valueOf(@Nonnull Variable variable) { return valueOf(Literal.valueOf(variable)); } Expression();   Expression(int size); static Variable[] variables(Generic elements[]); @Nonnull static Expression valueOf(@Nonnull Variable variable); @Nonnull static Expression valueOf(@Nonnull Literal literal); @Nonnull static Expression valueOf(@Nonnull JsclInteger integer); @Nonnull static Expression valueOf(@Nonnull Literal literal, @Nonnull JsclInteger integer); static Expression valueOf(Rational rational); static Expression valueOf(@Nonnull Constant constant); static Expression valueOf(double value); static Expression valueOf(@Nonnull String expression); Expression init(@Nonnull NumericWrapper numericWrapper); static void separateSign(MathML element, Generic generic); int size(); Literal literal(int n); JsclInteger coef(int n); Expression add(@Nonnull Expression that); @Nonnull Generic add(@Nonnull Generic that); Expression subtract(Expression expression); @Nonnull Generic subtract(@Nonnull Generic that); Expression multiply(Expression expression); @Nonnull Generic multiply(@Nonnull Generic that); @Nonnull Generic divide(@Nonnull Generic that); Generic[] divideAndRemainder(Generic generic); Generic gcd(@Nonnull Generic generic); @Nonnull Generic gcd(); @Nonnull Literal literalScm(); Generic negate(); int signum(); int degree(); Generic antiDerivative(@Nonnull Variable variable); Generic derivative(@Nonnull Variable variable); Generic substitute(@Nonnull final Variable variable, final Generic generic); Generic expand(); Generic factorize(); Generic elementary(); Generic simplify(); Generic numeric(); @Nonnull Generic valueOf(@Nonnull Generic generic); @Nonnull Generic[] sumValue(); @Nonnull Generic[] productValue(); Power powerValue(); Expression expressionValue(); @Override boolean isInteger(); JsclInteger integerValue(); @Override double doubleValue(); Variable variableValue(); Variable[] variables(); boolean isPolynomial(@Nonnull Variable variable); boolean isConstant(@Nonnull Variable variable); JsclVector grad(Variable variable[]); Generic laplacian(Variable variable[]); Generic dalembertian(Variable variable[]); int compareTo(Expression expression); int compareTo(@Nonnull Generic generic); String toString(); String toJava(); void toMathML(MathML element, @Nullable Object data); @Nonnull @Override Set<? extends Constant> getConstants(); }
Expression extends Generic { @Nonnull public static Expression valueOf(@Nonnull Variable variable) { return valueOf(Literal.valueOf(variable)); } Expression();   Expression(int size); static Variable[] variables(Generic elements[]); @Nonnull static Expression valueOf(@Nonnull Variable variable); @Nonnull static Expression valueOf(@Nonnull Literal literal); @Nonnull static Expression valueOf(@Nonnull JsclInteger integer); @Nonnull static Expression valueOf(@Nonnull Literal literal, @Nonnull JsclInteger integer); static Expression valueOf(Rational rational); static Expression valueOf(@Nonnull Constant constant); static Expression valueOf(double value); static Expression valueOf(@Nonnull String expression); Expression init(@Nonnull NumericWrapper numericWrapper); static void separateSign(MathML element, Generic generic); int size(); Literal literal(int n); JsclInteger coef(int n); Expression add(@Nonnull Expression that); @Nonnull Generic add(@Nonnull Generic that); Expression subtract(Expression expression); @Nonnull Generic subtract(@Nonnull Generic that); Expression multiply(Expression expression); @Nonnull Generic multiply(@Nonnull Generic that); @Nonnull Generic divide(@Nonnull Generic that); Generic[] divideAndRemainder(Generic generic); Generic gcd(@Nonnull Generic generic); @Nonnull Generic gcd(); @Nonnull Literal literalScm(); Generic negate(); int signum(); int degree(); Generic antiDerivative(@Nonnull Variable variable); Generic derivative(@Nonnull Variable variable); Generic substitute(@Nonnull final Variable variable, final Generic generic); Generic expand(); Generic factorize(); Generic elementary(); Generic simplify(); Generic numeric(); @Nonnull Generic valueOf(@Nonnull Generic generic); @Nonnull Generic[] sumValue(); @Nonnull Generic[] productValue(); Power powerValue(); Expression expressionValue(); @Override boolean isInteger(); JsclInteger integerValue(); @Override double doubleValue(); Variable variableValue(); Variable[] variables(); boolean isPolynomial(@Nonnull Variable variable); boolean isConstant(@Nonnull Variable variable); JsclVector grad(Variable variable[]); Generic laplacian(Variable variable[]); Generic dalembertian(Variable variable[]); int compareTo(Expression expression); int compareTo(@Nonnull Generic generic); String toString(); String toJava(); void toMathML(MathML element, @Nullable Object data); @Nonnull @Override Set<? extends Constant> getConstants();  }