Average Error: 4.5 → 1.8
Time: 3.8s
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 r260078 = x;
        double r260079 = y;
        double r260080 = z;
        double r260081 = r260079 * r260080;
        double r260082 = t;
        double r260083 = r260082 / r260079;
        double r260084 = tanh(r260083);
        double r260085 = r260078 / r260079;
        double r260086 = tanh(r260085);
        double r260087 = r260084 - r260086;
        double r260088 = r260081 * r260087;
        double r260089 = r260078 + r260088;
        return r260089;
}

double f(double x, double y, double z, double t) {
        double r260090 = y;
        double r260091 = z;
        double r260092 = t;
        double r260093 = r260092 / r260090;
        double r260094 = tanh(r260093);
        double r260095 = x;
        double r260096 = r260095 / r260090;
        double r260097 = tanh(r260096);
        double r260098 = r260094 - r260097;
        double r260099 = r260091 * r260098;
        double r260100 = fma(r260090, r260099, r260095);
        return r260100;
}

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 2020056 +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))))))