| Alternative 1 | |
|---|---|
| Error | 2.13% |
| 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 (if (or (<= y -5.4e+169) (not (<= y 2.9e+180))) (fma (- t x) z x) (+ x (* (- (tanh (/ t y)) (tanh (/ x y))) (* z y)))))
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 tmp;
if ((y <= -5.4e+169) || !(y <= 2.9e+180)) {
tmp = fma((t - x), z, x);
} else {
tmp = x + ((tanh((t / y)) - tanh((x / y))) * (z * y));
}
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) tmp = 0.0 if ((y <= -5.4e+169) || !(y <= 2.9e+180)) tmp = fma(Float64(t - x), z, x); else tmp = Float64(x + Float64(Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))) * Float64(z * y))); 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_] := If[Or[LessEqual[y, -5.4e+169], N[Not[LessEqual[y, 2.9e+180]], $MachinePrecision]], N[(N[(t - x), $MachinePrecision] * z + x), $MachinePrecision], 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]]
x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\begin{array}{l}
\mathbf{if}\;y \leq -5.4 \cdot 10^{+169} \lor \neg \left(y \leq 2.9 \cdot 10^{+180}\right):\\
\;\;\;\;\mathsf{fma}\left(t - x, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot \left(z \cdot y\right)\\
\end{array}
| Original | 7.04% |
|---|---|
| Target | 2.87% |
| Herbie | 3.82% |
if y < -5.39999999999999981e169 or 2.90000000000000007e180 < y Initial program 27.47
Simplified9.75
[Start]27.47 | \[ x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\] |
|---|---|
+-commutative [=>]27.47 | \[ \color{blue}{\left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) + x}
\] |
*-commutative [=>]27.47 | \[ \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* [=>]9.76 | \[ \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 [=>]9.75 | \[ \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 9.84
Simplified9.83
[Start]9.84 | \[ \left(t - x\right) \cdot z + x
\] |
|---|---|
fma-def [=>]9.83 | \[ \color{blue}{\mathsf{fma}\left(t - x, z, x\right)}
\] |
if -5.39999999999999981e169 < y < 2.90000000000000007e180Initial program 2.48
Final simplification3.82
| Alternative 1 | |
|---|---|
| Error | 2.13% |
| Cost | 19904 |
| Alternative 2 | |
|---|---|
| Error | 2.13% |
| Cost | 13632 |
| Alternative 3 | |
|---|---|
| Error | 13.73% |
| Cost | 7372 |
| Alternative 4 | |
|---|---|
| Error | 14.12% |
| Cost | 7368 |
| Alternative 5 | |
|---|---|
| Error | 16.63% |
| Cost | 7241 |
| Alternative 6 | |
|---|---|
| Error | 22.67% |
| Cost | 6985 |
| Alternative 7 | |
|---|---|
| Error | 22.67% |
| Cost | 1225 |
| Alternative 8 | |
|---|---|
| Error | 33.08% |
| Cost | 716 |
| Alternative 9 | |
|---|---|
| Error | 30.52% |
| Cost | 716 |
| Alternative 10 | |
|---|---|
| Error | 30.47% |
| Cost | 716 |
| Alternative 11 | |
|---|---|
| Error | 24.12% |
| Cost | 713 |
| Alternative 12 | |
|---|---|
| Error | 36.97% |
| Cost | 456 |
| Alternative 13 | |
|---|---|
| Error | 35.7% |
| Cost | 64 |
herbie shell --seed 2023115
(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))))))