Average Error: 4.8 → 2.0
Time: 9.1s
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 r330458 = x;
        double r330459 = y;
        double r330460 = z;
        double r330461 = r330459 * r330460;
        double r330462 = t;
        double r330463 = r330462 / r330459;
        double r330464 = tanh(r330463);
        double r330465 = r330458 / r330459;
        double r330466 = tanh(r330465);
        double r330467 = r330464 - r330466;
        double r330468 = r330461 * r330467;
        double r330469 = r330458 + r330468;
        return r330469;
}

double f(double x, double y, double z, double t) {
        double r330470 = y;
        double r330471 = z;
        double r330472 = t;
        double r330473 = r330472 / r330470;
        double r330474 = tanh(r330473);
        double r330475 = x;
        double r330476 = r330475 / r330470;
        double r330477 = tanh(r330476);
        double r330478 = r330474 - r330477;
        double r330479 = r330471 * r330478;
        double r330480 = fma(r330470, r330479, r330475);
        return r330480;
}

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))))))