
(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) (- 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.3%
Final simplification99.3%
(FPCore (x y z t) :precision binary64 (if (<= z -5.1e-25) (- 1.0 (/ x (* z (- t y)))) (+ 1.0 (/ 1.0 (* (/ y x) (- t y))))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -5.1e-25) {
tmp = 1.0 - (x / (z * (t - y)));
} else {
tmp = 1.0 + (1.0 / ((y / x) * (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 <= (-5.1d-25)) then
tmp = 1.0d0 - (x / (z * (t - y)))
else
tmp = 1.0d0 + (1.0d0 / ((y / x) * (t - y)))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -5.1e-25) {
tmp = 1.0 - (x / (z * (t - y)));
} else {
tmp = 1.0 + (1.0 / ((y / x) * (t - y)));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -5.1e-25: tmp = 1.0 - (x / (z * (t - y))) else: tmp = 1.0 + (1.0 / ((y / x) * (t - y))) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -5.1e-25) tmp = Float64(1.0 - Float64(x / Float64(z * Float64(t - y)))); else tmp = Float64(1.0 + Float64(1.0 / Float64(Float64(y / x) * Float64(t - y)))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -5.1e-25) tmp = 1.0 - (x / (z * (t - y))); else tmp = 1.0 + (1.0 / ((y / x) * (t - y))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -5.1e-25], N[(1.0 - N[(x / N[(z * N[(t - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(1.0 / N[(N[(y / x), $MachinePrecision] * N[(t - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.1 \cdot 10^{-25}:\\
\;\;\;\;1 - \frac{x}{z \cdot \left(t - y\right)}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{1}{\frac{y}{x} \cdot \left(t - y\right)}\\
\end{array}
\end{array}
if z < -5.1000000000000003e-25Initial program 100.0%
Taylor expanded in z around inf 95.4%
associate-*r/95.4%
neg-mul-195.4%
*-commutative95.4%
Simplified95.4%
if -5.1000000000000003e-25 < z Initial program 99.0%
Taylor expanded in z around 0 77.3%
associate-/r*77.8%
Simplified77.8%
clear-num77.8%
inv-pow77.8%
div-inv77.8%
clear-num77.8%
Applied egg-rr77.8%
unpow-177.8%
Simplified77.8%
Final simplification82.3%
(FPCore (x y z t) :precision binary64 (if (<= y 1.8e-102) 1.0 (+ 1.0 (/ (/ x y) (- z y)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.8e-102) {
tmp = 1.0;
} else {
tmp = 1.0 + ((x / y) / (z - 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 (y <= 1.8d-102) then
tmp = 1.0d0
else
tmp = 1.0d0 + ((x / y) / (z - y))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.8e-102) {
tmp = 1.0;
} else {
tmp = 1.0 + ((x / y) / (z - y));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.8e-102: tmp = 1.0 else: tmp = 1.0 + ((x / y) / (z - y)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.8e-102) tmp = 1.0; else tmp = Float64(1.0 + Float64(Float64(x / y) / Float64(z - y))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1.8e-102) tmp = 1.0; else tmp = 1.0 + ((x / y) / (z - y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.8e-102], 1.0, N[(1.0 + N[(N[(x / y), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.8 \cdot 10^{-102}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{\frac{x}{y}}{z - y}\\
\end{array}
\end{array}
if y < 1.8e-102Initial program 99.0%
Taylor expanded in t around inf 84.7%
associate-*r/84.7%
neg-mul-184.7%
Simplified84.7%
Taylor expanded in y around inf 56.9%
div-inv56.9%
add-sqr-sqrt31.4%
sqrt-unprod50.6%
sqr-neg50.6%
sqrt-unprod23.5%
add-sqr-sqrt49.2%
*-commutative49.2%
Applied egg-rr49.2%
associate-*r/49.2%
*-rgt-identity49.2%
associate-/l/49.2%
Simplified49.2%
Taylor expanded in x around 0 74.8%
if 1.8e-102 < y Initial program 100.0%
Taylor expanded in t around 0 90.9%
associate-/r*90.9%
Simplified90.9%
Final simplification79.4%
(FPCore (x y z t) :precision binary64 (if (<= t 3100000000000.0) (+ 1.0 (/ (/ x y) (- z y))) (+ 1.0 (/ 1.0 (* t (/ y x))))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= 3100000000000.0) {
tmp = 1.0 + ((x / y) / (z - y));
} else {
tmp = 1.0 + (1.0 / (t * (y / 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
real(8) :: tmp
if (t <= 3100000000000.0d0) then
tmp = 1.0d0 + ((x / y) / (z - y))
else
tmp = 1.0d0 + (1.0d0 / (t * (y / x)))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= 3100000000000.0) {
tmp = 1.0 + ((x / y) / (z - y));
} else {
tmp = 1.0 + (1.0 / (t * (y / x)));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= 3100000000000.0: tmp = 1.0 + ((x / y) / (z - y)) else: tmp = 1.0 + (1.0 / (t * (y / x))) return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= 3100000000000.0) tmp = Float64(1.0 + Float64(Float64(x / y) / Float64(z - y))); else tmp = Float64(1.0 + Float64(1.0 / Float64(t * Float64(y / x)))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= 3100000000000.0) tmp = 1.0 + ((x / y) / (z - y)); else tmp = 1.0 + (1.0 / (t * (y / x))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, 3100000000000.0], N[(1.0 + N[(N[(x / y), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(1.0 / N[(t * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq 3100000000000:\\
\;\;\;\;1 + \frac{\frac{x}{y}}{z - y}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{1}{t \cdot \frac{y}{x}}\\
\end{array}
\end{array}
if t < 3.1e12Initial program 99.0%
Taylor expanded in t around 0 77.2%
associate-/r*76.7%
Simplified76.7%
if 3.1e12 < t Initial program 100.0%
Taylor expanded in z around 0 82.1%
associate-/r*80.4%
Simplified80.4%
clear-num80.4%
inv-pow80.4%
div-inv80.4%
clear-num80.4%
Applied egg-rr80.4%
unpow-180.4%
Simplified80.4%
Taylor expanded in y around 0 81.4%
mul-1-neg81.4%
associate-/l*79.7%
distribute-rgt-neg-in79.7%
distribute-neg-frac279.7%
Simplified79.7%
Final simplification77.4%
(FPCore (x y z t) :precision binary64 (if (<= y -1.4e-102) (+ 1.0 (/ x (* y (- z y)))) (+ 1.0 (/ x (* (- y z) t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.4e-102) {
tmp = 1.0 + (x / (y * (z - y)));
} else {
tmp = 1.0 + (x / ((y - z) * 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 <= (-1.4d-102)) then
tmp = 1.0d0 + (x / (y * (z - y)))
else
tmp = 1.0d0 + (x / ((y - z) * t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.4e-102) {
tmp = 1.0 + (x / (y * (z - y)));
} else {
tmp = 1.0 + (x / ((y - z) * t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1.4e-102: tmp = 1.0 + (x / (y * (z - y))) else: tmp = 1.0 + (x / ((y - z) * t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1.4e-102) tmp = Float64(1.0 + Float64(x / Float64(y * Float64(z - y)))); else tmp = Float64(1.0 + Float64(x / Float64(Float64(y - z) * t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -1.4e-102) tmp = 1.0 + (x / (y * (z - y))); else tmp = 1.0 + (x / ((y - z) * t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.4e-102], N[(1.0 + N[(x / N[(y * N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(x / N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.4 \cdot 10^{-102}:\\
\;\;\;\;1 + \frac{x}{y \cdot \left(z - y\right)}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{x}{\left(y - z\right) \cdot t}\\
\end{array}
\end{array}
if y < -1.40000000000000006e-102Initial program 100.0%
clear-num100.0%
associate-/r/99.9%
Applied egg-rr99.9%
Taylor expanded in t around 0 93.0%
if -1.40000000000000006e-102 < y Initial program 98.8%
Taylor expanded in t around inf 83.8%
associate-*r/83.8%
neg-mul-183.8%
Simplified83.8%
Final simplification87.4%
(FPCore (x y z t) :precision binary64 (if (<= y -9e-29) (+ 1.0 (/ x (* y (- t y)))) (- 1.0 (/ x (* z (- t y))))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -9e-29) {
tmp = 1.0 + (x / (y * (t - y)));
} else {
tmp = 1.0 - (x / (z * (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 (y <= (-9d-29)) then
tmp = 1.0d0 + (x / (y * (t - y)))
else
tmp = 1.0d0 - (x / (z * (t - y)))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -9e-29) {
tmp = 1.0 + (x / (y * (t - y)));
} else {
tmp = 1.0 - (x / (z * (t - y)));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -9e-29: tmp = 1.0 + (x / (y * (t - y))) else: tmp = 1.0 - (x / (z * (t - y))) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -9e-29) tmp = Float64(1.0 + Float64(x / Float64(y * Float64(t - y)))); else tmp = Float64(1.0 - Float64(x / Float64(z * Float64(t - y)))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -9e-29) tmp = 1.0 + (x / (y * (t - y))); else tmp = 1.0 - (x / (z * (t - y))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -9e-29], N[(1.0 + N[(x / N[(y * N[(t - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(x / N[(z * N[(t - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9 \cdot 10^{-29}:\\
\;\;\;\;1 + \frac{x}{y \cdot \left(t - y\right)}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{z \cdot \left(t - y\right)}\\
\end{array}
\end{array}
if y < -8.9999999999999996e-29Initial program 100.0%
Taylor expanded in z around 0 94.1%
if -8.9999999999999996e-29 < y Initial program 98.9%
Taylor expanded in z around inf 83.6%
associate-*r/83.6%
neg-mul-183.6%
*-commutative83.6%
Simplified83.6%
Final simplification87.2%
(FPCore (x y z t) :precision binary64 (if (<= y -1.25e-28) (+ 1.0 (/ x (* y (- t y)))) (+ 1.0 (/ (/ x z) (- y t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.25e-28) {
tmp = 1.0 + (x / (y * (t - y)));
} else {
tmp = 1.0 + ((x / z) / (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 <= (-1.25d-28)) then
tmp = 1.0d0 + (x / (y * (t - y)))
else
tmp = 1.0d0 + ((x / z) / (y - t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.25e-28) {
tmp = 1.0 + (x / (y * (t - y)));
} else {
tmp = 1.0 + ((x / z) / (y - t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1.25e-28: tmp = 1.0 + (x / (y * (t - y))) else: tmp = 1.0 + ((x / z) / (y - t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1.25e-28) tmp = Float64(1.0 + Float64(x / Float64(y * Float64(t - y)))); else tmp = Float64(1.0 + Float64(Float64(x / z) / Float64(y - t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -1.25e-28) tmp = 1.0 + (x / (y * (t - y))); else tmp = 1.0 + ((x / z) / (y - t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.25e-28], N[(1.0 + N[(x / N[(y * N[(t - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(x / z), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.25 \cdot 10^{-28}:\\
\;\;\;\;1 + \frac{x}{y \cdot \left(t - y\right)}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{\frac{x}{z}}{y - t}\\
\end{array}
\end{array}
if y < -1.25e-28Initial program 100.0%
Taylor expanded in z around 0 94.1%
if -1.25e-28 < y Initial program 98.9%
Taylor expanded in z around inf 83.6%
mul-1-neg83.6%
associate-/r*83.0%
distribute-neg-frac83.0%
Simplified83.0%
Final simplification86.8%
(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.3%
Taylor expanded in t around inf 82.5%
associate-*r/82.5%
neg-mul-182.5%
Simplified82.5%
Taylor expanded in y around inf 59.5%
div-inv59.5%
add-sqr-sqrt31.4%
sqrt-unprod52.3%
sqr-neg52.3%
sqrt-unprod26.5%
add-sqr-sqrt53.2%
*-commutative53.2%
Applied egg-rr53.2%
associate-*r/53.2%
*-rgt-identity53.2%
associate-/l/53.1%
Simplified53.1%
Taylor expanded in x around 0 77.5%
Final simplification77.5%
herbie shell --seed 2024066
(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)))))