
(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 11 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 -1e-252) (not (<= t_0 0.0)))
t_0
(- (/ (* z (- (- x) z)) y) z))))
double code(double x, double y, double z) {
double t_0 = (x + y) / (1.0 - (y / z));
double tmp;
if ((t_0 <= -1e-252) || !(t_0 <= 0.0)) {
tmp = t_0;
} else {
tmp = ((z * (-x - z)) / y) - 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 + y) / (1.0d0 - (y / z))
if ((t_0 <= (-1d-252)) .or. (.not. (t_0 <= 0.0d0))) then
tmp = t_0
else
tmp = ((z * (-x - z)) / y) - z
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 <= -1e-252) || !(t_0 <= 0.0)) {
tmp = t_0;
} else {
tmp = ((z * (-x - z)) / y) - z;
}
return tmp;
}
def code(x, y, z): t_0 = (x + y) / (1.0 - (y / z)) tmp = 0 if (t_0 <= -1e-252) or not (t_0 <= 0.0): tmp = t_0 else: tmp = ((z * (-x - z)) / y) - z 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 <= -1e-252) || !(t_0 <= 0.0)) tmp = t_0; else tmp = Float64(Float64(Float64(z * Float64(Float64(-x) - z)) / y) - z); 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 <= -1e-252) || ~((t_0 <= 0.0))) tmp = t_0; else tmp = ((z * (-x - z)) / y) - z; 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, -1e-252], N[Not[LessEqual[t$95$0, 0.0]], $MachinePrecision]], t$95$0, N[(N[(N[(z * N[((-x) - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision] - z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + y}{1 - \frac{y}{z}}\\
\mathbf{if}\;t_0 \leq -1 \cdot 10^{-252} \lor \neg \left(t_0 \leq 0\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{z \cdot \left(\left(-x\right) - z\right)}{y} - z\\
\end{array}
\end{array}
if (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < -9.99999999999999943e-253 or -0.0 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) Initial program 99.9%
if -9.99999999999999943e-253 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < -0.0Initial program 8.7%
Taylor expanded in y around inf 100.0%
associate--l+100.0%
+-commutative100.0%
associate-*r/100.0%
div-sub100.0%
sub-neg100.0%
mul-1-neg100.0%
distribute-neg-out100.0%
*-lft-identity100.0%
metadata-eval100.0%
cancel-sign-sub-inv100.0%
distribute-neg-frac100.0%
mul-1-neg100.0%
mul-1-neg100.0%
unsub-neg100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (let* ((t_0 (/ (+ x y) (- 1.0 (/ y z))))) (if (or (<= t_0 -1e-233) (not (<= t_0 0.0))) t_0 (/ (- z) (/ y (+ x y))))))
double code(double x, double y, double z) {
double t_0 = (x + y) / (1.0 - (y / z));
double tmp;
if ((t_0 <= -1e-233) || !(t_0 <= 0.0)) {
tmp = t_0;
} else {
tmp = -z / (y / (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) :: t_0
real(8) :: tmp
t_0 = (x + y) / (1.0d0 - (y / z))
if ((t_0 <= (-1d-233)) .or. (.not. (t_0 <= 0.0d0))) then
tmp = t_0
else
tmp = -z / (y / (x + 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 <= -1e-233) || !(t_0 <= 0.0)) {
tmp = t_0;
} else {
tmp = -z / (y / (x + y));
}
return tmp;
}
def code(x, y, z): t_0 = (x + y) / (1.0 - (y / z)) tmp = 0 if (t_0 <= -1e-233) or not (t_0 <= 0.0): tmp = t_0 else: tmp = -z / (y / (x + 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 <= -1e-233) || !(t_0 <= 0.0)) tmp = t_0; else tmp = Float64(Float64(-z) / Float64(y / Float64(x + 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 <= -1e-233) || ~((t_0 <= 0.0))) tmp = t_0; else tmp = -z / (y / (x + 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, -1e-233], N[Not[LessEqual[t$95$0, 0.0]], $MachinePrecision]], t$95$0, N[((-z) / N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + y}{1 - \frac{y}{z}}\\
\mathbf{if}\;t_0 \leq -1 \cdot 10^{-233} \lor \neg \left(t_0 \leq 0\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{-z}{\frac{y}{x + y}}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < -9.99999999999999958e-234 or -0.0 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) Initial program 99.9%
if -9.99999999999999958e-234 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < -0.0Initial program 11.2%
Taylor expanded in z around 0 94.7%
mul-1-neg94.7%
associate-/l*99.9%
distribute-neg-frac99.9%
+-commutative99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ y z))) (t_1 (- (- z) (* z (/ x y)))))
(if (<= y -2.8e+144)
t_1
(if (<= y -7.1e+59)
(/ y t_0)
(if (<= y 6e-98) (/ x t_0) (if (<= y 6.8e+57) (+ x y) t_1))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double t_1 = -z - (z * (x / y));
double tmp;
if (y <= -2.8e+144) {
tmp = t_1;
} else if (y <= -7.1e+59) {
tmp = y / t_0;
} else if (y <= 6e-98) {
tmp = x / t_0;
} else if (y <= 6.8e+57) {
tmp = x + y;
} else {
tmp = t_1;
}
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) :: tmp
t_0 = 1.0d0 - (y / z)
t_1 = -z - (z * (x / y))
if (y <= (-2.8d+144)) then
tmp = t_1
else if (y <= (-7.1d+59)) then
tmp = y / t_0
else if (y <= 6d-98) then
tmp = x / t_0
else if (y <= 6.8d+57) then
tmp = x + y
else
tmp = t_1
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 = -z - (z * (x / y));
double tmp;
if (y <= -2.8e+144) {
tmp = t_1;
} else if (y <= -7.1e+59) {
tmp = y / t_0;
} else if (y <= 6e-98) {
tmp = x / t_0;
} else if (y <= 6.8e+57) {
tmp = x + y;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (y / z) t_1 = -z - (z * (x / y)) tmp = 0 if y <= -2.8e+144: tmp = t_1 elif y <= -7.1e+59: tmp = y / t_0 elif y <= 6e-98: tmp = x / t_0 elif y <= 6.8e+57: tmp = x + y else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(y / z)) t_1 = Float64(Float64(-z) - Float64(z * Float64(x / y))) tmp = 0.0 if (y <= -2.8e+144) tmp = t_1; elseif (y <= -7.1e+59) tmp = Float64(y / t_0); elseif (y <= 6e-98) tmp = Float64(x / t_0); elseif (y <= 6.8e+57) tmp = Float64(x + y); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (y / z); t_1 = -z - (z * (x / y)); tmp = 0.0; if (y <= -2.8e+144) tmp = t_1; elseif (y <= -7.1e+59) tmp = y / t_0; elseif (y <= 6e-98) tmp = x / t_0; elseif (y <= 6.8e+57) tmp = x + y; else tmp = t_1; 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[((-z) - N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.8e+144], t$95$1, If[LessEqual[y, -7.1e+59], N[(y / t$95$0), $MachinePrecision], If[LessEqual[y, 6e-98], N[(x / t$95$0), $MachinePrecision], If[LessEqual[y, 6.8e+57], N[(x + y), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{y}{z}\\
t_1 := \left(-z\right) - z \cdot \frac{x}{y}\\
\mathbf{if}\;y \leq -2.8 \cdot 10^{+144}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -7.1 \cdot 10^{+59}:\\
\;\;\;\;\frac{y}{t_0}\\
\mathbf{elif}\;y \leq 6 \cdot 10^{-98}:\\
\;\;\;\;\frac{x}{t_0}\\
\mathbf{elif}\;y \leq 6.8 \cdot 10^{+57}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if y < -2.80000000000000007e144 or 6.79999999999999984e57 < y Initial program 63.1%
Taylor expanded in y around inf 77.2%
associate--l+77.2%
+-commutative77.2%
associate-*r/77.2%
div-sub77.2%
sub-neg77.2%
mul-1-neg77.2%
distribute-neg-out77.2%
*-lft-identity77.2%
metadata-eval77.2%
cancel-sign-sub-inv77.2%
distribute-neg-frac77.2%
mul-1-neg77.2%
mul-1-neg77.2%
unsub-neg77.2%
Simplified77.2%
Taylor expanded in z around 0 79.1%
mul-1-neg79.1%
*-commutative79.1%
associate-*r/83.8%
distribute-rgt-neg-in83.8%
distribute-neg-frac83.8%
Simplified83.8%
if -2.80000000000000007e144 < y < -7.10000000000000003e59Initial program 92.8%
Taylor expanded in x around 0 91.5%
if -7.10000000000000003e59 < y < 6e-98Initial program 99.2%
Taylor expanded in x around inf 80.2%
if 6e-98 < y < 6.79999999999999984e57Initial program 95.2%
Taylor expanded in z around inf 68.1%
+-commutative68.1%
Simplified68.1%
Final simplification80.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ y z))))
(if (<= y -2.2e+174)
(- z)
(if (<= y -1.36e+57)
(/ y t_0)
(if (<= y 8.5e-97) (/ x t_0) (if (<= y 9.6e+120) (+ x y) (- z)))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double tmp;
if (y <= -2.2e+174) {
tmp = -z;
} else if (y <= -1.36e+57) {
tmp = y / t_0;
} else if (y <= 8.5e-97) {
tmp = x / t_0;
} else if (y <= 9.6e+120) {
tmp = x + y;
} 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 = 1.0d0 - (y / z)
if (y <= (-2.2d+174)) then
tmp = -z
else if (y <= (-1.36d+57)) then
tmp = y / t_0
else if (y <= 8.5d-97) then
tmp = x / t_0
else if (y <= 9.6d+120) then
tmp = x + y
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 tmp;
if (y <= -2.2e+174) {
tmp = -z;
} else if (y <= -1.36e+57) {
tmp = y / t_0;
} else if (y <= 8.5e-97) {
tmp = x / t_0;
} else if (y <= 9.6e+120) {
tmp = x + y;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (y / z) tmp = 0 if y <= -2.2e+174: tmp = -z elif y <= -1.36e+57: tmp = y / t_0 elif y <= 8.5e-97: tmp = x / t_0 elif y <= 9.6e+120: tmp = x + y else: tmp = -z return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(y / z)) tmp = 0.0 if (y <= -2.2e+174) tmp = Float64(-z); elseif (y <= -1.36e+57) tmp = Float64(y / t_0); elseif (y <= 8.5e-97) tmp = Float64(x / t_0); elseif (y <= 9.6e+120) tmp = Float64(x + y); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (y / z); tmp = 0.0; if (y <= -2.2e+174) tmp = -z; elseif (y <= -1.36e+57) tmp = y / t_0; elseif (y <= 8.5e-97) tmp = x / t_0; elseif (y <= 9.6e+120) tmp = x + y; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.2e+174], (-z), If[LessEqual[y, -1.36e+57], N[(y / t$95$0), $MachinePrecision], If[LessEqual[y, 8.5e-97], N[(x / t$95$0), $MachinePrecision], If[LessEqual[y, 9.6e+120], N[(x + y), $MachinePrecision], (-z)]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{y}{z}\\
\mathbf{if}\;y \leq -2.2 \cdot 10^{+174}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -1.36 \cdot 10^{+57}:\\
\;\;\;\;\frac{y}{t_0}\\
\mathbf{elif}\;y \leq 8.5 \cdot 10^{-97}:\\
\;\;\;\;\frac{x}{t_0}\\
\mathbf{elif}\;y \leq 9.6 \cdot 10^{+120}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -2.2000000000000002e174 or 9.60000000000000004e120 < y Initial program 60.5%
Taylor expanded in y around inf 74.6%
mul-1-neg74.6%
Simplified74.6%
if -2.2000000000000002e174 < y < -1.36e57Initial program 85.2%
Taylor expanded in x around 0 79.3%
if -1.36e57 < y < 8.5000000000000002e-97Initial program 99.2%
Taylor expanded in x around inf 80.2%
if 8.5000000000000002e-97 < y < 9.60000000000000004e120Initial program 90.6%
Taylor expanded in z around inf 61.7%
+-commutative61.7%
Simplified61.7%
Final simplification75.3%
(FPCore (x y z) :precision binary64 (if (or (<= z -8e-134) (not (<= z 1.5e+97))) (+ x y) (/ (- z) (/ y (+ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -8e-134) || !(z <= 1.5e+97)) {
tmp = x + y;
} else {
tmp = -z / (y / (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 ((z <= (-8d-134)) .or. (.not. (z <= 1.5d+97))) then
tmp = x + y
else
tmp = -z / (y / (x + y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -8e-134) || !(z <= 1.5e+97)) {
tmp = x + y;
} else {
tmp = -z / (y / (x + y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -8e-134) or not (z <= 1.5e+97): tmp = x + y else: tmp = -z / (y / (x + y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -8e-134) || !(z <= 1.5e+97)) tmp = Float64(x + y); else tmp = Float64(Float64(-z) / Float64(y / Float64(x + y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -8e-134) || ~((z <= 1.5e+97))) tmp = x + y; else tmp = -z / (y / (x + y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -8e-134], N[Not[LessEqual[z, 1.5e+97]], $MachinePrecision]], N[(x + y), $MachinePrecision], N[((-z) / N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8 \cdot 10^{-134} \lor \neg \left(z \leq 1.5 \cdot 10^{+97}\right):\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;\frac{-z}{\frac{y}{x + y}}\\
\end{array}
\end{array}
if z < -8.00000000000000032e-134 or 1.4999999999999999e97 < z Initial program 95.9%
Taylor expanded in z around inf 78.7%
+-commutative78.7%
Simplified78.7%
if -8.00000000000000032e-134 < z < 1.4999999999999999e97Initial program 76.9%
Taylor expanded in z around 0 69.2%
mul-1-neg69.2%
associate-/l*75.2%
distribute-neg-frac75.2%
+-commutative75.2%
Simplified75.2%
Final simplification77.1%
(FPCore (x y z) :precision binary64 (if (<= z -8.5e-134) (* (+ x y) (+ 1.0 (/ y z))) (if (<= z 1.36e+97) (/ (- z) (/ y (+ x y))) (+ x y))))
double code(double x, double y, double z) {
double tmp;
if (z <= -8.5e-134) {
tmp = (x + y) * (1.0 + (y / z));
} else if (z <= 1.36e+97) {
tmp = -z / (y / (x + y));
} 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 (z <= (-8.5d-134)) then
tmp = (x + y) * (1.0d0 + (y / z))
else if (z <= 1.36d+97) then
tmp = -z / (y / (x + y))
else
tmp = x + y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -8.5e-134) {
tmp = (x + y) * (1.0 + (y / z));
} else if (z <= 1.36e+97) {
tmp = -z / (y / (x + y));
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -8.5e-134: tmp = (x + y) * (1.0 + (y / z)) elif z <= 1.36e+97: tmp = -z / (y / (x + y)) else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if (z <= -8.5e-134) tmp = Float64(Float64(x + y) * Float64(1.0 + Float64(y / z))); elseif (z <= 1.36e+97) tmp = Float64(Float64(-z) / Float64(y / Float64(x + y))); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -8.5e-134) tmp = (x + y) * (1.0 + (y / z)); elseif (z <= 1.36e+97) tmp = -z / (y / (x + y)); else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -8.5e-134], N[(N[(x + y), $MachinePrecision] * N[(1.0 + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.36e+97], N[((-z) / N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.5 \cdot 10^{-134}:\\
\;\;\;\;\left(x + y\right) \cdot \left(1 + \frac{y}{z}\right)\\
\mathbf{elif}\;z \leq 1.36 \cdot 10^{+97}:\\
\;\;\;\;\frac{-z}{\frac{y}{x + y}}\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if z < -8.50000000000000015e-134Initial program 94.3%
Taylor expanded in z around inf 66.6%
associate-+r+66.6%
*-lft-identity66.6%
associate-/l*70.4%
associate-/r/73.3%
distribute-rgt-in73.2%
+-commutative73.2%
Simplified73.2%
if -8.50000000000000015e-134 < z < 1.36e97Initial program 76.9%
Taylor expanded in z around 0 69.2%
mul-1-neg69.2%
associate-/l*75.2%
distribute-neg-frac75.2%
+-commutative75.2%
Simplified75.2%
if 1.36e97 < z Initial program 99.9%
Taylor expanded in z around inf 92.7%
+-commutative92.7%
Simplified92.7%
Final simplification77.2%
(FPCore (x y z)
:precision binary64
(if (<= y -7.2e+67)
(- z)
(if (<= y 2.7e-97)
(/ x (- 1.0 (/ y z)))
(if (<= y 4.8e+122) (+ x y) (- z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -7.2e+67) {
tmp = -z;
} else if (y <= 2.7e-97) {
tmp = x / (1.0 - (y / z));
} else if (y <= 4.8e+122) {
tmp = x + y;
} 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 <= (-7.2d+67)) then
tmp = -z
else if (y <= 2.7d-97) then
tmp = x / (1.0d0 - (y / z))
else if (y <= 4.8d+122) then
tmp = x + y
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -7.2e+67) {
tmp = -z;
} else if (y <= 2.7e-97) {
tmp = x / (1.0 - (y / z));
} else if (y <= 4.8e+122) {
tmp = x + y;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -7.2e+67: tmp = -z elif y <= 2.7e-97: tmp = x / (1.0 - (y / z)) elif y <= 4.8e+122: tmp = x + y else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -7.2e+67) tmp = Float64(-z); elseif (y <= 2.7e-97) tmp = Float64(x / Float64(1.0 - Float64(y / z))); elseif (y <= 4.8e+122) tmp = Float64(x + y); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -7.2e+67) tmp = -z; elseif (y <= 2.7e-97) tmp = x / (1.0 - (y / z)); elseif (y <= 4.8e+122) tmp = x + y; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -7.2e+67], (-z), If[LessEqual[y, 2.7e-97], N[(x / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.8e+122], N[(x + y), $MachinePrecision], (-z)]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.2 \cdot 10^{+67}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq 2.7 \cdot 10^{-97}:\\
\;\;\;\;\frac{x}{1 - \frac{y}{z}}\\
\mathbf{elif}\;y \leq 4.8 \cdot 10^{+122}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -7.1999999999999998e67 or 4.8000000000000004e122 < y Initial program 66.4%
Taylor expanded in y around inf 69.5%
mul-1-neg69.5%
Simplified69.5%
if -7.1999999999999998e67 < y < 2.69999999999999985e-97Initial program 99.2%
Taylor expanded in x around inf 80.2%
if 2.69999999999999985e-97 < y < 4.8000000000000004e122Initial program 90.6%
Taylor expanded in z around inf 61.7%
+-commutative61.7%
Simplified61.7%
Final simplification73.3%
(FPCore (x y z) :precision binary64 (if (<= y -2.1e+62) (- z) (if (<= y 5600000000.0) x (if (<= y 2.6e+120) y (- z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.1e+62) {
tmp = -z;
} else if (y <= 5600000000.0) {
tmp = x;
} else if (y <= 2.6e+120) {
tmp = y;
} 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 <= (-2.1d+62)) then
tmp = -z
else if (y <= 5600000000.0d0) then
tmp = x
else if (y <= 2.6d+120) then
tmp = y
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2.1e+62) {
tmp = -z;
} else if (y <= 5600000000.0) {
tmp = x;
} else if (y <= 2.6e+120) {
tmp = y;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.1e+62: tmp = -z elif y <= 5600000000.0: tmp = x elif y <= 2.6e+120: tmp = y else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.1e+62) tmp = Float64(-z); elseif (y <= 5600000000.0) tmp = x; elseif (y <= 2.6e+120) tmp = y; else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.1e+62) tmp = -z; elseif (y <= 5600000000.0) tmp = x; elseif (y <= 2.6e+120) tmp = y; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.1e+62], (-z), If[LessEqual[y, 5600000000.0], x, If[LessEqual[y, 2.6e+120], y, (-z)]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.1 \cdot 10^{+62}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq 5600000000:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 2.6 \cdot 10^{+120}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -2.1e62 or 2.5999999999999999e120 < y Initial program 66.4%
Taylor expanded in y around inf 69.5%
mul-1-neg69.5%
Simplified69.5%
if -2.1e62 < y < 5.6e9Initial program 99.3%
Taylor expanded in y around 0 58.4%
if 5.6e9 < y < 2.5999999999999999e120Initial program 77.0%
Taylor expanded in z around inf 50.5%
associate-+r+50.5%
*-lft-identity50.5%
associate-/l*55.5%
associate-/r/55.5%
distribute-rgt-in55.5%
+-commutative55.5%
Simplified55.5%
Taylor expanded in x around 0 45.7%
Taylor expanded in y around 0 47.1%
Final simplification60.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.8e+76) (not (<= y 4.3e+120))) (- z) (+ x y)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.8e+76) || !(y <= 4.3e+120)) {
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 <= (-1.8d+76)) .or. (.not. (y <= 4.3d+120))) 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 <= -1.8e+76) || !(y <= 4.3e+120)) {
tmp = -z;
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.8e+76) or not (y <= 4.3e+120): tmp = -z else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.8e+76) || !(y <= 4.3e+120)) tmp = Float64(-z); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.8e+76) || ~((y <= 4.3e+120))) tmp = -z; else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.8e+76], N[Not[LessEqual[y, 4.3e+120]], $MachinePrecision]], (-z), N[(x + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.8 \cdot 10^{+76} \lor \neg \left(y \leq 4.3 \cdot 10^{+120}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if y < -1.8000000000000001e76 or 4.3000000000000002e120 < y Initial program 66.4%
Taylor expanded in y around inf 69.5%
mul-1-neg69.5%
Simplified69.5%
if -1.8000000000000001e76 < y < 4.3000000000000002e120Initial program 96.8%
Taylor expanded in z around inf 69.3%
+-commutative69.3%
Simplified69.3%
Final simplification69.3%
(FPCore (x y z) :precision binary64 (if (<= x -7.6e-154) x (if (<= x 2.4e-67) y x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -7.6e-154) {
tmp = x;
} else if (x <= 2.4e-67) {
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 <= (-7.6d-154)) then
tmp = x
else if (x <= 2.4d-67) 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 <= -7.6e-154) {
tmp = x;
} else if (x <= 2.4e-67) {
tmp = y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -7.6e-154: tmp = x elif x <= 2.4e-67: tmp = y else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -7.6e-154) tmp = x; elseif (x <= 2.4e-67) tmp = y; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -7.6e-154) tmp = x; elseif (x <= 2.4e-67) tmp = y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -7.6e-154], x, If[LessEqual[x, 2.4e-67], y, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.6 \cdot 10^{-154}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 2.4 \cdot 10^{-67}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -7.60000000000000019e-154 or 2.4e-67 < x Initial program 86.2%
Taylor expanded in y around 0 47.8%
if -7.60000000000000019e-154 < x < 2.4e-67Initial program 90.7%
Taylor expanded in z around inf 47.3%
associate-+r+47.3%
*-lft-identity47.3%
associate-/l*49.9%
associate-/r/49.9%
distribute-rgt-in49.9%
+-commutative49.9%
Simplified49.9%
Taylor expanded in x around 0 39.6%
Taylor expanded in y around 0 40.2%
Final simplification45.7%
(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 87.4%
Taylor expanded in y around 0 38.2%
Final simplification38.2%
(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 2023318
(FPCore (x y z)
:name "Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, A"
:precision binary64
:herbie-target
(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))))