Average Error: 4.9 → 2.2
Time: 11.3s
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(\left(\sqrt[3]{\tanh \left(\frac{t}{y}\right)} \cdot \sqrt[3]{\tanh \left(\frac{t}{y}\right)}\right) \cdot \sqrt[3]{\tanh \left(\frac{t}{y}\right)}\right) \cdot z + \left(-\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(\left(\sqrt[3]{\tanh \left(\frac{t}{y}\right)} \cdot \sqrt[3]{\tanh \left(\frac{t}{y}\right)}\right) \cdot \sqrt[3]{\tanh \left(\frac{t}{y}\right)}\right) \cdot z + \left(-\tanh \left(\frac{x}{y}\right)\right) \cdot z, x\right)
double f(double x, double y, double z, double t) {
        double r287232 = x;
        double r287233 = y;
        double r287234 = z;
        double r287235 = r287233 * r287234;
        double r287236 = t;
        double r287237 = r287236 / r287233;
        double r287238 = tanh(r287237);
        double r287239 = r287232 / r287233;
        double r287240 = tanh(r287239);
        double r287241 = r287238 - r287240;
        double r287242 = r287235 * r287241;
        double r287243 = r287232 + r287242;
        return r287243;
}

double f(double x, double y, double z, double t) {
        double r287244 = y;
        double r287245 = t;
        double r287246 = r287245 / r287244;
        double r287247 = tanh(r287246);
        double r287248 = cbrt(r287247);
        double r287249 = r287248 * r287248;
        double r287250 = r287249 * r287248;
        double r287251 = z;
        double r287252 = r287250 * r287251;
        double r287253 = x;
        double r287254 = r287253 / r287244;
        double r287255 = tanh(r287254);
        double r287256 = -r287255;
        double r287257 = r287256 * r287251;
        double r287258 = r287252 + r287257;
        double r287259 = fma(r287244, r287258, r287253);
        return r287259;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original4.9
Target2.1
Herbie2.2
\[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.9

    \[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. Using strategy rm
  4. Applied sub-neg2.1

    \[\leadsto \mathsf{fma}\left(y, z \cdot \color{blue}{\left(\tanh \left(\frac{t}{y}\right) + \left(-\tanh \left(\frac{x}{y}\right)\right)\right)}, x\right)\]
  5. Applied distribute-lft-in2.1

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

    \[\leadsto \mathsf{fma}\left(y, \color{blue}{\tanh \left(\frac{t}{y}\right) \cdot z} + z \cdot \left(-\tanh \left(\frac{x}{y}\right)\right), x\right)\]
  7. Simplified2.1

    \[\leadsto \mathsf{fma}\left(y, \tanh \left(\frac{t}{y}\right) \cdot z + \color{blue}{\left(-\tanh \left(\frac{x}{y}\right)\right) \cdot z}, x\right)\]
  8. Using strategy rm
  9. Applied add-cube-cbrt2.2

    \[\leadsto \mathsf{fma}\left(y, \color{blue}{\left(\left(\sqrt[3]{\tanh \left(\frac{t}{y}\right)} \cdot \sqrt[3]{\tanh \left(\frac{t}{y}\right)}\right) \cdot \sqrt[3]{\tanh \left(\frac{t}{y}\right)}\right)} \cdot z + \left(-\tanh \left(\frac{x}{y}\right)\right) \cdot z, x\right)\]
  10. Final simplification2.2

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

Reproduce

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