Average Error: 4.5 → 1.6
Time: 20.6s
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 2.902682278233576076217373163478672292182 \cdot 10^{190}:\\ \;\;\;\;\mathsf{fma}\left(y, z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(t - x\right) \cdot z\\ \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 2.902682278233576076217373163478672292182 \cdot 10^{190}:\\
\;\;\;\;\mathsf{fma}\left(y, z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r217469 = x;
        double r217470 = y;
        double r217471 = z;
        double r217472 = r217470 * r217471;
        double r217473 = t;
        double r217474 = r217473 / r217470;
        double r217475 = tanh(r217474);
        double r217476 = r217469 / r217470;
        double r217477 = tanh(r217476);
        double r217478 = r217475 - r217477;
        double r217479 = r217472 * r217478;
        double r217480 = r217469 + r217479;
        return r217480;
}

double f(double x, double y, double z, double t) {
        double r217481 = y;
        double r217482 = 2.902682278233576e+190;
        bool r217483 = r217481 <= r217482;
        double r217484 = z;
        double r217485 = t;
        double r217486 = r217485 / r217481;
        double r217487 = tanh(r217486);
        double r217488 = x;
        double r217489 = r217488 / r217481;
        double r217490 = tanh(r217489);
        double r217491 = r217487 - r217490;
        double r217492 = r217484 * r217491;
        double r217493 = fma(r217481, r217492, r217488);
        double r217494 = r217485 - r217488;
        double r217495 = r217494 * r217484;
        double r217496 = r217488 + r217495;
        double r217497 = r217483 ? r217493 : r217496;
        return r217497;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original4.5
Target2.0
Herbie1.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 y < 2.902682278233576e+190

    1. Initial program 3.2

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

      \[\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)}\]

    if 2.902682278233576e+190 < y

    1. Initial program 19.9

      \[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 pow119.9

      \[\leadsto x + \left(y \cdot z\right) \cdot \color{blue}{{\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)}^{1}}\]
    4. Applied pow119.9

      \[\leadsto x + \left(y \cdot \color{blue}{{z}^{1}}\right) \cdot {\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)}^{1}\]
    5. Applied pow119.9

      \[\leadsto x + \left(\color{blue}{{y}^{1}} \cdot {z}^{1}\right) \cdot {\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)}^{1}\]
    6. Applied pow-prod-down19.9

      \[\leadsto x + \color{blue}{{\left(y \cdot z\right)}^{1}} \cdot {\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)}^{1}\]
    7. Applied pow-prod-down19.9

      \[\leadsto x + \color{blue}{{\left(\left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)}^{1}}\]
    8. Simplified7.3

      \[\leadsto x + {\color{blue}{\left(\left(y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right) \cdot z\right)}}^{1}\]
    9. Taylor expanded around 0 4.9

      \[\leadsto x + {\left(\color{blue}{\left(t - x\right)} \cdot z\right)}^{1}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.6

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

Reproduce

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