
(FPCore (x y z t) :precision binary64 (- 1.0 (/ x (* (- y z) (- y t)))))
double code(double x, double y, double z, double t) {
return 1.0 - (x / ((y - z) * (y - t)));
}
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 - (x / ((y - z) * (y - t)))
end function
public static double code(double x, double y, double z, double t) {
return 1.0 - (x / ((y - z) * (y - t)));
}
def code(x, y, z, t): return 1.0 - (x / ((y - z) * (y - t)))
function code(x, y, z, t) return Float64(1.0 - Float64(x / Float64(Float64(y - z) * Float64(y - t)))) end
function tmp = code(x, y, z, t) tmp = 1.0 - (x / ((y - z) * (y - t))); end
code[x_, y_, z_, t_] := N[(1.0 - N[(x / N[(N[(y - z), $MachinePrecision] * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (- 1.0 (/ x (* (- y z) (- y t)))))
double code(double x, double y, double z, double t) {
return 1.0 - (x / ((y - z) * (y - t)));
}
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 - (x / ((y - z) * (y - t)))
end function
public static double code(double x, double y, double z, double t) {
return 1.0 - (x / ((y - z) * (y - t)));
}
def code(x, y, z, t): return 1.0 - (x / ((y - z) * (y - t)))
function code(x, y, z, t) return Float64(1.0 - Float64(x / Float64(Float64(y - z) * Float64(y - t)))) end
function tmp = code(x, y, z, t) tmp = 1.0 - (x / ((y - z) * (y - t))); end
code[x_, y_, z_, t_] := N[(1.0 - N[(x / N[(N[(y - z), $MachinePrecision] * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)}
\end{array}
(FPCore (x y z t) :precision binary64 (+ (/ x (* (- y z) (- t y))) 1.0))
double code(double x, double y, double z, double t) {
return (x / ((y - z) * (t - y))) + 1.0;
}
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 - y))) + 1.0d0
end function
public static double code(double x, double y, double z, double t) {
return (x / ((y - z) * (t - y))) + 1.0;
}
def code(x, y, z, t): return (x / ((y - z) * (t - y))) + 1.0
function code(x, y, z, t) return Float64(Float64(x / Float64(Float64(y - z) * Float64(t - y))) + 1.0) end
function tmp = code(x, y, z, t) tmp = (x / ((y - z) * (t - y))) + 1.0; end
code[x_, y_, z_, t_] := N[(N[(x / N[(N[(y - z), $MachinePrecision] * N[(t - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{\left(y - z\right) \cdot \left(t - y\right)} + 1
\end{array}
Initial program 99.7%
Final simplification99.7%
(FPCore (x y z t)
:precision binary64
(if (<= z -5.6e-55)
(+ (/ (/ x z) (- y t)) 1.0)
(if (<= z 8.8e-167)
(- 1.0 (/ (/ x y) (- y t)))
(+ (/ (/ x t) (- y z)) 1.0))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -5.6e-55) {
tmp = ((x / z) / (y - t)) + 1.0;
} else if (z <= 8.8e-167) {
tmp = 1.0 - ((x / y) / (y - t));
} else {
tmp = ((x / t) / (y - z)) + 1.0;
}
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 (z <= (-5.6d-55)) then
tmp = ((x / z) / (y - t)) + 1.0d0
else if (z <= 8.8d-167) then
tmp = 1.0d0 - ((x / y) / (y - t))
else
tmp = ((x / t) / (y - z)) + 1.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -5.6e-55) {
tmp = ((x / z) / (y - t)) + 1.0;
} else if (z <= 8.8e-167) {
tmp = 1.0 - ((x / y) / (y - t));
} else {
tmp = ((x / t) / (y - z)) + 1.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -5.6e-55: tmp = ((x / z) / (y - t)) + 1.0 elif z <= 8.8e-167: tmp = 1.0 - ((x / y) / (y - t)) else: tmp = ((x / t) / (y - z)) + 1.0 return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -5.6e-55) tmp = Float64(Float64(Float64(x / z) / Float64(y - t)) + 1.0); elseif (z <= 8.8e-167) tmp = Float64(1.0 - Float64(Float64(x / y) / Float64(y - t))); else tmp = Float64(Float64(Float64(x / t) / Float64(y - z)) + 1.0); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -5.6e-55) tmp = ((x / z) / (y - t)) + 1.0; elseif (z <= 8.8e-167) tmp = 1.0 - ((x / y) / (y - t)); else tmp = ((x / t) / (y - z)) + 1.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -5.6e-55], N[(N[(N[(x / z), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[z, 8.8e-167], N[(1.0 - N[(N[(x / y), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x / t), $MachinePrecision] / N[(y - z), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.6 \cdot 10^{-55}:\\
\;\;\;\;\frac{\frac{x}{z}}{y - t} + 1\\
\mathbf{elif}\;z \leq 8.8 \cdot 10^{-167}:\\
\;\;\;\;1 - \frac{\frac{x}{y}}{y - t}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{t}}{y - z} + 1\\
\end{array}
\end{array}
if z < -5.59999999999999968e-55Initial program 99.9%
Taylor expanded in z around inf 97.2%
associate-/r*97.3%
Simplified97.3%
if -5.59999999999999968e-55 < z < 8.7999999999999999e-167Initial program 99.4%
Taylor expanded in z around 0 92.0%
sub-neg92.0%
associate-/r*89.2%
distribute-neg-frac289.2%
neg-sub089.2%
sub-neg89.2%
+-commutative89.2%
associate--r+89.2%
neg-sub089.2%
remove-double-neg89.2%
Simplified89.2%
if 8.7999999999999999e-167 < z Initial program 100.0%
Taylor expanded in t around inf 82.4%
associate-/r*80.9%
Simplified80.9%
Final simplification88.1%
(FPCore (x y z t)
:precision binary64
(if (<= y -2.25e-38)
1.0
(if (<= y 7.5e-81)
(+ (/ (/ x t) (- y z)) 1.0)
(- 1.0 (/ (/ x y) (- y t))))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -2.25e-38) {
tmp = 1.0;
} else if (y <= 7.5e-81) {
tmp = ((x / t) / (y - z)) + 1.0;
} else {
tmp = 1.0 - ((x / y) / (y - t));
}
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 (y <= (-2.25d-38)) then
tmp = 1.0d0
else if (y <= 7.5d-81) then
tmp = ((x / t) / (y - z)) + 1.0d0
else
tmp = 1.0d0 - ((x / y) / (y - t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -2.25e-38) {
tmp = 1.0;
} else if (y <= 7.5e-81) {
tmp = ((x / t) / (y - z)) + 1.0;
} else {
tmp = 1.0 - ((x / y) / (y - t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -2.25e-38: tmp = 1.0 elif y <= 7.5e-81: tmp = ((x / t) / (y - z)) + 1.0 else: tmp = 1.0 - ((x / y) / (y - t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -2.25e-38) tmp = 1.0; elseif (y <= 7.5e-81) tmp = Float64(Float64(Float64(x / t) / Float64(y - z)) + 1.0); else tmp = Float64(1.0 - Float64(Float64(x / y) / Float64(y - t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -2.25e-38) tmp = 1.0; elseif (y <= 7.5e-81) tmp = ((x / t) / (y - z)) + 1.0; else tmp = 1.0 - ((x / y) / (y - t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -2.25e-38], 1.0, If[LessEqual[y, 7.5e-81], N[(N[(N[(x / t), $MachinePrecision] / N[(y - z), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], N[(1.0 - N[(N[(x / y), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.25 \cdot 10^{-38}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 7.5 \cdot 10^{-81}:\\
\;\;\;\;\frac{\frac{x}{t}}{y - z} + 1\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{\frac{x}{y}}{y - t}\\
\end{array}
\end{array}
if y < -2.25000000000000004e-38Initial program 100.0%
Taylor expanded in x around 0 92.7%
if -2.25000000000000004e-38 < y < 7.50000000000000018e-81Initial program 99.4%
Taylor expanded in t around inf 91.8%
associate-/r*89.9%
Simplified89.9%
if 7.50000000000000018e-81 < y Initial program 100.0%
Taylor expanded in z around 0 90.3%
sub-neg90.3%
associate-/r*90.3%
distribute-neg-frac290.3%
neg-sub090.3%
sub-neg90.3%
+-commutative90.3%
associate--r+90.3%
neg-sub090.3%
remove-double-neg90.3%
Simplified90.3%
Final simplification90.9%
(FPCore (x y z t) :precision binary64 (if (<= y -1.85e-18) 1.0 (if (<= y 2.6e-67) (- 1.0 (/ x (* z t))) 1.0)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.85e-18) {
tmp = 1.0;
} else if (y <= 2.6e-67) {
tmp = 1.0 - (x / (z * t));
} else {
tmp = 1.0;
}
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 (y <= (-1.85d-18)) then
tmp = 1.0d0
else if (y <= 2.6d-67) then
tmp = 1.0d0 - (x / (z * t))
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.85e-18) {
tmp = 1.0;
} else if (y <= 2.6e-67) {
tmp = 1.0 - (x / (z * t));
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1.85e-18: tmp = 1.0 elif y <= 2.6e-67: tmp = 1.0 - (x / (z * t)) else: tmp = 1.0 return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1.85e-18) tmp = 1.0; elseif (y <= 2.6e-67) tmp = Float64(1.0 - Float64(x / Float64(z * t))); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -1.85e-18) tmp = 1.0; elseif (y <= 2.6e-67) tmp = 1.0 - (x / (z * t)); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.85e-18], 1.0, If[LessEqual[y, 2.6e-67], N[(1.0 - N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.85 \cdot 10^{-18}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 2.6 \cdot 10^{-67}:\\
\;\;\;\;1 - \frac{x}{z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.8500000000000002e-18 or 2.5999999999999999e-67 < y Initial program 100.0%
Taylor expanded in x around 0 90.9%
if -1.8500000000000002e-18 < y < 2.5999999999999999e-67Initial program 99.5%
Taylor expanded in y around 0 82.3%
Final simplification87.0%
(FPCore (x y z t) :precision binary64 (if (<= t 1.65e-165) (+ (* (/ x z) (/ 1.0 y)) 1.0) (+ (/ (/ x t) (- y z)) 1.0)))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= 1.65e-165) {
tmp = ((x / z) * (1.0 / y)) + 1.0;
} else {
tmp = ((x / t) / (y - z)) + 1.0;
}
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 (t <= 1.65d-165) then
tmp = ((x / z) * (1.0d0 / y)) + 1.0d0
else
tmp = ((x / t) / (y - z)) + 1.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= 1.65e-165) {
tmp = ((x / z) * (1.0 / y)) + 1.0;
} else {
tmp = ((x / t) / (y - z)) + 1.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= 1.65e-165: tmp = ((x / z) * (1.0 / y)) + 1.0 else: tmp = ((x / t) / (y - z)) + 1.0 return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= 1.65e-165) tmp = Float64(Float64(Float64(x / z) * Float64(1.0 / y)) + 1.0); else tmp = Float64(Float64(Float64(x / t) / Float64(y - z)) + 1.0); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= 1.65e-165) tmp = ((x / z) * (1.0 / y)) + 1.0; else tmp = ((x / t) / (y - z)) + 1.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, 1.65e-165], N[(N[(N[(x / z), $MachinePrecision] * N[(1.0 / y), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], N[(N[(N[(x / t), $MachinePrecision] / N[(y - z), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq 1.65 \cdot 10^{-165}:\\
\;\;\;\;\frac{x}{z} \cdot \frac{1}{y} + 1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{t}}{y - z} + 1\\
\end{array}
\end{array}
if t < 1.6499999999999999e-165Initial program 99.6%
Taylor expanded in z around inf 78.9%
associate-/r*78.9%
Simplified78.9%
Taylor expanded in y around inf 59.2%
*-un-lft-identity59.2%
times-frac59.1%
Applied egg-rr59.1%
if 1.6499999999999999e-165 < t Initial program 99.9%
Taylor expanded in t around inf 89.4%
associate-/r*89.3%
Simplified89.3%
Final simplification72.2%
(FPCore (x y z t) :precision binary64 (if (<= t 1.3e-162) (+ (/ x (* y z)) 1.0) 1.0))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= 1.3e-162) {
tmp = (x / (y * z)) + 1.0;
} else {
tmp = 1.0;
}
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 (t <= 1.3d-162) then
tmp = (x / (y * z)) + 1.0d0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= 1.3e-162) {
tmp = (x / (y * z)) + 1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= 1.3e-162: tmp = (x / (y * z)) + 1.0 else: tmp = 1.0 return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= 1.3e-162) tmp = Float64(Float64(x / Float64(y * z)) + 1.0); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= 1.3e-162) tmp = (x / (y * z)) + 1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, 1.3e-162], N[(N[(x / N[(y * z), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq 1.3 \cdot 10^{-162}:\\
\;\;\;\;\frac{x}{y \cdot z} + 1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if t < 1.3e-162Initial program 99.6%
Taylor expanded in z around inf 79.4%
associate-/r*79.4%
Simplified79.4%
Taylor expanded in y around inf 59.3%
if 1.3e-162 < t Initial program 99.9%
Taylor expanded in x around 0 81.6%
Final simplification68.7%
(FPCore (x y z t) :precision binary64 (if (<= x -4.3e+220) (/ x (* z (- t))) 1.0))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -4.3e+220) {
tmp = x / (z * -t);
} else {
tmp = 1.0;
}
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 <= (-4.3d+220)) then
tmp = x / (z * -t)
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= -4.3e+220) {
tmp = x / (z * -t);
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -4.3e+220: tmp = x / (z * -t) else: tmp = 1.0 return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -4.3e+220) tmp = Float64(x / Float64(z * Float64(-t))); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -4.3e+220) tmp = x / (z * -t); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -4.3e+220], N[(x / N[(z * (-t)), $MachinePrecision]), $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.3 \cdot 10^{+220}:\\
\;\;\;\;\frac{x}{z \cdot \left(-t\right)}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -4.3e220Initial program 100.0%
Taylor expanded in t around inf 76.1%
associate-/r*70.0%
Simplified70.0%
Taylor expanded in x around inf 55.0%
Taylor expanded in y around 0 47.0%
associate-*r/47.0%
neg-mul-147.0%
Simplified47.0%
if -4.3e220 < x Initial program 99.7%
Taylor expanded in x around 0 78.3%
Final simplification75.5%
(FPCore (x y z t) :precision binary64 1.0)
double code(double x, double y, double z, double t) {
return 1.0;
}
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
end function
public static double code(double x, double y, double z, double t) {
return 1.0;
}
def code(x, y, z, t): return 1.0
function code(x, y, z, t) return 1.0 end
function tmp = code(x, y, z, t) tmp = 1.0; end
code[x_, y_, z_, t_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 99.7%
Taylor expanded in x around 0 73.8%
herbie shell --seed 2024185
(FPCore (x y z t)
:name "Data.Random.Distribution.Triangular:triangularCDF from random-fu-0.2.6.2, A"
:precision binary64
(- 1.0 (/ x (* (- y z) (- y t)))))