Average Error: 4.6 → 2.1
Time: 4.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 r269937 = x;
        double r269938 = y;
        double r269939 = z;
        double r269940 = r269938 * r269939;
        double r269941 = t;
        double r269942 = r269941 / r269938;
        double r269943 = tanh(r269942);
        double r269944 = r269937 / r269938;
        double r269945 = tanh(r269944);
        double r269946 = r269943 - r269945;
        double r269947 = r269940 * r269946;
        double r269948 = r269937 + r269947;
        return r269948;
}

double f(double x, double y, double z, double t) {
        double r269949 = y;
        double r269950 = z;
        double r269951 = t;
        double r269952 = r269951 / r269949;
        double r269953 = tanh(r269952);
        double r269954 = x;
        double r269955 = r269954 / r269949;
        double r269956 = tanh(r269955);
        double r269957 = r269953 - r269956;
        double r269958 = r269950 * r269957;
        double r269959 = fma(r269949, r269958, r269954);
        return r269959;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original4.6
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.6

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