(FPCore (x y z t a b)
:precision binary64
(/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y)))))
↓
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y)))))
(t_2 (+ (- (/ x (- z 1.0))) (- (/ (- t a) y)))))
(if (<= t_1 (- INFINITY))
t_2
(if (<= t_1 -2e-301)
t_1
(if (<= t_1 0.0)
(-
(+
(/ t (- b y))
(-
(/
(+ (- (/ (* y x) (- b y))) (/ (* (- t a) y) (pow (- b y) 2.0)))
z)))
(/ a (- b y)))
(if (<= t_1 4e+236) t_1 t_2))))))
double code(double x, double y, double z, double t, double a, double b) {
return ((x * y) + (z * (t - a))) / (y + (z * (b - y)));
}
↓
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = ((x * y) + (z * (t - a))) / (y + (z * (b - y)));
double t_2 = -(x / (z - 1.0)) + -((t - a) / y);
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = t_2;
} else if (t_1 <= -2e-301) {
tmp = t_1;
} else if (t_1 <= 0.0) {
tmp = ((t / (b - y)) + -((-((y * x) / (b - y)) + (((t - a) * y) / pow((b - y), 2.0))) / z)) - (a / (b - y));
} else if (t_1 <= 4e+236) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
public static double code(double x, double y, double z, double t, double a, double b) {
return ((x * y) + (z * (t - a))) / (y + (z * (b - y)));
}
↓
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = ((x * y) + (z * (t - a))) / (y + (z * (b - y)));
double t_2 = -(x / (z - 1.0)) + -((t - a) / y);
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = t_2;
} else if (t_1 <= -2e-301) {
tmp = t_1;
} else if (t_1 <= 0.0) {
tmp = ((t / (b - y)) + -((-((y * x) / (b - y)) + (((t - a) * y) / Math.pow((b - y), 2.0))) / z)) - (a / (b - y));
} else if (t_1 <= 4e+236) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t, a, b):
return ((x * y) + (z * (t - a))) / (y + (z * (b - y)))
\[\frac{z \cdot t + y \cdot x}{y + z \cdot \left(b - y\right)} - \frac{a}{\left(b - y\right) + \frac{y}{z}}
\]
Derivation
Split input into 3 regimes
if (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < -inf.0 or 4.00000000000000021e236 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y))))
Initial program 59.0
\[\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}
\]
Simplified59.0
\[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, y, z \cdot \left(t - a\right)\right)}{\mathsf{fma}\left(z, b - y, y\right)}}
\]
if -inf.0 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < -2.00000000000000013e-301 or -0.0 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < 4.00000000000000021e236
Initial program 0.3
\[\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}
\]
if -2.00000000000000013e-301 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < -0.0
Initial program 46.3
\[\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}
\]
herbie shell --seed 2023010
(FPCore (x y z t a b)
:name "Development.Shake.Progress:decay from shake-0.15.5"
:precision binary64
:herbie-target
(- (/ (+ (* z t) (* y x)) (+ y (* z (- b y)))) (/ a (+ (- b y) (/ y z))))
(/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y)))))