Average Error: 5.0 → 1.6
Time: 22.2s
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 \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), 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 \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), z, x\right)
double f(double x, double y, double z, double t) {
        double r12312233 = x;
        double r12312234 = y;
        double r12312235 = z;
        double r12312236 = r12312234 * r12312235;
        double r12312237 = t;
        double r12312238 = r12312237 / r12312234;
        double r12312239 = tanh(r12312238);
        double r12312240 = r12312233 / r12312234;
        double r12312241 = tanh(r12312240);
        double r12312242 = r12312239 - r12312241;
        double r12312243 = r12312236 * r12312242;
        double r12312244 = r12312233 + r12312243;
        return r12312244;
}

double f(double x, double y, double z, double t) {
        double r12312245 = y;
        double r12312246 = t;
        double r12312247 = r12312246 / r12312245;
        double r12312248 = tanh(r12312247);
        double r12312249 = x;
        double r12312250 = r12312249 / r12312245;
        double r12312251 = tanh(r12312250);
        double r12312252 = r12312248 - r12312251;
        double r12312253 = r12312245 * r12312252;
        double r12312254 = z;
        double r12312255 = fma(r12312253, r12312254, r12312249);
        return r12312255;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original5.0
Target2.1
Herbie1.6
\[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 5.0

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(y \cdot z, \tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right), x\right)}\]
  3. Using strategy rm
  4. Applied add-cbrt-cube6.1

    \[\leadsto \mathsf{fma}\left(y \cdot z, \tanh \left(\frac{t}{y}\right) - \color{blue}{\sqrt[3]{\left(\tanh \left(\frac{x}{y}\right) \cdot \tanh \left(\frac{x}{y}\right)\right) \cdot \tanh \left(\frac{x}{y}\right)}}, x\right)\]
  5. Using strategy rm
  6. Applied fma-udef6.1

    \[\leadsto \color{blue}{\left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \sqrt[3]{\left(\tanh \left(\frac{x}{y}\right) \cdot \tanh \left(\frac{x}{y}\right)\right) \cdot \tanh \left(\frac{x}{y}\right)}\right) + x}\]
  7. Simplified1.6

    \[\leadsto \color{blue}{\left(\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot y\right) \cdot z} + x\]
  8. Using strategy rm
  9. Applied fma-def1.6

    \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot y, z, x\right)}\]
  10. Final simplification1.6

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

Reproduce

herbie shell --seed 2019179 +o rules:numerics
(FPCore (x y z t)
  :name "SynthBasics:moogVCF from YampaSynth-0.2"

  :herbie-target
  (+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y))))))

  (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))