
(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 7 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 (/ 1.0 (* (- y z) (/ (- t y) x)))))
double code(double x, double y, double z, double t) {
return 1.0 + (1.0 / ((y - z) * ((t - y) / x)));
}
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 + (1.0d0 / ((y - z) * ((t - y) / x)))
end function
public static double code(double x, double y, double z, double t) {
return 1.0 + (1.0 / ((y - z) * ((t - y) / x)));
}
def code(x, y, z, t): return 1.0 + (1.0 / ((y - z) * ((t - y) / x)))
function code(x, y, z, t) return Float64(1.0 + Float64(1.0 / Float64(Float64(y - z) * Float64(Float64(t - y) / x)))) end
function tmp = code(x, y, z, t) tmp = 1.0 + (1.0 / ((y - z) * ((t - y) / x))); end
code[x_, y_, z_, t_] := N[(1.0 + N[(1.0 / N[(N[(y - z), $MachinePrecision] * N[(N[(t - y), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{1}{\left(y - z\right) \cdot \frac{t - y}{x}}
\end{array}
Initial program 99.2%
clear-num99.2%
inv-pow99.2%
associate-/l*99.6%
Applied egg-rr99.6%
unpow-199.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x y z t) :precision binary64 (if (<= y -8.5e-44) 1.0 (if (<= y 2.4e-121) (- 1.0 (/ x (* z t))) 1.0)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -8.5e-44) {
tmp = 1.0;
} else if (y <= 2.4e-121) {
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 <= (-8.5d-44)) then
tmp = 1.0d0
else if (y <= 2.4d-121) 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 <= -8.5e-44) {
tmp = 1.0;
} else if (y <= 2.4e-121) {
tmp = 1.0 - (x / (z * t));
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -8.5e-44: tmp = 1.0 elif y <= 2.4e-121: tmp = 1.0 - (x / (z * t)) else: tmp = 1.0 return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -8.5e-44) tmp = 1.0; elseif (y <= 2.4e-121) 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 <= -8.5e-44) tmp = 1.0; elseif (y <= 2.4e-121) tmp = 1.0 - (x / (z * t)); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -8.5e-44], 1.0, If[LessEqual[y, 2.4e-121], N[(1.0 - N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.5 \cdot 10^{-44}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 2.4 \cdot 10^{-121}:\\
\;\;\;\;1 - \frac{x}{z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -8.5000000000000002e-44 or 2.40000000000000003e-121 < y Initial program 99.9%
Taylor expanded in x around 0 88.9%
if -8.5000000000000002e-44 < y < 2.40000000000000003e-121Initial program 98.0%
Taylor expanded in y around 0 79.1%
Final simplification85.3%
(FPCore (x y z t) :precision binary64 (if (<= z -2.1e-43) (- 1.0 (/ (/ x z) (- t y))) (+ 1.0 (/ (/ x y) (- t y)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -2.1e-43) {
tmp = 1.0 - ((x / z) / (t - y));
} 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 <= (-2.1d-43)) then
tmp = 1.0d0 - ((x / z) / (t - y))
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 <= -2.1e-43) {
tmp = 1.0 - ((x / z) / (t - y));
} else {
tmp = 1.0 + ((x / y) / (t - y));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -2.1e-43: tmp = 1.0 - ((x / z) / (t - y)) else: tmp = 1.0 + ((x / y) / (t - y)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -2.1e-43) tmp = Float64(1.0 - Float64(Float64(x / z) / Float64(t - y))); else tmp = Float64(1.0 + Float64(Float64(x / y) / Float64(t - y))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -2.1e-43) tmp = 1.0 - ((x / z) / (t - y)); else tmp = 1.0 + ((x / y) / (t - y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -2.1e-43], N[(1.0 - N[(N[(x / z), $MachinePrecision] / N[(t - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(x / y), $MachinePrecision] / N[(t - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.1 \cdot 10^{-43}:\\
\;\;\;\;1 - \frac{\frac{x}{z}}{t - y}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{\frac{x}{y}}{t - y}\\
\end{array}
\end{array}
if z < -2.1000000000000001e-43Initial program 100.0%
Taylor expanded in z around inf 96.8%
associate-/r*96.7%
Simplified96.7%
if -2.1000000000000001e-43 < z Initial program 98.9%
Taylor expanded in z around 0 79.7%
sub-neg79.7%
associate-/r*79.7%
distribute-neg-frac279.7%
neg-sub079.7%
sub-neg79.7%
+-commutative79.7%
associate--r+79.7%
neg-sub079.7%
remove-double-neg79.7%
Simplified79.7%
Final simplification84.1%
(FPCore (x y z t) :precision binary64 (if (<= z -3.1e-57) 1.0 (+ 1.0 (/ (/ x y) (- t y)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3.1e-57) {
tmp = 1.0;
} 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 <= (-3.1d-57)) then
tmp = 1.0d0
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 <= -3.1e-57) {
tmp = 1.0;
} else {
tmp = 1.0 + ((x / y) / (t - y));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -3.1e-57: tmp = 1.0 else: tmp = 1.0 + ((x / y) / (t - y)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -3.1e-57) tmp = 1.0; else tmp = Float64(1.0 + Float64(Float64(x / y) / Float64(t - y))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -3.1e-57) tmp = 1.0; else tmp = 1.0 + ((x / y) / (t - y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -3.1e-57], 1.0, N[(1.0 + N[(N[(x / y), $MachinePrecision] / N[(t - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.1 \cdot 10^{-57}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{\frac{x}{y}}{t - y}\\
\end{array}
\end{array}
if z < -3.09999999999999976e-57Initial program 100.0%
Taylor expanded in x around 0 88.8%
if -3.09999999999999976e-57 < z Initial program 98.9%
Taylor expanded in z around 0 79.4%
sub-neg79.4%
associate-/r*79.3%
distribute-neg-frac279.3%
neg-sub079.3%
sub-neg79.3%
+-commutative79.3%
associate--r+79.3%
neg-sub079.3%
remove-double-neg79.3%
Simplified79.3%
(FPCore (x y z t) :precision binary64 (if (<= z -9e-255) 1.0 (+ 1.0 (/ (/ x y) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -9e-255) {
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 <= (-9d-255)) 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 <= -9e-255) {
tmp = 1.0;
} else {
tmp = 1.0 + ((x / y) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -9e-255: tmp = 1.0 else: tmp = 1.0 + ((x / y) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -9e-255) tmp = 1.0; else tmp = Float64(1.0 + Float64(Float64(x / y) / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -9e-255) tmp = 1.0; else tmp = 1.0 + ((x / y) / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -9e-255], 1.0, N[(1.0 + N[(N[(x / y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9 \cdot 10^{-255}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{\frac{x}{y}}{t}\\
\end{array}
\end{array}
if z < -8.99999999999999959e-255Initial program 100.0%
Taylor expanded in x around 0 83.1%
if -8.99999999999999959e-255 < z Initial program 98.7%
Taylor expanded in z around 0 76.6%
sub-neg76.6%
associate-/r*77.8%
distribute-neg-frac277.8%
neg-sub077.8%
sub-neg77.8%
+-commutative77.8%
associate--r+77.8%
neg-sub077.8%
remove-double-neg77.8%
Simplified77.8%
Taylor expanded in t around inf 58.9%
(FPCore (x y z t) :precision binary64 (+ 1.0 (/ x (* (- y z) (- t y)))))
double code(double x, double y, double z, double t) {
return 1.0 + (x / ((y - z) * (t - y)));
}
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) * (t - y)))
end function
public static double code(double x, double y, double z, double t) {
return 1.0 + (x / ((y - z) * (t - y)));
}
def code(x, y, z, t): return 1.0 + (x / ((y - z) * (t - y)))
function code(x, y, z, t) return Float64(1.0 + Float64(x / Float64(Float64(y - z) * Float64(t - y)))) end
function tmp = code(x, y, z, t) tmp = 1.0 + (x / ((y - z) * (t - y))); end
code[x_, y_, z_, t_] := N[(1.0 + N[(x / N[(N[(y - z), $MachinePrecision] * N[(t - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{x}{\left(y - z\right) \cdot \left(t - y\right)}
\end{array}
Initial program 99.2%
Final simplification99.2%
(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.2%
Taylor expanded in x around 0 80.2%
herbie shell --seed 2024141
(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)))))