
(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 (/ 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.1%
Final simplification99.1%
(FPCore (x y z t) :precision binary64 (if (or (<= t -6.5e-114) (not (<= t 6e-115))) (+ 1.0 (/ (/ x t) (- y z))) (+ 1.0 (/ x (* y z)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -6.5e-114) || !(t <= 6e-115)) {
tmp = 1.0 + ((x / t) / (y - z));
} else {
tmp = 1.0 + (x / (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 ((t <= (-6.5d-114)) .or. (.not. (t <= 6d-115))) then
tmp = 1.0d0 + ((x / t) / (y - z))
else
tmp = 1.0d0 + (x / (y * z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -6.5e-114) || !(t <= 6e-115)) {
tmp = 1.0 + ((x / t) / (y - z));
} else {
tmp = 1.0 + (x / (y * z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -6.5e-114) or not (t <= 6e-115): tmp = 1.0 + ((x / t) / (y - z)) else: tmp = 1.0 + (x / (y * z)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -6.5e-114) || !(t <= 6e-115)) tmp = Float64(1.0 + Float64(Float64(x / t) / Float64(y - z))); else tmp = Float64(1.0 + Float64(x / Float64(y * z))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -6.5e-114) || ~((t <= 6e-115))) tmp = 1.0 + ((x / t) / (y - z)); else tmp = 1.0 + (x / (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -6.5e-114], N[Not[LessEqual[t, 6e-115]], $MachinePrecision]], N[(1.0 + N[(N[(x / t), $MachinePrecision] / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(x / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -6.5 \cdot 10^{-114} \lor \neg \left(t \leq 6 \cdot 10^{-115}\right):\\
\;\;\;\;1 + \frac{\frac{x}{t}}{y - z}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{x}{y \cdot z}\\
\end{array}
\end{array}
if t < -6.4999999999999998e-114 or 6.0000000000000003e-115 < t Initial program 100.0%
Taylor expanded in t around inf 96.6%
+-commutative96.6%
associate-/r*95.2%
Simplified95.2%
if -6.4999999999999998e-114 < t < 6.0000000000000003e-115Initial program 97.2%
Taylor expanded in z around inf 73.2%
+-commutative73.2%
associate-/r*75.4%
Simplified75.4%
Taylor expanded in y around inf 64.5%
Final simplification85.2%
(FPCore (x y z t)
:precision binary64
(if (<= z -1e-150)
(- 1.0 (/ (/ x z) (- t y)))
(if (<= z 2.7e-186)
(- 1.0 (/ x (* y (- y t))))
(+ 1.0 (/ (/ x t) (- y z))))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1e-150) {
tmp = 1.0 - ((x / z) / (t - y));
} else if (z <= 2.7e-186) {
tmp = 1.0 - (x / (y * (y - t)));
} else {
tmp = 1.0 + ((x / t) / (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 (z <= (-1d-150)) then
tmp = 1.0d0 - ((x / z) / (t - y))
else if (z <= 2.7d-186) then
tmp = 1.0d0 - (x / (y * (y - t)))
else
tmp = 1.0d0 + ((x / t) / (y - z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1e-150) {
tmp = 1.0 - ((x / z) / (t - y));
} else if (z <= 2.7e-186) {
tmp = 1.0 - (x / (y * (y - t)));
} else {
tmp = 1.0 + ((x / t) / (y - z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1e-150: tmp = 1.0 - ((x / z) / (t - y)) elif z <= 2.7e-186: tmp = 1.0 - (x / (y * (y - t))) else: tmp = 1.0 + ((x / t) / (y - z)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1e-150) tmp = Float64(1.0 - Float64(Float64(x / z) / Float64(t - y))); elseif (z <= 2.7e-186) tmp = Float64(1.0 - Float64(x / Float64(y * Float64(y - t)))); else tmp = Float64(1.0 + Float64(Float64(x / t) / Float64(y - z))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -1e-150) tmp = 1.0 - ((x / z) / (t - y)); elseif (z <= 2.7e-186) tmp = 1.0 - (x / (y * (y - t))); else tmp = 1.0 + ((x / t) / (y - z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -1e-150], N[(1.0 - N[(N[(x / z), $MachinePrecision] / N[(t - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.7e-186], N[(1.0 - N[(x / N[(y * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(x / t), $MachinePrecision] / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \cdot 10^{-150}:\\
\;\;\;\;1 - \frac{\frac{x}{z}}{t - y}\\
\mathbf{elif}\;z \leq 2.7 \cdot 10^{-186}:\\
\;\;\;\;1 - \frac{x}{y \cdot \left(y - t\right)}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{\frac{x}{t}}{y - z}\\
\end{array}
\end{array}
if z < -1.00000000000000001e-150Initial program 97.6%
Taylor expanded in z around inf 90.0%
+-commutative90.0%
associate-/r*92.2%
Simplified92.2%
if -1.00000000000000001e-150 < z < 2.6999999999999999e-186Initial program 99.3%
Taylor expanded in z around 0 95.6%
if 2.6999999999999999e-186 < z Initial program 100.0%
Taylor expanded in t around inf 80.3%
+-commutative80.3%
associate-/r*78.3%
Simplified78.3%
Final simplification86.3%
(FPCore (x y z t) :precision binary64 (if (<= y -8.2e-123) 1.0 (if (<= y 4.2e-86) (- 1.0 (/ x (* z t))) 1.0)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -8.2e-123) {
tmp = 1.0;
} else if (y <= 4.2e-86) {
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.2d-123)) then
tmp = 1.0d0
else if (y <= 4.2d-86) 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.2e-123) {
tmp = 1.0;
} else if (y <= 4.2e-86) {
tmp = 1.0 - (x / (z * t));
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -8.2e-123: tmp = 1.0 elif y <= 4.2e-86: tmp = 1.0 - (x / (z * t)) else: tmp = 1.0 return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -8.2e-123) tmp = 1.0; elseif (y <= 4.2e-86) 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.2e-123) tmp = 1.0; elseif (y <= 4.2e-86) tmp = 1.0 - (x / (z * t)); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -8.2e-123], 1.0, If[LessEqual[y, 4.2e-86], N[(1.0 - N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.2 \cdot 10^{-123}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 4.2 \cdot 10^{-86}:\\
\;\;\;\;1 - \frac{x}{z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -8.2000000000000001e-123 or 4.2e-86 < y Initial program 99.9%
Taylor expanded in x around 0 82.3%
if -8.2000000000000001e-123 < y < 4.2e-86Initial program 97.6%
Taylor expanded in y around 0 79.3%
Final simplification81.2%
(FPCore (x y z t) :precision binary64 (if (<= t 4.3e-75) (- 1.0 (/ (/ x z) (- t y))) (+ 1.0 (/ (/ x t) (- y z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= 4.3e-75) {
tmp = 1.0 - ((x / z) / (t - y));
} else {
tmp = 1.0 + ((x / t) / (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 (t <= 4.3d-75) then
tmp = 1.0d0 - ((x / z) / (t - y))
else
tmp = 1.0d0 + ((x / t) / (y - z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= 4.3e-75) {
tmp = 1.0 - ((x / z) / (t - y));
} else {
tmp = 1.0 + ((x / t) / (y - z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= 4.3e-75: tmp = 1.0 - ((x / z) / (t - y)) else: tmp = 1.0 + ((x / t) / (y - z)) return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= 4.3e-75) tmp = Float64(1.0 - Float64(Float64(x / z) / Float64(t - y))); else tmp = Float64(1.0 + Float64(Float64(x / t) / Float64(y - z))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= 4.3e-75) tmp = 1.0 - ((x / z) / (t - y)); else tmp = 1.0 + ((x / t) / (y - z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, 4.3e-75], N[(1.0 - N[(N[(x / z), $MachinePrecision] / N[(t - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(x / t), $MachinePrecision] / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq 4.3 \cdot 10^{-75}:\\
\;\;\;\;1 - \frac{\frac{x}{z}}{t - y}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{\frac{x}{t}}{y - z}\\
\end{array}
\end{array}
if t < 4.2999999999999999e-75Initial program 98.8%
Taylor expanded in z around inf 79.6%
+-commutative79.6%
associate-/r*79.5%
Simplified79.5%
if 4.2999999999999999e-75 < t Initial program 100.0%
Taylor expanded in t around inf 97.7%
+-commutative97.7%
associate-/r*97.6%
Simplified97.6%
Final simplification84.2%
(FPCore (x y z t) :precision binary64 (if (<= t 3.7e-177) (+ 1.0 (/ x (* y z))) 1.0))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= 3.7e-177) {
tmp = 1.0 + (x / (y * z));
} 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 <= 3.7d-177) then
tmp = 1.0d0 + (x / (y * z))
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 <= 3.7e-177) {
tmp = 1.0 + (x / (y * z));
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= 3.7e-177: tmp = 1.0 + (x / (y * z)) else: tmp = 1.0 return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= 3.7e-177) tmp = Float64(1.0 + Float64(x / Float64(y * z))); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= 3.7e-177) tmp = 1.0 + (x / (y * z)); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, 3.7e-177], N[(1.0 + N[(x / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq 3.7 \cdot 10^{-177}:\\
\;\;\;\;1 + \frac{x}{y \cdot z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if t < 3.69999999999999993e-177Initial program 98.6%
Taylor expanded in z around inf 80.5%
+-commutative80.5%
associate-/r*80.5%
Simplified80.5%
Taylor expanded in y around inf 64.2%
if 3.69999999999999993e-177 < t Initial program 100.0%
Taylor expanded in x around 0 76.8%
Final simplification68.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.1%
Taylor expanded in x around 0 72.0%
herbie shell --seed 2024100
(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)))))