Average Error: 4.8 → 2.0
Time: 9.0s
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 r317319 = x;
        double r317320 = y;
        double r317321 = z;
        double r317322 = r317320 * r317321;
        double r317323 = t;
        double r317324 = r317323 / r317320;
        double r317325 = tanh(r317324);
        double r317326 = r317319 / r317320;
        double r317327 = tanh(r317326);
        double r317328 = r317325 - r317327;
        double r317329 = r317322 * r317328;
        double r317330 = r317319 + r317329;
        return r317330;
}

double f(double x, double y, double z, double t) {
        double r317331 = y;
        double r317332 = z;
        double r317333 = t;
        double r317334 = r317333 / r317331;
        double r317335 = tanh(r317334);
        double r317336 = x;
        double r317337 = r317336 / r317331;
        double r317338 = tanh(r317337);
        double r317339 = r317335 - r317338;
        double r317340 = r317332 * r317339;
        double r317341 = fma(r317331, r317340, r317336);
        return r317341;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original4.8
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.8

    \[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 2020060 +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))))))