(FPCore (x y z t a) :precision binary64 (+ x (/ (* (- y x) (- z t)) (- a t))))
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ (fma z (/ (- y x) (- a t)) x) (* (/ t (- a t)) (- x y))))
(t_2 (+ x (/ (* (- y x) (- z t)) (- a t)))))
(if (<= t_2 -2e+284)
t_1
(if (<= t_2 -1e-279)
t_2
(if (<= t_2 0.0) (- y (/ (* (- y x) (- z a)) t)) t_1)))))double code(double x, double y, double z, double t, double a) {
return x + (((y - x) * (z - t)) / (a - t));
}
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(z, ((y - x) / (a - t)), x) + ((t / (a - t)) * (x - y));
double t_2 = x + (((y - x) * (z - t)) / (a - t));
double tmp;
if (t_2 <= -2e+284) {
tmp = t_1;
} else if (t_2 <= -1e-279) {
tmp = t_2;
} else if (t_2 <= 0.0) {
tmp = y - (((y - x) * (z - a)) / t);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) return Float64(x + Float64(Float64(Float64(y - x) * Float64(z - t)) / Float64(a - t))) end
function code(x, y, z, t, a) t_1 = Float64(fma(z, Float64(Float64(y - x) / Float64(a - t)), x) + Float64(Float64(t / Float64(a - t)) * Float64(x - y))) t_2 = Float64(x + Float64(Float64(Float64(y - x) * Float64(z - t)) / Float64(a - t))) tmp = 0.0 if (t_2 <= -2e+284) tmp = t_1; elseif (t_2 <= -1e-279) tmp = t_2; elseif (t_2 <= 0.0) tmp = Float64(y - Float64(Float64(Float64(y - x) * Float64(z - a)) / t)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(z * N[(N[(y - x), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision] + N[(N[(t / N[(a - t), $MachinePrecision]), $MachinePrecision] * N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x + N[(N[(N[(y - x), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -2e+284], t$95$1, If[LessEqual[t$95$2, -1e-279], t$95$2, If[LessEqual[t$95$2, 0.0], N[(y - N[(N[(N[(y - x), $MachinePrecision] * N[(z - a), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}
\begin{array}{l}
t_1 := \mathsf{fma}\left(z, \frac{y - x}{a - t}, x\right) + \frac{t}{a - t} \cdot \left(x - y\right)\\
t_2 := x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\\
\mathbf{if}\;t_2 \leq -2 \cdot 10^{+284}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_2 \leq -1 \cdot 10^{-279}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_2 \leq 0:\\
\;\;\;\;y - \frac{\left(y - x\right) \cdot \left(z - a\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t




Bits error versus a
| Original | 24.5 |
|---|---|
| Target | 9.5 |
| Herbie | 7.8 |
if (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < -2.00000000000000016e284 or 0.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) Initial program 30.4
Simplified12.3
Taylor expanded in z around 0 26.3
Simplified11.1
if -2.00000000000000016e284 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < -1.00000000000000006e-279Initial program 2.6
if -1.00000000000000006e-279 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < 0.0Initial program 59.5
Simplified59.2
Taylor expanded in t around -inf 2.0
Simplified2.0
Final simplification7.8
herbie shell --seed 2022170
(FPCore (x y z t a)
:name "Graphics.Rendering.Chart.Axis.Types:linMap from Chart-1.5.3"
:precision binary64
:herbie-target
(if (< a -1.6153062845442575e-142) (+ x (* (/ (- y x) 1.0) (/ (- z t) (- a t)))) (if (< a 3.774403170083174e-182) (- y (* (/ z t) (- y x))) (+ x (* (/ (- y x) 1.0) (/ (- z t) (- a t))))))
(+ x (/ (* (- y x) (- z t)) (- a t))))