@Test public void testAntiDerivative() throws Exception { JsclMathEngine mathEngine = JsclMathEngine.getInstance(); final CustomFunction.Builder jBuilder = new CustomFunction.Builder("t1", asList("a"), "sin(a)"); mathEngine.getFunctionsRegistry().addOrUpdate(jBuilder.create()); assertEquals("1", Expression.valueOf("t1(90)").numeric().toString()); try { mathEngine.setAngleUnits(AngleUnit.rad); assertEquals("-cos(t)", Expression.valueOf("∫(t1(t), t)").expand().toString()); assertEquals("t2*sin(t)", Expression.valueOf("∫(t1(t), t2)").expand().toString()); assertEquals("-cos(a)", Expression.valueOf("∫(t1(a), a)").expand().toString()); assertEquals("1/2*sin(a)^2", Expression.valueOf("∫(t1(a), t1(a))").expand().toString()); final CustomFunction.Builder jBuilder1 = new CustomFunction.Builder("t2", asList("a", "b"), "b*sin(a)"); mathEngine.getFunctionsRegistry().addOrUpdate(jBuilder1.create()); assertEquals("-y*cos(x)", Expression.valueOf("∫(t2(x, y), x)").expand().toString()); assertEquals("1/2*y^2*sin(x)", Expression.valueOf("∫(t2(x, y), y)").expand().toString()); } finally { mathEngine.setAngleUnits(AngleUnit.deg); } }
@Override public Generic antiDerivative(@Nonnull Variable variable) throws NotIntegrableException { if (getParameterForAntiDerivation(variable) < 0) { throw new NotIntegrableException(this); } else { return this.content.antiDerivative(variable); } }
CustomFunction extends Function implements IFunction { @Override public Generic antiDerivative(@Nonnull Variable variable) throws NotIntegrableException { if (getParameterForAntiDerivation(variable) < 0) { throw new NotIntegrableException(this); } else { return this.content.antiDerivative(variable); } } }
CustomFunction extends Function implements IFunction { @Override public Generic antiDerivative(@Nonnull Variable variable) throws NotIntegrableException { if (getParameterForAntiDerivation(variable) < 0) { throw new NotIntegrableException(this); } else { return this.content.antiDerivative(variable); } } private  CustomFunction(@Nonnull String name,
                           @Nonnull List<String> parameterNames,
                           @Nonnull Expression content,
                           @Nullable String description); private  CustomFunction(@Nonnull String name,
                           @Nonnull List<String> parameterNames,
                           @Nonnull String content,
                           @Nullable String description); }
CustomFunction extends Function implements IFunction { @Override public Generic antiDerivative(@Nonnull Variable variable) throws NotIntegrableException { if (getParameterForAntiDerivation(variable) < 0) { throw new NotIntegrableException(this); } else { return this.content.antiDerivative(variable); } } private  CustomFunction(@Nonnull String name,
                           @Nonnull List<String> parameterNames,
                           @Nonnull Expression content,
                           @Nullable String description); private  CustomFunction(@Nonnull String name,
                           @Nonnull List<String> parameterNames,
                           @Nonnull String content,
                           @Nullable String description); @Override int getMinParameters(); @Override int getMaxParameters(); @Override Generic substitute(@Nonnull Variable variable, @Nonnull Generic generic); @Override Generic numeric(); @Override Generic expand(); @Override Generic elementary(); @Override Generic factorize(); @Override Generic selfExpand(); @Override void copy(@Nonnull MathEntity mathEntity); @Override Generic selfElementary(); @Override Generic selfSimplify(); @Override Generic selfNumeric(); @Override Generic antiDerivative(@Nonnull Variable variable); @Override Generic antiDerivative(int n); @Nonnull @Override Generic derivative(@Nonnull Variable variable); @Override Generic derivative(int n); @Nonnull String getContent(); @Nullable String getDescription(); @Nonnull List<String> getParameterNames(); @Nonnull @Override CustomFunction newInstance(); }
CustomFunction extends Function implements IFunction { @Override public Generic antiDerivative(@Nonnull Variable variable) throws NotIntegrableException { if (getParameterForAntiDerivation(variable) < 0) { throw new NotIntegrableException(this); } else { return this.content.antiDerivative(variable); } } private  CustomFunction(@Nonnull String name,
                           @Nonnull List<String> parameterNames,
                           @Nonnull Expression content,
                           @Nullable String description); private  CustomFunction(@Nonnull String name,
                           @Nonnull List<String> parameterNames,
                           @Nonnull String content,
                           @Nullable String description); @Override int getMinParameters(); @Override int getMaxParameters(); @Override Generic substitute(@Nonnull Variable variable, @Nonnull Generic generic); @Override Generic numeric(); @Override Generic expand(); @Override Generic elementary(); @Override Generic factorize(); @Override Generic selfExpand(); @Override void copy(@Nonnull MathEntity mathEntity); @Override Generic selfElementary(); @Override Generic selfSimplify(); @Override Generic selfNumeric(); @Override Generic antiDerivative(@Nonnull Variable variable); @Override Generic antiDerivative(int n); @Nonnull @Override Generic derivative(@Nonnull Variable variable); @Override Generic derivative(int n); @Nonnull String getContent(); @Nullable String getDescription(); @Nonnull List<String> getParameterNames(); @Nonnull @Override CustomFunction newInstance();  }