Average Error: 4.7 → 1.9
Time: 19.4s
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 r220010 = x;
        double r220011 = y;
        double r220012 = z;
        double r220013 = r220011 * r220012;
        double r220014 = t;
        double r220015 = r220014 / r220011;
        double r220016 = tanh(r220015);
        double r220017 = r220010 / r220011;
        double r220018 = tanh(r220017);
        double r220019 = r220016 - r220018;
        double r220020 = r220013 * r220019;
        double r220021 = r220010 + r220020;
        return r220021;
}

double f(double x, double y, double z, double t) {
        double r220022 = y;
        double r220023 = z;
        double r220024 = t;
        double r220025 = r220024 / r220022;
        double r220026 = tanh(r220025);
        double r220027 = x;
        double r220028 = r220027 / r220022;
        double r220029 = tanh(r220028);
        double r220030 = r220026 - r220029;
        double r220031 = r220023 * r220030;
        double r220032 = fma(r220022, r220031, r220027);
        return r220032;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original4.7
Target1.9
Herbie1.9
\[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.7

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

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

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