Average Error: 5.0 → 1.6
Time: 16.5s
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(z, \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot y, 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(z, \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot y, x\right)
double f(double x, double y, double z, double t) {
        double r185784 = x;
        double r185785 = y;
        double r185786 = z;
        double r185787 = r185785 * r185786;
        double r185788 = t;
        double r185789 = r185788 / r185785;
        double r185790 = tanh(r185789);
        double r185791 = r185784 / r185785;
        double r185792 = tanh(r185791);
        double r185793 = r185790 - r185792;
        double r185794 = r185787 * r185793;
        double r185795 = r185784 + r185794;
        return r185795;
}

double f(double x, double y, double z, double t) {
        double r185796 = z;
        double r185797 = t;
        double r185798 = y;
        double r185799 = r185797 / r185798;
        double r185800 = tanh(r185799);
        double r185801 = x;
        double r185802 = r185801 / r185798;
        double r185803 = tanh(r185802);
        double r185804 = r185800 - r185803;
        double r185805 = r185804 * r185798;
        double r185806 = fma(r185796, r185805, r185801);
        return r185806;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original5.0
Target2.1
Herbie1.6
\[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 5.0

    \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\]
  2. Simplified5.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(y \cdot z, \tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right), x\right)}\]
  3. Using strategy rm
  4. Applied fma-udef5.0

    \[\leadsto \color{blue}{\left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) + x}\]
  5. Simplified1.6

    \[\leadsto \color{blue}{z \cdot \left(y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)} + x\]
  6. Using strategy rm
  7. Applied fma-def1.6

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

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

Reproduce

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