
(FPCore (x y z t) :precision binary64 (* x (- (/ y z) (/ t (- 1.0 z)))))
double code(double x, double y, double z, double t) {
return x * ((y / z) - (t / (1.0 - z)));
}
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
public static double code(double x, double y, double z, double t) {
return x * ((y / z) - (t / (1.0 - z)));
}
def code(x, y, z, t): return x * ((y / z) - (t / (1.0 - z)))
function code(x, y, z, t) return Float64(x * Float64(Float64(y / z) - Float64(t / Float64(1.0 - z)))) end
function tmp = code(x, y, z, t) tmp = x * ((y / z) - (t / (1.0 - z))); end
code[x_, y_, z_, t_] := N[(x * N[(N[(y / z), $MachinePrecision] - N[(t / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (* x (- (/ y z) (/ t (- 1.0 z)))))
double code(double x, double y, double z, double t) {
return x * ((y / z) - (t / (1.0 - z)));
}
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
public static double code(double x, double y, double z, double t) {
return x * ((y / z) - (t / (1.0 - z)));
}
def code(x, y, z, t): return x * ((y / z) - (t / (1.0 - z)))
function code(x, y, z, t) return Float64(x * Float64(Float64(y / z) - Float64(t / Float64(1.0 - z)))) end
function tmp = code(x, y, z, t) tmp = x * ((y / z) - (t / (1.0 - z))); end
code[x_, y_, z_, t_] := N[(x * N[(N[(y / z), $MachinePrecision] - N[(t / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)
\end{array}
(FPCore (x y z t) :precision binary64 (* x (- (/ y z) (/ t (- 1.0 z)))))
double code(double x, double y, double z, double t) {
return x * ((y / z) - (t / (1.0 - z)));
}
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
public static double code(double x, double y, double z, double t) {
return x * ((y / z) - (t / (1.0 - z)));
}
def code(x, y, z, t): return x * ((y / z) - (t / (1.0 - z)))
function code(x, y, z, t) return Float64(x * Float64(Float64(y / z) - Float64(t / Float64(1.0 - z)))) end
function tmp = code(x, y, z, t) tmp = x * ((y / z) - (t / (1.0 - z))); end
code[x_, y_, z_, t_] := N[(x * N[(N[(y / z), $MachinePrecision] - N[(t / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)
\end{array}
Initial program 93.7%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (/ t (- 1.0 z)))) (if (<= x 1.4e-146) (* x t_1) (- (/ y z) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = t / (1.0 - z);
double tmp;
if (x <= 1.4e-146) {
tmp = x * t_1;
} else {
tmp = (y / z) - t_1;
}
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
real(8) :: t_1
real(8) :: tmp
t_1 = t / (1.0d0 - z)
if (x <= 1.4d-146) then
tmp = x * t_1
else
tmp = (y / z) - t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = t / (1.0 - z);
double tmp;
if (x <= 1.4e-146) {
tmp = x * t_1;
} else {
tmp = (y / z) - t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = t / (1.0 - z) tmp = 0 if x <= 1.4e-146: tmp = x * t_1 else: tmp = (y / z) - t_1 return tmp
function code(x, y, z, t) t_1 = Float64(t / Float64(1.0 - z)) tmp = 0.0 if (x <= 1.4e-146) tmp = Float64(x * t_1); else tmp = Float64(Float64(y / z) - t_1); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = t / (1.0 - z); tmp = 0.0; if (x <= 1.4e-146) tmp = x * t_1; else tmp = (y / z) - t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(t / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 1.4e-146], N[(x * t$95$1), $MachinePrecision], N[(N[(y / z), $MachinePrecision] - t$95$1), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{t}{1 - z}\\
\mathbf{if}\;x \leq 1.4 \cdot 10^{-146}:\\
\;\;\;\;x \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{z} - t\_1\\
\end{array}
\end{array}
if x < 1.40000000000000001e-146Initial program 92.9%
Taylor expanded in y around 0
Applied rewrites17.8%
if 1.40000000000000001e-146 < x Initial program 95.6%
Taylor expanded in y around 0
Applied rewrites26.8%
(FPCore (x y z t) :precision binary64 (if (<= x 1.4e-146) (* x (/ t (- 1.0 z))) (/ y z)))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= 1.4e-146) {
tmp = x * (t / (1.0 - z));
} else {
tmp = y / z;
}
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
real(8) :: tmp
if (x <= 1.4d-146) then
tmp = x * (t / (1.0d0 - z))
else
tmp = y / z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= 1.4e-146) {
tmp = x * (t / (1.0 - z));
} else {
tmp = y / z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= 1.4e-146: tmp = x * (t / (1.0 - z)) else: tmp = y / z return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= 1.4e-146) tmp = Float64(x * Float64(t / Float64(1.0 - z))); else tmp = Float64(y / z); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= 1.4e-146) tmp = x * (t / (1.0 - z)); else tmp = y / z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, 1.4e-146], N[(x * N[(t / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.4 \cdot 10^{-146}:\\
\;\;\;\;x \cdot \frac{t}{1 - z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{z}\\
\end{array}
\end{array}
if x < 1.40000000000000001e-146Initial program 92.9%
Taylor expanded in y around 0
Applied rewrites17.8%
if 1.40000000000000001e-146 < x Initial program 95.6%
Taylor expanded in y around 0
Applied rewrites25.6%
(FPCore (x y z t) :precision binary64 (if (<= x 5.2e-295) (/ t (- 1.0 z)) (/ y z)))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= 5.2e-295) {
tmp = t / (1.0 - z);
} else {
tmp = y / z;
}
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
real(8) :: tmp
if (x <= 5.2d-295) then
tmp = t / (1.0d0 - z)
else
tmp = y / z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= 5.2e-295) {
tmp = t / (1.0 - z);
} else {
tmp = y / z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= 5.2e-295: tmp = t / (1.0 - z) else: tmp = y / z return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= 5.2e-295) tmp = Float64(t / Float64(1.0 - z)); else tmp = Float64(y / z); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= 5.2e-295) tmp = t / (1.0 - z); else tmp = y / z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, 5.2e-295], N[(t / N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(y / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.2 \cdot 10^{-295}:\\
\;\;\;\;\frac{t}{1 - z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{z}\\
\end{array}
\end{array}
if x < 5.1999999999999997e-295Initial program 94.5%
Taylor expanded in y around 0
Applied rewrites5.2%
Taylor expanded in y around 0
Applied rewrites12.1%
if 5.1999999999999997e-295 < x Initial program 92.7%
Taylor expanded in y around 0
Applied rewrites22.0%
(FPCore (x y z t) :precision binary64 (/ y z))
double code(double x, double y, double z, double t) {
return y / z;
}
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 = y / z
end function
public static double code(double x, double y, double z, double t) {
return y / z;
}
def code(x, y, z, t): return y / z
function code(x, y, z, t) return Float64(y / z) end
function tmp = code(x, y, z, t) tmp = y / z; end
code[x_, y_, z_, t_] := N[(y / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{y}{z}
\end{array}
Initial program 93.7%
Taylor expanded in y around 0
Applied rewrites13.6%
(FPCore (x y z t) :precision binary64 (* x (- 1.0 z)))
double code(double x, double y, double z, double t) {
return x * (1.0 - z);
}
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 * (1.0d0 - z)
end function
public static double code(double x, double y, double z, double t) {
return x * (1.0 - z);
}
def code(x, y, z, t): return x * (1.0 - z)
function code(x, y, z, t) return Float64(x * Float64(1.0 - z)) end
function tmp = code(x, y, z, t) tmp = x * (1.0 - z); end
code[x_, y_, z_, t_] := N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - z\right)
\end{array}
Initial program 93.7%
Taylor expanded in y around 0
Applied rewrites5.1%
(FPCore (x y z t) :precision binary64 (- 1.0 z))
double code(double x, double y, double z, double t) {
return 1.0 - z;
}
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 = 1.0d0 - z
end function
public static double code(double x, double y, double z, double t) {
return 1.0 - z;
}
def code(x, y, z, t): return 1.0 - z
function code(x, y, z, t) return Float64(1.0 - z) end
function tmp = code(x, y, z, t) tmp = 1.0 - z; end
code[x_, y_, z_, t_] := N[(1.0 - z), $MachinePrecision]
\begin{array}{l}
\\
1 - z
\end{array}
Initial program 93.7%
Taylor expanded in y around 0
Applied rewrites12.1%
Taylor expanded in y around inf
Applied rewrites2.9%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* x (- (/ y z) (* t (/ 1.0 (- 1.0 z))))))
(t_2 (* x (- (/ y z) (/ t (- 1.0 z))))))
(if (< t_2 -7.623226303312042e-196)
t_1
(if (< t_2 1.4133944927702302e-211)
(+ (/ (* y x) z) (- (/ (* t x) (- 1.0 z))))
t_1))))
double code(double x, double y, double z, double t) {
double t_1 = x * ((y / z) - (t * (1.0 / (1.0 - z))));
double t_2 = x * ((y / z) - (t / (1.0 - z)));
double tmp;
if (t_2 < -7.623226303312042e-196) {
tmp = t_1;
} else if (t_2 < 1.4133944927702302e-211) {
tmp = ((y * x) / z) + -((t * x) / (1.0 - z));
} else {
tmp = t_1;
}
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
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = x * ((y / z) - (t * (1.0d0 / (1.0d0 - z))))
t_2 = x * ((y / z) - (t / (1.0d0 - z)))
if (t_2 < (-7.623226303312042d-196)) then
tmp = t_1
else if (t_2 < 1.4133944927702302d-211) then
tmp = ((y * x) / z) + -((t * x) / (1.0d0 - z))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = x * ((y / z) - (t * (1.0 / (1.0 - z))));
double t_2 = x * ((y / z) - (t / (1.0 - z)));
double tmp;
if (t_2 < -7.623226303312042e-196) {
tmp = t_1;
} else if (t_2 < 1.4133944927702302e-211) {
tmp = ((y * x) / z) + -((t * x) / (1.0 - z));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = x * ((y / z) - (t * (1.0 / (1.0 - z)))) t_2 = x * ((y / z) - (t / (1.0 - z))) tmp = 0 if t_2 < -7.623226303312042e-196: tmp = t_1 elif t_2 < 1.4133944927702302e-211: tmp = ((y * x) / z) + -((t * x) / (1.0 - z)) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(x * Float64(Float64(y / z) - Float64(t * Float64(1.0 / Float64(1.0 - z))))) t_2 = Float64(x * Float64(Float64(y / z) - Float64(t / Float64(1.0 - z)))) tmp = 0.0 if (t_2 < -7.623226303312042e-196) tmp = t_1; elseif (t_2 < 1.4133944927702302e-211) tmp = Float64(Float64(Float64(y * x) / z) + Float64(-Float64(Float64(t * x) / Float64(1.0 - z)))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x * ((y / z) - (t * (1.0 / (1.0 - z)))); t_2 = x * ((y / z) - (t / (1.0 - z))); tmp = 0.0; if (t_2 < -7.623226303312042e-196) tmp = t_1; elseif (t_2 < 1.4133944927702302e-211) tmp = ((y * x) / z) + -((t * x) / (1.0 - z)); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[(N[(y / z), $MachinePrecision] - N[(t * N[(1.0 / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x * N[(N[(y / z), $MachinePrecision] - N[(t / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Less[t$95$2, -7.623226303312042e-196], t$95$1, If[Less[t$95$2, 1.4133944927702302e-211], N[(N[(N[(y * x), $MachinePrecision] / z), $MachinePrecision] + (-N[(N[(t * x), $MachinePrecision] / N[(1.0 - z), $MachinePrecision]), $MachinePrecision])), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \left(\frac{y}{z} - t \cdot \frac{1}{1 - z}\right)\\
t_2 := x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\\
\mathbf{if}\;t\_2 < -7.623226303312042 \cdot 10^{-196}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 < 1.4133944927702302 \cdot 10^{-211}:\\
\;\;\;\;\frac{y \cdot x}{z} + \left(-\frac{t \cdot x}{1 - z}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
herbie shell --seed 2024321
(FPCore (x y z t)
:name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, C"
:precision binary64
:pre (TRUE)
:alt
(! :herbie-platform default (if (< (* x (- (/ y z) (/ t (- 1 z)))) -3811613151656021/5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (* x (- (/ y z) (* t (/ 1 (- 1 z))))) (if (< (* x (- (/ y z) (/ t (- 1 z)))) 7066972463851151/50000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (+ (/ (* y x) z) (- (/ (* t x) (- 1 z)))) (* x (- (/ y z) (* t (/ 1 (- 1 z))))))))
(* x (- (/ y z) (/ t (- 1.0 z)))))