Average Error: 4.5 → 2.5
Time: 9.4s
Precision: 64
\[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\]
\[\begin{array}{l} \mathbf{if}\;x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) = -\infty:\\ \;\;\;\;\left(\sqrt[3]{\mathsf{fma}\left(y, z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)} \cdot \sqrt[3]{\mathsf{fma}\left(y, z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)}\right) \cdot \sqrt[3]{\mathsf{fma}\left(y, z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)}\\ \mathbf{elif}\;x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \le 5.136736371015830348947780040880154350207 \cdot 10^{293}:\\ \;\;\;\;x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, \frac{t \cdot z}{y}, x\right)\\ \end{array}\]
x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\begin{array}{l}
\mathbf{if}\;x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) = -\infty:\\
\;\;\;\;\left(\sqrt[3]{\mathsf{fma}\left(y, z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)} \cdot \sqrt[3]{\mathsf{fma}\left(y, z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)}\right) \cdot \sqrt[3]{\mathsf{fma}\left(y, z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)}\\

\mathbf{elif}\;x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \le 5.136736371015830348947780040880154350207 \cdot 10^{293}:\\
\;\;\;\;x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t \cdot z}{y}, x\right)\\

\end{array}
double f(double x, double y, double z, double t) {
        double r277588 = x;
        double r277589 = y;
        double r277590 = z;
        double r277591 = r277589 * r277590;
        double r277592 = t;
        double r277593 = r277592 / r277589;
        double r277594 = tanh(r277593);
        double r277595 = r277588 / r277589;
        double r277596 = tanh(r277595);
        double r277597 = r277594 - r277596;
        double r277598 = r277591 * r277597;
        double r277599 = r277588 + r277598;
        return r277599;
}

double f(double x, double y, double z, double t) {
        double r277600 = x;
        double r277601 = y;
        double r277602 = z;
        double r277603 = r277601 * r277602;
        double r277604 = t;
        double r277605 = r277604 / r277601;
        double r277606 = tanh(r277605);
        double r277607 = r277600 / r277601;
        double r277608 = tanh(r277607);
        double r277609 = r277606 - r277608;
        double r277610 = r277603 * r277609;
        double r277611 = r277600 + r277610;
        double r277612 = -inf.0;
        bool r277613 = r277611 <= r277612;
        double r277614 = r277602 * r277609;
        double r277615 = fma(r277601, r277614, r277600);
        double r277616 = cbrt(r277615);
        double r277617 = r277616 * r277616;
        double r277618 = r277617 * r277616;
        double r277619 = 5.13673637101583e+293;
        bool r277620 = r277611 <= r277619;
        double r277621 = r277604 * r277602;
        double r277622 = r277621 / r277601;
        double r277623 = fma(r277601, r277622, r277600);
        double r277624 = r277620 ? r277611 : r277623;
        double r277625 = r277613 ? r277618 : r277624;
        return r277625;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original4.5
Target1.9
Herbie2.5
\[x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)\]

Derivation

  1. Split input into 3 regimes
  2. if (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))) < -inf.0

    1. Initial program 64.0

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

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

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

    if -inf.0 < (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))) < 5.13673637101583e+293

    1. Initial program 0.5

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

    if 5.13673637101583e+293 < (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y)))))

    1. Initial program 48.3

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

      \[\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. Taylor expanded around inf 36.6

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{\frac{t \cdot z}{y}}, x\right)\]
  3. Recombined 3 regimes into one program.
  4. Final simplification2.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) = -\infty:\\ \;\;\;\;\left(\sqrt[3]{\mathsf{fma}\left(y, z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)} \cdot \sqrt[3]{\mathsf{fma}\left(y, z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)}\right) \cdot \sqrt[3]{\mathsf{fma}\left(y, z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)}\\ \mathbf{elif}\;x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \le 5.136736371015830348947780040880154350207 \cdot 10^{293}:\\ \;\;\;\;x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, \frac{t \cdot z}{y}, x\right)\\ \end{array}\]

Reproduce

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