Average Error: 4.8 → 2.0
Time: 20.7s
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(\mathsf{log1p}\left(\mathsf{expm1}\left(\tanh \left(\frac{t}{y}\right)\right)\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(\mathsf{log1p}\left(\mathsf{expm1}\left(\tanh \left(\frac{t}{y}\right)\right)\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)
double f(double x, double y, double z, double t) {
        double r152716 = x;
        double r152717 = y;
        double r152718 = z;
        double r152719 = r152717 * r152718;
        double r152720 = t;
        double r152721 = r152720 / r152717;
        double r152722 = tanh(r152721);
        double r152723 = r152716 / r152717;
        double r152724 = tanh(r152723);
        double r152725 = r152722 - r152724;
        double r152726 = r152719 * r152725;
        double r152727 = r152716 + r152726;
        return r152727;
}

double f(double x, double y, double z, double t) {
        double r152728 = y;
        double r152729 = z;
        double r152730 = t;
        double r152731 = r152730 / r152728;
        double r152732 = tanh(r152731);
        double r152733 = expm1(r152732);
        double r152734 = log1p(r152733);
        double r152735 = x;
        double r152736 = r152735 / r152728;
        double r152737 = tanh(r152736);
        double r152738 = r152734 - r152737;
        double r152739 = r152729 * r152738;
        double r152740 = fma(r152728, r152739, r152735);
        return r152740;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

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

    \[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. Using strategy rm
  4. Applied log1p-expm1-u2.0

    \[\leadsto \mathsf{fma}\left(y, z \cdot \left(\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\tanh \left(\frac{t}{y}\right)\right)\right)} - \tanh \left(\frac{x}{y}\right)\right), x\right)\]
  5. Final simplification2.0

    \[\leadsto \mathsf{fma}\left(y, z \cdot \left(\mathsf{log1p}\left(\mathsf{expm1}\left(\tanh \left(\frac{t}{y}\right)\right)\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)\]

Reproduce

herbie shell --seed 2019303 +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))))))