Average Error: 4.7 → 2.1
Time: 33.9s
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 r170469 = x;
        double r170470 = y;
        double r170471 = z;
        double r170472 = r170470 * r170471;
        double r170473 = t;
        double r170474 = r170473 / r170470;
        double r170475 = tanh(r170474);
        double r170476 = r170469 / r170470;
        double r170477 = tanh(r170476);
        double r170478 = r170475 - r170477;
        double r170479 = r170472 * r170478;
        double r170480 = r170469 + r170479;
        return r170480;
}

double f(double x, double y, double z, double t) {
        double r170481 = y;
        double r170482 = z;
        double r170483 = t;
        double r170484 = r170483 / r170481;
        double r170485 = tanh(r170484);
        double r170486 = x;
        double r170487 = r170486 / r170481;
        double r170488 = tanh(r170487);
        double r170489 = r170485 - r170488;
        double r170490 = r170482 * r170489;
        double r170491 = fma(r170481, r170490, r170486);
        return r170491;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

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

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

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

    \[\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. Using strategy rm
  7. Applied distribute-lft-out2.1

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

    \[\leadsto \mathsf{fma}\left(y, z \cdot \color{blue}{\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)}, x\right)\]
  9. 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 2019199 +o rules:numerics
(FPCore (x y z t)
  :name "SynthBasics:moogVCF from YampaSynth-0.2"

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

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