### Question:
CustomFunction extends Function implements IFunction { @Nonnull @Override public Generic derivative(@Nonnull Variable variable) { Generic result = JsclInteger.valueOf(0); for (int i = 0; i < parameters.length; i++) { final Generic hd = parameters[i].derivative(variable); final Generic gd = this.content.derivative(variable); result = result.add(hd.multiply(gd)); } return result; } 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();  }### Answer:
@Test public void testDerivative() 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()); assertEquals("cos(t)", Expression.valueOf("∂(t1(t), t)").expand().toString()); assertEquals("0", Expression.valueOf("∂(t1(t), t2)").expand().toString()); assertEquals("cos(a)", Expression.valueOf("∂(t1(a), a)").expand().toString()); assertEquals("1", 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("sin(x)", Expression.valueOf("∂(t2(x, y), y)").expand().toString()); }