public void CentralDifferenceFirstOrderThreePointTest()
 {
     double[] results = { -0.5, 0, 0.5 };
     var finite = new FiniteDifferenceCoefficients(3);
     var coeff = finite.GetCoefficients(1, 1);
     Assert.AreEqual(results, coeff);
 }
 public void CentralDifferenceSecondOrderFivePointsTest()
 {
     double[] results = { (double)-1 / 12, (double)4 / 3, (double)-5 / 2, (double)4 / 3, (double)-1 / 12 };
     var finite = new FiniteDifferenceCoefficients(5);
     var coeff = finite.GetCoefficients(2, 2);
     for (int i = 0; i < coeff.Length; i++)
         Assert.AreEqual(results[i], coeff[i]);
 }
        public void BackwardDifferenceThirdOrderFourPointsTest()
        {
            double[] results = { -1, 3, -3, 1 };
            var finite = new FiniteDifferenceCoefficients(4);
            var coeff = finite.GetCoefficients(3, 3);
            for (int i = 0; i < coeff.Length; i++)
                Assert.AreEqual(results[i], coeff[i]);

        }
 public void ForwardDifferenceThirdOrderEightPointsTest()
 {
     double[] results = { (double)-967 / 120, (double)638 / 15, (double)-3929 / 40, (double)389 / 3,
                          (double)-2545 / 24, (double)268 / 5, (double)-1849 / 120, (double)29 / 15 };
     var finite = new FiniteDifferenceCoefficients(8);
     var coeff = finite.GetCoefficients(0, 3);
     for (int i = 0; i < coeff.Length; i++)
         Assert.AreEqual(results[i], coeff[i]);
 }
        /// <summary>
        /// Initialized a NumericalDerivative class.
        /// </summary>
        /// <param name="points">Number of points for finite difference derivatives.</param>
        /// <param name="center">Location of the center with respect to other points. Value ranges from zero to points-1.</param>
        public NumericalDerivative(int points, int center)
        {
            if (points < 2)
            {
                throw new ArgumentOutOfRangeException(nameof(points), "Points must be two or greater.");
            }

            _center       = center;
            _points       = points;
            Center        = center;
            _coefficients = new FiniteDifferenceCoefficients(points);
        }
 /// <summary>
 /// Initialized a NumericalDerivative class.
 /// </summary>
 /// <param name="points">Number of points for finite difference derivatives.</param>
 /// <param name="center">Location of the center with respect to other points. Value ranges from zero to points-1.</param>
 public NumericalDerivative(int points, int center)
 {
     _center = center;
     if (points < 2)
     {
         throw new ArgumentOutOfRangeException("points", "Points must be two or greater.");
     }
     _points       = points;
     Center        = center;
     _epsilon      = CalculateMachineEpsilon();
     _coefficients = new FiniteDifferenceCoefficients(points);
 }
        /// <summary>
        /// Initialized a NumericalDerivative class.
        /// </summary>
        /// <param name="points">Number of points for finite difference derivatives.</param>
        /// <param name="center">Location of the center with respect to other points. Value ranges from zero to points-1.</param>
        public NumericalDerivative(int points, int center)
        {
            if (points < 2)
            {
                throw new ArgumentOutOfRangeException("points", "Points must be two or greater.");
            }

            _center = center;
            _points = points;
            Center = center;
            _coefficients = new FiniteDifferenceCoefficients(points);
        }
 /// <summary>
 /// Initialized a NumericalDerivative class.
 /// </summary>
 /// <param name="points">Number of points for finite difference derivatives.</param>
 /// <param name="center">Location of the center with respect to other points. Value ranges from zero to points-1.</param>
 public NumericalDerivative(int points, int center)
 {
     _center = center;
     if (points < 2)
         throw new ArgumentOutOfRangeException("points", "Points must be two or greater.");
     _points = points;
     Center = center;
     _epsilon = Precision.PositiveMachineEpsilon;
     _coefficients = new FiniteDifferenceCoefficients(points);
 }