
(FPCore (x y z t) :precision binary64 (/ (+ x (/ (- (* y z) x) (- (* t z) x))) (+ x 1.0)))
double code(double x, double y, double z, double t) {
return (x + (((y * z) - x) / ((t * z) - x))) / (x + 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 = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0d0)
end function
public static double code(double x, double y, double z, double t) {
return (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0);
}
def code(x, y, z, t): return (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0)
function code(x, y, z, t) return Float64(Float64(x + Float64(Float64(Float64(y * z) - x) / Float64(Float64(t * z) - x))) / Float64(x + 1.0)) end
function tmp = code(x, y, z, t) tmp = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0); end
code[x_, y_, z_, t_] := N[(N[(x + N[(N[(N[(y * z), $MachinePrecision] - x), $MachinePrecision] / N[(N[(t * z), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (/ (+ x (/ (- (* y z) x) (- (* t z) x))) (+ x 1.0)))
double code(double x, double y, double z, double t) {
return (x + (((y * z) - x) / ((t * z) - x))) / (x + 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 = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0d0)
end function
public static double code(double x, double y, double z, double t) {
return (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0);
}
def code(x, y, z, t): return (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0)
function code(x, y, z, t) return Float64(Float64(x + Float64(Float64(Float64(y * z) - x) / Float64(Float64(t * z) - x))) / Float64(x + 1.0)) end
function tmp = code(x, y, z, t) tmp = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0); end
code[x_, y_, z_, t_] := N[(N[(x + N[(N[(N[(y * z), $MachinePrecision] - x), $MachinePrecision] / N[(N[(t * z), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}
\end{array}
(FPCore (x y z t) :precision binary64 (if (or (<= z -4.7e+156) (not (<= z 1.05e+124))) (/ (+ x (/ y (- t (/ x z)))) (+ x 1.0)) (/ (+ x (/ (- (* z y) x) (- (* z t) x))) (+ x 1.0))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -4.7e+156) || !(z <= 1.05e+124)) {
tmp = (x + (y / (t - (x / z)))) / (x + 1.0);
} else {
tmp = (x + (((z * y) - x) / ((z * t) - x))) / (x + 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 <= (-4.7d+156)) .or. (.not. (z <= 1.05d+124))) then
tmp = (x + (y / (t - (x / z)))) / (x + 1.0d0)
else
tmp = (x + (((z * y) - x) / ((z * t) - x))) / (x + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -4.7e+156) || !(z <= 1.05e+124)) {
tmp = (x + (y / (t - (x / z)))) / (x + 1.0);
} else {
tmp = (x + (((z * y) - x) / ((z * t) - x))) / (x + 1.0);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -4.7e+156) or not (z <= 1.05e+124): tmp = (x + (y / (t - (x / z)))) / (x + 1.0) else: tmp = (x + (((z * y) - x) / ((z * t) - x))) / (x + 1.0) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -4.7e+156) || !(z <= 1.05e+124)) tmp = Float64(Float64(x + Float64(y / Float64(t - Float64(x / z)))) / Float64(x + 1.0)); else tmp = Float64(Float64(x + Float64(Float64(Float64(z * y) - x) / Float64(Float64(z * t) - x))) / Float64(x + 1.0)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -4.7e+156) || ~((z <= 1.05e+124))) tmp = (x + (y / (t - (x / z)))) / (x + 1.0); else tmp = (x + (((z * y) - x) / ((z * t) - x))) / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -4.7e+156], N[Not[LessEqual[z, 1.05e+124]], $MachinePrecision]], N[(N[(x + N[(y / N[(t - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[(N[(N[(z * y), $MachinePrecision] - x), $MachinePrecision] / N[(N[(z * t), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.7 \cdot 10^{+156} \lor \neg \left(z \leq 1.05 \cdot 10^{+124}\right):\\
\;\;\;\;\frac{x + \frac{y}{t - \frac{x}{z}}}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x + \frac{z \cdot y - x}{z \cdot t - x}}{x + 1}\\
\end{array}
\end{array}
if z < -4.7e156 or 1.05000000000000006e124 < z Initial program 76.3%
*-commutative76.3%
Simplified76.3%
Taylor expanded in y around inf 76.3%
associate-/l*91.7%
Simplified91.7%
Taylor expanded in t around 0 100.0%
mul-1-neg100.0%
unsub-neg100.0%
Simplified100.0%
if -4.7e156 < z < 1.05000000000000006e124Initial program 99.4%
Final simplification99.6%
(FPCore (x y z t)
:precision binary64
(if (or (<= z -2.7e+122)
(not (or (<= z -11.0) (and (not (<= z -1.4e-39)) (<= z 1.8e-30)))))
(/ (+ x (/ y t)) (+ x 1.0))
(- 1.0 (/ (/ (* z y) (+ x 1.0)) x))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -2.7e+122) || !((z <= -11.0) || (!(z <= -1.4e-39) && (z <= 1.8e-30)))) {
tmp = (x + (y / t)) / (x + 1.0);
} else {
tmp = 1.0 - (((z * y) / (x + 1.0)) / 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 ((z <= (-2.7d+122)) .or. (.not. (z <= (-11.0d0)) .or. (.not. (z <= (-1.4d-39))) .and. (z <= 1.8d-30))) then
tmp = (x + (y / t)) / (x + 1.0d0)
else
tmp = 1.0d0 - (((z * y) / (x + 1.0d0)) / x)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -2.7e+122) || !((z <= -11.0) || (!(z <= -1.4e-39) && (z <= 1.8e-30)))) {
tmp = (x + (y / t)) / (x + 1.0);
} else {
tmp = 1.0 - (((z * y) / (x + 1.0)) / x);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -2.7e+122) or not ((z <= -11.0) or (not (z <= -1.4e-39) and (z <= 1.8e-30))): tmp = (x + (y / t)) / (x + 1.0) else: tmp = 1.0 - (((z * y) / (x + 1.0)) / x) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -2.7e+122) || !((z <= -11.0) || (!(z <= -1.4e-39) && (z <= 1.8e-30)))) tmp = Float64(Float64(x + Float64(y / t)) / Float64(x + 1.0)); else tmp = Float64(1.0 - Float64(Float64(Float64(z * y) / Float64(x + 1.0)) / x)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -2.7e+122) || ~(((z <= -11.0) || (~((z <= -1.4e-39)) && (z <= 1.8e-30))))) tmp = (x + (y / t)) / (x + 1.0); else tmp = 1.0 - (((z * y) / (x + 1.0)) / x); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -2.7e+122], N[Not[Or[LessEqual[z, -11.0], And[N[Not[LessEqual[z, -1.4e-39]], $MachinePrecision], LessEqual[z, 1.8e-30]]]], $MachinePrecision]], N[(N[(x + N[(y / t), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(N[(N[(z * y), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.7 \cdot 10^{+122} \lor \neg \left(z \leq -11 \lor \neg \left(z \leq -1.4 \cdot 10^{-39}\right) \land z \leq 1.8 \cdot 10^{-30}\right):\\
\;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{\frac{z \cdot y}{x + 1}}{x}\\
\end{array}
\end{array}
if z < -2.6999999999999998e122 or -11 < z < -1.4000000000000001e-39 or 1.8000000000000002e-30 < z Initial program 85.2%
*-commutative85.2%
Simplified85.2%
Taylor expanded in z around inf 89.6%
if -2.6999999999999998e122 < z < -11 or -1.4000000000000001e-39 < z < 1.8000000000000002e-30Initial program 99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in t around 0 82.5%
mul-1-neg82.5%
unsub-neg82.5%
*-commutative82.5%
+-commutative82.5%
Simplified82.5%
Taylor expanded in z around 0 82.5%
mul-1-neg82.5%
unsub-neg82.5%
*-commutative82.5%
associate-/r*82.5%
*-commutative82.5%
+-commutative82.5%
Simplified82.5%
Final simplification85.7%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ y (* t (+ x 1.0)))) (t_2 (/ x (+ x 1.0))))
(if (<= x -1.7e-9)
t_2
(if (<= x -2.7e-119)
(- 1.0 (/ (* z y) x))
(if (<= x -1.32e-173)
t_1
(if (<= x -1.2e-241)
(+ x (* x (/ -1.0 (* z t))))
(if (<= x 4.2e-107) t_1 t_2)))))))
double code(double x, double y, double z, double t) {
double t_1 = y / (t * (x + 1.0));
double t_2 = x / (x + 1.0);
double tmp;
if (x <= -1.7e-9) {
tmp = t_2;
} else if (x <= -2.7e-119) {
tmp = 1.0 - ((z * y) / x);
} else if (x <= -1.32e-173) {
tmp = t_1;
} else if (x <= -1.2e-241) {
tmp = x + (x * (-1.0 / (z * t)));
} else if (x <= 4.2e-107) {
tmp = t_1;
} else {
tmp = t_2;
}
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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = y / (t * (x + 1.0d0))
t_2 = x / (x + 1.0d0)
if (x <= (-1.7d-9)) then
tmp = t_2
else if (x <= (-2.7d-119)) then
tmp = 1.0d0 - ((z * y) / x)
else if (x <= (-1.32d-173)) then
tmp = t_1
else if (x <= (-1.2d-241)) then
tmp = x + (x * ((-1.0d0) / (z * t)))
else if (x <= 4.2d-107) then
tmp = t_1
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = y / (t * (x + 1.0));
double t_2 = x / (x + 1.0);
double tmp;
if (x <= -1.7e-9) {
tmp = t_2;
} else if (x <= -2.7e-119) {
tmp = 1.0 - ((z * y) / x);
} else if (x <= -1.32e-173) {
tmp = t_1;
} else if (x <= -1.2e-241) {
tmp = x + (x * (-1.0 / (z * t)));
} else if (x <= 4.2e-107) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t): t_1 = y / (t * (x + 1.0)) t_2 = x / (x + 1.0) tmp = 0 if x <= -1.7e-9: tmp = t_2 elif x <= -2.7e-119: tmp = 1.0 - ((z * y) / x) elif x <= -1.32e-173: tmp = t_1 elif x <= -1.2e-241: tmp = x + (x * (-1.0 / (z * t))) elif x <= 4.2e-107: tmp = t_1 else: tmp = t_2 return tmp
function code(x, y, z, t) t_1 = Float64(y / Float64(t * Float64(x + 1.0))) t_2 = Float64(x / Float64(x + 1.0)) tmp = 0.0 if (x <= -1.7e-9) tmp = t_2; elseif (x <= -2.7e-119) tmp = Float64(1.0 - Float64(Float64(z * y) / x)); elseif (x <= -1.32e-173) tmp = t_1; elseif (x <= -1.2e-241) tmp = Float64(x + Float64(x * Float64(-1.0 / Float64(z * t)))); elseif (x <= 4.2e-107) tmp = t_1; else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = y / (t * (x + 1.0)); t_2 = x / (x + 1.0); tmp = 0.0; if (x <= -1.7e-9) tmp = t_2; elseif (x <= -2.7e-119) tmp = 1.0 - ((z * y) / x); elseif (x <= -1.32e-173) tmp = t_1; elseif (x <= -1.2e-241) tmp = x + (x * (-1.0 / (z * t))); elseif (x <= 4.2e-107) tmp = t_1; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y / N[(t * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.7e-9], t$95$2, If[LessEqual[x, -2.7e-119], N[(1.0 - N[(N[(z * y), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.32e-173], t$95$1, If[LessEqual[x, -1.2e-241], N[(x + N[(x * N[(-1.0 / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.2e-107], t$95$1, t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y}{t \cdot \left(x + 1\right)}\\
t_2 := \frac{x}{x + 1}\\
\mathbf{if}\;x \leq -1.7 \cdot 10^{-9}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq -2.7 \cdot 10^{-119}:\\
\;\;\;\;1 - \frac{z \cdot y}{x}\\
\mathbf{elif}\;x \leq -1.32 \cdot 10^{-173}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -1.2 \cdot 10^{-241}:\\
\;\;\;\;x + x \cdot \frac{-1}{z \cdot t}\\
\mathbf{elif}\;x \leq 4.2 \cdot 10^{-107}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if x < -1.6999999999999999e-9 or 4.1999999999999998e-107 < x Initial program 94.6%
*-commutative94.6%
Simplified94.6%
Taylor expanded in t around inf 85.3%
+-commutative85.3%
Simplified85.3%
if -1.6999999999999999e-9 < x < -2.70000000000000027e-119Initial program 99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in t around 0 58.3%
mul-1-neg58.3%
unsub-neg58.3%
*-commutative58.3%
+-commutative58.3%
Simplified58.3%
Taylor expanded in z around 0 58.3%
mul-1-neg58.3%
unsub-neg58.3%
*-commutative58.3%
associate-/r*58.3%
*-commutative58.3%
+-commutative58.3%
Simplified58.3%
Taylor expanded in x around 0 58.3%
if -2.70000000000000027e-119 < x < -1.32e-173 or -1.2e-241 < x < 4.1999999999999998e-107Initial program 86.1%
*-commutative86.1%
Simplified86.1%
Taylor expanded in z around inf 78.6%
Taylor expanded in y around inf 63.6%
+-commutative63.6%
Simplified63.6%
if -1.32e-173 < x < -1.2e-241Initial program 93.6%
*-commutative93.6%
Simplified93.6%
Taylor expanded in y around 0 72.6%
+-commutative72.6%
Simplified72.6%
Taylor expanded in x around 0 65.4%
sub-neg65.4%
distribute-lft-in65.4%
*-rgt-identity65.4%
distribute-neg-frac65.4%
metadata-eval65.4%
Simplified65.4%
Final simplification77.3%
(FPCore (x y z t) :precision binary64 (if (or (<= y -1.9e-194) (not (<= y 300000000000.0))) (/ (+ x (/ y (- t (/ x z)))) (+ x 1.0)) (/ (- x (/ x (- (* z t) x))) (+ x 1.0))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.9e-194) || !(y <= 300000000000.0)) {
tmp = (x + (y / (t - (x / z)))) / (x + 1.0);
} else {
tmp = (x - (x / ((z * t) - x))) / (x + 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 <= (-1.9d-194)) .or. (.not. (y <= 300000000000.0d0))) then
tmp = (x + (y / (t - (x / z)))) / (x + 1.0d0)
else
tmp = (x - (x / ((z * t) - x))) / (x + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.9e-194) || !(y <= 300000000000.0)) {
tmp = (x + (y / (t - (x / z)))) / (x + 1.0);
} else {
tmp = (x - (x / ((z * t) - x))) / (x + 1.0);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -1.9e-194) or not (y <= 300000000000.0): tmp = (x + (y / (t - (x / z)))) / (x + 1.0) else: tmp = (x - (x / ((z * t) - x))) / (x + 1.0) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -1.9e-194) || !(y <= 300000000000.0)) tmp = Float64(Float64(x + Float64(y / Float64(t - Float64(x / z)))) / Float64(x + 1.0)); else tmp = Float64(Float64(x - Float64(x / Float64(Float64(z * t) - x))) / Float64(x + 1.0)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -1.9e-194) || ~((y <= 300000000000.0))) tmp = (x + (y / (t - (x / z)))) / (x + 1.0); else tmp = (x - (x / ((z * t) - x))) / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -1.9e-194], N[Not[LessEqual[y, 300000000000.0]], $MachinePrecision]], N[(N[(x + N[(y / N[(t - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x - N[(x / N[(N[(z * t), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.9 \cdot 10^{-194} \lor \neg \left(y \leq 300000000000\right):\\
\;\;\;\;\frac{x + \frac{y}{t - \frac{x}{z}}}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x - \frac{x}{z \cdot t - x}}{x + 1}\\
\end{array}
\end{array}
if y < -1.9000000000000001e-194 or 3e11 < y Initial program 88.9%
*-commutative88.9%
Simplified88.9%
Taylor expanded in y around inf 86.9%
associate-/l*93.7%
Simplified93.7%
Taylor expanded in t around 0 97.9%
mul-1-neg97.9%
unsub-neg97.9%
Simplified97.9%
if -1.9000000000000001e-194 < y < 3e11Initial program 100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 93.3%
+-commutative93.3%
Simplified93.3%
Final simplification96.2%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ x (+ x 1.0))))
(if (<= x -1.05e-9)
t_1
(if (<= x -1e-116)
(- 1.0 (/ (* z y) x))
(if (<= x 1.9e-104) (/ y (* t (+ x 1.0))) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = x / (x + 1.0);
double tmp;
if (x <= -1.05e-9) {
tmp = t_1;
} else if (x <= -1e-116) {
tmp = 1.0 - ((z * y) / x);
} else if (x <= 1.9e-104) {
tmp = y / (t * (x + 1.0));
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_1 = x / (x + 1.0d0)
if (x <= (-1.05d-9)) then
tmp = t_1
else if (x <= (-1d-116)) then
tmp = 1.0d0 - ((z * y) / x)
else if (x <= 1.9d-104) then
tmp = y / (t * (x + 1.0d0))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = x / (x + 1.0);
double tmp;
if (x <= -1.05e-9) {
tmp = t_1;
} else if (x <= -1e-116) {
tmp = 1.0 - ((z * y) / x);
} else if (x <= 1.9e-104) {
tmp = y / (t * (x + 1.0));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = x / (x + 1.0) tmp = 0 if x <= -1.05e-9: tmp = t_1 elif x <= -1e-116: tmp = 1.0 - ((z * y) / x) elif x <= 1.9e-104: tmp = y / (t * (x + 1.0)) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(x / Float64(x + 1.0)) tmp = 0.0 if (x <= -1.05e-9) tmp = t_1; elseif (x <= -1e-116) tmp = Float64(1.0 - Float64(Float64(z * y) / x)); elseif (x <= 1.9e-104) tmp = Float64(y / Float64(t * Float64(x + 1.0))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x / (x + 1.0); tmp = 0.0; if (x <= -1.05e-9) tmp = t_1; elseif (x <= -1e-116) tmp = 1.0 - ((z * y) / x); elseif (x <= 1.9e-104) tmp = y / (t * (x + 1.0)); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.05e-9], t$95$1, If[LessEqual[x, -1e-116], N[(1.0 - N[(N[(z * y), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.9e-104], N[(y / N[(t * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{x}{x + 1}\\
\mathbf{if}\;x \leq -1.05 \cdot 10^{-9}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -1 \cdot 10^{-116}:\\
\;\;\;\;1 - \frac{z \cdot y}{x}\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{-104}:\\
\;\;\;\;\frac{y}{t \cdot \left(x + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if x < -1.0500000000000001e-9 or 1.9e-104 < x Initial program 94.6%
*-commutative94.6%
Simplified94.6%
Taylor expanded in t around inf 85.3%
+-commutative85.3%
Simplified85.3%
if -1.0500000000000001e-9 < x < -9.9999999999999999e-117Initial program 99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in t around 0 58.3%
mul-1-neg58.3%
unsub-neg58.3%
*-commutative58.3%
+-commutative58.3%
Simplified58.3%
Taylor expanded in z around 0 58.3%
mul-1-neg58.3%
unsub-neg58.3%
*-commutative58.3%
associate-/r*58.3%
*-commutative58.3%
+-commutative58.3%
Simplified58.3%
Taylor expanded in x around 0 58.3%
if -9.9999999999999999e-117 < x < 1.9e-104Initial program 87.6%
*-commutative87.6%
Simplified87.6%
Taylor expanded in z around inf 78.8%
Taylor expanded in y around inf 57.3%
+-commutative57.3%
Simplified57.3%
Final simplification75.4%
(FPCore (x y z t) :precision binary64 (if (or (<= z -4.9e-40) (not (<= z 6.8e-32))) (/ (+ x (/ y t)) (+ x 1.0)) (- 1.0 (/ (* z y) x))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -4.9e-40) || !(z <= 6.8e-32)) {
tmp = (x + (y / t)) / (x + 1.0);
} else {
tmp = 1.0 - ((z * 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 ((z <= (-4.9d-40)) .or. (.not. (z <= 6.8d-32))) then
tmp = (x + (y / t)) / (x + 1.0d0)
else
tmp = 1.0d0 - ((z * y) / x)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -4.9e-40) || !(z <= 6.8e-32)) {
tmp = (x + (y / t)) / (x + 1.0);
} else {
tmp = 1.0 - ((z * y) / x);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -4.9e-40) or not (z <= 6.8e-32): tmp = (x + (y / t)) / (x + 1.0) else: tmp = 1.0 - ((z * y) / x) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -4.9e-40) || !(z <= 6.8e-32)) tmp = Float64(Float64(x + Float64(y / t)) / Float64(x + 1.0)); else tmp = Float64(1.0 - Float64(Float64(z * y) / x)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -4.9e-40) || ~((z <= 6.8e-32))) tmp = (x + (y / t)) / (x + 1.0); else tmp = 1.0 - ((z * y) / x); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -4.9e-40], N[Not[LessEqual[z, 6.8e-32]], $MachinePrecision]], N[(N[(x + N[(y / t), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(N[(z * y), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.9 \cdot 10^{-40} \lor \neg \left(z \leq 6.8 \cdot 10^{-32}\right):\\
\;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{z \cdot y}{x}\\
\end{array}
\end{array}
if z < -4.8999999999999997e-40 or 6.79999999999999956e-32 < z Initial program 88.2%
*-commutative88.2%
Simplified88.2%
Taylor expanded in z around inf 84.5%
if -4.8999999999999997e-40 < z < 6.79999999999999956e-32Initial program 99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in t around 0 82.1%
mul-1-neg82.1%
unsub-neg82.1%
*-commutative82.1%
+-commutative82.1%
Simplified82.1%
Taylor expanded in z around 0 82.1%
mul-1-neg82.1%
unsub-neg82.1%
*-commutative82.1%
associate-/r*82.1%
*-commutative82.1%
+-commutative82.1%
Simplified82.1%
Taylor expanded in x around 0 78.6%
Final simplification82.0%
(FPCore (x y z t) :precision binary64 (/ (+ x (/ y (- t (/ x z)))) (+ x 1.0)))
double code(double x, double y, double z, double t) {
return (x + (y / (t - (x / z)))) / (x + 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 = (x + (y / (t - (x / z)))) / (x + 1.0d0)
end function
public static double code(double x, double y, double z, double t) {
return (x + (y / (t - (x / z)))) / (x + 1.0);
}
def code(x, y, z, t): return (x + (y / (t - (x / z)))) / (x + 1.0)
function code(x, y, z, t) return Float64(Float64(x + Float64(y / Float64(t - Float64(x / z)))) / Float64(x + 1.0)) end
function tmp = code(x, y, z, t) tmp = (x + (y / (t - (x / z)))) / (x + 1.0); end
code[x_, y_, z_, t_] := N[(N[(x + N[(y / N[(t - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + \frac{y}{t - \frac{x}{z}}}{x + 1}
\end{array}
Initial program 93.1%
*-commutative93.1%
Simplified93.1%
Taylor expanded in y around inf 83.7%
associate-/l*88.0%
Simplified88.0%
Taylor expanded in t around 0 90.6%
mul-1-neg90.6%
unsub-neg90.6%
Simplified90.6%
Final simplification90.6%
(FPCore (x y z t) :precision binary64 (if (or (<= t -2.9e-71) (not (<= t 4e-97))) (/ x (+ x 1.0)) (- 1.0 (* y (/ z x)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -2.9e-71) || !(t <= 4e-97)) {
tmp = x / (x + 1.0);
} else {
tmp = 1.0 - (y * (z / 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 <= (-2.9d-71)) .or. (.not. (t <= 4d-97))) then
tmp = x / (x + 1.0d0)
else
tmp = 1.0d0 - (y * (z / x))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -2.9e-71) || !(t <= 4e-97)) {
tmp = x / (x + 1.0);
} else {
tmp = 1.0 - (y * (z / x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -2.9e-71) or not (t <= 4e-97): tmp = x / (x + 1.0) else: tmp = 1.0 - (y * (z / x)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -2.9e-71) || !(t <= 4e-97)) tmp = Float64(x / Float64(x + 1.0)); else tmp = Float64(1.0 - Float64(y * Float64(z / x))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -2.9e-71) || ~((t <= 4e-97))) tmp = x / (x + 1.0); else tmp = 1.0 - (y * (z / x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -2.9e-71], N[Not[LessEqual[t, 4e-97]], $MachinePrecision]], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(y * N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -2.9 \cdot 10^{-71} \lor \neg \left(t \leq 4 \cdot 10^{-97}\right):\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;1 - y \cdot \frac{z}{x}\\
\end{array}
\end{array}
if t < -2.8999999999999999e-71 or 4.00000000000000014e-97 < t Initial program 92.6%
*-commutative92.6%
Simplified92.6%
Taylor expanded in t around inf 70.4%
+-commutative70.4%
Simplified70.4%
if -2.8999999999999999e-71 < t < 4.00000000000000014e-97Initial program 94.0%
*-commutative94.0%
Simplified94.0%
Taylor expanded in t around 0 78.1%
mul-1-neg78.1%
unsub-neg78.1%
*-commutative78.1%
+-commutative78.1%
Simplified78.1%
Taylor expanded in z around 0 78.0%
mul-1-neg78.0%
unsub-neg78.0%
*-commutative78.0%
associate-/r*78.1%
*-commutative78.1%
+-commutative78.1%
Simplified78.1%
Taylor expanded in x around 0 71.8%
*-commutative71.8%
associate-*l/71.8%
*-commutative71.8%
Simplified71.8%
Final simplification71.0%
(FPCore (x y z t) :precision binary64 (if (or (<= t -6.4e+153) (not (<= t 8.8e+61))) (/ x (+ x 1.0)) 1.0))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -6.4e+153) || !(t <= 8.8e+61)) {
tmp = x / (x + 1.0);
} 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 <= (-6.4d+153)) .or. (.not. (t <= 8.8d+61))) then
tmp = x / (x + 1.0d0)
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 <= -6.4e+153) || !(t <= 8.8e+61)) {
tmp = x / (x + 1.0);
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -6.4e+153) or not (t <= 8.8e+61): tmp = x / (x + 1.0) else: tmp = 1.0 return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -6.4e+153) || !(t <= 8.8e+61)) tmp = Float64(x / Float64(x + 1.0)); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -6.4e+153) || ~((t <= 8.8e+61))) tmp = x / (x + 1.0); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -6.4e+153], N[Not[LessEqual[t, 8.8e+61]], $MachinePrecision]], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -6.4 \cdot 10^{+153} \lor \neg \left(t \leq 8.8 \cdot 10^{+61}\right):\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if t < -6.4000000000000003e153 or 8.8000000000000001e61 < t Initial program 91.1%
*-commutative91.1%
Simplified91.1%
Taylor expanded in t around inf 80.4%
+-commutative80.4%
Simplified80.4%
if -6.4000000000000003e153 < t < 8.8000000000000001e61Initial program 94.2%
*-commutative94.2%
Simplified94.2%
Taylor expanded in y around inf 82.2%
associate-/l*87.3%
Simplified87.3%
Taylor expanded in x around inf 61.9%
Final simplification68.2%
(FPCore (x y z t) :precision binary64 (if (<= x -7.5e-100) 1.0 (if (<= x 5.2e-19) (- x (* x x)) 1.0)))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -7.5e-100) {
tmp = 1.0;
} else if (x <= 5.2e-19) {
tmp = x - (x * x);
} 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 (x <= (-7.5d-100)) then
tmp = 1.0d0
else if (x <= 5.2d-19) then
tmp = x - (x * x)
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 (x <= -7.5e-100) {
tmp = 1.0;
} else if (x <= 5.2e-19) {
tmp = x - (x * x);
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -7.5e-100: tmp = 1.0 elif x <= 5.2e-19: tmp = x - (x * x) else: tmp = 1.0 return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -7.5e-100) tmp = 1.0; elseif (x <= 5.2e-19) tmp = Float64(x - Float64(x * x)); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -7.5e-100) tmp = 1.0; elseif (x <= 5.2e-19) tmp = x - (x * x); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -7.5e-100], 1.0, If[LessEqual[x, 5.2e-19], N[(x - N[(x * x), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.5 \cdot 10^{-100}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 5.2 \cdot 10^{-19}:\\
\;\;\;\;x - x \cdot x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -7.50000000000000015e-100 or 5.20000000000000026e-19 < x Initial program 94.7%
*-commutative94.7%
Simplified94.7%
Taylor expanded in y around inf 87.8%
associate-/l*91.9%
Simplified91.9%
Taylor expanded in x around inf 81.4%
if -7.50000000000000015e-100 < x < 5.20000000000000026e-19Initial program 90.0%
*-commutative90.0%
Simplified90.0%
Taylor expanded in t around inf 29.2%
+-commutative29.2%
Simplified29.2%
Taylor expanded in x around 0 29.2%
mul-1-neg29.2%
unsub-neg29.2%
unpow229.2%
Simplified29.2%
Final simplification63.7%
(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 93.1%
*-commutative93.1%
Simplified93.1%
Taylor expanded in y around inf 83.7%
associate-/l*88.0%
Simplified88.0%
Taylor expanded in x around inf 57.9%
Final simplification57.9%
(FPCore (x y z t) :precision binary64 (/ (+ x (- (/ y (- t (/ x z))) (/ x (- (* t z) x)))) (+ x 1.0)))
double code(double x, double y, double z, double t) {
return (x + ((y / (t - (x / z))) - (x / ((t * z) - x)))) / (x + 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 = (x + ((y / (t - (x / z))) - (x / ((t * z) - x)))) / (x + 1.0d0)
end function
public static double code(double x, double y, double z, double t) {
return (x + ((y / (t - (x / z))) - (x / ((t * z) - x)))) / (x + 1.0);
}
def code(x, y, z, t): return (x + ((y / (t - (x / z))) - (x / ((t * z) - x)))) / (x + 1.0)
function code(x, y, z, t) return Float64(Float64(x + Float64(Float64(y / Float64(t - Float64(x / z))) - Float64(x / Float64(Float64(t * z) - x)))) / Float64(x + 1.0)) end
function tmp = code(x, y, z, t) tmp = (x + ((y / (t - (x / z))) - (x / ((t * z) - x)))) / (x + 1.0); end
code[x_, y_, z_, t_] := N[(N[(x + N[(N[(y / N[(t - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x / N[(N[(t * z), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + \left(\frac{y}{t - \frac{x}{z}} - \frac{x}{t \cdot z - x}\right)}{x + 1}
\end{array}
herbie shell --seed 2023271
(FPCore (x y z t)
:name "Diagrams.Trail:splitAtParam from diagrams-lib-1.3.0.3, A"
:precision binary64
:herbie-target
(/ (+ x (- (/ y (- t (/ x z))) (/ x (- (* t z) x)))) (+ x 1.0))
(/ (+ x (/ (- (* y z) x) (- (* t z) x))) (+ x 1.0)))