
(FPCore (x y z) :precision binary64 (/ (+ x y) (- 1.0 (/ y z))))
double code(double x, double y, double z) {
return (x + y) / (1.0 - (y / z));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + y) / (1.0d0 - (y / z))
end function
public static double code(double x, double y, double z) {
return (x + y) / (1.0 - (y / z));
}
def code(x, y, z): return (x + y) / (1.0 - (y / z))
function code(x, y, z) return Float64(Float64(x + y) / Float64(1.0 - Float64(y / z))) end
function tmp = code(x, y, z) tmp = (x + y) / (1.0 - (y / z)); end
code[x_, y_, z_] := N[(N[(x + y), $MachinePrecision] / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + y}{1 - \frac{y}{z}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (+ x y) (- 1.0 (/ y z))))
double code(double x, double y, double z) {
return (x + y) / (1.0 - (y / z));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + y) / (1.0d0 - (y / z))
end function
public static double code(double x, double y, double z) {
return (x + y) / (1.0 - (y / z));
}
def code(x, y, z): return (x + y) / (1.0 - (y / z))
function code(x, y, z) return Float64(Float64(x + y) / Float64(1.0 - Float64(y / z))) end
function tmp = code(x, y, z) tmp = (x + y) / (1.0 - (y / z)); end
code[x_, y_, z_] := N[(N[(x + y), $MachinePrecision] / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + y}{1 - \frac{y}{z}}
\end{array}
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (+ x y) (- 1.0 (/ y z)))))
(if (or (<= t_0 -5e-305) (not (<= t_0 2e-287)))
t_0
(- (- z) (/ (* z (+ x z)) y)))))
double code(double x, double y, double z) {
double t_0 = (x + y) / (1.0 - (y / z));
double tmp;
if ((t_0 <= -5e-305) || !(t_0 <= 2e-287)) {
tmp = t_0;
} else {
tmp = -z - ((z * (x + z)) / y);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (x + y) / (1.0d0 - (y / z))
if ((t_0 <= (-5d-305)) .or. (.not. (t_0 <= 2d-287))) then
tmp = t_0
else
tmp = -z - ((z * (x + z)) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x + y) / (1.0 - (y / z));
double tmp;
if ((t_0 <= -5e-305) || !(t_0 <= 2e-287)) {
tmp = t_0;
} else {
tmp = -z - ((z * (x + z)) / y);
}
return tmp;
}
def code(x, y, z): t_0 = (x + y) / (1.0 - (y / z)) tmp = 0 if (t_0 <= -5e-305) or not (t_0 <= 2e-287): tmp = t_0 else: tmp = -z - ((z * (x + z)) / y) return tmp
function code(x, y, z) t_0 = Float64(Float64(x + y) / Float64(1.0 - Float64(y / z))) tmp = 0.0 if ((t_0 <= -5e-305) || !(t_0 <= 2e-287)) tmp = t_0; else tmp = Float64(Float64(-z) - Float64(Float64(z * Float64(x + z)) / y)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x + y) / (1.0 - (y / z)); tmp = 0.0; if ((t_0 <= -5e-305) || ~((t_0 <= 2e-287))) tmp = t_0; else tmp = -z - ((z * (x + z)) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + y), $MachinePrecision] / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -5e-305], N[Not[LessEqual[t$95$0, 2e-287]], $MachinePrecision]], t$95$0, N[((-z) - N[(N[(z * N[(x + z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + y}{1 - \frac{y}{z}}\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-305} \lor \neg \left(t\_0 \leq 2 \cdot 10^{-287}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - \frac{z \cdot \left(x + z\right)}{y}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < -4.99999999999999985e-305 or 2.00000000000000004e-287 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) Initial program 99.9%
if -4.99999999999999985e-305 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < 2.00000000000000004e-287Initial program 8.6%
Taylor expanded in y around inf 99.9%
associate--l+99.9%
associate-*r/99.9%
div-sub99.9%
remove-double-neg99.9%
mul-1-neg99.9%
neg-mul-199.9%
distribute-lft-out--99.9%
mul-1-neg99.9%
distribute-neg-frac99.9%
unsub-neg99.9%
mul-1-neg99.9%
cancel-sign-sub-inv99.9%
metadata-eval99.9%
*-lft-identity99.9%
+-commutative99.9%
unpow299.9%
distribute-rgt-out99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (+ x y) (- 1.0 (/ y z)))))
(if (or (<= t_0 -5e-305) (not (<= t_0 2e-287)))
t_0
(- (- z) (/ (* x z) y)))))
double code(double x, double y, double z) {
double t_0 = (x + y) / (1.0 - (y / z));
double tmp;
if ((t_0 <= -5e-305) || !(t_0 <= 2e-287)) {
tmp = t_0;
} else {
tmp = -z - ((x * z) / y);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (x + y) / (1.0d0 - (y / z))
if ((t_0 <= (-5d-305)) .or. (.not. (t_0 <= 2d-287))) then
tmp = t_0
else
tmp = -z - ((x * z) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x + y) / (1.0 - (y / z));
double tmp;
if ((t_0 <= -5e-305) || !(t_0 <= 2e-287)) {
tmp = t_0;
} else {
tmp = -z - ((x * z) / y);
}
return tmp;
}
def code(x, y, z): t_0 = (x + y) / (1.0 - (y / z)) tmp = 0 if (t_0 <= -5e-305) or not (t_0 <= 2e-287): tmp = t_0 else: tmp = -z - ((x * z) / y) return tmp
function code(x, y, z) t_0 = Float64(Float64(x + y) / Float64(1.0 - Float64(y / z))) tmp = 0.0 if ((t_0 <= -5e-305) || !(t_0 <= 2e-287)) tmp = t_0; else tmp = Float64(Float64(-z) - Float64(Float64(x * z) / y)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x + y) / (1.0 - (y / z)); tmp = 0.0; if ((t_0 <= -5e-305) || ~((t_0 <= 2e-287))) tmp = t_0; else tmp = -z - ((x * z) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + y), $MachinePrecision] / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -5e-305], N[Not[LessEqual[t$95$0, 2e-287]], $MachinePrecision]], t$95$0, N[((-z) - N[(N[(x * z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + y}{1 - \frac{y}{z}}\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-305} \lor \neg \left(t\_0 \leq 2 \cdot 10^{-287}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - \frac{x \cdot z}{y}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < -4.99999999999999985e-305 or 2.00000000000000004e-287 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) Initial program 99.9%
if -4.99999999999999985e-305 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < 2.00000000000000004e-287Initial program 8.6%
Taylor expanded in z around 0 97.0%
Taylor expanded in x around 0 99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ y z))) (t_1 (/ y t_0)) (t_2 (/ x t_0)))
(if (<= y -1.75e+15)
t_1
(if (<= y -7.5e-262)
t_2
(if (<= y 7.5e-183)
(+ x y)
(if (<= y 4.5e-8) t_2 (if (<= y 1.9e+219) t_1 (- z))))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double t_1 = y / t_0;
double t_2 = x / t_0;
double tmp;
if (y <= -1.75e+15) {
tmp = t_1;
} else if (y <= -7.5e-262) {
tmp = t_2;
} else if (y <= 7.5e-183) {
tmp = x + y;
} else if (y <= 4.5e-8) {
tmp = t_2;
} else if (y <= 1.9e+219) {
tmp = t_1;
} else {
tmp = -z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = 1.0d0 - (y / z)
t_1 = y / t_0
t_2 = x / t_0
if (y <= (-1.75d+15)) then
tmp = t_1
else if (y <= (-7.5d-262)) then
tmp = t_2
else if (y <= 7.5d-183) then
tmp = x + y
else if (y <= 4.5d-8) then
tmp = t_2
else if (y <= 1.9d+219) then
tmp = t_1
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double t_1 = y / t_0;
double t_2 = x / t_0;
double tmp;
if (y <= -1.75e+15) {
tmp = t_1;
} else if (y <= -7.5e-262) {
tmp = t_2;
} else if (y <= 7.5e-183) {
tmp = x + y;
} else if (y <= 4.5e-8) {
tmp = t_2;
} else if (y <= 1.9e+219) {
tmp = t_1;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (y / z) t_1 = y / t_0 t_2 = x / t_0 tmp = 0 if y <= -1.75e+15: tmp = t_1 elif y <= -7.5e-262: tmp = t_2 elif y <= 7.5e-183: tmp = x + y elif y <= 4.5e-8: tmp = t_2 elif y <= 1.9e+219: tmp = t_1 else: tmp = -z return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(y / z)) t_1 = Float64(y / t_0) t_2 = Float64(x / t_0) tmp = 0.0 if (y <= -1.75e+15) tmp = t_1; elseif (y <= -7.5e-262) tmp = t_2; elseif (y <= 7.5e-183) tmp = Float64(x + y); elseif (y <= 4.5e-8) tmp = t_2; elseif (y <= 1.9e+219) tmp = t_1; else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (y / z); t_1 = y / t_0; t_2 = x / t_0; tmp = 0.0; if (y <= -1.75e+15) tmp = t_1; elseif (y <= -7.5e-262) tmp = t_2; elseif (y <= 7.5e-183) tmp = x + y; elseif (y <= 4.5e-8) tmp = t_2; elseif (y <= 1.9e+219) tmp = t_1; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y / t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(x / t$95$0), $MachinePrecision]}, If[LessEqual[y, -1.75e+15], t$95$1, If[LessEqual[y, -7.5e-262], t$95$2, If[LessEqual[y, 7.5e-183], N[(x + y), $MachinePrecision], If[LessEqual[y, 4.5e-8], t$95$2, If[LessEqual[y, 1.9e+219], t$95$1, (-z)]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{y}{z}\\
t_1 := \frac{y}{t\_0}\\
t_2 := \frac{x}{t\_0}\\
\mathbf{if}\;y \leq -1.75 \cdot 10^{+15}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -7.5 \cdot 10^{-262}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;y \leq 7.5 \cdot 10^{-183}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;y \leq 4.5 \cdot 10^{-8}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;y \leq 1.9 \cdot 10^{+219}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -1.75e15 or 4.49999999999999993e-8 < y < 1.89999999999999998e219Initial program 79.0%
Taylor expanded in x around 0 64.7%
if -1.75e15 < y < -7.5000000000000002e-262 or 7.5000000000000004e-183 < y < 4.49999999999999993e-8Initial program 99.9%
Taylor expanded in x around inf 71.2%
if -7.5000000000000002e-262 < y < 7.5000000000000004e-183Initial program 100.0%
Taylor expanded in z around inf 97.8%
+-commutative97.8%
Simplified97.8%
if 1.89999999999999998e219 < y Initial program 47.3%
Taylor expanded in y around inf 94.5%
mul-1-neg94.5%
Simplified94.5%
Final simplification74.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ x (- 1.0 (/ y z)))))
(if (<= y -1.02e+71)
(- z)
(if (<= y -2.5e-262)
t_0
(if (<= y 1.85e-183) (+ x y) (if (<= y 0.00015) t_0 (- z)))))))
double code(double x, double y, double z) {
double t_0 = x / (1.0 - (y / z));
double tmp;
if (y <= -1.02e+71) {
tmp = -z;
} else if (y <= -2.5e-262) {
tmp = t_0;
} else if (y <= 1.85e-183) {
tmp = x + y;
} else if (y <= 0.00015) {
tmp = t_0;
} else {
tmp = -z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = x / (1.0d0 - (y / z))
if (y <= (-1.02d+71)) then
tmp = -z
else if (y <= (-2.5d-262)) then
tmp = t_0
else if (y <= 1.85d-183) then
tmp = x + y
else if (y <= 0.00015d0) then
tmp = t_0
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x / (1.0 - (y / z));
double tmp;
if (y <= -1.02e+71) {
tmp = -z;
} else if (y <= -2.5e-262) {
tmp = t_0;
} else if (y <= 1.85e-183) {
tmp = x + y;
} else if (y <= 0.00015) {
tmp = t_0;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): t_0 = x / (1.0 - (y / z)) tmp = 0 if y <= -1.02e+71: tmp = -z elif y <= -2.5e-262: tmp = t_0 elif y <= 1.85e-183: tmp = x + y elif y <= 0.00015: tmp = t_0 else: tmp = -z return tmp
function code(x, y, z) t_0 = Float64(x / Float64(1.0 - Float64(y / z))) tmp = 0.0 if (y <= -1.02e+71) tmp = Float64(-z); elseif (y <= -2.5e-262) tmp = t_0; elseif (y <= 1.85e-183) tmp = Float64(x + y); elseif (y <= 0.00015) tmp = t_0; else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x / (1.0 - (y / z)); tmp = 0.0; if (y <= -1.02e+71) tmp = -z; elseif (y <= -2.5e-262) tmp = t_0; elseif (y <= 1.85e-183) tmp = x + y; elseif (y <= 0.00015) tmp = t_0; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.02e+71], (-z), If[LessEqual[y, -2.5e-262], t$95$0, If[LessEqual[y, 1.85e-183], N[(x + y), $MachinePrecision], If[LessEqual[y, 0.00015], t$95$0, (-z)]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{1 - \frac{y}{z}}\\
\mathbf{if}\;y \leq -1.02 \cdot 10^{+71}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -2.5 \cdot 10^{-262}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.85 \cdot 10^{-183}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;y \leq 0.00015:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -1.02000000000000003e71 or 1.49999999999999987e-4 < y Initial program 71.2%
Taylor expanded in y around inf 65.0%
mul-1-neg65.0%
Simplified65.0%
if -1.02000000000000003e71 < y < -2.49999999999999996e-262 or 1.8499999999999999e-183 < y < 1.49999999999999987e-4Initial program 99.1%
Taylor expanded in x around inf 66.6%
if -2.49999999999999996e-262 < y < 1.8499999999999999e-183Initial program 100.0%
Taylor expanded in z around inf 97.8%
+-commutative97.8%
Simplified97.8%
Final simplification71.1%
(FPCore (x y z) :precision binary64 (if (<= y -1.12e-20) (- z) (if (<= y 1.35e-119) x (if (<= y 2.2e-66) y (if (<= y 1.5e-11) x (- z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.12e-20) {
tmp = -z;
} else if (y <= 1.35e-119) {
tmp = x;
} else if (y <= 2.2e-66) {
tmp = y;
} else if (y <= 1.5e-11) {
tmp = x;
} else {
tmp = -z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-1.12d-20)) then
tmp = -z
else if (y <= 1.35d-119) then
tmp = x
else if (y <= 2.2d-66) then
tmp = y
else if (y <= 1.5d-11) then
tmp = x
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.12e-20) {
tmp = -z;
} else if (y <= 1.35e-119) {
tmp = x;
} else if (y <= 2.2e-66) {
tmp = y;
} else if (y <= 1.5e-11) {
tmp = x;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.12e-20: tmp = -z elif y <= 1.35e-119: tmp = x elif y <= 2.2e-66: tmp = y elif y <= 1.5e-11: tmp = x else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.12e-20) tmp = Float64(-z); elseif (y <= 1.35e-119) tmp = x; elseif (y <= 2.2e-66) tmp = y; elseif (y <= 1.5e-11) tmp = x; else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.12e-20) tmp = -z; elseif (y <= 1.35e-119) tmp = x; elseif (y <= 2.2e-66) tmp = y; elseif (y <= 1.5e-11) tmp = x; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.12e-20], (-z), If[LessEqual[y, 1.35e-119], x, If[LessEqual[y, 2.2e-66], y, If[LessEqual[y, 1.5e-11], x, (-z)]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.12 \cdot 10^{-20}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{-119}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 2.2 \cdot 10^{-66}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 1.5 \cdot 10^{-11}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -1.12000000000000002e-20 or 1.5e-11 < y Initial program 75.3%
Taylor expanded in y around inf 59.2%
mul-1-neg59.2%
Simplified59.2%
if -1.12000000000000002e-20 < y < 1.35000000000000013e-119 or 2.2000000000000001e-66 < y < 1.5e-11Initial program 99.9%
Taylor expanded in y around 0 63.6%
if 1.35000000000000013e-119 < y < 2.2000000000000001e-66Initial program 99.9%
Taylor expanded in x around 0 59.9%
Taylor expanded in y around 0 38.1%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.3e+25) (not (<= z 1.2e-52))) (+ x y) (- (- z) (/ (* x z) y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.3e+25) || !(z <= 1.2e-52)) {
tmp = x + y;
} else {
tmp = -z - ((x * z) / y);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-2.3d+25)) .or. (.not. (z <= 1.2d-52))) then
tmp = x + y
else
tmp = -z - ((x * z) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -2.3e+25) || !(z <= 1.2e-52)) {
tmp = x + y;
} else {
tmp = -z - ((x * z) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.3e+25) or not (z <= 1.2e-52): tmp = x + y else: tmp = -z - ((x * z) / y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.3e+25) || !(z <= 1.2e-52)) tmp = Float64(x + y); else tmp = Float64(Float64(-z) - Float64(Float64(x * z) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2.3e+25) || ~((z <= 1.2e-52))) tmp = x + y; else tmp = -z - ((x * z) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.3e+25], N[Not[LessEqual[z, 1.2e-52]], $MachinePrecision]], N[(x + y), $MachinePrecision], N[((-z) - N[(N[(x * z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.3 \cdot 10^{+25} \lor \neg \left(z \leq 1.2 \cdot 10^{-52}\right):\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - \frac{x \cdot z}{y}\\
\end{array}
\end{array}
if z < -2.2999999999999998e25 or 1.2000000000000001e-52 < z Initial program 99.9%
Taylor expanded in z around inf 77.7%
+-commutative77.7%
Simplified77.7%
if -2.2999999999999998e25 < z < 1.2000000000000001e-52Initial program 74.9%
Taylor expanded in z around 0 76.0%
Taylor expanded in x around 0 83.6%
Final simplification80.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.5e+25) (not (<= z 2.15e-51))) (+ x y) (* z (/ (+ x y) (- y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.5e+25) || !(z <= 2.15e-51)) {
tmp = x + y;
} else {
tmp = z * ((x + y) / -y);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-2.5d+25)) .or. (.not. (z <= 2.15d-51))) then
tmp = x + y
else
tmp = z * ((x + y) / -y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -2.5e+25) || !(z <= 2.15e-51)) {
tmp = x + y;
} else {
tmp = z * ((x + y) / -y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.5e+25) or not (z <= 2.15e-51): tmp = x + y else: tmp = z * ((x + y) / -y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.5e+25) || !(z <= 2.15e-51)) tmp = Float64(x + y); else tmp = Float64(z * Float64(Float64(x + y) / Float64(-y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2.5e+25) || ~((z <= 2.15e-51))) tmp = x + y; else tmp = z * ((x + y) / -y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.5e+25], N[Not[LessEqual[z, 2.15e-51]], $MachinePrecision]], N[(x + y), $MachinePrecision], N[(z * N[(N[(x + y), $MachinePrecision] / (-y)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.5 \cdot 10^{+25} \lor \neg \left(z \leq 2.15 \cdot 10^{-51}\right):\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{x + y}{-y}\\
\end{array}
\end{array}
if z < -2.50000000000000012e25 or 2.1499999999999999e-51 < z Initial program 99.9%
Taylor expanded in z around inf 77.7%
+-commutative77.7%
Simplified77.7%
if -2.50000000000000012e25 < z < 2.1499999999999999e-51Initial program 74.9%
Taylor expanded in z around 0 76.0%
*-commutative76.0%
associate-/l*83.0%
associate-*r*83.0%
associate-*l/83.0%
*-commutative83.0%
neg-mul-183.0%
distribute-neg-in83.0%
unsub-neg83.0%
Simplified83.0%
Final simplification80.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -8.2e+73) (not (<= y 2.1e+28))) (- z) (+ x y)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -8.2e+73) || !(y <= 2.1e+28)) {
tmp = -z;
} else {
tmp = x + y;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-8.2d+73)) .or. (.not. (y <= 2.1d+28))) then
tmp = -z
else
tmp = x + y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -8.2e+73) || !(y <= 2.1e+28)) {
tmp = -z;
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -8.2e+73) or not (y <= 2.1e+28): tmp = -z else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -8.2e+73) || !(y <= 2.1e+28)) tmp = Float64(-z); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -8.2e+73) || ~((y <= 2.1e+28))) tmp = -z; else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -8.2e+73], N[Not[LessEqual[y, 2.1e+28]], $MachinePrecision]], (-z), N[(x + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.2 \cdot 10^{+73} \lor \neg \left(y \leq 2.1 \cdot 10^{+28}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if y < -8.1999999999999996e73 or 2.09999999999999989e28 < y Initial program 68.7%
Taylor expanded in y around inf 66.9%
mul-1-neg66.9%
Simplified66.9%
if -8.1999999999999996e73 < y < 2.09999999999999989e28Initial program 99.4%
Taylor expanded in z around inf 67.7%
+-commutative67.7%
Simplified67.7%
Final simplification67.4%
(FPCore (x y z) :precision binary64 (if (<= x -1.6e-165) x (if (<= x 7.5e-159) y x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.6e-165) {
tmp = x;
} else if (x <= 7.5e-159) {
tmp = y;
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= (-1.6d-165)) then
tmp = x
else if (x <= 7.5d-159) then
tmp = y
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.6e-165) {
tmp = x;
} else if (x <= 7.5e-159) {
tmp = y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.6e-165: tmp = x elif x <= 7.5e-159: tmp = y else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.6e-165) tmp = x; elseif (x <= 7.5e-159) tmp = y; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.6e-165) tmp = x; elseif (x <= 7.5e-159) tmp = y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.6e-165], x, If[LessEqual[x, 7.5e-159], y, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.6 \cdot 10^{-165}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{-159}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1.60000000000000006e-165 or 7.5e-159 < x Initial program 88.3%
Taylor expanded in y around 0 40.2%
if -1.60000000000000006e-165 < x < 7.5e-159Initial program 87.5%
Taylor expanded in x around 0 73.9%
Taylor expanded in y around 0 36.0%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x
end function
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 88.1%
Taylor expanded in y around 0 34.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (/ (+ y x) (- y)) z)))
(if (< y -3.7429310762689856e+171)
t_0
(if (< y 3.5534662456086734e+168) (/ (+ x y) (- 1.0 (/ y z))) t_0))))
double code(double x, double y, double z) {
double t_0 = ((y + x) / -y) * z;
double tmp;
if (y < -3.7429310762689856e+171) {
tmp = t_0;
} else if (y < 3.5534662456086734e+168) {
tmp = (x + y) / (1.0 - (y / z));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = ((y + x) / -y) * z
if (y < (-3.7429310762689856d+171)) then
tmp = t_0
else if (y < 3.5534662456086734d+168) then
tmp = (x + y) / (1.0d0 - (y / z))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = ((y + x) / -y) * z;
double tmp;
if (y < -3.7429310762689856e+171) {
tmp = t_0;
} else if (y < 3.5534662456086734e+168) {
tmp = (x + y) / (1.0 - (y / z));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = ((y + x) / -y) * z tmp = 0 if y < -3.7429310762689856e+171: tmp = t_0 elif y < 3.5534662456086734e+168: tmp = (x + y) / (1.0 - (y / z)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(y + x) / Float64(-y)) * z) tmp = 0.0 if (y < -3.7429310762689856e+171) tmp = t_0; elseif (y < 3.5534662456086734e+168) tmp = Float64(Float64(x + y) / Float64(1.0 - Float64(y / z))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = ((y + x) / -y) * z; tmp = 0.0; if (y < -3.7429310762689856e+171) tmp = t_0; elseif (y < 3.5534662456086734e+168) tmp = (x + y) / (1.0 - (y / z)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(y + x), $MachinePrecision] / (-y)), $MachinePrecision] * z), $MachinePrecision]}, If[Less[y, -3.7429310762689856e+171], t$95$0, If[Less[y, 3.5534662456086734e+168], N[(N[(x + y), $MachinePrecision] / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y + x}{-y} \cdot z\\
\mathbf{if}\;y < -3.7429310762689856 \cdot 10^{+171}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y < 3.5534662456086734 \cdot 10^{+168}:\\
\;\;\;\;\frac{x + y}{1 - \frac{y}{z}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
herbie shell --seed 2024103
(FPCore (x y z)
:name "Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, A"
:precision binary64
:alt
(if (< y -3.7429310762689856e+171) (* (/ (+ y x) (- y)) z) (if (< y 3.5534662456086734e+168) (/ (+ x y) (- 1.0 (/ y z))) (* (/ (+ y x) (- y)) z)))
(/ (+ x y) (- 1.0 (/ y z))))