Average Error: 4.7 → 2.3
Time: 21.1s
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(-\left(\sqrt[3]{\tanh \left(\frac{x}{y}\right)} \cdot \sqrt[3]{\tanh \left(\frac{x}{y}\right)}\right) \cdot \left(\left(\sqrt[3]{\sqrt[3]{\tanh \left(\frac{x}{y}\right)}} \cdot \sqrt[3]{\sqrt[3]{\tanh \left(\frac{x}{y}\right)}}\right) \cdot \sqrt[3]{\sqrt[3]{\tanh \left(\frac{x}{y}\right)}}\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(-\left(\sqrt[3]{\tanh \left(\frac{x}{y}\right)} \cdot \sqrt[3]{\tanh \left(\frac{x}{y}\right)}\right) \cdot \left(\left(\sqrt[3]{\sqrt[3]{\tanh \left(\frac{x}{y}\right)}} \cdot \sqrt[3]{\sqrt[3]{\tanh \left(\frac{x}{y}\right)}}\right) \cdot \sqrt[3]{\sqrt[3]{\tanh \left(\frac{x}{y}\right)}}\right)\right) \cdot z, x\right)
double f(double x, double y, double z, double t) {
        double r193703 = x;
        double r193704 = y;
        double r193705 = z;
        double r193706 = r193704 * r193705;
        double r193707 = t;
        double r193708 = r193707 / r193704;
        double r193709 = tanh(r193708);
        double r193710 = r193703 / r193704;
        double r193711 = tanh(r193710);
        double r193712 = r193709 - r193711;
        double r193713 = r193706 * r193712;
        double r193714 = r193703 + r193713;
        return r193714;
}

double f(double x, double y, double z, double t) {
        double r193715 = y;
        double r193716 = t;
        double r193717 = r193716 / r193715;
        double r193718 = tanh(r193717);
        double r193719 = z;
        double r193720 = r193718 * r193719;
        double r193721 = x;
        double r193722 = r193721 / r193715;
        double r193723 = tanh(r193722);
        double r193724 = cbrt(r193723);
        double r193725 = r193724 * r193724;
        double r193726 = cbrt(r193724);
        double r193727 = r193726 * r193726;
        double r193728 = r193727 * r193726;
        double r193729 = r193725 * r193728;
        double r193730 = -r193729;
        double r193731 = r193730 * r193719;
        double r193732 = r193720 + r193731;
        double r193733 = fma(r193715, r193732, r193721);
        return r193733;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original4.7
Target2.2
Herbie2.3
\[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.2

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

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

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

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

    \[\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. Using strategy rm
  9. Applied add-cube-cbrt2.2

    \[\leadsto \mathsf{fma}\left(y, \tanh \left(\frac{t}{y}\right) \cdot z + \left(-\color{blue}{\left(\sqrt[3]{\tanh \left(\frac{x}{y}\right)} \cdot \sqrt[3]{\tanh \left(\frac{x}{y}\right)}\right) \cdot \sqrt[3]{\tanh \left(\frac{x}{y}\right)}}\right) \cdot z, x\right)\]
  10. Using strategy rm
  11. Applied add-cube-cbrt2.3

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

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

Reproduce

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