
(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.2%
Final simplification99.2%
(FPCore (x y z t)
:precision binary64
(if (<= y -8.5e-79)
1.0
(if (<= y 7.8e-91)
(- 1.0 (/ x (* z t)))
(if (<= y 6.4e-14) (+ 1.0 (/ x (* y t))) (- 1.0 (/ (/ x y) y))))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -8.5e-79) {
tmp = 1.0;
} else if (y <= 7.8e-91) {
tmp = 1.0 - (x / (z * t));
} else if (y <= 6.4e-14) {
tmp = 1.0 + (x / (y * t));
} else {
tmp = 1.0 - ((x / y) / 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 <= (-8.5d-79)) then
tmp = 1.0d0
else if (y <= 7.8d-91) then
tmp = 1.0d0 - (x / (z * t))
else if (y <= 6.4d-14) then
tmp = 1.0d0 + (x / (y * t))
else
tmp = 1.0d0 - ((x / y) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -8.5e-79) {
tmp = 1.0;
} else if (y <= 7.8e-91) {
tmp = 1.0 - (x / (z * t));
} else if (y <= 6.4e-14) {
tmp = 1.0 + (x / (y * t));
} else {
tmp = 1.0 - ((x / y) / y);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -8.5e-79: tmp = 1.0 elif y <= 7.8e-91: tmp = 1.0 - (x / (z * t)) elif y <= 6.4e-14: tmp = 1.0 + (x / (y * t)) else: tmp = 1.0 - ((x / y) / y) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -8.5e-79) tmp = 1.0; elseif (y <= 7.8e-91) tmp = Float64(1.0 - Float64(x / Float64(z * t))); elseif (y <= 6.4e-14) tmp = Float64(1.0 + Float64(x / Float64(y * t))); else tmp = Float64(1.0 - Float64(Float64(x / y) / y)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -8.5e-79) tmp = 1.0; elseif (y <= 7.8e-91) tmp = 1.0 - (x / (z * t)); elseif (y <= 6.4e-14) tmp = 1.0 + (x / (y * t)); else tmp = 1.0 - ((x / y) / y); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -8.5e-79], 1.0, If[LessEqual[y, 7.8e-91], N[(1.0 - N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 6.4e-14], N[(1.0 + N[(x / N[(y * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.5 \cdot 10^{-79}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 7.8 \cdot 10^{-91}:\\
\;\;\;\;1 - \frac{x}{z \cdot t}\\
\mathbf{elif}\;y \leq 6.4 \cdot 10^{-14}:\\
\;\;\;\;1 + \frac{x}{y \cdot t}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{\frac{x}{y}}{y}\\
\end{array}
\end{array}
if y < -8.50000000000000029e-79Initial program 100.0%
Taylor expanded in x around 0 88.6%
if -8.50000000000000029e-79 < y < 7.79999999999999987e-91Initial program 97.9%
Taylor expanded in y around 0 81.3%
if 7.79999999999999987e-91 < y < 6.4000000000000005e-14Initial program 99.9%
Taylor expanded in t around inf 73.0%
+-commutative73.0%
associate-/r*72.9%
Simplified72.9%
Taylor expanded in y around inf 57.2%
if 6.4000000000000005e-14 < y Initial program 99.9%
Taylor expanded in z around 0 98.2%
associate-/r*98.2%
Simplified98.2%
Taylor expanded in y around inf 96.4%
Final simplification84.1%
(FPCore (x y z t)
:precision binary64
(if (<= t -7e-89)
(+ 1.0 (/ -1.0 (* t (/ z x))))
(if (<= t 1.15e-22)
(+ 1.0 (/ x (* y (- z y))))
(+ 1.0 (/ (/ x t) (- y z))))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -7e-89) {
tmp = 1.0 + (-1.0 / (t * (z / x)));
} else if (t <= 1.15e-22) {
tmp = 1.0 + (x / (y * (z - 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 <= (-7d-89)) then
tmp = 1.0d0 + ((-1.0d0) / (t * (z / x)))
else if (t <= 1.15d-22) then
tmp = 1.0d0 + (x / (y * (z - 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 <= -7e-89) {
tmp = 1.0 + (-1.0 / (t * (z / x)));
} else if (t <= 1.15e-22) {
tmp = 1.0 + (x / (y * (z - y)));
} else {
tmp = 1.0 + ((x / t) / (y - z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -7e-89: tmp = 1.0 + (-1.0 / (t * (z / x))) elif t <= 1.15e-22: tmp = 1.0 + (x / (y * (z - y))) else: tmp = 1.0 + ((x / t) / (y - z)) return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -7e-89) tmp = Float64(1.0 + Float64(-1.0 / Float64(t * Float64(z / x)))); elseif (t <= 1.15e-22) tmp = Float64(1.0 + Float64(x / Float64(y * Float64(z - 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 <= -7e-89) tmp = 1.0 + (-1.0 / (t * (z / x))); elseif (t <= 1.15e-22) tmp = 1.0 + (x / (y * (z - y))); else tmp = 1.0 + ((x / t) / (y - z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -7e-89], N[(1.0 + N[(-1.0 / N[(t * N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 1.15e-22], N[(1.0 + N[(x / N[(y * N[(z - y), $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}\;t \leq -7 \cdot 10^{-89}:\\
\;\;\;\;1 + \frac{-1}{t \cdot \frac{z}{x}}\\
\mathbf{elif}\;t \leq 1.15 \cdot 10^{-22}:\\
\;\;\;\;1 + \frac{x}{y \cdot \left(z - y\right)}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{\frac{x}{t}}{y - z}\\
\end{array}
\end{array}
if t < -6.9999999999999994e-89Initial program 99.9%
Taylor expanded in y around 0 79.7%
clear-num79.8%
inv-pow79.8%
Applied egg-rr79.8%
unpow-179.8%
associate-/l*78.5%
Simplified78.5%
if -6.9999999999999994e-89 < t < 1.1499999999999999e-22Initial program 98.3%
Taylor expanded in y around inf 89.6%
if 1.1499999999999999e-22 < t Initial program 99.9%
Taylor expanded in t around inf 95.9%
+-commutative95.9%
associate-/r*95.8%
Simplified95.8%
Final simplification87.9%
(FPCore (x y z t) :precision binary64 (if (<= y -6.5e-11) 1.0 (if (<= y 1.72e-13) (+ 1.0 (/ (/ x t) (- y z))) (- 1.0 (/ (/ x y) y)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -6.5e-11) {
tmp = 1.0;
} else if (y <= 1.72e-13) {
tmp = 1.0 + ((x / t) / (y - z));
} else {
tmp = 1.0 - ((x / y) / 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 <= (-6.5d-11)) then
tmp = 1.0d0
else if (y <= 1.72d-13) then
tmp = 1.0d0 + ((x / t) / (y - z))
else
tmp = 1.0d0 - ((x / y) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -6.5e-11) {
tmp = 1.0;
} else if (y <= 1.72e-13) {
tmp = 1.0 + ((x / t) / (y - z));
} else {
tmp = 1.0 - ((x / y) / y);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -6.5e-11: tmp = 1.0 elif y <= 1.72e-13: tmp = 1.0 + ((x / t) / (y - z)) else: tmp = 1.0 - ((x / y) / y) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -6.5e-11) tmp = 1.0; elseif (y <= 1.72e-13) tmp = Float64(1.0 + Float64(Float64(x / t) / Float64(y - z))); else tmp = Float64(1.0 - Float64(Float64(x / y) / y)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -6.5e-11) tmp = 1.0; elseif (y <= 1.72e-13) tmp = 1.0 + ((x / t) / (y - z)); else tmp = 1.0 - ((x / y) / y); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -6.5e-11], 1.0, If[LessEqual[y, 1.72e-13], N[(1.0 + N[(N[(x / t), $MachinePrecision] / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.5 \cdot 10^{-11}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.72 \cdot 10^{-13}:\\
\;\;\;\;1 + \frac{\frac{x}{t}}{y - z}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{\frac{x}{y}}{y}\\
\end{array}
\end{array}
if y < -6.49999999999999953e-11Initial program 100.0%
Taylor expanded in x around 0 95.0%
if -6.49999999999999953e-11 < y < 1.71999999999999999e-13Initial program 98.6%
Taylor expanded in t around inf 84.5%
+-commutative84.5%
associate-/r*83.8%
Simplified83.8%
if 1.71999999999999999e-13 < y Initial program 99.9%
Taylor expanded in z around 0 98.2%
associate-/r*98.2%
Simplified98.2%
Taylor expanded in y around inf 96.4%
Final simplification88.9%
(FPCore (x y z t) :precision binary64 (if (<= y -5.5e-77) 1.0 (if (<= y 2.25e-73) (- 1.0 (/ x (* z t))) 1.0)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -5.5e-77) {
tmp = 1.0;
} else if (y <= 2.25e-73) {
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 <= (-5.5d-77)) then
tmp = 1.0d0
else if (y <= 2.25d-73) 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 <= -5.5e-77) {
tmp = 1.0;
} else if (y <= 2.25e-73) {
tmp = 1.0 - (x / (z * t));
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -5.5e-77: tmp = 1.0 elif y <= 2.25e-73: tmp = 1.0 - (x / (z * t)) else: tmp = 1.0 return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -5.5e-77) tmp = 1.0; elseif (y <= 2.25e-73) 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 <= -5.5e-77) tmp = 1.0; elseif (y <= 2.25e-73) tmp = 1.0 - (x / (z * t)); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -5.5e-77], 1.0, If[LessEqual[y, 2.25e-73], N[(1.0 - N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.5 \cdot 10^{-77}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 2.25 \cdot 10^{-73}:\\
\;\;\;\;1 - \frac{x}{z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -5.49999999999999998e-77 or 2.25e-73 < y Initial program 100.0%
Taylor expanded in x around 0 85.6%
if -5.49999999999999998e-77 < y < 2.25e-73Initial program 98.0%
Taylor expanded in y around 0 79.4%
Final simplification83.1%
(FPCore (x y z t) :precision binary64 (if (<= z -1.25e-247) 1.0 (if (<= z 1.3e-194) (+ 1.0 (/ x (* y t))) 1.0)))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.25e-247) {
tmp = 1.0;
} else if (z <= 1.3e-194) {
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 (z <= (-1.25d-247)) then
tmp = 1.0d0
else if (z <= 1.3d-194) 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 (z <= -1.25e-247) {
tmp = 1.0;
} else if (z <= 1.3e-194) {
tmp = 1.0 + (x / (y * t));
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1.25e-247: tmp = 1.0 elif z <= 1.3e-194: tmp = 1.0 + (x / (y * t)) else: tmp = 1.0 return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1.25e-247) tmp = 1.0; elseif (z <= 1.3e-194) 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 (z <= -1.25e-247) tmp = 1.0; elseif (z <= 1.3e-194) tmp = 1.0 + (x / (y * t)); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.25e-247], 1.0, If[LessEqual[z, 1.3e-194], N[(1.0 + N[(x / N[(y * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.25 \cdot 10^{-247}:\\
\;\;\;\;1\\
\mathbf{elif}\;z \leq 1.3 \cdot 10^{-194}:\\
\;\;\;\;1 + \frac{x}{y \cdot t}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if z < -1.24999999999999994e-247 or 1.30000000000000001e-194 < z Initial program 99.9%
Taylor expanded in x around 0 75.9%
if -1.24999999999999994e-247 < z < 1.30000000000000001e-194Initial program 93.9%
Taylor expanded in t around inf 78.5%
+-commutative78.5%
associate-/r*78.5%
Simplified78.5%
Taylor expanded in y around inf 72.9%
Final simplification75.6%
(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 72.8%
herbie shell --seed 2024110
(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)))))