
(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 13 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
(let* ((t_1 (- (* y z) x))
(t_2 (- (* z t) x))
(t_3 (/ (+ x (/ t_1 t_2)) (+ x 1.0))))
(if (<= t_3 (- INFINITY))
(/ (+ x (* z (/ y t_2))) (+ x 1.0))
(if (<= t_3 2e+254)
(/ (+ x (/ t_1 (fma z t (- x)))) (+ x 1.0))
(/ (+ x (/ y t)) (+ x 1.0))))))
double code(double x, double y, double z, double t) {
double t_1 = (y * z) - x;
double t_2 = (z * t) - x;
double t_3 = (x + (t_1 / t_2)) / (x + 1.0);
double tmp;
if (t_3 <= -((double) INFINITY)) {
tmp = (x + (z * (y / t_2))) / (x + 1.0);
} else if (t_3 <= 2e+254) {
tmp = (x + (t_1 / fma(z, t, -x))) / (x + 1.0);
} else {
tmp = (x + (y / t)) / (x + 1.0);
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(y * z) - x) t_2 = Float64(Float64(z * t) - x) t_3 = Float64(Float64(x + Float64(t_1 / t_2)) / Float64(x + 1.0)) tmp = 0.0 if (t_3 <= Float64(-Inf)) tmp = Float64(Float64(x + Float64(z * Float64(y / t_2))) / Float64(x + 1.0)); elseif (t_3 <= 2e+254) tmp = Float64(Float64(x + Float64(t_1 / fma(z, t, Float64(-x)))) / Float64(x + 1.0)); else tmp = Float64(Float64(x + Float64(y / t)) / Float64(x + 1.0)); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(y * z), $MachinePrecision] - x), $MachinePrecision]}, Block[{t$95$2 = N[(N[(z * t), $MachinePrecision] - x), $MachinePrecision]}, Block[{t$95$3 = N[(N[(x + N[(t$95$1 / t$95$2), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, (-Infinity)], N[(N[(x + N[(z * N[(y / t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 2e+254], N[(N[(x + N[(t$95$1 / N[(z * t + (-x)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[(y / t), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot z - x\\
t_2 := z \cdot t - x\\
t_3 := \frac{x + \frac{t_1}{t_2}}{x + 1}\\
\mathbf{if}\;t_3 \leq -\infty:\\
\;\;\;\;\frac{x + z \cdot \frac{y}{t_2}}{x + 1}\\
\mathbf{elif}\;t_3 \leq 2 \cdot 10^{+254}:\\
\;\;\;\;\frac{x + \frac{t_1}{\mathsf{fma}\left(z, t, -x\right)}}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1)) < -inf.0Initial program 38.7%
*-commutative38.7%
Simplified38.7%
Taylor expanded in y around inf 38.7%
associate-/l*99.8%
*-commutative99.8%
associate-/r/99.8%
*-commutative99.8%
Simplified99.8%
if -inf.0 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1)) < 1.9999999999999999e254Initial program 99.8%
*-commutative99.8%
Simplified99.8%
fma-neg99.8%
Applied egg-rr99.8%
if 1.9999999999999999e254 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1)) Initial program 27.8%
*-commutative27.8%
Simplified27.8%
Taylor expanded in z around inf 99.9%
Final simplification99.8%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (* z t) x)) (t_2 (/ (+ x (/ (- (* y z) x) t_1)) (+ x 1.0))))
(if (<= t_2 (- INFINITY))
(/ (+ x (* z (/ y t_1))) (+ x 1.0))
(if (<= t_2 2e+254) t_2 (/ (+ x (/ y t)) (+ x 1.0))))))
double code(double x, double y, double z, double t) {
double t_1 = (z * t) - x;
double t_2 = (x + (((y * z) - x) / t_1)) / (x + 1.0);
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = (x + (z * (y / t_1))) / (x + 1.0);
} else if (t_2 <= 2e+254) {
tmp = t_2;
} else {
tmp = (x + (y / t)) / (x + 1.0);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = (z * t) - x;
double t_2 = (x + (((y * z) - x) / t_1)) / (x + 1.0);
double tmp;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp = (x + (z * (y / t_1))) / (x + 1.0);
} else if (t_2 <= 2e+254) {
tmp = t_2;
} else {
tmp = (x + (y / t)) / (x + 1.0);
}
return tmp;
}
def code(x, y, z, t): t_1 = (z * t) - x t_2 = (x + (((y * z) - x) / t_1)) / (x + 1.0) tmp = 0 if t_2 <= -math.inf: tmp = (x + (z * (y / t_1))) / (x + 1.0) elif t_2 <= 2e+254: tmp = t_2 else: tmp = (x + (y / t)) / (x + 1.0) return tmp
function code(x, y, z, t) t_1 = Float64(Float64(z * t) - x) t_2 = Float64(Float64(x + Float64(Float64(Float64(y * z) - x) / t_1)) / Float64(x + 1.0)) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = Float64(Float64(x + Float64(z * Float64(y / t_1))) / Float64(x + 1.0)); elseif (t_2 <= 2e+254) tmp = t_2; else tmp = Float64(Float64(x + Float64(y / t)) / Float64(x + 1.0)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (z * t) - x; t_2 = (x + (((y * z) - x) / t_1)) / (x + 1.0); tmp = 0.0; if (t_2 <= -Inf) tmp = (x + (z * (y / t_1))) / (x + 1.0); elseif (t_2 <= 2e+254) tmp = t_2; else tmp = (x + (y / t)) / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(z * t), $MachinePrecision] - x), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x + N[(N[(N[(y * z), $MachinePrecision] - x), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(N[(x + N[(z * N[(y / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e+254], t$95$2, N[(N[(x + N[(y / t), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot t - x\\
t_2 := \frac{x + \frac{y \cdot z - x}{t_1}}{x + 1}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;\frac{x + z \cdot \frac{y}{t_1}}{x + 1}\\
\mathbf{elif}\;t_2 \leq 2 \cdot 10^{+254}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1)) < -inf.0Initial program 38.7%
*-commutative38.7%
Simplified38.7%
Taylor expanded in y around inf 38.7%
associate-/l*99.8%
*-commutative99.8%
associate-/r/99.8%
*-commutative99.8%
Simplified99.8%
if -inf.0 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1)) < 1.9999999999999999e254Initial program 99.8%
if 1.9999999999999999e254 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1)) Initial program 27.8%
*-commutative27.8%
Simplified27.8%
Taylor expanded in z around inf 99.9%
Final simplification99.8%
(FPCore (x y z t) :precision binary64 (if (or (<= z -2.7e-209) (not (<= z 3.6e-126))) (/ (+ x (* z (/ y (- (* z t) x)))) (+ x 1.0)) (/ (+ x (/ (- x (* y z)) x)) (+ x 1.0))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -2.7e-209) || !(z <= 3.6e-126)) {
tmp = (x + (z * (y / ((z * t) - x)))) / (x + 1.0);
} else {
tmp = (x + ((x - (y * z)) / 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 <= (-2.7d-209)) .or. (.not. (z <= 3.6d-126))) then
tmp = (x + (z * (y / ((z * t) - x)))) / (x + 1.0d0)
else
tmp = (x + ((x - (y * z)) / 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 <= -2.7e-209) || !(z <= 3.6e-126)) {
tmp = (x + (z * (y / ((z * t) - x)))) / (x + 1.0);
} else {
tmp = (x + ((x - (y * z)) / x)) / (x + 1.0);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -2.7e-209) or not (z <= 3.6e-126): tmp = (x + (z * (y / ((z * t) - x)))) / (x + 1.0) else: tmp = (x + ((x - (y * z)) / x)) / (x + 1.0) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -2.7e-209) || !(z <= 3.6e-126)) tmp = Float64(Float64(x + Float64(z * Float64(y / Float64(Float64(z * t) - x)))) / Float64(x + 1.0)); else tmp = Float64(Float64(x + Float64(Float64(x - Float64(y * z)) / x)) / Float64(x + 1.0)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -2.7e-209) || ~((z <= 3.6e-126))) tmp = (x + (z * (y / ((z * t) - x)))) / (x + 1.0); else tmp = (x + ((x - (y * z)) / x)) / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -2.7e-209], N[Not[LessEqual[z, 3.6e-126]], $MachinePrecision]], N[(N[(x + N[(z * N[(y / N[(N[(z * t), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[(N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.7 \cdot 10^{-209} \lor \neg \left(z \leq 3.6 \cdot 10^{-126}\right):\\
\;\;\;\;\frac{x + z \cdot \frac{y}{z \cdot t - x}}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x + \frac{x - y \cdot z}{x}}{x + 1}\\
\end{array}
\end{array}
if z < -2.69999999999999998e-209 or 3.5999999999999999e-126 < z Initial program 87.3%
*-commutative87.3%
Simplified87.3%
Taylor expanded in y around inf 83.1%
associate-/l*94.4%
*-commutative94.4%
associate-/r/92.7%
*-commutative92.7%
Simplified92.7%
if -2.69999999999999998e-209 < z < 3.5999999999999999e-126Initial program 99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in t around 0 86.2%
fma-neg86.2%
associate-*r/86.2%
neg-mul-186.2%
neg-sub086.2%
fma-def86.2%
+-commutative86.2%
associate--r+86.2%
neg-sub086.2%
remove-double-neg86.2%
*-commutative86.2%
Simplified86.2%
Final simplification91.4%
(FPCore (x y z t) :precision binary64 (if (or (<= z -4e-160) (not (<= z 6e-71))) (/ (+ x (/ y t)) (+ x 1.0)) (/ (+ x (/ (- x (* y z)) x)) (+ x 1.0))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -4e-160) || !(z <= 6e-71)) {
tmp = (x + (y / t)) / (x + 1.0);
} else {
tmp = (x + ((x - (y * z)) / 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 <= (-4d-160)) .or. (.not. (z <= 6d-71))) then
tmp = (x + (y / t)) / (x + 1.0d0)
else
tmp = (x + ((x - (y * z)) / 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 <= -4e-160) || !(z <= 6e-71)) {
tmp = (x + (y / t)) / (x + 1.0);
} else {
tmp = (x + ((x - (y * z)) / x)) / (x + 1.0);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -4e-160) or not (z <= 6e-71): tmp = (x + (y / t)) / (x + 1.0) else: tmp = (x + ((x - (y * z)) / x)) / (x + 1.0) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -4e-160) || !(z <= 6e-71)) tmp = Float64(Float64(x + Float64(y / t)) / Float64(x + 1.0)); else tmp = Float64(Float64(x + Float64(Float64(x - Float64(y * z)) / x)) / Float64(x + 1.0)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -4e-160) || ~((z <= 6e-71))) tmp = (x + (y / t)) / (x + 1.0); else tmp = (x + ((x - (y * z)) / x)) / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -4e-160], N[Not[LessEqual[z, 6e-71]], $MachinePrecision]], N[(N[(x + N[(y / t), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[(N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4 \cdot 10^{-160} \lor \neg \left(z \leq 6 \cdot 10^{-71}\right):\\
\;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x + \frac{x - y \cdot z}{x}}{x + 1}\\
\end{array}
\end{array}
if z < -4e-160 or 6.0000000000000003e-71 < z Initial program 85.6%
*-commutative85.6%
Simplified85.6%
Taylor expanded in z around inf 86.4%
if -4e-160 < z < 6.0000000000000003e-71Initial program 99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in t around 0 81.4%
fma-neg81.4%
associate-*r/81.4%
neg-mul-181.4%
neg-sub081.4%
fma-def81.4%
+-commutative81.4%
associate--r+81.4%
neg-sub081.4%
remove-double-neg81.4%
*-commutative81.4%
Simplified81.4%
Final simplification84.9%
(FPCore (x y z t) :precision binary64 (if (or (<= z -2.3e-44) (not (<= z 4.5e-70))) (/ (+ x (/ y t)) (+ x 1.0)) (/ (- x (/ x (- (* z t) x))) (+ x 1.0))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -2.3e-44) || !(z <= 4.5e-70)) {
tmp = (x + (y / t)) / (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 ((z <= (-2.3d-44)) .or. (.not. (z <= 4.5d-70))) then
tmp = (x + (y / t)) / (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 ((z <= -2.3e-44) || !(z <= 4.5e-70)) {
tmp = (x + (y / t)) / (x + 1.0);
} else {
tmp = (x - (x / ((z * t) - x))) / (x + 1.0);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -2.3e-44) or not (z <= 4.5e-70): tmp = (x + (y / t)) / (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 ((z <= -2.3e-44) || !(z <= 4.5e-70)) tmp = Float64(Float64(x + Float64(y / t)) / 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 ((z <= -2.3e-44) || ~((z <= 4.5e-70))) tmp = (x + (y / t)) / (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[z, -2.3e-44], N[Not[LessEqual[z, 4.5e-70]], $MachinePrecision]], N[(N[(x + N[(y / t), $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}\;z \leq -2.3 \cdot 10^{-44} \lor \neg \left(z \leq 4.5 \cdot 10^{-70}\right):\\
\;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x - \frac{x}{z \cdot t - x}}{x + 1}\\
\end{array}
\end{array}
if z < -2.29999999999999998e-44 or 4.50000000000000022e-70 < z Initial program 84.1%
*-commutative84.1%
Simplified84.1%
Taylor expanded in z around inf 88.4%
if -2.29999999999999998e-44 < z < 4.50000000000000022e-70Initial program 99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in y around 0 81.2%
Final simplification85.9%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (+ x 1.0) (+ x 1.0))))
(if (<= x -5.5e-17)
t_1
(if (<= x -6.4e-127)
(* x (+ 1.0 (/ -1.0 (* z t))))
(if (<= x 1.7e-118) (/ (/ y t) (+ x 1.0)) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = (x + 1.0) / (x + 1.0);
double tmp;
if (x <= -5.5e-17) {
tmp = t_1;
} else if (x <= -6.4e-127) {
tmp = x * (1.0 + (-1.0 / (z * t)));
} else if (x <= 1.7e-118) {
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 + 1.0d0) / (x + 1.0d0)
if (x <= (-5.5d-17)) then
tmp = t_1
else if (x <= (-6.4d-127)) then
tmp = x * (1.0d0 + ((-1.0d0) / (z * t)))
else if (x <= 1.7d-118) 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 + 1.0) / (x + 1.0);
double tmp;
if (x <= -5.5e-17) {
tmp = t_1;
} else if (x <= -6.4e-127) {
tmp = x * (1.0 + (-1.0 / (z * t)));
} else if (x <= 1.7e-118) {
tmp = (y / t) / (x + 1.0);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = (x + 1.0) / (x + 1.0) tmp = 0 if x <= -5.5e-17: tmp = t_1 elif x <= -6.4e-127: tmp = x * (1.0 + (-1.0 / (z * t))) elif x <= 1.7e-118: tmp = (y / t) / (x + 1.0) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(x + 1.0) / Float64(x + 1.0)) tmp = 0.0 if (x <= -5.5e-17) tmp = t_1; elseif (x <= -6.4e-127) tmp = Float64(x * Float64(1.0 + Float64(-1.0 / Float64(z * t)))); elseif (x <= 1.7e-118) tmp = Float64(Float64(y / t) / Float64(x + 1.0)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (x + 1.0) / (x + 1.0); tmp = 0.0; if (x <= -5.5e-17) tmp = t_1; elseif (x <= -6.4e-127) tmp = x * (1.0 + (-1.0 / (z * t))); elseif (x <= 1.7e-118) 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[(N[(x + 1.0), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -5.5e-17], t$95$1, If[LessEqual[x, -6.4e-127], N[(x * N[(1.0 + N[(-1.0 / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.7e-118], N[(N[(y / t), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{x + 1}{x + 1}\\
\mathbf{if}\;x \leq -5.5 \cdot 10^{-17}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -6.4 \cdot 10^{-127}:\\
\;\;\;\;x \cdot \left(1 + \frac{-1}{z \cdot t}\right)\\
\mathbf{elif}\;x \leq 1.7 \cdot 10^{-118}:\\
\;\;\;\;\frac{\frac{y}{t}}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if x < -5.50000000000000001e-17 or 1.69999999999999995e-118 < x Initial program 89.3%
*-commutative89.3%
Simplified89.3%
Taylor expanded in z around 0 82.6%
if -5.50000000000000001e-17 < x < -6.40000000000000035e-127Initial program 95.4%
*-commutative95.4%
Simplified95.4%
Taylor expanded in y around 0 67.7%
Taylor expanded in x around 0 53.9%
Taylor expanded in x around 0 53.9%
*-commutative53.9%
Simplified53.9%
if -6.40000000000000035e-127 < x < 1.69999999999999995e-118Initial program 89.0%
*-commutative89.0%
Simplified89.0%
Taylor expanded in z around inf 82.2%
Taylor expanded in y around inf 68.8%
associate-/r*68.8%
+-commutative68.8%
Simplified68.8%
Final simplification75.5%
(FPCore (x y z t) :precision binary64 (if (<= x -2.2e-45) (/ (+ x 1.0) (+ x 1.0)) (if (<= x 6.2e+14) (/ (+ x (/ y t)) (+ x 1.0)) (+ 1.0 (/ -1.0 x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -2.2e-45) {
tmp = (x + 1.0) / (x + 1.0);
} else if (x <= 6.2e+14) {
tmp = (x + (y / t)) / (x + 1.0);
} else {
tmp = 1.0 + (-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 (x <= (-2.2d-45)) then
tmp = (x + 1.0d0) / (x + 1.0d0)
else if (x <= 6.2d+14) then
tmp = (x + (y / t)) / (x + 1.0d0)
else
tmp = 1.0d0 + ((-1.0d0) / x)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= -2.2e-45) {
tmp = (x + 1.0) / (x + 1.0);
} else if (x <= 6.2e+14) {
tmp = (x + (y / t)) / (x + 1.0);
} else {
tmp = 1.0 + (-1.0 / x);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -2.2e-45: tmp = (x + 1.0) / (x + 1.0) elif x <= 6.2e+14: tmp = (x + (y / t)) / (x + 1.0) else: tmp = 1.0 + (-1.0 / x) return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -2.2e-45) tmp = Float64(Float64(x + 1.0) / Float64(x + 1.0)); elseif (x <= 6.2e+14) tmp = Float64(Float64(x + Float64(y / t)) / Float64(x + 1.0)); else tmp = Float64(1.0 + Float64(-1.0 / x)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -2.2e-45) tmp = (x + 1.0) / (x + 1.0); elseif (x <= 6.2e+14) tmp = (x + (y / t)) / (x + 1.0); else tmp = 1.0 + (-1.0 / x); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -2.2e-45], N[(N[(x + 1.0), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 6.2e+14], N[(N[(x + N[(y / t), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.2 \cdot 10^{-45}:\\
\;\;\;\;\frac{x + 1}{x + 1}\\
\mathbf{elif}\;x \leq 6.2 \cdot 10^{+14}:\\
\;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{-1}{x}\\
\end{array}
\end{array}
if x < -2.19999999999999993e-45Initial program 89.6%
*-commutative89.6%
Simplified89.6%
Taylor expanded in z around 0 86.2%
if -2.19999999999999993e-45 < x < 6.2e14Initial program 88.9%
*-commutative88.9%
Simplified88.9%
Taylor expanded in z around inf 73.0%
if 6.2e14 < x Initial program 91.5%
*-commutative91.5%
Simplified91.5%
Taylor expanded in x around inf 96.8%
Taylor expanded in x around inf 96.8%
Final simplification81.8%
(FPCore (x y z t) :precision binary64 (if (or (<= t -0.0115) (not (<= t 1.1e+17))) (/ x (+ x 1.0)) (/ (+ x 1.0) (+ x 1.0))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -0.0115) || !(t <= 1.1e+17)) {
tmp = x / (x + 1.0);
} else {
tmp = (x + 1.0) / (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 ((t <= (-0.0115d0)) .or. (.not. (t <= 1.1d+17))) then
tmp = x / (x + 1.0d0)
else
tmp = (x + 1.0d0) / (x + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -0.0115) || !(t <= 1.1e+17)) {
tmp = x / (x + 1.0);
} else {
tmp = (x + 1.0) / (x + 1.0);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -0.0115) or not (t <= 1.1e+17): tmp = x / (x + 1.0) else: tmp = (x + 1.0) / (x + 1.0) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -0.0115) || !(t <= 1.1e+17)) tmp = Float64(x / Float64(x + 1.0)); else tmp = Float64(Float64(x + 1.0) / Float64(x + 1.0)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -0.0115) || ~((t <= 1.1e+17))) tmp = x / (x + 1.0); else tmp = (x + 1.0) / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -0.0115], N[Not[LessEqual[t, 1.1e+17]], $MachinePrecision]], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x + 1.0), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -0.0115 \lor \neg \left(t \leq 1.1 \cdot 10^{+17}\right):\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x + 1}{x + 1}\\
\end{array}
\end{array}
if t < -0.0115 or 1.1e17 < t Initial program 88.7%
*-commutative88.7%
Simplified88.7%
Taylor expanded in x around inf 72.5%
if -0.0115 < t < 1.1e17Initial program 90.6%
*-commutative90.6%
Simplified90.6%
Taylor expanded in z around 0 49.1%
Final simplification60.3%
(FPCore (x y z t) :precision binary64 (if (<= x -6e-126) (/ x (+ x 1.0)) (if (<= x 1.65e-118) (/ (/ y t) (+ x 1.0)) (/ (+ x 1.0) (+ x 1.0)))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -6e-126) {
tmp = x / (x + 1.0);
} else if (x <= 1.65e-118) {
tmp = (y / t) / (x + 1.0);
} else {
tmp = (x + 1.0) / (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 (x <= (-6d-126)) then
tmp = x / (x + 1.0d0)
else if (x <= 1.65d-118) then
tmp = (y / t) / (x + 1.0d0)
else
tmp = (x + 1.0d0) / (x + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= -6e-126) {
tmp = x / (x + 1.0);
} else if (x <= 1.65e-118) {
tmp = (y / t) / (x + 1.0);
} else {
tmp = (x + 1.0) / (x + 1.0);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -6e-126: tmp = x / (x + 1.0) elif x <= 1.65e-118: tmp = (y / t) / (x + 1.0) else: tmp = (x + 1.0) / (x + 1.0) return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -6e-126) tmp = Float64(x / Float64(x + 1.0)); elseif (x <= 1.65e-118) tmp = Float64(Float64(y / t) / Float64(x + 1.0)); else tmp = Float64(Float64(x + 1.0) / Float64(x + 1.0)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -6e-126) tmp = x / (x + 1.0); elseif (x <= 1.65e-118) tmp = (y / t) / (x + 1.0); else tmp = (x + 1.0) / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -6e-126], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.65e-118], N[(N[(y / t), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x + 1.0), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6 \cdot 10^{-126}:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{elif}\;x \leq 1.65 \cdot 10^{-118}:\\
\;\;\;\;\frac{\frac{y}{t}}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x + 1}{x + 1}\\
\end{array}
\end{array}
if x < -6.0000000000000003e-126Initial program 90.5%
*-commutative90.5%
Simplified90.5%
Taylor expanded in x around inf 75.7%
if -6.0000000000000003e-126 < x < 1.65e-118Initial program 89.0%
*-commutative89.0%
Simplified89.0%
Taylor expanded in z around inf 82.2%
Taylor expanded in y around inf 68.8%
associate-/r*68.8%
+-commutative68.8%
Simplified68.8%
if 1.65e-118 < x Initial program 89.6%
*-commutative89.6%
Simplified89.6%
Taylor expanded in z around 0 77.4%
Final simplification73.9%
(FPCore (x y z t) :precision binary64 (+ 1.0 (/ -1.0 x)))
double code(double x, double y, double z, double t) {
return 1.0 + (-1.0 / x);
}
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 + ((-1.0d0) / x)
end function
public static double code(double x, double y, double z, double t) {
return 1.0 + (-1.0 / x);
}
def code(x, y, z, t): return 1.0 + (-1.0 / x)
function code(x, y, z, t) return Float64(1.0 + Float64(-1.0 / x)) end
function tmp = code(x, y, z, t) tmp = 1.0 + (-1.0 / x); end
code[x_, y_, z_, t_] := N[(1.0 + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{-1}{x}
\end{array}
Initial program 89.7%
*-commutative89.7%
Simplified89.7%
Taylor expanded in x around inf 54.2%
Taylor expanded in x around inf 44.3%
Final simplification44.3%
(FPCore (x y z t) :precision binary64 (/ x (+ x 1.0)))
double code(double x, double y, double z, double t) {
return 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 / (x + 1.0d0)
end function
public static double code(double x, double y, double z, double t) {
return x / (x + 1.0);
}
def code(x, y, z, t): return x / (x + 1.0)
function code(x, y, z, t) return Float64(x / Float64(x + 1.0)) end
function tmp = code(x, y, z, t) tmp = x / (x + 1.0); end
code[x_, y_, z_, t_] := N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{x + 1}
\end{array}
Initial program 89.7%
*-commutative89.7%
Simplified89.7%
Taylor expanded in x around inf 54.2%
Final simplification54.2%
(FPCore (x y z t) :precision binary64 (- x))
double code(double x, double y, double z, double t) {
return -x;
}
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
end function
public static double code(double x, double y, double z, double t) {
return -x;
}
def code(x, y, z, t): return -x
function code(x, y, z, t) return Float64(-x) end
function tmp = code(x, y, z, t) tmp = -x; end
code[x_, y_, z_, t_] := (-x)
\begin{array}{l}
\\
-x
\end{array}
Initial program 89.7%
*-commutative89.7%
Simplified89.7%
Taylor expanded in x around inf 54.2%
frac-2neg54.2%
neg-sub054.2%
div-sub54.2%
add-sqr-sqrt26.9%
sqrt-unprod13.8%
sqr-neg13.8%
sqrt-unprod1.3%
add-sqr-sqrt2.6%
frac-2neg2.6%
Applied egg-rr2.6%
div02.6%
+-commutative2.6%
neg-sub02.6%
distribute-neg-frac2.6%
+-commutative2.6%
Simplified2.6%
Taylor expanded in x around 0 3.2%
mul-1-neg3.2%
Simplified3.2%
Final simplification3.2%
(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 89.7%
*-commutative89.7%
Simplified89.7%
Taylor expanded in x around inf 54.2%
frac-2neg54.2%
neg-sub054.2%
div-sub54.2%
add-sqr-sqrt26.9%
sqrt-unprod13.8%
sqr-neg13.8%
sqrt-unprod1.3%
add-sqr-sqrt2.6%
frac-2neg2.6%
Applied egg-rr2.6%
div02.6%
+-commutative2.6%
neg-sub02.6%
distribute-neg-frac2.6%
+-commutative2.6%
Simplified2.6%
Taylor expanded in x around inf 2.6%
Final simplification2.6%
(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 2023332
(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)))