x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\\
\mathbf{if}\;\begin{array}{l}
t_2 := x + \left(y \cdot z\right) \cdot t_1\\
t_2 \leq -\infty \lor \neg \left(t_2 \leq 1.0953066441175457 \cdot 10^{+308}\right)
\end{array}:\\
\;\;\;\;\mathsf{fma}\left(t - x, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot z, t_1, x\right)\\
\end{array}
(FPCore (x y z t) :precision binary64 (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (tanh (/ t y)) (tanh (/ x y)))))
(if (let* ((t_2 (+ x (* (* y z) t_1))))
(or (<= t_2 (- INFINITY)) (not (<= t_2 1.0953066441175457e+308))))
(fma (- t x) z x)
(fma (* y z) t_1 x))))double code(double x, double y, double z, double t) {
return x + ((y * z) * (tanh(t / y) - tanh(x / y)));
}
double code(double x, double y, double z, double t) {
double t_1 = tanh(t / y) - tanh(x / y);
double t_2 = x + ((y * z) * t_1);
double tmp;
if ((t_2 <= -((double) INFINITY)) || !(t_2 <= 1.0953066441175457e+308)) {
tmp = fma((t - x), z, x);
} else {
tmp = fma((y * z), t_1, x);
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
| Original | 4.6 |
|---|---|
| Target | 2.0 |
| Herbie | 0.8 |
if (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < -inf.0 or 1.09530664411754572e308 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 63.9
Simplified63.9
Applied add-log-exp_binary6463.9
Taylor expanded in y around inf 3.7
Simplified3.7
Taylor expanded in x around 0 3.7
Simplified3.7
if -inf.0 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 1.09530664411754572e308Initial program 0.6
Simplified0.6
Final simplification0.8
herbie shell --seed 2021280
(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))))))