| Alternative 1 | |
|---|---|
| Error | 1.4 |
| Cost | 19904 |
\[\mathsf{fma}\left(z, y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)
\]
(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 (+ x (* (- (tanh (/ t y)) (tanh (/ x y))) (* z y))))) (if (<= t_1 5e+306) t_1 (fma (- t x) z 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 = x + ((tanh((t / y)) - tanh((x / y))) * (z * y));
double tmp;
if (t_1 <= 5e+306) {
tmp = t_1;
} else {
tmp = fma((t - x), z, x);
}
return tmp;
}
function code(x, y, z, t) return Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))))) end
function code(x, y, z, t) t_1 = Float64(x + Float64(Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))) * Float64(z * y))) tmp = 0.0 if (t_1 <= 5e+306) tmp = t_1; else tmp = fma(Float64(t - x), z, x); end return tmp end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * z), $MachinePrecision] * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 5e+306], t$95$1, N[(N[(t - x), $MachinePrecision] * z + x), $MachinePrecision]]]
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 := x + \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot \left(z \cdot y\right)\\
\mathbf{if}\;t_1 \leq 5 \cdot 10^{+306}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t - x, z, x\right)\\
\end{array}
| Original | 4.5 |
|---|---|
| Target | 1.9 |
| Herbie | 2.2 |
if (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 4.99999999999999993e306Initial program 2.1
if 4.99999999999999993e306 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 61.5
Simplified20.0
[Start]61.5 | \[ x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\] |
|---|---|
+-commutative [=>]61.5 | \[ \color{blue}{\left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) + x}
\] |
*-commutative [=>]61.5 | \[ \color{blue}{\left(z \cdot y\right)} \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) + x
\] |
associate-*l* [=>]20.0 | \[ \color{blue}{z \cdot \left(y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)} + x
\] |
fma-def [=>]20.0 | \[ \color{blue}{\mathsf{fma}\left(z, y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)}
\] |
Taylor expanded in y around inf 5.6
Simplified5.6
[Start]5.6 | \[ \left(t - x\right) \cdot z + x
\] |
|---|---|
fma-def [=>]5.6 | \[ \color{blue}{\mathsf{fma}\left(t - x, z, x\right)}
\] |
Final simplification2.2
| Alternative 1 | |
|---|---|
| Error | 1.4 |
| Cost | 19904 |
| Alternative 2 | |
|---|---|
| Error | 9.8 |
| Cost | 7241 |
| Alternative 3 | |
|---|---|
| Error | 16.0 |
| Cost | 6985 |
| Alternative 4 | |
|---|---|
| Error | 19.6 |
| Cost | 717 |
| Alternative 5 | |
|---|---|
| Error | 16.0 |
| Cost | 713 |
| Alternative 6 | |
|---|---|
| Error | 21.7 |
| Cost | 585 |
| Alternative 7 | |
|---|---|
| Error | 23.0 |
| Cost | 456 |
| Alternative 8 | |
|---|---|
| Error | 23.4 |
| Cost | 64 |
herbie shell --seed 2023027
(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))))))