Average Error: 4.4 → 2.0
Time: 11.2s
Precision: 64
\[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\]
\[\mathsf{fma}\left(y, z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)\]
x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\mathsf{fma}\left(y, z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)
double f(double x, double y, double z, double t) {
        double r301391 = x;
        double r301392 = y;
        double r301393 = z;
        double r301394 = r301392 * r301393;
        double r301395 = t;
        double r301396 = r301395 / r301392;
        double r301397 = tanh(r301396);
        double r301398 = r301391 / r301392;
        double r301399 = tanh(r301398);
        double r301400 = r301397 - r301399;
        double r301401 = r301394 * r301400;
        double r301402 = r301391 + r301401;
        return r301402;
}

double f(double x, double y, double z, double t) {
        double r301403 = y;
        double r301404 = z;
        double r301405 = t;
        double r301406 = r301405 / r301403;
        double r301407 = tanh(r301406);
        double r301408 = x;
        double r301409 = r301408 / r301403;
        double r301410 = tanh(r301409);
        double r301411 = r301407 - r301410;
        double r301412 = r301404 * r301411;
        double r301413 = fma(r301403, r301412, r301408);
        return r301413;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original4.4
Target2.0
Herbie2.0
\[x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)\]

Derivation

  1. Initial program 4.4

    \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\]
  2. Simplified2.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(y, z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)}\]
  3. Final simplification2.0

    \[\leadsto \mathsf{fma}\left(y, z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)\]

Reproduce

herbie shell --seed 2020047 +o rules:numerics
(FPCore (x y z t)
  :name "SynthBasics:moogVCF from YampaSynth-0.2"
  :precision binary64

  :herbie-target
  (+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y))))))

  (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))