(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
(+
(+ y (* a (/ y t)))
(- (/ x (/ t z)) (+ (* x (/ a t)) (* z (/ y t))))))
(t_2 (+ x (/ (* (- y x) (- z t)) (- a t)))))
(if (<= t_2 (- INFINITY))
t_1
(if (<= t_2 7.519815301157898e+296)
(-
(+ (/ (* x t) (- a t)) (+ x (/ (* y z) (- a t))))
(+ (/ (* x z) (- a t)) (/ (* y t) (- 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 = (y + (a * (y / t))) + ((x / (t / z)) - ((x * (a / t)) + (z * (y / t))));
double t_2 = x + (((y - x) * (z - t)) / (a - t));
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_2 <= 7.519815301157898e+296) {
tmp = (((x * t) / (a - t)) + (x + ((y * z) / (a - t)))) - (((x * z) / (a - t)) + ((y * t) / (a - t)));
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x, double y, double z, double t, double a) {
return x + (((y - x) * (z - t)) / (a - t));
}
public static double code(double x, double y, double z, double t, double a) {
double t_1 = (y + (a * (y / t))) + ((x / (t / z)) - ((x * (a / t)) + (z * (y / t))));
double t_2 = x + (((y - x) * (z - t)) / (a - t));
double tmp;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp = t_1;
} else if (t_2 <= 7.519815301157898e+296) {
tmp = (((x * t) / (a - t)) + (x + ((y * z) / (a - t)))) - (((x * z) / (a - t)) + ((y * t) / (a - t)));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): return x + (((y - x) * (z - t)) / (a - t))
def code(x, y, z, t, a): t_1 = (y + (a * (y / t))) + ((x / (t / z)) - ((x * (a / t)) + (z * (y / t)))) t_2 = x + (((y - x) * (z - t)) / (a - t)) tmp = 0 if t_2 <= -math.inf: tmp = t_1 elif t_2 <= 7.519815301157898e+296: tmp = (((x * t) / (a - t)) + (x + ((y * z) / (a - t)))) - (((x * z) / (a - t)) + ((y * t) / (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(Float64(y + Float64(a * Float64(y / t))) + Float64(Float64(x / Float64(t / z)) - Float64(Float64(x * Float64(a / t)) + Float64(z * Float64(y / t))))) t_2 = Float64(x + Float64(Float64(Float64(y - x) * Float64(z - t)) / Float64(a - t))) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = t_1; elseif (t_2 <= 7.519815301157898e+296) tmp = Float64(Float64(Float64(Float64(x * t) / Float64(a - t)) + Float64(x + Float64(Float64(y * z) / Float64(a - t)))) - Float64(Float64(Float64(x * z) / Float64(a - t)) + Float64(Float64(y * t) / Float64(a - t)))); else tmp = t_1; end return tmp end
function tmp = code(x, y, z, t, a) tmp = x + (((y - x) * (z - t)) / (a - t)); end
function tmp_2 = code(x, y, z, t, a) t_1 = (y + (a * (y / t))) + ((x / (t / z)) - ((x * (a / t)) + (z * (y / t)))); t_2 = x + (((y - x) * (z - t)) / (a - t)); tmp = 0.0; if (t_2 <= -Inf) tmp = t_1; elseif (t_2 <= 7.519815301157898e+296) tmp = (((x * t) / (a - t)) + (x + ((y * z) / (a - t)))) - (((x * z) / (a - t)) + ((y * t) / (a - t))); else tmp = t_1; end tmp_2 = 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[(y + N[(a * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(x / N[(t / z), $MachinePrecision]), $MachinePrecision] - N[(N[(x * N[(a / t), $MachinePrecision]), $MachinePrecision] + N[(z * N[(y / t), $MachinePrecision]), $MachinePrecision]), $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, (-Infinity)], t$95$1, If[LessEqual[t$95$2, 7.519815301157898e+296], N[(N[(N[(N[(x * t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision] + N[(x + N[(N[(y * z), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(x * z), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision] + N[(N[(y * t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}
\begin{array}{l}
t_1 := \left(y + a \cdot \frac{y}{t}\right) + \left(\frac{x}{\frac{t}{z}} - \left(x \cdot \frac{a}{t} + z \cdot \frac{y}{t}\right)\right)\\
t_2 := x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_2 \leq 7.519815301157898 \cdot 10^{+296}:\\
\;\;\;\;\left(\frac{x \cdot t}{a - t} + \left(x + \frac{y \cdot z}{a - t}\right)\right) - \left(\frac{x \cdot z}{a - t} + \frac{y \cdot t}{a - t}\right)\\
\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
Results
| Original | 25.0 |
|---|---|
| Target | 9.1 |
| Herbie | 8.9 |
if (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < -inf.0 or 7.51981530115789836e296 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) Initial program 63.3
Simplified17.6
Taylor expanded in t around inf 39.6
Simplified21.7
if -inf.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < 7.51981530115789836e296Initial program 8.8
Simplified13.3
Taylor expanded in z around 0 3.5
Final simplification8.9
herbie shell --seed 2022150
(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))))