
(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 10 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 (- (* z t) x)) (t_2 (/ (+ x (/ (- (* y z) x) t_1)) (+ x 1.0))))
(if (<= t_2 -1e+305)
(* y (/ (/ z (+ x 1.0)) t_1))
(if (<= t_2 2e+245)
t_2
(+ (/ x (+ x 1.0)) (/ (- (/ y (+ x 1.0)) (/ x (* z (+ x 1.0)))) t))))))
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 <= -1e+305) {
tmp = y * ((z / (x + 1.0)) / t_1);
} else if (t_2 <= 2e+245) {
tmp = t_2;
} else {
tmp = (x / (x + 1.0)) + (((y / (x + 1.0)) - (x / (z * (x + 1.0)))) / t);
}
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 = (z * t) - x
t_2 = (x + (((y * z) - x) / t_1)) / (x + 1.0d0)
if (t_2 <= (-1d+305)) then
tmp = y * ((z / (x + 1.0d0)) / t_1)
else if (t_2 <= 2d+245) then
tmp = t_2
else
tmp = (x / (x + 1.0d0)) + (((y / (x + 1.0d0)) - (x / (z * (x + 1.0d0)))) / t)
end if
code = tmp
end function
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 <= -1e+305) {
tmp = y * ((z / (x + 1.0)) / t_1);
} else if (t_2 <= 2e+245) {
tmp = t_2;
} else {
tmp = (x / (x + 1.0)) + (((y / (x + 1.0)) - (x / (z * (x + 1.0)))) / t);
}
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 <= -1e+305: tmp = y * ((z / (x + 1.0)) / t_1) elif t_2 <= 2e+245: tmp = t_2 else: tmp = (x / (x + 1.0)) + (((y / (x + 1.0)) - (x / (z * (x + 1.0)))) / t) 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 <= -1e+305) tmp = Float64(y * Float64(Float64(z / Float64(x + 1.0)) / t_1)); elseif (t_2 <= 2e+245) tmp = t_2; else tmp = Float64(Float64(x / Float64(x + 1.0)) + Float64(Float64(Float64(y / Float64(x + 1.0)) - Float64(x / Float64(z * Float64(x + 1.0)))) / t)); 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 <= -1e+305) tmp = y * ((z / (x + 1.0)) / t_1); elseif (t_2 <= 2e+245) tmp = t_2; else tmp = (x / (x + 1.0)) + (((y / (x + 1.0)) - (x / (z * (x + 1.0)))) / t); 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, -1e+305], N[(y * N[(N[(z / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e+245], t$95$2, N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(y / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(x / N[(z * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t), $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 -1 \cdot 10^{+305}:\\
\;\;\;\;y \cdot \frac{\frac{z}{x + 1}}{t\_1}\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+245}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x + 1} + \frac{\frac{y}{x + 1} - \frac{x}{z \cdot \left(x + 1\right)}}{t}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) < -9.9999999999999994e304Initial program 55.4%
*-commutative55.4%
Simplified55.4%
clear-num55.5%
inv-pow55.5%
fma-neg55.5%
Applied egg-rr55.5%
Taylor expanded in y around inf 54.3%
associate-/l*67.5%
associate-/r*93.3%
*-commutative93.3%
Simplified93.3%
if -9.9999999999999994e304 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) < 2.00000000000000009e245Initial program 99.0%
if 2.00000000000000009e245 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) Initial program 31.3%
*-commutative31.3%
Simplified31.3%
Taylor expanded in t around -inf 88.2%
+-commutative88.2%
mul-1-neg88.2%
unsub-neg88.2%
+-commutative88.2%
Simplified88.2%
Final simplification97.9%
(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 -1e+305)
(* y (/ (/ z (+ x 1.0)) t_1))
(if (<= t_2 2e+245) 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 <= -1e+305) {
tmp = y * ((z / (x + 1.0)) / t_1);
} else if (t_2 <= 2e+245) {
tmp = t_2;
} else {
tmp = (x + (y / t)) / (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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = (z * t) - x
t_2 = (x + (((y * z) - x) / t_1)) / (x + 1.0d0)
if (t_2 <= (-1d+305)) then
tmp = y * ((z / (x + 1.0d0)) / t_1)
else if (t_2 <= 2d+245) then
tmp = t_2
else
tmp = (x + (y / t)) / (x + 1.0d0)
end if
code = tmp
end function
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 <= -1e+305) {
tmp = y * ((z / (x + 1.0)) / t_1);
} else if (t_2 <= 2e+245) {
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 <= -1e+305: tmp = y * ((z / (x + 1.0)) / t_1) elif t_2 <= 2e+245: 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 <= -1e+305) tmp = Float64(y * Float64(Float64(z / Float64(x + 1.0)) / t_1)); elseif (t_2 <= 2e+245) 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 <= -1e+305) tmp = y * ((z / (x + 1.0)) / t_1); elseif (t_2 <= 2e+245) 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, -1e+305], N[(y * N[(N[(z / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e+245], 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 -1 \cdot 10^{+305}:\\
\;\;\;\;y \cdot \frac{\frac{z}{x + 1}}{t\_1}\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+245}:\\
\;\;\;\;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 #s(literal 1 binary64))) < -9.9999999999999994e304Initial program 55.4%
*-commutative55.4%
Simplified55.4%
clear-num55.5%
inv-pow55.5%
fma-neg55.5%
Applied egg-rr55.5%
Taylor expanded in y around inf 54.3%
associate-/l*67.5%
associate-/r*93.3%
*-commutative93.3%
Simplified93.3%
if -9.9999999999999994e304 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) < 2.00000000000000009e245Initial program 99.0%
if 2.00000000000000009e245 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) Initial program 31.3%
*-commutative31.3%
Simplified31.3%
Taylor expanded in z around inf 88.1%
Final simplification97.9%
(FPCore (x y z t) :precision binary64 (if (or (<= t -3.2e-78) (not (<= t 1.15e-138))) (/ (+ x (/ y t)) (+ x 1.0)) (/ (- (+ x 1.0) (* y (/ z x))) (+ x 1.0))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -3.2e-78) || !(t <= 1.15e-138)) {
tmp = (x + (y / t)) / (x + 1.0);
} else {
tmp = ((x + 1.0) - (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 ((t <= (-3.2d-78)) .or. (.not. (t <= 1.15d-138))) then
tmp = (x + (y / t)) / (x + 1.0d0)
else
tmp = ((x + 1.0d0) - (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 ((t <= -3.2e-78) || !(t <= 1.15e-138)) {
tmp = (x + (y / t)) / (x + 1.0);
} else {
tmp = ((x + 1.0) - (y * (z / x))) / (x + 1.0);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -3.2e-78) or not (t <= 1.15e-138): tmp = (x + (y / t)) / (x + 1.0) else: tmp = ((x + 1.0) - (y * (z / x))) / (x + 1.0) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -3.2e-78) || !(t <= 1.15e-138)) tmp = Float64(Float64(x + Float64(y / t)) / Float64(x + 1.0)); else tmp = Float64(Float64(Float64(x + 1.0) - Float64(y * Float64(z / x))) / Float64(x + 1.0)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -3.2e-78) || ~((t <= 1.15e-138))) tmp = (x + (y / t)) / (x + 1.0); else tmp = ((x + 1.0) - (y * (z / x))) / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -3.2e-78], N[Not[LessEqual[t, 1.15e-138]], $MachinePrecision]], N[(N[(x + N[(y / t), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x + 1.0), $MachinePrecision] - N[(y * N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -3.2 \cdot 10^{-78} \lor \neg \left(t \leq 1.15 \cdot 10^{-138}\right):\\
\;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(x + 1\right) - y \cdot \frac{z}{x}}{x + 1}\\
\end{array}
\end{array}
if t < -3.2e-78 or 1.14999999999999995e-138 < t Initial program 89.3%
*-commutative89.3%
Simplified89.3%
Taylor expanded in z around inf 88.8%
if -3.2e-78 < t < 1.14999999999999995e-138Initial program 96.7%
*-commutative96.7%
Simplified96.7%
Taylor expanded in t around 0 85.1%
associate-+r+85.1%
mul-1-neg85.1%
unsub-neg85.1%
+-commutative85.1%
associate-/l*87.2%
+-commutative87.2%
Simplified87.2%
Final simplification88.2%
(FPCore (x y z t) :precision binary64 (if (or (<= t -1.5e-81) (not (<= t 9.6e-139))) (/ (+ x (/ y t)) (+ x 1.0)) (/ (+ -1.0 (- (/ (* y z) x) x)) (- -1.0 x))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -1.5e-81) || !(t <= 9.6e-139)) {
tmp = (x + (y / t)) / (x + 1.0);
} else {
tmp = (-1.0 + (((y * z) / x) - 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 ((t <= (-1.5d-81)) .or. (.not. (t <= 9.6d-139))) then
tmp = (x + (y / t)) / (x + 1.0d0)
else
tmp = ((-1.0d0) + (((y * z) / x) - 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 ((t <= -1.5e-81) || !(t <= 9.6e-139)) {
tmp = (x + (y / t)) / (x + 1.0);
} else {
tmp = (-1.0 + (((y * z) / x) - x)) / (-1.0 - x);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -1.5e-81) or not (t <= 9.6e-139): tmp = (x + (y / t)) / (x + 1.0) else: tmp = (-1.0 + (((y * z) / x) - x)) / (-1.0 - x) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -1.5e-81) || !(t <= 9.6e-139)) tmp = Float64(Float64(x + Float64(y / t)) / Float64(x + 1.0)); else tmp = Float64(Float64(-1.0 + Float64(Float64(Float64(y * z) / x) - x)) / Float64(-1.0 - x)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -1.5e-81) || ~((t <= 9.6e-139))) tmp = (x + (y / t)) / (x + 1.0); else tmp = (-1.0 + (((y * z) / x) - x)) / (-1.0 - x); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -1.5e-81], N[Not[LessEqual[t, 9.6e-139]], $MachinePrecision]], N[(N[(x + N[(y / t), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 + N[(N[(N[(y * z), $MachinePrecision] / x), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision] / N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.5 \cdot 10^{-81} \lor \neg \left(t \leq 9.6 \cdot 10^{-139}\right):\\
\;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1 + \left(\frac{y \cdot z}{x} - x\right)}{-1 - x}\\
\end{array}
\end{array}
if t < -1.4999999999999999e-81 or 9.60000000000000059e-139 < t Initial program 89.3%
*-commutative89.3%
Simplified89.3%
Taylor expanded in z around inf 88.8%
if -1.4999999999999999e-81 < t < 9.60000000000000059e-139Initial program 96.7%
*-commutative96.7%
Simplified96.7%
clear-num96.7%
inv-pow96.7%
fma-neg96.7%
Applied egg-rr96.7%
div-inv96.5%
unpow-prod-down96.6%
fma-neg96.6%
Applied egg-rr96.6%
unpow-196.6%
fma-neg96.6%
unpow-196.6%
fma-neg96.6%
*-commutative96.6%
Simplified96.6%
Taylor expanded in t around 0 85.1%
mul-1-neg85.1%
unsub-neg85.1%
*-commutative85.1%
Simplified85.1%
Final simplification87.5%
(FPCore (x y z t) :precision binary64 (if (or (<= z -1e-184) (not (<= z 4.8e-138))) (/ (+ x (/ y t)) (+ x 1.0)) (/ (+ x 1.0) (+ x 1.0))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -1e-184) || !(z <= 4.8e-138)) {
tmp = (x + (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 ((z <= (-1d-184)) .or. (.not. (z <= 4.8d-138))) then
tmp = (x + (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 ((z <= -1e-184) || !(z <= 4.8e-138)) {
tmp = (x + (y / t)) / (x + 1.0);
} else {
tmp = (x + 1.0) / (x + 1.0);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -1e-184) or not (z <= 4.8e-138): tmp = (x + (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 ((z <= -1e-184) || !(z <= 4.8e-138)) tmp = Float64(Float64(x + 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 ((z <= -1e-184) || ~((z <= 4.8e-138))) tmp = (x + (y / t)) / (x + 1.0); else tmp = (x + 1.0) / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -1e-184], N[Not[LessEqual[z, 4.8e-138]], $MachinePrecision]], N[(N[(x + N[(y / t), $MachinePrecision]), $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}\;z \leq -1 \cdot 10^{-184} \lor \neg \left(z \leq 4.8 \cdot 10^{-138}\right):\\
\;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x + 1}{x + 1}\\
\end{array}
\end{array}
if z < -1.0000000000000001e-184 or 4.7999999999999998e-138 < z Initial program 89.5%
*-commutative89.5%
Simplified89.5%
Taylor expanded in z around inf 79.4%
if -1.0000000000000001e-184 < z < 4.7999999999999998e-138Initial program 99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in z around 0 74.9%
Final simplification78.4%
(FPCore (x y z t) :precision binary64 (if (<= x -6.1e-30) (/ (+ x 1.0) (+ x 1.0)) (if (<= x 1.8e-97) (/ y (* t (+ x 1.0))) (/ x (+ x 1.0)))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -6.1e-30) {
tmp = (x + 1.0) / (x + 1.0);
} else if (x <= 1.8e-97) {
tmp = y / (t * (x + 1.0));
} else {
tmp = 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 (x <= (-6.1d-30)) then
tmp = (x + 1.0d0) / (x + 1.0d0)
else if (x <= 1.8d-97) then
tmp = y / (t * (x + 1.0d0))
else
tmp = 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 (x <= -6.1e-30) {
tmp = (x + 1.0) / (x + 1.0);
} else if (x <= 1.8e-97) {
tmp = y / (t * (x + 1.0));
} else {
tmp = x / (x + 1.0);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -6.1e-30: tmp = (x + 1.0) / (x + 1.0) elif x <= 1.8e-97: tmp = y / (t * (x + 1.0)) else: tmp = x / (x + 1.0) return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -6.1e-30) tmp = Float64(Float64(x + 1.0) / Float64(x + 1.0)); elseif (x <= 1.8e-97) tmp = Float64(y / Float64(t * Float64(x + 1.0))); else tmp = Float64(x / Float64(x + 1.0)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -6.1e-30) tmp = (x + 1.0) / (x + 1.0); elseif (x <= 1.8e-97) tmp = y / (t * (x + 1.0)); else tmp = x / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -6.1e-30], N[(N[(x + 1.0), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.8e-97], N[(y / N[(t * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.1 \cdot 10^{-30}:\\
\;\;\;\;\frac{x + 1}{x + 1}\\
\mathbf{elif}\;x \leq 1.8 \cdot 10^{-97}:\\
\;\;\;\;\frac{y}{t \cdot \left(x + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x + 1}\\
\end{array}
\end{array}
if x < -6.09999999999999981e-30Initial program 90.3%
*-commutative90.3%
Simplified90.3%
Taylor expanded in z around 0 88.2%
if -6.09999999999999981e-30 < x < 1.79999999999999999e-97Initial program 93.4%
*-commutative93.4%
Simplified93.4%
Taylor expanded in t around -inf 78.6%
mul-1-neg78.6%
unsub-neg78.6%
sub-neg78.6%
mul-1-neg78.6%
remove-double-neg78.6%
+-commutative78.6%
mul-1-neg78.6%
unsub-neg78.6%
Simplified78.6%
Taylor expanded in y around inf 60.9%
if 1.79999999999999999e-97 < x Initial program 91.4%
*-commutative91.4%
Simplified91.4%
Taylor expanded in t around inf 72.5%
+-commutative72.5%
Simplified72.5%
Final simplification72.1%
(FPCore (x y z t) :precision binary64 (if (<= x -950000000.0) (+ 1.0 (/ -1.0 x)) (if (<= x 1.3e-100) (/ y (* t (+ x 1.0))) (/ x (+ x 1.0)))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -950000000.0) {
tmp = 1.0 + (-1.0 / x);
} else if (x <= 1.3e-100) {
tmp = y / (t * (x + 1.0));
} else {
tmp = 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 (x <= (-950000000.0d0)) then
tmp = 1.0d0 + ((-1.0d0) / x)
else if (x <= 1.3d-100) then
tmp = y / (t * (x + 1.0d0))
else
tmp = 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 (x <= -950000000.0) {
tmp = 1.0 + (-1.0 / x);
} else if (x <= 1.3e-100) {
tmp = y / (t * (x + 1.0));
} else {
tmp = x / (x + 1.0);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -950000000.0: tmp = 1.0 + (-1.0 / x) elif x <= 1.3e-100: tmp = y / (t * (x + 1.0)) else: tmp = x / (x + 1.0) return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -950000000.0) tmp = Float64(1.0 + Float64(-1.0 / x)); elseif (x <= 1.3e-100) tmp = Float64(y / Float64(t * Float64(x + 1.0))); else tmp = Float64(x / Float64(x + 1.0)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -950000000.0) tmp = 1.0 + (-1.0 / x); elseif (x <= 1.3e-100) tmp = y / (t * (x + 1.0)); else tmp = x / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -950000000.0], N[(1.0 + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.3e-100], N[(y / N[(t * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -950000000:\\
\;\;\;\;1 + \frac{-1}{x}\\
\mathbf{elif}\;x \leq 1.3 \cdot 10^{-100}:\\
\;\;\;\;\frac{y}{t \cdot \left(x + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x + 1}\\
\end{array}
\end{array}
if x < -9.5e8Initial program 90.1%
*-commutative90.1%
Simplified90.1%
Taylor expanded in t around inf 95.1%
+-commutative95.1%
Simplified95.1%
Taylor expanded in x around inf 95.1%
if -9.5e8 < x < 1.2999999999999999e-100Initial program 93.2%
*-commutative93.2%
Simplified93.2%
Taylor expanded in t around -inf 75.6%
mul-1-neg75.6%
unsub-neg75.6%
sub-neg75.6%
mul-1-neg75.6%
remove-double-neg75.6%
+-commutative75.6%
mul-1-neg75.6%
unsub-neg75.6%
Simplified75.6%
Taylor expanded in y around inf 58.1%
if 1.2999999999999999e-100 < x Initial program 91.4%
*-commutative91.4%
Simplified91.4%
Taylor expanded in t around inf 72.5%
+-commutative72.5%
Simplified72.5%
Final simplification71.2%
(FPCore (x y z t) :precision binary64 (if (or (<= x -2.05e-17) (not (<= x 420.0))) (+ 1.0 (/ -1.0 x)) (* x (- 1.0 x))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -2.05e-17) || !(x <= 420.0)) {
tmp = 1.0 + (-1.0 / x);
} else {
tmp = 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 ((x <= (-2.05d-17)) .or. (.not. (x <= 420.0d0))) then
tmp = 1.0d0 + ((-1.0d0) / x)
else
tmp = 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 ((x <= -2.05e-17) || !(x <= 420.0)) {
tmp = 1.0 + (-1.0 / x);
} else {
tmp = x * (1.0 - x);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -2.05e-17) or not (x <= 420.0): tmp = 1.0 + (-1.0 / x) else: tmp = x * (1.0 - x) return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -2.05e-17) || !(x <= 420.0)) tmp = Float64(1.0 + Float64(-1.0 / x)); else tmp = Float64(x * Float64(1.0 - x)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x <= -2.05e-17) || ~((x <= 420.0))) tmp = 1.0 + (-1.0 / x); else tmp = x * (1.0 - x); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -2.05e-17], N[Not[LessEqual[x, 420.0]], $MachinePrecision]], N[(1.0 + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.05 \cdot 10^{-17} \lor \neg \left(x \leq 420\right):\\
\;\;\;\;1 + \frac{-1}{x}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - x\right)\\
\end{array}
\end{array}
if x < -2.05e-17 or 420 < x Initial program 89.0%
*-commutative89.0%
Simplified89.0%
Taylor expanded in t around inf 85.0%
+-commutative85.0%
Simplified85.0%
Taylor expanded in x around inf 84.8%
if -2.05e-17 < x < 420Initial program 94.7%
*-commutative94.7%
Simplified94.7%
Taylor expanded in t around inf 19.5%
+-commutative19.5%
Simplified19.5%
Taylor expanded in x around 0 19.5%
neg-mul-119.5%
sub-neg19.5%
Simplified19.5%
Final simplification51.1%
(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 91.9%
*-commutative91.9%
Simplified91.9%
Taylor expanded in t around inf 51.2%
+-commutative51.2%
Simplified51.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 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 91.9%
*-commutative91.9%
Simplified91.9%
Taylor expanded in t around inf 51.2%
+-commutative51.2%
Simplified51.2%
Taylor expanded in x around 0 10.6%
neg-mul-110.6%
sub-neg10.6%
Simplified10.6%
Taylor expanded in x around 0 11.4%
(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 2024114
(FPCore (x y z t)
:name "Diagrams.Trail:splitAtParam from diagrams-lib-1.3.0.3, A"
:precision binary64
:alt
(! :herbie-platform default (/ (+ x (- (/ y (- t (/ x z))) (/ x (- (* t z) x)))) (+ x 1)))
(/ (+ x (/ (- (* y z) x) (- (* t z) x))) (+ x 1.0)))