x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\begin{array}{l}
t_1 := \frac{a - z}{t - x}\\
t_2 := \frac{y}{t_1} - \left(\frac{z}{t_1} - x\right)\\
t_3 := x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\\
t_4 := \left(\frac{x \cdot z}{a - z} + \left(x + \frac{y \cdot t}{a - z}\right)\right) - \left(\frac{x \cdot y}{a - z} + \frac{z \cdot t}{a - z}\right)\\
\mathbf{if}\;t_3 \leq -\infty:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_3 \leq -3.1877021894739583 \cdot 10^{-305}:\\
\;\;\;\;t_4\\
\mathbf{elif}\;t_3 \leq 0:\\
\;\;\;\;\left(\frac{x \cdot y}{z} + \left(t + \frac{t \cdot a}{z}\right)\right) - \left(\frac{y \cdot t}{z} + \frac{x \cdot a}{z}\right)\\
\mathbf{elif}\;t_3 \leq 9.694805148247403 \cdot 10^{+275}:\\
\;\;\;\;t_4\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
(FPCore (x y z t a) :precision binary64 (+ x (/ (* (- y z) (- t x)) (- a z))))
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (- a z) (- t x)))
(t_2 (- (/ y t_1) (- (/ z t_1) x)))
(t_3 (+ x (/ (* (- y z) (- t x)) (- a z))))
(t_4
(-
(+ (/ (* x z) (- a z)) (+ x (/ (* y t) (- a z))))
(+ (/ (* x y) (- a z)) (/ (* z t) (- a z))))))
(if (<= t_3 (- INFINITY))
t_2
(if (<= t_3 -3.1877021894739583e-305)
t_4
(if (<= t_3 0.0)
(-
(+ (/ (* x y) z) (+ t (/ (* t a) z)))
(+ (/ (* y t) z) (/ (* x a) z)))
(if (<= t_3 9.694805148247403e+275) t_4 t_2))))))double code(double x, double y, double z, double t, double a) {
return x + (((y - z) * (t - x)) / (a - z));
}
double code(double x, double y, double z, double t, double a) {
double t_1 = (a - z) / (t - x);
double t_2 = (y / t_1) - ((z / t_1) - x);
double t_3 = x + (((y - z) * (t - x)) / (a - z));
double t_4 = (((x * z) / (a - z)) + (x + ((y * t) / (a - z)))) - (((x * y) / (a - z)) + ((z * t) / (a - z)));
double tmp;
if (t_3 <= -((double) INFINITY)) {
tmp = t_2;
} else if (t_3 <= -3.1877021894739583e-305) {
tmp = t_4;
} else if (t_3 <= 0.0) {
tmp = (((x * y) / z) + (t + ((t * a) / z))) - (((y * t) / z) + ((x * a) / z));
} else if (t_3 <= 9.694805148247403e+275) {
tmp = t_4;
} else {
tmp = t_2;
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t




Bits error versus a
Results
| Original | 24.6 |
|---|---|
| Target | 12.1 |
| Herbie | 5.0 |
if (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) < -inf.0 or 9.6948051482474029e275 < (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) Initial program 61.3
Simplified17.8
Applied egg-rr17.9
Applied egg-rr17.8
Applied egg-rr13.1
if -inf.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) < -3.1877021894739583e-305 or 0.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) < 9.6948051482474029e275Initial program 2.1
Simplified7.1
Taylor expanded in y around 0 1.7
if -3.1877021894739583e-305 < (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) < 0.0Initial program 60.8
Simplified60.8
Taylor expanded in z around inf 0.7
Final simplification5.0
herbie shell --seed 2022130
(FPCore (x y z t a)
:name "Graphics.Rendering.Chart.Axis.Types:invLinMap from Chart-1.5.3"
:precision binary64
:herbie-target
(if (< z -1.2536131056095036e+188) (- t (* (/ y z) (- t x))) (if (< z 4.446702369113811e+64) (+ x (/ (- y z) (/ (- a z) (- t x)))) (- t (* (/ y z) (- t x)))))
(+ x (/ (* (- y z) (- t x)) (- a z))))