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.809893081464871 \cdot 10^{+293}:\\
\;\;\;\;\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)))) (t_2 (+ x (* (* y z) t_1))))
(if (<= t_2 (- INFINITY))
(* z (- t x))
(if (<= t_2 2.809893081464871e+293)
(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 t_2 = x + ((y * z) * t_1);
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = z * (t - x);
} else if (t_2 <= 2.809893081464871e+293) {
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.7 |
|---|---|
| Target | 2.1 |
| Herbie | 1.1 |
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 around inf 0.0
Simplified0.0
Taylor expanded around -inf 0.0
Simplified0.0
if -inf.0 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 2.8098930814648709e293Initial program 0.6
Simplified0.6
if 2.8098930814648709e293 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 50.2
Simplified50.2
Taylor expanded around inf 11.0
Simplified11.0
Taylor expanded around 0 11.0
Simplified11.0
Final simplification1.1
herbie shell --seed 2021211
(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))))))