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)\\
t_2 := \tanh \left(\frac{x}{y}\right)\\
\mathbf{if}\;\begin{array}{l}
t_3 := x + \left(y \cdot z\right) \cdot \left(t_1 - t_2\right)\\
t_3 \leq -\infty \lor \neg \left(t_3 \leq 7.862601540192698 \cdot 10^{+302}\right)
\end{array}:\\
\;\;\;\;\mathsf{fma}\left(z, t, x\right) - x \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot z, t_1 - \mathsf{expm1}\left(\mathsf{log1p}\left(t_2\right)\right), 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))) (t_2 (tanh (/ x y))))
(if (let* ((t_3 (+ x (* (* y z) (- t_1 t_2)))))
(or (<= t_3 (- INFINITY)) (not (<= t_3 7.862601540192698e+302))))
(- (fma z t x) (* x z))
(fma (* y z) (- t_1 (expm1 (log1p t_2))) 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);
double t_2 = tanh(x / y);
double t_3 = x + ((y * z) * (t_1 - t_2));
double tmp;
if ((t_3 <= -((double) INFINITY)) || !(t_3 <= 7.862601540192698e+302)) {
tmp = fma(z, t, x) - (x * z);
} else {
tmp = fma((y * z), (t_1 - expm1(log1p(t_2))), x);
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
| Original | 5.0 |
|---|---|
| Target | 2.0 |
| Herbie | 0.9 |
if (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < -inf.0 or 7.8626015401926985e302 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 59.4
Simplified59.4
Taylor expanded in y around inf 5.4
Simplified5.4
if -inf.0 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 7.8626015401926985e302Initial program 0.6
Simplified0.6
Applied expm1-log1p-u_binary640.6
Final simplification0.9
herbie shell --seed 2022067
(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))))))