Average Error: 4.5 → 1.8
Time: 7.0s
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 r326130 = x;
        double r326131 = y;
        double r326132 = z;
        double r326133 = r326131 * r326132;
        double r326134 = t;
        double r326135 = r326134 / r326131;
        double r326136 = tanh(r326135);
        double r326137 = r326130 / r326131;
        double r326138 = tanh(r326137);
        double r326139 = r326136 - r326138;
        double r326140 = r326133 * r326139;
        double r326141 = r326130 + r326140;
        return r326141;
}

double f(double x, double y, double z, double t) {
        double r326142 = y;
        double r326143 = z;
        double r326144 = t;
        double r326145 = r326144 / r326142;
        double r326146 = tanh(r326145);
        double r326147 = x;
        double r326148 = r326147 / r326142;
        double r326149 = tanh(r326148);
        double r326150 = r326146 - r326149;
        double r326151 = r326143 * r326150;
        double r326152 = fma(r326142, r326151, r326147);
        return r326152;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original4.5
Target1.8
Herbie1.8
\[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. Simplified1.8

    \[\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 simplification1.8

    \[\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 2020064 +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))))))