Average Error: 4.6 → 1.6
Time: 14.0s
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(z, y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right) + \left(z \cdot \mathsf{fma}\left(-\tanh \left(\frac{x}{y}\right), 1, \tanh \left(\frac{x}{y}\right)\right)\right) \cdot y\]
x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\mathsf{fma}\left(z, y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right) + \left(z \cdot \mathsf{fma}\left(-\tanh \left(\frac{x}{y}\right), 1, \tanh \left(\frac{x}{y}\right)\right)\right) \cdot y
double f(double x, double y, double z, double t) {
        double r5409318 = x;
        double r5409319 = y;
        double r5409320 = z;
        double r5409321 = r5409319 * r5409320;
        double r5409322 = t;
        double r5409323 = r5409322 / r5409319;
        double r5409324 = tanh(r5409323);
        double r5409325 = r5409318 / r5409319;
        double r5409326 = tanh(r5409325);
        double r5409327 = r5409324 - r5409326;
        double r5409328 = r5409321 * r5409327;
        double r5409329 = r5409318 + r5409328;
        return r5409329;
}

double f(double x, double y, double z, double t) {
        double r5409330 = z;
        double r5409331 = y;
        double r5409332 = t;
        double r5409333 = r5409332 / r5409331;
        double r5409334 = tanh(r5409333);
        double r5409335 = x;
        double r5409336 = r5409335 / r5409331;
        double r5409337 = tanh(r5409336);
        double r5409338 = r5409334 - r5409337;
        double r5409339 = r5409331 * r5409338;
        double r5409340 = fma(r5409330, r5409339, r5409335);
        double r5409341 = -r5409337;
        double r5409342 = 1.0;
        double r5409343 = fma(r5409341, r5409342, r5409337);
        double r5409344 = r5409330 * r5409343;
        double r5409345 = r5409344 * r5409331;
        double r5409346 = r5409340 + r5409345;
        return r5409346;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original4.6
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 4.6

    \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\]
  2. Using strategy rm
  3. Applied associate-*l*2.1

    \[\leadsto x + \color{blue}{y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)}\]
  4. Using strategy rm
  5. Applied *-un-lft-identity2.1

    \[\leadsto x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \color{blue}{1 \cdot \tanh \left(\frac{x}{y}\right)}\right)\right)\]
  6. Applied add-sqr-sqrt29.1

    \[\leadsto x + y \cdot \left(z \cdot \left(\color{blue}{\sqrt{\tanh \left(\frac{t}{y}\right)} \cdot \sqrt{\tanh \left(\frac{t}{y}\right)}} - 1 \cdot \tanh \left(\frac{x}{y}\right)\right)\right)\]
  7. Applied prod-diff29.1

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

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

    \[\leadsto x + \color{blue}{\left(\left(z \cdot \mathsf{fma}\left(\sqrt{\tanh \left(\frac{t}{y}\right)}, \sqrt{\tanh \left(\frac{t}{y}\right)}, -\tanh \left(\frac{x}{y}\right) \cdot 1\right)\right) \cdot y + \left(z \cdot \mathsf{fma}\left(-\tanh \left(\frac{x}{y}\right), 1, \tanh \left(\frac{x}{y}\right) \cdot 1\right)\right) \cdot y\right)}\]
  10. Applied associate-+r+29.1

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

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

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

Reproduce

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