Average Error: 5.0 → 2.1
Time: 21.0s
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 \mathsf{fma}\left(\sqrt[3]{\tanh \left(\frac{t}{y}\right)} \cdot \sqrt[3]{\tanh \left(\frac{t}{y}\right)}, \sqrt[3]{\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 \mathsf{fma}\left(\sqrt[3]{\tanh \left(\frac{t}{y}\right)} \cdot \sqrt[3]{\tanh \left(\frac{t}{y}\right)}, \sqrt[3]{\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 r190774 = x;
        double r190775 = y;
        double r190776 = z;
        double r190777 = r190775 * r190776;
        double r190778 = t;
        double r190779 = r190778 / r190775;
        double r190780 = tanh(r190779);
        double r190781 = r190774 / r190775;
        double r190782 = tanh(r190781);
        double r190783 = r190780 - r190782;
        double r190784 = r190777 * r190783;
        double r190785 = r190774 + r190784;
        return r190785;
}

double f(double x, double y, double z, double t) {
        double r190786 = y;
        double r190787 = z;
        double r190788 = t;
        double r190789 = r190788 / r190786;
        double r190790 = tanh(r190789);
        double r190791 = cbrt(r190790);
        double r190792 = r190791 * r190791;
        double r190793 = x;
        double r190794 = r190793 / r190786;
        double r190795 = tanh(r190794);
        double r190796 = -r190795;
        double r190797 = fma(r190792, r190791, r190796);
        double r190798 = r190787 * r190797;
        double r190799 = fma(r190786, r190798, r190793);
        return r190799;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original5.0
Target2.0
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 5.0

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

    \[\leadsto \mathsf{fma}\left(y, z \cdot \left(\color{blue}{\left(\sqrt[3]{\tanh \left(\frac{t}{y}\right)} \cdot \sqrt[3]{\tanh \left(\frac{t}{y}\right)}\right) \cdot \sqrt[3]{\tanh \left(\frac{t}{y}\right)}} - \tanh \left(\frac{x}{y}\right)\right), x\right)\]
  5. Applied fma-neg2.1

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

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

Reproduce

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