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{x}{y}\right)\\
t_2 := \tanh \left(\frac{t}{y}\right) - t_1\\
\mathbf{if}\;t \leq -2.2211093071045775 \cdot 10^{-30}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot z, t_2, x\right)\\
\mathbf{elif}\;t \leq 1.2596353575889675 \cdot 10^{-263}:\\
\;\;\;\;\mathsf{fma}\left(z, \mathsf{fma}\left(y, -t_1, t\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, z \cdot t_2, 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 (/ x y))) (t_2 (- (tanh (/ t y)) t_1)))
(if (<= t -2.2211093071045775e-30)
(fma (* y z) t_2 x)
(if (<= t 1.2596353575889675e-263)
(fma z (fma y (- t_1) t) x)
(fma y (* z 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(x / y);
double t_2 = tanh(t / y) - t_1;
double tmp;
if (t <= -2.2211093071045775e-30) {
tmp = fma((y * z), t_2, x);
} else if (t <= 1.2596353575889675e-263) {
tmp = fma(z, fma(y, -t_1, t), x);
} else {
tmp = fma(y, (z * t_2), x);
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
| Original | 4.0 |
|---|---|
| Target | 2.0 |
| Herbie | 3.1 |
if t < -2.2211093071045775e-30Initial program 2.6
Simplified2.6
Applied sub-neg_binary642.6
if -2.2211093071045775e-30 < t < 1.2596353575889675e-263Initial program 6.1
Simplified6.1
Applied add-log-exp_binary6412.2
Applied add-log-exp_binary6415.6
Applied diff-log_binary6415.6
Taylor expanded in t around 0 42.6
Simplified5.9
if 1.2596353575889675e-263 < t Initial program 3.7
Simplified3.7
Applied add-log-exp_binary646.4
Applied add-log-exp_binary6412.5
Applied diff-log_binary6412.5
Taylor expanded in y around 0 54.9
Simplified1.9
Final simplification3.1
herbie shell --seed 2022068
(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))))))