Average Error: 4.4 → 4.4
Time: 6.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}\;y \le -3.7198484520496166 \cdot 10^{265}:\\ \;\;\;\;x - x \cdot z\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\sqrt[3]{\tanh \left(\frac{t}{y}\right)} \cdot \sqrt[3]{\tanh \left(\frac{t}{y}\right)}, \sqrt[3]{\tanh \left(\frac{t}{y}\right)}, -\tanh \left(\frac{x}{y}\right) \cdot 1\right) \cdot y, z, x\right) + \mathsf{fma}\left(-\sqrt[3]{\tanh \left(\frac{x}{y}\right)}, \sqrt[3]{\tanh \left(\frac{x}{y}\right)} \cdot \sqrt[3]{\tanh \left(\frac{x}{y}\right)}, \sqrt[3]{\tanh \left(\frac{x}{y}\right)} \cdot \left(\sqrt[3]{\tanh \left(\frac{x}{y}\right)} \cdot \sqrt[3]{\tanh \left(\frac{x}{y}\right)}\right)\right) \cdot \left(y \cdot z\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}\;y \le -3.7198484520496166 \cdot 10^{265}:\\
\;\;\;\;x - x \cdot z\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\sqrt[3]{\tanh \left(\frac{t}{y}\right)} \cdot \sqrt[3]{\tanh \left(\frac{t}{y}\right)}, \sqrt[3]{\tanh \left(\frac{t}{y}\right)}, -\tanh \left(\frac{x}{y}\right) \cdot 1\right) \cdot y, z, x\right) + \mathsf{fma}\left(-\sqrt[3]{\tanh \left(\frac{x}{y}\right)}, \sqrt[3]{\tanh \left(\frac{x}{y}\right)} \cdot \sqrt[3]{\tanh \left(\frac{x}{y}\right)}, \sqrt[3]{\tanh \left(\frac{x}{y}\right)} \cdot \left(\sqrt[3]{\tanh \left(\frac{x}{y}\right)} \cdot \sqrt[3]{\tanh \left(\frac{x}{y}\right)}\right)\right) \cdot \left(y \cdot z\right)\\

\end{array}
double f(double x, double y, double z, double t) {
        double r344241 = x;
        double r344242 = y;
        double r344243 = z;
        double r344244 = r344242 * r344243;
        double r344245 = t;
        double r344246 = r344245 / r344242;
        double r344247 = tanh(r344246);
        double r344248 = r344241 / r344242;
        double r344249 = tanh(r344248);
        double r344250 = r344247 - r344249;
        double r344251 = r344244 * r344250;
        double r344252 = r344241 + r344251;
        return r344252;
}

double f(double x, double y, double z, double t) {
        double r344253 = y;
        double r344254 = -3.7198484520496166e+265;
        bool r344255 = r344253 <= r344254;
        double r344256 = x;
        double r344257 = z;
        double r344258 = r344256 * r344257;
        double r344259 = r344256 - r344258;
        double r344260 = t;
        double r344261 = r344260 / r344253;
        double r344262 = tanh(r344261);
        double r344263 = cbrt(r344262);
        double r344264 = r344263 * r344263;
        double r344265 = r344256 / r344253;
        double r344266 = tanh(r344265);
        double r344267 = 1.0;
        double r344268 = r344266 * r344267;
        double r344269 = -r344268;
        double r344270 = fma(r344264, r344263, r344269);
        double r344271 = r344270 * r344253;
        double r344272 = fma(r344271, r344257, r344256);
        double r344273 = cbrt(r344266);
        double r344274 = -r344273;
        double r344275 = r344273 * r344273;
        double r344276 = r344273 * r344275;
        double r344277 = fma(r344274, r344275, r344276);
        double r344278 = r344253 * r344257;
        double r344279 = r344277 * r344278;
        double r344280 = r344272 + r344279;
        double r344281 = r344255 ? r344259 : r344280;
        return r344281;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original4.4
Target2.0
Herbie4.4
\[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 y < -3.7198484520496166e+265

    1. Initial program 21.3

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

      \[\leadsto \color{blue}{x - x \cdot z}\]

    if -3.7198484520496166e+265 < y

    1. Initial program 4.0

      \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\]
    2. Using strategy rm
    3. Applied add-cube-cbrt4.0

      \[\leadsto x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \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)\]
    4. Applied add-cube-cbrt4.1

      \[\leadsto x + \left(y \cdot z\right) \cdot \left(\color{blue}{\left(\sqrt[3]{\tanh \left(\frac{t}{y}\right)} \cdot \sqrt[3]{\tanh \left(\frac{t}{y}\right)}\right) \cdot \sqrt[3]{\tanh \left(\frac{t}{y}\right)}} - \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)\]
    5. Applied prod-diff4.1

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

      \[\leadsto x + \color{blue}{\left(\mathsf{fma}\left(\sqrt[3]{\tanh \left(\frac{t}{y}\right)} \cdot \sqrt[3]{\tanh \left(\frac{t}{y}\right)}, \sqrt[3]{\tanh \left(\frac{t}{y}\right)}, -\sqrt[3]{\tanh \left(\frac{x}{y}\right)} \cdot \left(\sqrt[3]{\tanh \left(\frac{x}{y}\right)} \cdot \sqrt[3]{\tanh \left(\frac{x}{y}\right)}\right)\right) \cdot \left(y \cdot z\right) + \mathsf{fma}\left(-\sqrt[3]{\tanh \left(\frac{x}{y}\right)}, \sqrt[3]{\tanh \left(\frac{x}{y}\right)} \cdot \sqrt[3]{\tanh \left(\frac{x}{y}\right)}, \sqrt[3]{\tanh \left(\frac{x}{y}\right)} \cdot \left(\sqrt[3]{\tanh \left(\frac{x}{y}\right)} \cdot \sqrt[3]{\tanh \left(\frac{x}{y}\right)}\right)\right) \cdot \left(y \cdot z\right)\right)}\]
    7. Applied associate-+r+4.1

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\sqrt[3]{\tanh \left(\frac{t}{y}\right)} \cdot \sqrt[3]{\tanh \left(\frac{t}{y}\right)}, \sqrt[3]{\tanh \left(\frac{t}{y}\right)}, -\tanh \left(\frac{x}{y}\right) \cdot 1\right) \cdot y, z, x\right)} + \mathsf{fma}\left(-\sqrt[3]{\tanh \left(\frac{x}{y}\right)}, \sqrt[3]{\tanh \left(\frac{x}{y}\right)} \cdot \sqrt[3]{\tanh \left(\frac{x}{y}\right)}, \sqrt[3]{\tanh \left(\frac{x}{y}\right)} \cdot \left(\sqrt[3]{\tanh \left(\frac{x}{y}\right)} \cdot \sqrt[3]{\tanh \left(\frac{x}{y}\right)}\right)\right) \cdot \left(y \cdot z\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification4.4

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

Reproduce

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