//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testDerivative() public virtual void testDerivative() { assertEquals(F1.derivative().applyAsDouble(X), DF1.applyAsDouble(X), 1e-3); assertEquals(F2.derivative().applyAsDouble(X), DF2.applyAsDouble(X), 1e-3); assertEquals(F1.derivative(FiniteDifferenceType.CENTRAL, 1e-5).applyAsDouble(X), DF1.applyAsDouble(X), 1e-3); assertEquals(F2.derivative(FiniteDifferenceType.CENTRAL, 1e-5).applyAsDouble(X), DF2.applyAsDouble(X), 1e-3); assertEquals(F1.derivative(FiniteDifferenceType.FORWARD, 1e-5).applyAsDouble(X), DF1.applyAsDouble(X), 1e-3); assertEquals(F2.derivative(FiniteDifferenceType.FORWARD, 1e-5).applyAsDouble(X), DF2.applyAsDouble(X), 1e-3); assertEquals(F1.derivative(FiniteDifferenceType.BACKWARD, 1e-5).applyAsDouble(X), DF1.applyAsDouble(X), 1e-3); assertEquals(F2.derivative(FiniteDifferenceType.BACKWARD, 1e-5).applyAsDouble(X), DF2.applyAsDouble(X), 1e-3); assertEquals(F3.derivative().applyAsDouble(X), DF1.applyAsDouble(X), 1e-15); assertEquals(F4.derivative().applyAsDouble(X), DF2.applyAsDouble(X), 1e-15); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testDerivative() public virtual void testDerivative() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double x = RANDOM.nextDouble(); double x = RANDOM.NextDouble(); assertEquals(3 * C[3] * Math.Pow(x, 2) + 2 * C[2] * x + C[1], F.derivative().applyAsDouble(x), EPS); }
//------------------------------------------------------------------------- public virtual double?getRoot(System.Func <double, double> function, double?x) { ArgChecker.notNull(function, "function"); ArgChecker.notNull(x, "x"); DoubleFunction1D f = DoubleFunction1D.from(function); return(getRoot(f, f.derivative(), x)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testConversion() public virtual void testConversion() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.function.Function<double, double> f1 = x -> x * x * x + 2 * x * x - 7 * x + 12; System.Func <double, double> f1 = x => x * x * x + 2 * x * x - 7 * x + 12; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final DoubleFunction1D f2 = DoubleFunction1D.from(f1); DoubleFunction1D f2 = DoubleFunction1D.from(f1); for (int i = 0; i < 100; i++) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double x = Math.random(); double x = GlobalRandom.NextDouble; assertEquals(f2.applyAsDouble(x), F1.applyAsDouble(x), 0); assertEquals(f2.derivative().applyAsDouble(x), F1.derivative().applyAsDouble(x), 0); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(expectedExceptions = IllegalArgumentException.class) public void testDerivativeNullType() public virtual void testDerivativeNullType() { F1.derivative(null, EPS); }
/// <summary> /// Uses the <seealso cref="DoubleFunction1D#derivative()"/> method. <i>x<sub>1</sub></i> and /// <i>x<sub>2</sub></i> do not have to be increasing. /// </summary> /// <param name="function"> The function, not null </param> /// <param name="x1"> The first bound of the root, not null </param> /// <param name="x2"> The second bound of the root, not null </param> /// <returns> The root </returns> /// <exception cref="MathException"> If the root is not found in 1000 attempts; if the Newton /// step takes the estimate for the root outside the original bounds. </exception> public virtual double?getRoot(DoubleFunction1D function, double?x1, double?x2) { ArgChecker.notNull(function, "function"); return(getRoot(function, function.derivative(), x1, x2)); }