SparseGradient implements RealFieldElement<SparseGradient>, Serializable { public SparseGradient reciprocal() { return new SparseGradient(1.0 / value, -1.0 / (value * value), derivatives); } private  SparseGradient(final double value, final Map<Integer, Double> derivatives); private  SparseGradient(final double value, final double scale,
                             final Map<Integer, Double> derivatives); static SparseGradient createConstant(final double value); static SparseGradient createVariable(final int idx, final double value); int numVars(); double getDerivative(final int index); double getValue(); double getReal(); SparseGradient add(final SparseGradient a); void addInPlace(final SparseGradient a); SparseGradient add(final double c); SparseGradient subtract(final SparseGradient a); SparseGradient subtract(double c); SparseGradient multiply(final SparseGradient a); void multiplyInPlace(final SparseGradient a); SparseGradient multiply(final double c); SparseGradient multiply(final int n); SparseGradient divide(final SparseGradient a); SparseGradient divide(final double c); SparseGradient negate(); Field<SparseGradient> getField(); SparseGradient remainder(final double a); SparseGradient remainder(final SparseGradient a); SparseGradient abs(); SparseGradient ceil(); SparseGradient floor(); SparseGradient rint(); long round(); SparseGradient signum(); SparseGradient copySign(final SparseGradient sign); SparseGradient copySign(final double sign); SparseGradient scalb(final int n); SparseGradient hypot(final SparseGradient y); static SparseGradient hypot(final SparseGradient x, final SparseGradient y); SparseGradient reciprocal(); SparseGradient sqrt(); SparseGradient cbrt(); SparseGradient rootN(final int n); SparseGradient pow(final double p); SparseGradient pow(final int n); SparseGradient pow(final SparseGradient e); static SparseGradient pow(final double a, final SparseGradient x); SparseGradient exp(); SparseGradient expm1(); SparseGradient log(); SparseGradient log10(); SparseGradient log1p(); SparseGradient cos(); SparseGradient sin(); SparseGradient tan(); SparseGradient acos(); SparseGradient asin(); SparseGradient atan(); SparseGradient atan2(final SparseGradient x); static SparseGradient atan2(final SparseGradient y, final SparseGradient x); SparseGradient cosh(); SparseGradient sinh(); SparseGradient tanh(); SparseGradient acosh(); SparseGradient asinh(); SparseGradient atanh(); SparseGradient toDegrees(); SparseGradient toRadians(); double taylor(final double ... delta); SparseGradient compose(final double f0, final double f1); SparseGradient linearCombination(final SparseGradient[] a,
                                              final SparseGradient[] b); SparseGradient linearCombination(final double[] a, final SparseGradient[] b); SparseGradient linearCombination(final SparseGradient a1, final SparseGradient b1,
                                              final SparseGradient a2, final SparseGradient b2); SparseGradient linearCombination(final double a1, final SparseGradient b1,
                                              final double a2, final SparseGradient b2); SparseGradient linearCombination(final SparseGradient a1, final SparseGradient b1,
                                              final SparseGradient a2, final SparseGradient b2,
                                              final SparseGradient a3, final SparseGradient b3); SparseGradient linearCombination(final double a1, final SparseGradient b1,
                                              final double a2, final SparseGradient b2,
                                              final double a3, final SparseGradient b3); SparseGradient linearCombination(final SparseGradient a1, final SparseGradient b1,
                                              final SparseGradient a2, final SparseGradient b2,
                                              final SparseGradient a3, final SparseGradient b3,
                                              final SparseGradient a4, final SparseGradient b4); SparseGradient linearCombination(final double a1, final SparseGradient b1,
                                              final double a2, final SparseGradient b2,
                                              final double a3, final SparseGradient b3,
                                              final double a4, final SparseGradient b4); @Override boolean equals(Object other); @Override int hashCode();  }
@Test public void testReciprocal() { for (double x = 0.1; x < 1.2; x += 0.1) { SparseGradient r = SparseGradient.createVariable(0, x).reciprocal(); Assert.assertEquals(1 / x, r.getValue(), 1.0e-15); final double expected = -1 / (x * x); Assert.assertEquals(expected, r.getDerivative(0), 1.0e-15 * FastMath.abs(expected)); } }