Average Error: 4.4 → 2.0
Time: 11.5s
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 r346206 = x;
        double r346207 = y;
        double r346208 = z;
        double r346209 = r346207 * r346208;
        double r346210 = t;
        double r346211 = r346210 / r346207;
        double r346212 = tanh(r346211);
        double r346213 = r346206 / r346207;
        double r346214 = tanh(r346213);
        double r346215 = r346212 - r346214;
        double r346216 = r346209 * r346215;
        double r346217 = r346206 + r346216;
        return r346217;
}

double f(double x, double y, double z, double t) {
        double r346218 = y;
        double r346219 = z;
        double r346220 = t;
        double r346221 = r346220 / r346218;
        double r346222 = tanh(r346221);
        double r346223 = x;
        double r346224 = r346223 / r346218;
        double r346225 = tanh(r346224);
        double r346226 = r346222 - r346225;
        double r346227 = r346219 * r346226;
        double r346228 = fma(r346218, r346227, r346223);
        return r346228;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original4.4
Target2.0
Herbie2.0
\[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.4

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

    \[\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.0

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