Average Error: 4.3 → 2.0
Time: 58.8s
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, \tanh \left(\frac{t}{y}\right) \cdot z + \left(-\tanh \left(\frac{x}{y}\right)\right) \cdot z, 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, \tanh \left(\frac{t}{y}\right) \cdot z + \left(-\tanh \left(\frac{x}{y}\right)\right) \cdot z, x\right)
double f(double x, double y, double z, double t) {
        double r447246 = x;
        double r447247 = y;
        double r447248 = z;
        double r447249 = r447247 * r447248;
        double r447250 = t;
        double r447251 = r447250 / r447247;
        double r447252 = tanh(r447251);
        double r447253 = r447246 / r447247;
        double r447254 = tanh(r447253);
        double r447255 = r447252 - r447254;
        double r447256 = r447249 * r447255;
        double r447257 = r447246 + r447256;
        return r447257;
}

double f(double x, double y, double z, double t) {
        double r447258 = y;
        double r447259 = t;
        double r447260 = r447259 / r447258;
        double r447261 = tanh(r447260);
        double r447262 = z;
        double r447263 = r447261 * r447262;
        double r447264 = x;
        double r447265 = r447264 / r447258;
        double r447266 = tanh(r447265);
        double r447267 = -r447266;
        double r447268 = r447267 * r447262;
        double r447269 = r447263 + r447268;
        double r447270 = fma(r447258, r447269, r447264);
        return r447270;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original4.3
Target2.1
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.3

    \[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. Using strategy rm
  4. Applied sub-neg2.0

    \[\leadsto \mathsf{fma}\left(y, z \cdot \color{blue}{\left(\tanh \left(\frac{t}{y}\right) + \left(-\tanh \left(\frac{x}{y}\right)\right)\right)}, x\right)\]
  5. Applied distribute-lft-in2.0

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

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

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

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

Reproduce

herbie shell --seed 2020045 +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))))))