Average Error: 4.4 → 2.0
Time: 3.3m
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 r2042063 = x;
        double r2042064 = y;
        double r2042065 = z;
        double r2042066 = r2042064 * r2042065;
        double r2042067 = t;
        double r2042068 = r2042067 / r2042064;
        double r2042069 = tanh(r2042068);
        double r2042070 = r2042063 / r2042064;
        double r2042071 = tanh(r2042070);
        double r2042072 = r2042069 - r2042071;
        double r2042073 = r2042066 * r2042072;
        double r2042074 = r2042063 + r2042073;
        return r2042074;
}

double f(double x, double y, double z, double t) {
        double r2042075 = y;
        double r2042076 = z;
        double r2042077 = t;
        double r2042078 = r2042077 / r2042075;
        double r2042079 = tanh(r2042078);
        double r2042080 = x;
        double r2042081 = r2042080 / r2042075;
        double r2042082 = tanh(r2042081);
        double r2042083 = r2042079 - r2042082;
        double r2042084 = r2042076 * r2042083;
        double r2042085 = fma(r2042075, r2042084, r2042080);
        return r2042085;
}

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