/**
     * Computes the value of the gradient at {@code x}. The components of the gradient vector are
     * the partial derivatives of the function with respect to each of the <em>parameters</em>
     * (amplitude, angular frequency and phase).
     *
     * @param x Value at which the gradient must be computed.
     * @param param Values of amplitude, angular frequency and phase.
     * @return the gradient vector at {@code x}.
     * @throws NullArgumentException if {@code param} is {@code null}.
     * @throws DimensionMismatchException if the size of {@code param} is not 3.
     */
    public double[] gradient(double x, double... param) {
      validateParameters(param);

      final double amplitude = param[0];
      final double omega = param[1];
      final double phase = param[2];

      final double xTimesOmegaPlusPhase = omega * x + phase;
      final double a = HarmonicOscillator.value(xTimesOmegaPlusPhase, 1);
      final double p = -amplitude * FastMath.sin(xTimesOmegaPlusPhase);
      final double w = p * x;

      return new double[] {a, w, p};
    }
 /**
  * Computes the value of the harmonic oscillator at {@code x}.
  *
  * @param x Value for which the function must be computed.
  * @param param Values of norm, mean and standard deviation.
  * @return the value of the function.
  * @throws NullArgumentException if {@code param} is {@code null}.
  * @throws DimensionMismatchException if the size of {@code param} is not 3.
  */
 public double value(double x, double... param) {
   validateParameters(param);
   return HarmonicOscillator.value(x * param[1] + param[2], param[0]);
 }