(FPCore (x y z t a) :precision binary64 (+ x (* y (/ (- z t) (- a t)))))
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma y (/ (- z t) (- a t)) x)) (t_2 (!= (- z t) 0.0)))
(if (<= y -5.1e+46)
(if t_2 (+ (if t_2 (* (/ y (- a t)) (- z t)) NAN) x) t_1)
(if (<= y 0.002)
(+ (/ (* (- z t) y) (- a t)) x)
(if t_2 (+ (/ y (/ (- t a) (- t z))) x) t_1)))))double code(double x, double y, double z, double t, double a) {
return x + (y * ((z - t) / (a - t)));
}
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(y, ((z - t) / (a - t)), x);
int t_2 = (z - t) != 0.0;
double tmp_3;
if (y <= -5.1e+46) {
double tmp_5;
if (t_2) {
double tmp_6;
if (t_2) {
tmp_6 = (y / (a - t)) * (z - t);
} else {
tmp_6 = (double) NAN;
}
tmp_5 = tmp_6 + x;
} else {
tmp_5 = t_1;
}
tmp_3 = tmp_5;
} else if (y <= 0.002) {
tmp_3 = (((z - t) * y) / (a - t)) + x;
} else if (t_2) {
tmp_3 = (y / ((t - a) / (t - z))) + x;
} else {
tmp_3 = t_1;
}
return tmp_3;
}
function code(x, y, z, t, a) return Float64(x + Float64(y * Float64(Float64(z - t) / Float64(a - t)))) end
function code(x, y, z, t, a) t_1 = fma(y, Float64(Float64(z - t) / Float64(a - t)), x) t_2 = Float64(z - t) != 0.0 tmp_3 = 0.0 if (y <= -5.1e+46) tmp_5 = 0.0 if (t_2) tmp_6 = 0.0 if (t_2) tmp_6 = Float64(Float64(y / Float64(a - t)) * Float64(z - t)); else tmp_6 = NaN; end tmp_5 = Float64(tmp_6 + x); else tmp_5 = t_1; end tmp_3 = tmp_5; elseif (y <= 0.002) tmp_3 = Float64(Float64(Float64(Float64(z - t) * y) / Float64(a - t)) + x); elseif (t_2) tmp_3 = Float64(Float64(y / Float64(Float64(t - a) / Float64(t - z))) + x); else tmp_3 = t_1; end return tmp_3 end
code[x_, y_, z_, t_, a_] := N[(x + N[(y * N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(y * N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]}, Block[{t$95$2 = Unequal[N[(z - t), $MachinePrecision], 0.0]}, If[LessEqual[y, -5.1e+46], If[t$95$2, N[(If[t$95$2, N[(N[(y / N[(a - t), $MachinePrecision]), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision], Indeterminate] + x), $MachinePrecision], t$95$1], If[LessEqual[y, 0.002], N[(N[(N[(N[(z - t), $MachinePrecision] * y), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], If[t$95$2, N[(N[(y / N[(N[(t - a), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]]]
x + y \cdot \frac{z - t}{a - t}
\begin{array}{l}
t_1 := \mathsf{fma}\left(y, \frac{z - t}{a - t}, x\right)\\
t_2 := z - t \ne 0\\
\mathbf{if}\;y \leq -5.1 \cdot 10^{+46}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;t_2:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;t_2:\\
\;\;\;\;\frac{y}{a - t} \cdot \left(z - t\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{NaN}\\
\end{array} + x\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}\\
\mathbf{elif}\;y \leq 0.002:\\
\;\;\;\;\frac{\left(z - t\right) \cdot y}{a - t} + x\\
\mathbf{elif}\;t_2:\\
\;\;\;\;\frac{y}{\frac{t - a}{t - z}} + x\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
| Original | 2.17% |
|---|---|
| Target | 0.64% |
| Herbie | 1.62% |
if y < -5.0999999999999997e46Initial program 0.81
Simplified0.81
Applied egg-rr0.98
Applied egg-rr4.61
if -5.0999999999999997e46 < y < 2e-3Initial program 3.15
Simplified3.15
Taylor expanded in y around -inf 0.85
if 2e-3 < y Initial program 0.84
Simplified0.84
Applied egg-rr1.03
herbie shell --seed 2023136
(FPCore (x y z t a)
:name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisLine from plot-0.2.3.4, B"
:precision binary64
:herbie-target
(if (< y -8.508084860551241e-17) (+ x (* y (/ (- z t) (- a t)))) (if (< y 2.894426862792089e-49) (+ x (* (* y (- z t)) (/ 1.0 (- a t)))) (+ x (* y (/ (- z t) (- a t))))))
(+ x (* y (/ (- z t) (- a t)))))