(FPCore (x y z t) :precision binary64 (* x (- (/ y z) (/ t (- 1.0 z)))))
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (* y x) z)) (t_2 (/ t (- 1.0 z))) (t_3 (- (/ y z) t_2)))
(if (<= t_3 -5e+225)
(- t_1 (* t (/ 1.0 (/ (- 1.0 z) x))))
(if (<= t_3 -5e-215)
(- (* (/ y z) x) (* t_2 x))
(if (<= t_3 2e-156) (- t_1 (/ (* t x) (- 1.0 z))) (* t_3 x))))))double code(double x, double y, double z, double t) {
return x * ((y / z) - (t / (1.0 - z)));
}
double code(double x, double y, double z, double t) {
double t_1 = (y * x) / z;
double t_2 = t / (1.0 - z);
double t_3 = (y / z) - t_2;
double tmp;
if (t_3 <= -5e+225) {
tmp = t_1 - (t * (1.0 / ((1.0 - z) / x)));
} else if (t_3 <= -5e-215) {
tmp = ((y / z) * x) - (t_2 * x);
} else if (t_3 <= 2e-156) {
tmp = t_1 - ((t * x) / (1.0 - z));
} else {
tmp = t_3 * x;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x * ((y / z) - (t / (1.0d0 - z)))
end function
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_1 = (y * x) / z
t_2 = t / (1.0d0 - z)
t_3 = (y / z) - t_2
if (t_3 <= (-5d+225)) then
tmp = t_1 - (t * (1.0d0 / ((1.0d0 - z) / x)))
else if (t_3 <= (-5d-215)) then
tmp = ((y / z) * x) - (t_2 * x)
else if (t_3 <= 2d-156) then
tmp = t_1 - ((t * x) / (1.0d0 - z))
else
tmp = t_3 * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
return x * ((y / z) - (t / (1.0 - z)));
}
public static double code(double x, double y, double z, double t) {
double t_1 = (y * x) / z;
double t_2 = t / (1.0 - z);
double t_3 = (y / z) - t_2;
double tmp;
if (t_3 <= -5e+225) {
tmp = t_1 - (t * (1.0 / ((1.0 - z) / x)));
} else if (t_3 <= -5e-215) {
tmp = ((y / z) * x) - (t_2 * x);
} else if (t_3 <= 2e-156) {
tmp = t_1 - ((t * x) / (1.0 - z));
} else {
tmp = t_3 * x;
}
return tmp;
}
def code(x, y, z, t): return x * ((y / z) - (t / (1.0 - z)))
def code(x, y, z, t): t_1 = (y * x) / z t_2 = t / (1.0 - z) t_3 = (y / z) - t_2 tmp = 0 if t_3 <= -5e+225: tmp = t_1 - (t * (1.0 / ((1.0 - z) / x))) elif t_3 <= -5e-215: tmp = ((y / z) * x) - (t_2 * x) elif t_3 <= 2e-156: tmp = t_1 - ((t * x) / (1.0 - z)) else: tmp = t_3 * x return tmp
function code(x, y, z, t) return Float64(x * Float64(Float64(y / z) - Float64(t / Float64(1.0 - z)))) end
function code(x, y, z, t) t_1 = Float64(Float64(y * x) / z) t_2 = Float64(t / Float64(1.0 - z)) t_3 = Float64(Float64(y / z) - t_2) tmp = 0.0 if (t_3 <= -5e+225) tmp = Float64(t_1 - Float64(t * Float64(1.0 / Float64(Float64(1.0 - z) / x)))); elseif (t_3 <= -5e-215) tmp = Float64(Float64(Float64(y / z) * x) - Float64(t_2 * x)); elseif (t_3 <= 2e-156) tmp = Float64(t_1 - Float64(Float64(t * x) / Float64(1.0 - z))); else tmp = Float64(t_3 * x); end return tmp end
function tmp = code(x, y, z, t) tmp = x * ((y / z) - (t / (1.0 - z))); end
function tmp_2 = code(x, y, z, t) t_1 = (y * x) / z; t_2 = t / (1.0 - z); t_3 = (y / z) - t_2; tmp = 0.0; if (t_3 <= -5e+225) tmp = t_1 - (t * (1.0 / ((1.0 - z) / x))); elseif (t_3 <= -5e-215) tmp = ((y / z) * x) - (t_2 * x); elseif (t_3 <= 2e-156) tmp = t_1 - ((t * x) / (1.0 - z)); else tmp = t_3 * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := N[(x * N[(N[(y / z), $MachinePrecision] - N[(t / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(y * x), $MachinePrecision] / z), $MachinePrecision]}, Block[{t$95$2 = N[(t / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(y / z), $MachinePrecision] - t$95$2), $MachinePrecision]}, If[LessEqual[t$95$3, -5e+225], N[(t$95$1 - N[(t * N[(1.0 / N[(N[(1.0 - z), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, -5e-215], N[(N[(N[(y / z), $MachinePrecision] * x), $MachinePrecision] - N[(t$95$2 * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 2e-156], N[(t$95$1 - N[(N[(t * x), $MachinePrecision] / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$3 * x), $MachinePrecision]]]]]]]
x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)
\begin{array}{l}
t_1 := \frac{y \cdot x}{z}\\
t_2 := \frac{t}{1 - z}\\
t_3 := \frac{y}{z} - t_2\\
\mathbf{if}\;t_3 \leq -5 \cdot 10^{+225}:\\
\;\;\;\;t_1 - t \cdot \frac{1}{\frac{1 - z}{x}}\\
\mathbf{elif}\;t_3 \leq -5 \cdot 10^{-215}:\\
\;\;\;\;\frac{y}{z} \cdot x - t_2 \cdot x\\
\mathbf{elif}\;t_3 \leq 2 \cdot 10^{-156}:\\
\;\;\;\;t_1 - \frac{t \cdot x}{1 - z}\\
\mathbf{else}:\\
\;\;\;\;t_3 \cdot x\\
\end{array}
Results
| Original | 4.8 |
|---|---|
| Target | 4.4 |
| Herbie | 2.1 |
if (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < -4.99999999999999981e225Initial program 24.6
Taylor expanded in y around 0 0.7
Applied egg-rr0.7
if -4.99999999999999981e225 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < -4.99999999999999956e-215Initial program 0.2
Applied egg-rr1.3
Applied egg-rr0.2
if -4.99999999999999956e-215 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < 2.00000000000000008e-156Initial program 7.7
Taylor expanded in y around 0 1.3
if 2.00000000000000008e-156 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) Initial program 4.3
Final simplification2.1
herbie shell --seed 2022192
(FPCore (x y z t)
:name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, C"
:precision binary64
:herbie-target
(if (< (* x (- (/ y z) (/ t (- 1.0 z)))) -7.623226303312042e-196) (* x (- (/ y z) (* t (/ 1.0 (- 1.0 z))))) (if (< (* x (- (/ y z) (/ t (- 1.0 z)))) 1.4133944927702302e-211) (+ (/ (* y x) z) (- (/ (* t x) (- 1.0 z)))) (* x (- (/ y z) (* t (/ 1.0 (- 1.0 z)))))))
(* x (- (/ y z) (/ t (- 1.0 z)))))