Average Error: 4.6 → 3.5
Time: 4.3s
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) \le 1.7085444956025006 \cdot 10^{306}:\\ \;\;\;\;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(t, z, 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) \le 1.7085444956025006 \cdot 10^{306}:\\
\;\;\;\;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(t, z, x\right)\\

\end{array}
double f(double x, double y, double z, double t) {
        double r282302 = x;
        double r282303 = y;
        double r282304 = z;
        double r282305 = r282303 * r282304;
        double r282306 = t;
        double r282307 = r282306 / r282303;
        double r282308 = tanh(r282307);
        double r282309 = r282302 / r282303;
        double r282310 = tanh(r282309);
        double r282311 = r282308 - r282310;
        double r282312 = r282305 * r282311;
        double r282313 = r282302 + r282312;
        return r282313;
}

double f(double x, double y, double z, double t) {
        double r282314 = x;
        double r282315 = y;
        double r282316 = z;
        double r282317 = r282315 * r282316;
        double r282318 = t;
        double r282319 = r282318 / r282315;
        double r282320 = tanh(r282319);
        double r282321 = r282314 / r282315;
        double r282322 = tanh(r282321);
        double r282323 = r282320 - r282322;
        double r282324 = r282317 * r282323;
        double r282325 = r282314 + r282324;
        double r282326 = 1.7085444956025006e+306;
        bool r282327 = r282325 <= r282326;
        double r282328 = fma(r282318, r282316, r282314);
        double r282329 = r282327 ? r282325 : r282328;
        return r282329;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original4.6
Target2.0
Herbie3.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 2 regimes
  2. if (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))) < 1.7085444956025006e+306

    1. Initial program 2.3

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

    if 1.7085444956025006e+306 < (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y)))))

    1. Initial program 62.1

      \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\]
    2. Simplified21.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. Taylor expanded around inf 35.6

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{\frac{t \cdot z}{y}}, x\right)\]
    4. Taylor expanded around inf 34.2

      \[\leadsto \color{blue}{t \cdot z + x}\]
    5. Simplified34.2

      \[\leadsto \color{blue}{\mathsf{fma}\left(t, z, x\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification3.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) \le 1.7085444956025006 \cdot 10^{306}:\\ \;\;\;\;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(t, z, x\right)\\ \end{array}\]

Reproduce

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