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 5.073647105141176 \cdot 10^{+304}\right)
\end{array}:\\
\;\;\;\;x + z \cdot \left(t - 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 5.073647105141176e+304))))
(+ x (* z (- t 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 <= 5.073647105141176e+304)) {
tmp = x + (z * (t - 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.7 |
|---|---|
| Target | 2.1 |
| Herbie | 0.9 |
if (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < -inf.0 or 5.073647105141176e304 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 60.9
Simplified60.9
Applied expm1-log1p-u_binary6461.3
Taylor expanded in y around inf 3.6
Simplified3.6
if -inf.0 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 5.073647105141176e304Initial program 0.7
Simplified0.7
Applied pow1_binary640.7
Final simplification0.9
herbie shell --seed 2021340
(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))))))