Average Error: 4.7 → 2.3
Time: 22.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 r230364 = x;
        double r230365 = y;
        double r230366 = z;
        double r230367 = r230365 * r230366;
        double r230368 = t;
        double r230369 = r230368 / r230365;
        double r230370 = tanh(r230369);
        double r230371 = r230364 / r230365;
        double r230372 = tanh(r230371);
        double r230373 = r230370 - r230372;
        double r230374 = r230367 * r230373;
        double r230375 = r230364 + r230374;
        return r230375;
}

double f(double x, double y, double z, double t) {
        double r230376 = y;
        double r230377 = t;
        double r230378 = r230377 / r230376;
        double r230379 = tanh(r230378);
        double r230380 = z;
        double r230381 = r230379 * r230380;
        double r230382 = x;
        double r230383 = r230382 / r230376;
        double r230384 = tanh(r230383);
        double r230385 = cbrt(r230384);
        double r230386 = r230385 * r230385;
        double r230387 = cbrt(r230385);
        double r230388 = r230387 * r230387;
        double r230389 = r230388 * r230387;
        double r230390 = r230386 * r230389;
        double r230391 = -r230390;
        double r230392 = r230391 * r230380;
        double r230393 = r230381 + r230392;
        double r230394 = fma(r230376, r230393, r230382);
        return r230394;
}

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))))))