Average Error: 4.9 → 2.2
Time: 3.0m
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 \mathsf{fma}\left(\sqrt[3]{\tanh \left(\frac{t}{y}\right)} \cdot \sqrt[3]{\tanh \left(\frac{t}{y}\right)}, \sqrt[3]{\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 \mathsf{fma}\left(\sqrt[3]{\tanh \left(\frac{t}{y}\right)} \cdot \sqrt[3]{\tanh \left(\frac{t}{y}\right)}, \sqrt[3]{\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 r1223 = x;
        double r1224 = y;
        double r1225 = z;
        double r1226 = r1224 * r1225;
        double r1227 = t;
        double r1228 = r1227 / r1224;
        double r1229 = tanh(r1228);
        double r1230 = r1223 / r1224;
        double r1231 = tanh(r1230);
        double r1232 = r1229 - r1231;
        double r1233 = r1226 * r1232;
        double r1234 = r1223 + r1233;
        return r1234;
}

double f(double x, double y, double z, double t) {
        double r1235 = y;
        double r1236 = z;
        double r1237 = t;
        double r1238 = r1237 / r1235;
        double r1239 = tanh(r1238);
        double r1240 = cbrt(r1239);
        double r1241 = r1240 * r1240;
        double r1242 = x;
        double r1243 = r1242 / r1235;
        double r1244 = tanh(r1243);
        double r1245 = -r1244;
        double r1246 = fma(r1241, r1240, r1245);
        double r1247 = r1236 * r1246;
        double r1248 = fma(r1235, r1247, r1242);
        return r1248;
}

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 add-cube-cbrt2.2

    \[\leadsto \mathsf{fma}\left(y, z \cdot \left(\color{blue}{\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)}} - \tanh \left(\frac{x}{y}\right)\right), x\right)\]
  5. Applied fma-neg2.2

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

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

Reproduce

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