Average Error: 4.8 → 2.1
Time: 7.7s
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 r280236 = x;
        double r280237 = y;
        double r280238 = z;
        double r280239 = r280237 * r280238;
        double r280240 = t;
        double r280241 = r280240 / r280237;
        double r280242 = tanh(r280241);
        double r280243 = r280236 / r280237;
        double r280244 = tanh(r280243);
        double r280245 = r280242 - r280244;
        double r280246 = r280239 * r280245;
        double r280247 = r280236 + r280246;
        return r280247;
}

double f(double x, double y, double z, double t) {
        double r280248 = y;
        double r280249 = z;
        double r280250 = t;
        double r280251 = r280250 / r280248;
        double r280252 = tanh(r280251);
        double r280253 = x;
        double r280254 = r280253 / r280248;
        double r280255 = tanh(r280254);
        double r280256 = r280252 - r280255;
        double r280257 = r280249 * r280256;
        double r280258 = fma(r280248, r280257, r280253);
        return r280258;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original4.8
Target2.1
Herbie2.1
\[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.1

    \[\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.1

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