Average Error: 4.4 → 2.6
Time: 6.7s
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 \lor \neg \left(x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \le 6.64578806794399763 \cdot 10^{304}\right):\\ \;\;\;\;\mathsf{fma}\left(\sqrt[3]{-1} \cdot x, z, x\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\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 \lor \neg \left(x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \le 6.64578806794399763 \cdot 10^{304}\right):\\
\;\;\;\;\mathsf{fma}\left(\sqrt[3]{-1} \cdot x, z, x\right)\\

\mathbf{else}:\\
\;\;\;\;x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\\

\end{array}
double f(double x, double y, double z, double t) {
        double r230288 = x;
        double r230289 = y;
        double r230290 = z;
        double r230291 = r230289 * r230290;
        double r230292 = t;
        double r230293 = r230292 / r230289;
        double r230294 = tanh(r230293);
        double r230295 = r230288 / r230289;
        double r230296 = tanh(r230295);
        double r230297 = r230294 - r230296;
        double r230298 = r230291 * r230297;
        double r230299 = r230288 + r230298;
        return r230299;
}

double f(double x, double y, double z, double t) {
        double r230300 = x;
        double r230301 = y;
        double r230302 = z;
        double r230303 = r230301 * r230302;
        double r230304 = t;
        double r230305 = r230304 / r230301;
        double r230306 = tanh(r230305);
        double r230307 = r230300 / r230301;
        double r230308 = tanh(r230307);
        double r230309 = r230306 - r230308;
        double r230310 = r230303 * r230309;
        double r230311 = r230300 + r230310;
        double r230312 = -inf.0;
        bool r230313 = r230311 <= r230312;
        double r230314 = 6.645788067943998e+304;
        bool r230315 = r230311 <= r230314;
        double r230316 = !r230315;
        bool r230317 = r230313 || r230316;
        double r230318 = -1.0;
        double r230319 = cbrt(r230318);
        double r230320 = r230319 * r230300;
        double r230321 = fma(r230320, r230302, r230300);
        double r230322 = r230317 ? r230321 : r230311;
        return r230322;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original4.4
Target2.0
Herbie2.6
\[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 2 regimes
  2. if (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))) < -inf.0 or 6.645788067943998e+304 < (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y)))))

    1. Initial program 61.1

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

      \[\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-cbrt-cube48.7

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

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

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

      \[\leadsto \mathsf{fma}\left(y, \sqrt[3]{\color{blue}{{\left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)}^{3}}}, x\right)\]
    8. Taylor expanded around -inf 33.3

      \[\leadsto \color{blue}{x + \sqrt[3]{-1} \cdot \left(x \cdot z\right)}\]
    9. Simplified33.3

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

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

    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)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification2.6

    \[\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 \lor \neg \left(x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \le 6.64578806794399763 \cdot 10^{304}\right):\\ \;\;\;\;\mathsf{fma}\left(\sqrt[3]{-1} \cdot x, z, x\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\\ \end{array}\]

Reproduce

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