(FPCore (x y z t) :precision binary64 (+ x (* (- y x) (/ z t))))
(FPCore (x y z t)
:precision binary64
(if (<= t -1.802344879117195e+58)
(fma z (/ (- y x) t) x)
(if (<= t 7.032798435538504e+36)
(+ x (/ (* z (- y x)) t))
(fma (/ z t) (- y x) x))))double code(double x, double y, double z, double t) {
return x + ((y - x) * (z / t));
}
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.802344879117195e+58) {
tmp = fma(z, ((y - x) / t), x);
} else if (t <= 7.032798435538504e+36) {
tmp = x + ((z * (y - x)) / t);
} else {
tmp = fma((z / t), (y - x), x);
}
return tmp;
}
function code(x, y, z, t) return Float64(x + Float64(Float64(y - x) * Float64(z / t))) end
function code(x, y, z, t) tmp = 0.0 if (t <= -1.802344879117195e+58) tmp = fma(z, Float64(Float64(y - x) / t), x); elseif (t <= 7.032798435538504e+36) tmp = Float64(x + Float64(Float64(z * Float64(y - x)) / t)); else tmp = fma(Float64(z / t), Float64(y - x), x); end return tmp end
code[x_, y_, z_, t_] := N[(x + N[(N[(y - x), $MachinePrecision] * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := If[LessEqual[t, -1.802344879117195e+58], N[(z * N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[t, 7.032798435538504e+36], N[(x + N[(N[(z * N[(y - x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(N[(z / t), $MachinePrecision] * N[(y - x), $MachinePrecision] + x), $MachinePrecision]]]
x + \left(y - x\right) \cdot \frac{z}{t}
\begin{array}{l}
\mathbf{if}\;t \leq -1.802344879117195 \cdot 10^{+58}:\\
\;\;\;\;\mathsf{fma}\left(z, \frac{y - x}{t}, x\right)\\
\mathbf{elif}\;t \leq 7.032798435538504 \cdot 10^{+36}:\\
\;\;\;\;x + \frac{z \cdot \left(y - x\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y - x, x\right)\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
| Original | 1.9 |
|---|---|
| Target | 2.1 |
| Herbie | 1.5 |
if t < -1.802344879117195e58Initial program 1.1
Taylor expanded in x around 0 10.6
Simplified1.1
if -1.802344879117195e58 < t < 7.0327984355385045e36Initial program 3.0
Taylor expanded in z around 0 2.0
if 7.0327984355385045e36 < t Initial program 1.0
Applied egg-rr1.0
Final simplification1.5
herbie shell --seed 2022133
(FPCore (x y z t)
:name "Graphics.Rendering.Plot.Render.Plot.Axis:tickPosition from plot-0.2.3.4"
:precision binary64
:herbie-target
(if (< (* (- y x) (/ z t)) -1013646692435.8867) (+ x (/ (- y x) (/ t z))) (if (< (* (- y x) (/ z t)) 0.0) (+ x (/ (* (- y x) z) t)) (+ x (/ (- y x) (/ t z)))))
(+ x (* (- y x) (/ z t))))