
(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}
NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (- 1.0 (/ (/ x (- y t)) (- y z))))
assert(z < t);
double code(double x, double y, double z, double t) {
return 1.0 - ((x / (y - t)) / (y - z));
}
NOTE: z and t should be sorted in increasing order before calling this function.
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 - t)) / (y - z))
end function
assert z < t;
public static double code(double x, double y, double z, double t) {
return 1.0 - ((x / (y - t)) / (y - z));
}
[z, t] = sort([z, t]) def code(x, y, z, t): return 1.0 - ((x / (y - t)) / (y - z))
z, t = sort([z, t]) function code(x, y, z, t) return Float64(1.0 - Float64(Float64(x / Float64(y - t)) / Float64(y - z))) end
z, t = num2cell(sort([z, t])){:}
function tmp = code(x, y, z, t)
tmp = 1.0 - ((x / (y - t)) / (y - z));
end
NOTE: z and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := N[(1.0 - N[(N[(x / N[(y - t), $MachinePrecision]), $MachinePrecision] / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
1 - \frac{\frac{x}{y - t}}{y - z}
\end{array}
Initial program 99.6%
associate-/l/99.5%
Simplified99.5%
Final simplification99.5%
NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (or (<= y -7.5e-69) (not (<= y 1.3e-149))) (- 1.0 (/ x (* y (- y z)))) (- 1.0 (/ (/ x t) z))))
assert(z < t);
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -7.5e-69) || !(y <= 1.3e-149)) {
tmp = 1.0 - (x / (y * (y - z)));
} else {
tmp = 1.0 - ((x / t) / z);
}
return tmp;
}
NOTE: z and t should be sorted in increasing order before calling this function.
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 <= (-7.5d-69)) .or. (.not. (y <= 1.3d-149))) then
tmp = 1.0d0 - (x / (y * (y - z)))
else
tmp = 1.0d0 - ((x / t) / z)
end if
code = tmp
end function
assert z < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -7.5e-69) || !(y <= 1.3e-149)) {
tmp = 1.0 - (x / (y * (y - z)));
} else {
tmp = 1.0 - ((x / t) / z);
}
return tmp;
}
[z, t] = sort([z, t]) def code(x, y, z, t): tmp = 0 if (y <= -7.5e-69) or not (y <= 1.3e-149): tmp = 1.0 - (x / (y * (y - z))) else: tmp = 1.0 - ((x / t) / z) return tmp
z, t = sort([z, t]) function code(x, y, z, t) tmp = 0.0 if ((y <= -7.5e-69) || !(y <= 1.3e-149)) tmp = Float64(1.0 - Float64(x / Float64(y * Float64(y - z)))); else tmp = Float64(1.0 - Float64(Float64(x / t) / z)); end return tmp end
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if ((y <= -7.5e-69) || ~((y <= 1.3e-149)))
tmp = 1.0 - (x / (y * (y - z)));
else
tmp = 1.0 - ((x / t) / z);
end
tmp_2 = tmp;
end
NOTE: z and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[Or[LessEqual[y, -7.5e-69], N[Not[LessEqual[y, 1.3e-149]], $MachinePrecision]], N[(1.0 - N[(x / N[(y * N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(N[(x / t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.5 \cdot 10^{-69} \lor \neg \left(y \leq 1.3 \cdot 10^{-149}\right):\\
\;\;\;\;1 - \frac{x}{y \cdot \left(y - z\right)}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{\frac{x}{t}}{z}\\
\end{array}
\end{array}
if y < -7.5e-69 or 1.29999999999999999e-149 < y Initial program 100.0%
Taylor expanded in t around 0 87.7%
if -7.5e-69 < y < 1.29999999999999999e-149Initial program 98.6%
Taylor expanded in y around 0 87.2%
associate-/r*88.5%
Simplified88.5%
Final simplification87.9%
NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (or (<= t -4.1e-107) (not (<= t 5e-104))) (+ 1.0 (/ (/ x t) (- y z))) (- 1.0 (/ x (* y (- y z))))))
assert(z < t);
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -4.1e-107) || !(t <= 5e-104)) {
tmp = 1.0 + ((x / t) / (y - z));
} else {
tmp = 1.0 - (x / (y * (y - z)));
}
return tmp;
}
NOTE: z and t should be sorted in increasing order before calling this function.
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.1d-107)) .or. (.not. (t <= 5d-104))) then
tmp = 1.0d0 + ((x / t) / (y - z))
else
tmp = 1.0d0 - (x / (y * (y - z)))
end if
code = tmp
end function
assert z < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -4.1e-107) || !(t <= 5e-104)) {
tmp = 1.0 + ((x / t) / (y - z));
} else {
tmp = 1.0 - (x / (y * (y - z)));
}
return tmp;
}
[z, t] = sort([z, t]) def code(x, y, z, t): tmp = 0 if (t <= -4.1e-107) or not (t <= 5e-104): tmp = 1.0 + ((x / t) / (y - z)) else: tmp = 1.0 - (x / (y * (y - z))) return tmp
z, t = sort([z, t]) function code(x, y, z, t) tmp = 0.0 if ((t <= -4.1e-107) || !(t <= 5e-104)) tmp = Float64(1.0 + Float64(Float64(x / t) / Float64(y - z))); else tmp = Float64(1.0 - Float64(x / Float64(y * Float64(y - z)))); end return tmp end
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if ((t <= -4.1e-107) || ~((t <= 5e-104)))
tmp = 1.0 + ((x / t) / (y - z));
else
tmp = 1.0 - (x / (y * (y - z)));
end
tmp_2 = tmp;
end
NOTE: z and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[Or[LessEqual[t, -4.1e-107], N[Not[LessEqual[t, 5e-104]], $MachinePrecision]], N[(1.0 + N[(N[(x / t), $MachinePrecision] / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(x / N[(y * N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;t \leq -4.1 \cdot 10^{-107} \lor \neg \left(t \leq 5 \cdot 10^{-104}\right):\\
\;\;\;\;1 + \frac{\frac{x}{t}}{y - z}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{y \cdot \left(y - z\right)}\\
\end{array}
\end{array}
if t < -4.0999999999999999e-107 or 4.99999999999999979e-104 < t Initial program 100.0%
Taylor expanded in t around inf 96.5%
mul-1-neg96.5%
distribute-frac-neg96.5%
associate-/r*96.5%
Simplified96.5%
if -4.0999999999999999e-107 < t < 4.99999999999999979e-104Initial program 98.9%
Taylor expanded in t around 0 91.6%
Final simplification95.0%
NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= y -5.2e-66) (- 1.0 (/ x (* y (- y z)))) (if (<= y 1.95e-115) (- 1.0 (/ (/ x t) z)) (- 1.0 (/ x (* y (- y t)))))))
assert(z < t);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -5.2e-66) {
tmp = 1.0 - (x / (y * (y - z)));
} else if (y <= 1.95e-115) {
tmp = 1.0 - ((x / t) / z);
} else {
tmp = 1.0 - (x / (y * (y - t)));
}
return tmp;
}
NOTE: z and t should be sorted in increasing order before calling this function.
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.2d-66)) then
tmp = 1.0d0 - (x / (y * (y - z)))
else if (y <= 1.95d-115) then
tmp = 1.0d0 - ((x / t) / z)
else
tmp = 1.0d0 - (x / (y * (y - t)))
end if
code = tmp
end function
assert z < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -5.2e-66) {
tmp = 1.0 - (x / (y * (y - z)));
} else if (y <= 1.95e-115) {
tmp = 1.0 - ((x / t) / z);
} else {
tmp = 1.0 - (x / (y * (y - t)));
}
return tmp;
}
[z, t] = sort([z, t]) def code(x, y, z, t): tmp = 0 if y <= -5.2e-66: tmp = 1.0 - (x / (y * (y - z))) elif y <= 1.95e-115: tmp = 1.0 - ((x / t) / z) else: tmp = 1.0 - (x / (y * (y - t))) return tmp
z, t = sort([z, t]) function code(x, y, z, t) tmp = 0.0 if (y <= -5.2e-66) tmp = Float64(1.0 - Float64(x / Float64(y * Float64(y - z)))); elseif (y <= 1.95e-115) tmp = Float64(1.0 - Float64(Float64(x / t) / z)); else tmp = Float64(1.0 - Float64(x / Float64(y * Float64(y - t)))); end return tmp end
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if (y <= -5.2e-66)
tmp = 1.0 - (x / (y * (y - z)));
elseif (y <= 1.95e-115)
tmp = 1.0 - ((x / t) / z);
else
tmp = 1.0 - (x / (y * (y - t)));
end
tmp_2 = tmp;
end
NOTE: z and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[LessEqual[y, -5.2e-66], N[(1.0 - N[(x / N[(y * N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.95e-115], N[(1.0 - N[(N[(x / t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(x / N[(y * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.2 \cdot 10^{-66}:\\
\;\;\;\;1 - \frac{x}{y \cdot \left(y - z\right)}\\
\mathbf{elif}\;y \leq 1.95 \cdot 10^{-115}:\\
\;\;\;\;1 - \frac{\frac{x}{t}}{z}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{y \cdot \left(y - t\right)}\\
\end{array}
\end{array}
if y < -5.1999999999999998e-66Initial program 100.0%
Taylor expanded in t around 0 88.0%
if -5.1999999999999998e-66 < y < 1.9499999999999999e-115Initial program 98.8%
Taylor expanded in y around 0 86.2%
associate-/r*87.3%
Simplified87.3%
if 1.9499999999999999e-115 < y Initial program 100.0%
Taylor expanded in z around 0 88.3%
Final simplification87.9%
NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (or (<= y -1.3e-23) (not (<= y 300000000.0))) (- 1.0 (/ x (* y y))) (- 1.0 (/ x (* t z)))))
assert(z < t);
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.3e-23) || !(y <= 300000000.0)) {
tmp = 1.0 - (x / (y * y));
} else {
tmp = 1.0 - (x / (t * z));
}
return tmp;
}
NOTE: z and t should be sorted in increasing order before calling this function.
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.3d-23)) .or. (.not. (y <= 300000000.0d0))) then
tmp = 1.0d0 - (x / (y * y))
else
tmp = 1.0d0 - (x / (t * z))
end if
code = tmp
end function
assert z < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.3e-23) || !(y <= 300000000.0)) {
tmp = 1.0 - (x / (y * y));
} else {
tmp = 1.0 - (x / (t * z));
}
return tmp;
}
[z, t] = sort([z, t]) def code(x, y, z, t): tmp = 0 if (y <= -1.3e-23) or not (y <= 300000000.0): tmp = 1.0 - (x / (y * y)) else: tmp = 1.0 - (x / (t * z)) return tmp
z, t = sort([z, t]) function code(x, y, z, t) tmp = 0.0 if ((y <= -1.3e-23) || !(y <= 300000000.0)) tmp = Float64(1.0 - Float64(x / Float64(y * y))); else tmp = Float64(1.0 - Float64(x / Float64(t * z))); end return tmp end
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if ((y <= -1.3e-23) || ~((y <= 300000000.0)))
tmp = 1.0 - (x / (y * y));
else
tmp = 1.0 - (x / (t * z));
end
tmp_2 = tmp;
end
NOTE: z and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[Or[LessEqual[y, -1.3e-23], N[Not[LessEqual[y, 300000000.0]], $MachinePrecision]], N[(1.0 - N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(x / N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.3 \cdot 10^{-23} \lor \neg \left(y \leq 300000000\right):\\
\;\;\;\;1 - \frac{x}{y \cdot y}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{t \cdot z}\\
\end{array}
\end{array}
if y < -1.3e-23 or 3e8 < y Initial program 100.0%
Taylor expanded in y around inf 87.2%
unpow287.2%
Simplified87.2%
if -1.3e-23 < y < 3e8Initial program 99.2%
Taylor expanded in y around 0 79.1%
Final simplification83.6%
NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (or (<= y -3.1e-24) (not (<= y 270000000.0))) (- 1.0 (/ x (* y y))) (- 1.0 (/ (/ x t) z))))
assert(z < t);
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -3.1e-24) || !(y <= 270000000.0)) {
tmp = 1.0 - (x / (y * y));
} else {
tmp = 1.0 - ((x / t) / z);
}
return tmp;
}
NOTE: z and t should be sorted in increasing order before calling this function.
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 <= (-3.1d-24)) .or. (.not. (y <= 270000000.0d0))) then
tmp = 1.0d0 - (x / (y * y))
else
tmp = 1.0d0 - ((x / t) / z)
end if
code = tmp
end function
assert z < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -3.1e-24) || !(y <= 270000000.0)) {
tmp = 1.0 - (x / (y * y));
} else {
tmp = 1.0 - ((x / t) / z);
}
return tmp;
}
[z, t] = sort([z, t]) def code(x, y, z, t): tmp = 0 if (y <= -3.1e-24) or not (y <= 270000000.0): tmp = 1.0 - (x / (y * y)) else: tmp = 1.0 - ((x / t) / z) return tmp
z, t = sort([z, t]) function code(x, y, z, t) tmp = 0.0 if ((y <= -3.1e-24) || !(y <= 270000000.0)) tmp = Float64(1.0 - Float64(x / Float64(y * y))); else tmp = Float64(1.0 - Float64(Float64(x / t) / z)); end return tmp end
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if ((y <= -3.1e-24) || ~((y <= 270000000.0)))
tmp = 1.0 - (x / (y * y));
else
tmp = 1.0 - ((x / t) / z);
end
tmp_2 = tmp;
end
NOTE: z and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[Or[LessEqual[y, -3.1e-24], N[Not[LessEqual[y, 270000000.0]], $MachinePrecision]], N[(1.0 - N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(N[(x / t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.1 \cdot 10^{-24} \lor \neg \left(y \leq 270000000\right):\\
\;\;\;\;1 - \frac{x}{y \cdot y}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{\frac{x}{t}}{z}\\
\end{array}
\end{array}
if y < -3.1e-24 or 2.7e8 < y Initial program 100.0%
Taylor expanded in y around inf 87.2%
unpow287.2%
Simplified87.2%
if -3.1e-24 < y < 2.7e8Initial program 99.2%
Taylor expanded in y around 0 79.1%
associate-/r*79.9%
Simplified79.9%
Final simplification84.0%
NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (- 1.0 (/ x (* (- y t) (- y z)))))
assert(z < t);
double code(double x, double y, double z, double t) {
return 1.0 - (x / ((y - t) * (y - z)));
}
NOTE: z and t should be sorted in increasing order before calling this function.
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 - t) * (y - z)))
end function
assert z < t;
public static double code(double x, double y, double z, double t) {
return 1.0 - (x / ((y - t) * (y - z)));
}
[z, t] = sort([z, t]) def code(x, y, z, t): return 1.0 - (x / ((y - t) * (y - z)))
z, t = sort([z, t]) function code(x, y, z, t) return Float64(1.0 - Float64(x / Float64(Float64(y - t) * Float64(y - z)))) end
z, t = num2cell(sort([z, t])){:}
function tmp = code(x, y, z, t)
tmp = 1.0 - (x / ((y - t) * (y - z)));
end
NOTE: z and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := N[(1.0 - N[(x / N[(N[(y - t), $MachinePrecision] * N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
1 - \frac{x}{\left(y - t\right) \cdot \left(y - z\right)}
\end{array}
Initial program 99.6%
Final simplification99.6%
NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (- 1.0 (/ x (* t z))))
assert(z < t);
double code(double x, double y, double z, double t) {
return 1.0 - (x / (t * z));
}
NOTE: z and t should be sorted in increasing order before calling this function.
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 / (t * z))
end function
assert z < t;
public static double code(double x, double y, double z, double t) {
return 1.0 - (x / (t * z));
}
[z, t] = sort([z, t]) def code(x, y, z, t): return 1.0 - (x / (t * z))
z, t = sort([z, t]) function code(x, y, z, t) return Float64(1.0 - Float64(x / Float64(t * z))) end
z, t = num2cell(sort([z, t])){:}
function tmp = code(x, y, z, t)
tmp = 1.0 - (x / (t * z));
end
NOTE: z and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := N[(1.0 - N[(x / N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
1 - \frac{x}{t \cdot z}
\end{array}
Initial program 99.6%
Taylor expanded in y around 0 65.5%
Final simplification65.5%
herbie shell --seed 2023171
(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)))))