Average Error: 4.5 → 2.1
Time: 26.3s
Precision: 64
\[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\]
\[\mathsf{fma}\left(y, z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)\]
x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\mathsf{fma}\left(y, z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)
double f(double x, double y, double z, double t) {
        double r43256137 = x;
        double r43256138 = y;
        double r43256139 = z;
        double r43256140 = r43256138 * r43256139;
        double r43256141 = t;
        double r43256142 = r43256141 / r43256138;
        double r43256143 = tanh(r43256142);
        double r43256144 = r43256137 / r43256138;
        double r43256145 = tanh(r43256144);
        double r43256146 = r43256143 - r43256145;
        double r43256147 = r43256140 * r43256146;
        double r43256148 = r43256137 + r43256147;
        return r43256148;
}

double f(double x, double y, double z, double t) {
        double r43256149 = y;
        double r43256150 = z;
        double r43256151 = t;
        double r43256152 = r43256151 / r43256149;
        double r43256153 = tanh(r43256152);
        double r43256154 = x;
        double r43256155 = r43256154 / r43256149;
        double r43256156 = tanh(r43256155);
        double r43256157 = r43256153 - r43256156;
        double r43256158 = r43256150 * r43256157;
        double r43256159 = fma(r43256149, r43256158, r43256154);
        return r43256159;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

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

Derivation

  1. Initial program 4.5

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

    \[\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. Final simplification2.1

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

Reproduce

herbie shell --seed 2019173 +o rules:numerics
(FPCore (x y z t)
  :name "SynthBasics:moogVCF from YampaSynth-0.2"

  :herbie-target
  (+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y))))))

  (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))