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}\;x + \left(y \cdot z\right) \cdot t_1 \leq 4.889942237596147 \cdot 10^{+303}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot z, t_1, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, 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 (<= (+ x (* (* y z) t_1)) 4.889942237596147e+303)
(fma (* y z) t_1 x)
(fma z (- t x) 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 tmp;
if ((x + ((y * z) * t_1)) <= 4.889942237596147e+303) {
tmp = fma((y * z), t_1, x);
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
| Original | 4.9 |
|---|---|
| Target | 1.9 |
| Herbie | 2.4 |
if (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 4.8899422375961473e303Initial program 2.2
Simplified2.2
if 4.8899422375961473e303 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 58.5
Simplified58.5
Taylor expanded in y around inf 6.2
Simplified6.2
Taylor expanded in z around 0 6.2
Simplified6.2
Final simplification2.4
herbie shell --seed 2022081
(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))))))