
(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 (- 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}
Initial program 98.9%
Final simplification98.9%
(FPCore (x y z t) :precision binary64 (if (<= t 1.1e-213) (+ 1.0 (/ x (* y z))) (if (<= t 6e-34) 1.0 (if (<= t 1.9e+59) (+ 1.0 (/ x (* y t))) 1.0))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= 1.1e-213) {
tmp = 1.0 + (x / (y * z));
} else if (t <= 6e-34) {
tmp = 1.0;
} else if (t <= 1.9e+59) {
tmp = 1.0 + (x / (y * 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 (t <= 1.1d-213) then
tmp = 1.0d0 + (x / (y * z))
else if (t <= 6d-34) then
tmp = 1.0d0
else if (t <= 1.9d+59) then
tmp = 1.0d0 + (x / (y * 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 (t <= 1.1e-213) {
tmp = 1.0 + (x / (y * z));
} else if (t <= 6e-34) {
tmp = 1.0;
} else if (t <= 1.9e+59) {
tmp = 1.0 + (x / (y * t));
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= 1.1e-213: tmp = 1.0 + (x / (y * z)) elif t <= 6e-34: tmp = 1.0 elif t <= 1.9e+59: tmp = 1.0 + (x / (y * t)) else: tmp = 1.0 return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= 1.1e-213) tmp = Float64(1.0 + Float64(x / Float64(y * z))); elseif (t <= 6e-34) tmp = 1.0; elseif (t <= 1.9e+59) tmp = Float64(1.0 + Float64(x / Float64(y * t))); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= 1.1e-213) tmp = 1.0 + (x / (y * z)); elseif (t <= 6e-34) tmp = 1.0; elseif (t <= 1.9e+59) tmp = 1.0 + (x / (y * t)); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, 1.1e-213], N[(1.0 + N[(x / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 6e-34], 1.0, If[LessEqual[t, 1.9e+59], N[(1.0 + N[(x / N[(y * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq 1.1 \cdot 10^{-213}:\\
\;\;\;\;1 + \frac{x}{y \cdot z}\\
\mathbf{elif}\;t \leq 6 \cdot 10^{-34}:\\
\;\;\;\;1\\
\mathbf{elif}\;t \leq 1.9 \cdot 10^{+59}:\\
\;\;\;\;1 + \frac{x}{y \cdot t}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if t < 1.10000000000000005e-213Initial program 98.7%
Taylor expanded in z around inf 76.7%
+-commutative76.7%
*-commutative76.7%
Simplified76.7%
Taylor expanded in y around inf 60.7%
if 1.10000000000000005e-213 < t < 6e-34 or 1.9e59 < t Initial program 98.8%
Taylor expanded in x around 0 78.0%
if 6e-34 < t < 1.9e59Initial program 99.9%
Taylor expanded in z around 0 64.7%
Taylor expanded in y around 0 57.0%
associate-*r/57.0%
neg-mul-157.0%
*-commutative57.0%
Simplified57.0%
expm1-log1p-u49.9%
expm1-udef49.9%
add-sqr-sqrt26.9%
sqrt-unprod50.2%
sqr-neg50.2%
sqrt-unprod23.3%
add-sqr-sqrt41.9%
Applied egg-rr41.9%
expm1-def41.9%
expm1-log1p42.3%
associate-/l/42.3%
Simplified42.3%
sub-neg42.3%
distribute-frac-neg42.3%
+-commutative42.3%
add-sqr-sqrt18.8%
sqrt-unprod42.1%
sqr-neg42.1%
sqrt-unprod23.3%
add-sqr-sqrt57.0%
associate-/l/57.0%
Applied egg-rr57.0%
Final simplification66.2%
(FPCore (x y z t) :precision binary64 (if (<= y -2.2e-77) 1.0 (if (<= y 1.7e-79) (+ 1.0 (/ x (* z (- y t)))) 1.0)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -2.2e-77) {
tmp = 1.0;
} else if (y <= 1.7e-79) {
tmp = 1.0 + (x / (z * (y - 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 <= (-2.2d-77)) then
tmp = 1.0d0
else if (y <= 1.7d-79) then
tmp = 1.0d0 + (x / (z * (y - 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 <= -2.2e-77) {
tmp = 1.0;
} else if (y <= 1.7e-79) {
tmp = 1.0 + (x / (z * (y - t)));
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -2.2e-77: tmp = 1.0 elif y <= 1.7e-79: tmp = 1.0 + (x / (z * (y - t))) else: tmp = 1.0 return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -2.2e-77) tmp = 1.0; elseif (y <= 1.7e-79) tmp = Float64(1.0 + Float64(x / Float64(z * Float64(y - t)))); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -2.2e-77) tmp = 1.0; elseif (y <= 1.7e-79) tmp = 1.0 + (x / (z * (y - t))); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -2.2e-77], 1.0, If[LessEqual[y, 1.7e-79], N[(1.0 + N[(x / N[(z * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.2 \cdot 10^{-77}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.7 \cdot 10^{-79}:\\
\;\;\;\;1 + \frac{x}{z \cdot \left(y - t\right)}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -2.20000000000000007e-77 or 1.69999999999999988e-79 < y Initial program 100.0%
Taylor expanded in x around 0 90.0%
if -2.20000000000000007e-77 < y < 1.69999999999999988e-79Initial program 96.9%
Taylor expanded in z around inf 84.3%
+-commutative84.3%
*-commutative84.3%
Simplified84.3%
Final simplification87.9%
(FPCore (x y z t) :precision binary64 (if (<= y -1.35e-76) 1.0 (if (<= y 3.7e-81) (- 1.0 (/ x (* z t))) 1.0)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.35e-76) {
tmp = 1.0;
} else if (y <= 3.7e-81) {
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.35d-76)) then
tmp = 1.0d0
else if (y <= 3.7d-81) 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.35e-76) {
tmp = 1.0;
} else if (y <= 3.7e-81) {
tmp = 1.0 - (x / (z * t));
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1.35e-76: tmp = 1.0 elif y <= 3.7e-81: tmp = 1.0 - (x / (z * t)) else: tmp = 1.0 return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1.35e-76) tmp = 1.0; elseif (y <= 3.7e-81) 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.35e-76) tmp = 1.0; elseif (y <= 3.7e-81) tmp = 1.0 - (x / (z * t)); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.35e-76], 1.0, If[LessEqual[y, 3.7e-81], N[(1.0 - N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.35 \cdot 10^{-76}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 3.7 \cdot 10^{-81}:\\
\;\;\;\;1 - \frac{x}{z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.35e-76 or 3.69999999999999986e-81 < y Initial program 100.0%
Taylor expanded in x around 0 90.0%
if -1.35e-76 < y < 3.69999999999999986e-81Initial program 96.9%
Taylor expanded in y around 0 71.8%
Final simplification83.5%
(FPCore (x y z t) :precision binary64 (if (<= z -3300.0) (+ 1.0 (/ x (* z (- y t)))) (- 1.0 (/ x (* y (- y t))))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3300.0) {
tmp = 1.0 + (x / (z * (y - t)));
} 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 (z <= (-3300.0d0)) then
tmp = 1.0d0 + (x / (z * (y - t)))
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 (z <= -3300.0) {
tmp = 1.0 + (x / (z * (y - t)));
} else {
tmp = 1.0 - (x / (y * (y - t)));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -3300.0: tmp = 1.0 + (x / (z * (y - t))) else: tmp = 1.0 - (x / (y * (y - t))) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -3300.0) tmp = Float64(1.0 + Float64(x / Float64(z * Float64(y - t)))); else tmp = Float64(1.0 - Float64(x / Float64(y * Float64(y - t)))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -3300.0) tmp = 1.0 + (x / (z * (y - t))); else tmp = 1.0 - (x / (y * (y - t))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -3300.0], N[(1.0 + N[(x / N[(z * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(x / N[(y * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3300:\\
\;\;\;\;1 + \frac{x}{z \cdot \left(y - t\right)}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{y \cdot \left(y - t\right)}\\
\end{array}
\end{array}
if z < -3300Initial program 99.9%
Taylor expanded in z around inf 96.6%
+-commutative96.6%
*-commutative96.6%
Simplified96.6%
if -3300 < z Initial program 98.6%
Taylor expanded in z around 0 80.5%
Final simplification84.0%
(FPCore (x y z t) :precision binary64 (if (<= z -3300.0) (+ 1.0 (/ x (* z (- y t)))) (- 1.0 (/ (/ x (- y t)) y))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3300.0) {
tmp = 1.0 + (x / (z * (y - t)));
} else {
tmp = 1.0 - ((x / (y - t)) / y);
}
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 <= (-3300.0d0)) then
tmp = 1.0d0 + (x / (z * (y - t)))
else
tmp = 1.0d0 - ((x / (y - t)) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3300.0) {
tmp = 1.0 + (x / (z * (y - t)));
} else {
tmp = 1.0 - ((x / (y - t)) / y);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -3300.0: tmp = 1.0 + (x / (z * (y - t))) else: tmp = 1.0 - ((x / (y - t)) / y) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -3300.0) tmp = Float64(1.0 + Float64(x / Float64(z * Float64(y - t)))); else tmp = Float64(1.0 - Float64(Float64(x / Float64(y - t)) / y)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -3300.0) tmp = 1.0 + (x / (z * (y - t))); else tmp = 1.0 - ((x / (y - t)) / y); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -3300.0], N[(1.0 + N[(x / N[(z * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(N[(x / N[(y - t), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3300:\\
\;\;\;\;1 + \frac{x}{z \cdot \left(y - t\right)}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{\frac{x}{y - t}}{y}\\
\end{array}
\end{array}
if z < -3300Initial program 99.9%
Taylor expanded in z around inf 96.6%
+-commutative96.6%
*-commutative96.6%
Simplified96.6%
if -3300 < z Initial program 98.6%
Taylor expanded in z around 0 80.5%
associate-/r*80.4%
Simplified80.4%
Taylor expanded in x around 0 80.5%
*-commutative80.5%
associate-/r*81.0%
Simplified81.0%
Final simplification84.4%
(FPCore (x y z t) :precision binary64 (if (<= z -4.8e-143) 1.0 (+ 1.0 (/ x (* y t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -4.8e-143) {
tmp = 1.0;
} else {
tmp = 1.0 + (x / (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 (z <= (-4.8d-143)) then
tmp = 1.0d0
else
tmp = 1.0d0 + (x / (y * t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -4.8e-143) {
tmp = 1.0;
} else {
tmp = 1.0 + (x / (y * t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -4.8e-143: tmp = 1.0 else: tmp = 1.0 + (x / (y * t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -4.8e-143) tmp = 1.0; else tmp = Float64(1.0 + Float64(x / Float64(y * t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -4.8e-143) tmp = 1.0; else tmp = 1.0 + (x / (y * t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -4.8e-143], 1.0, N[(1.0 + N[(x / N[(y * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.8 \cdot 10^{-143}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{x}{y \cdot t}\\
\end{array}
\end{array}
if z < -4.7999999999999998e-143Initial program 100.0%
Taylor expanded in x around 0 80.0%
if -4.7999999999999998e-143 < z Initial program 98.2%
Taylor expanded in z around 0 77.4%
Taylor expanded in y around 0 60.9%
associate-*r/60.9%
neg-mul-160.9%
*-commutative60.9%
Simplified60.9%
expm1-log1p-u53.3%
expm1-udef53.3%
add-sqr-sqrt26.3%
sqrt-unprod46.8%
sqr-neg46.8%
sqrt-unprod26.1%
add-sqr-sqrt49.1%
Applied egg-rr49.1%
expm1-def49.1%
expm1-log1p51.9%
associate-/l/51.9%
Simplified51.9%
sub-neg51.9%
distribute-frac-neg51.9%
+-commutative51.9%
add-sqr-sqrt30.0%
sqrt-unprod55.1%
sqr-neg55.1%
sqrt-unprod33.6%
add-sqr-sqrt61.3%
associate-/l/60.9%
Applied egg-rr60.9%
Final simplification68.1%
(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 98.9%
Taylor expanded in x around 0 73.7%
Final simplification73.7%
herbie shell --seed 2023336
(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)))))