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




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
| Original | 4.8 |
|---|---|
| Target | 2.1 |
| Herbie | 1.2 |
if (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < -inf.0Initial program 64.0
Simplified64.0
Taylor expanded in y around inf 0.0
Simplified0.0
Taylor expanded in z around -inf 0.4
if -inf.0 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 2.381352279137968e295Initial program 0.6
Simplified0.6
if 2.381352279137968e295 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 47.6
Simplified47.6
Taylor expanded in y around inf 11.8
Simplified11.8
Final simplification1.2
herbie shell --seed 2022125
(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))))))