Average Error: 4.8 → 2.0
Time: 17.5s
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, \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot z, 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, \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot z, x\right)
double f(double x, double y, double z, double t) {
        double r199417 = x;
        double r199418 = y;
        double r199419 = z;
        double r199420 = r199418 * r199419;
        double r199421 = t;
        double r199422 = r199421 / r199418;
        double r199423 = tanh(r199422);
        double r199424 = r199417 / r199418;
        double r199425 = tanh(r199424);
        double r199426 = r199423 - r199425;
        double r199427 = r199420 * r199426;
        double r199428 = r199417 + r199427;
        return r199428;
}

double f(double x, double y, double z, double t) {
        double r199429 = y;
        double r199430 = t;
        double r199431 = r199430 / r199429;
        double r199432 = tanh(r199431);
        double r199433 = x;
        double r199434 = r199433 / r199429;
        double r199435 = tanh(r199434);
        double r199436 = r199432 - r199435;
        double r199437 = z;
        double r199438 = r199436 * r199437;
        double r199439 = fma(r199429, r199438, r199433);
        return r199439;
}

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 pow12.0

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

    \[\leadsto \mathsf{fma}\left(y, \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot z, 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))))))