
(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 9 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-284) (not (<= t_0 1e-268)))
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-284) || !(t_0 <= 1e-268)) {
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-284)) .or. (.not. (t_0 <= 1d-268))) 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-284) || !(t_0 <= 1e-268)) {
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-284) or not (t_0 <= 1e-268): 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-284) || !(t_0 <= 1e-268)) tmp = t_0; else tmp = Float64(z * Float64(Float64(Float64(-y) - 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-284) || ~((t_0 <= 1e-268))) 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-284], N[Not[LessEqual[t$95$0, 1e-268]], $MachinePrecision]], t$95$0, N[(z * N[(N[((-y) - x), $MachinePrecision] / y), $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^{-284} \lor \neg \left(t\_0 \leq 10^{-268}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{\left(-y\right) - x}{y}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < -1.00000000000000004e-284 or 9.99999999999999958e-269 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) Initial program 99.9%
if -1.00000000000000004e-284 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < 9.99999999999999958e-269Initial program 23.6%
Taylor expanded in z around 0 87.0%
mul-1-neg87.0%
associate-/l*99.9%
distribute-rgt-neg-in99.9%
distribute-neg-frac299.9%
+-commutative99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ y z))))
(if (<= y -3.8e+132)
(- z)
(if (<= y -1e-46)
(/ y t_0)
(if (<= y 1.1e-81)
(/ x t_0)
(if (<= y 1.4e+258) (* y (/ z (- z y))) (- z)))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double tmp;
if (y <= -3.8e+132) {
tmp = -z;
} else if (y <= -1e-46) {
tmp = y / t_0;
} else if (y <= 1.1e-81) {
tmp = x / t_0;
} else if (y <= 1.4e+258) {
tmp = y * (z / (z - 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 <= (-3.8d+132)) then
tmp = -z
else if (y <= (-1d-46)) then
tmp = y / t_0
else if (y <= 1.1d-81) then
tmp = x / t_0
else if (y <= 1.4d+258) then
tmp = y * (z / (z - 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 <= -3.8e+132) {
tmp = -z;
} else if (y <= -1e-46) {
tmp = y / t_0;
} else if (y <= 1.1e-81) {
tmp = x / t_0;
} else if (y <= 1.4e+258) {
tmp = y * (z / (z - y));
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (y / z) tmp = 0 if y <= -3.8e+132: tmp = -z elif y <= -1e-46: tmp = y / t_0 elif y <= 1.1e-81: tmp = x / t_0 elif y <= 1.4e+258: tmp = y * (z / (z - y)) else: tmp = -z return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(y / z)) tmp = 0.0 if (y <= -3.8e+132) tmp = Float64(-z); elseif (y <= -1e-46) tmp = Float64(y / t_0); elseif (y <= 1.1e-81) tmp = Float64(x / t_0); elseif (y <= 1.4e+258) tmp = Float64(y * Float64(z / Float64(z - 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 <= -3.8e+132) tmp = -z; elseif (y <= -1e-46) tmp = y / t_0; elseif (y <= 1.1e-81) tmp = x / t_0; elseif (y <= 1.4e+258) tmp = y * (z / (z - 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, -3.8e+132], (-z), If[LessEqual[y, -1e-46], N[(y / t$95$0), $MachinePrecision], If[LessEqual[y, 1.1e-81], N[(x / t$95$0), $MachinePrecision], If[LessEqual[y, 1.4e+258], N[(y * N[(z / N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-z)]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{y}{z}\\
\mathbf{if}\;y \leq -3.8 \cdot 10^{+132}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -1 \cdot 10^{-46}:\\
\;\;\;\;\frac{y}{t\_0}\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{-81}:\\
\;\;\;\;\frac{x}{t\_0}\\
\mathbf{elif}\;y \leq 1.4 \cdot 10^{+258}:\\
\;\;\;\;y \cdot \frac{z}{z - y}\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -3.80000000000000006e132 or 1.39999999999999991e258 < y Initial program 53.5%
Taylor expanded in y around inf 84.4%
neg-mul-184.4%
Simplified84.4%
if -3.80000000000000006e132 < y < -1.00000000000000002e-46Initial program 97.0%
Taylor expanded in x around 0 66.1%
if -1.00000000000000002e-46 < y < 1.1e-81Initial program 99.9%
Taylor expanded in x around inf 85.2%
if 1.1e-81 < y < 1.39999999999999991e258Initial program 90.6%
Taylor expanded in x around 0 69.2%
clear-num69.1%
associate-/r/69.1%
*-inverses69.1%
div-sub69.1%
clear-num69.7%
Applied egg-rr69.7%
Final simplification78.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (/ z (- z y)))))
(if (<= y -8.6e+132)
(- z)
(if (<= y -7e-47)
t_0
(if (<= y 1.85e-78)
(/ x (- 1.0 (/ y z)))
(if (<= y 1.45e+258) t_0 (- z)))))))
double code(double x, double y, double z) {
double t_0 = y * (z / (z - y));
double tmp;
if (y <= -8.6e+132) {
tmp = -z;
} else if (y <= -7e-47) {
tmp = t_0;
} else if (y <= 1.85e-78) {
tmp = x / (1.0 - (y / z));
} else if (y <= 1.45e+258) {
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 = y * (z / (z - y))
if (y <= (-8.6d+132)) then
tmp = -z
else if (y <= (-7d-47)) then
tmp = t_0
else if (y <= 1.85d-78) then
tmp = x / (1.0d0 - (y / z))
else if (y <= 1.45d+258) 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 = y * (z / (z - y));
double tmp;
if (y <= -8.6e+132) {
tmp = -z;
} else if (y <= -7e-47) {
tmp = t_0;
} else if (y <= 1.85e-78) {
tmp = x / (1.0 - (y / z));
} else if (y <= 1.45e+258) {
tmp = t_0;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): t_0 = y * (z / (z - y)) tmp = 0 if y <= -8.6e+132: tmp = -z elif y <= -7e-47: tmp = t_0 elif y <= 1.85e-78: tmp = x / (1.0 - (y / z)) elif y <= 1.45e+258: tmp = t_0 else: tmp = -z return tmp
function code(x, y, z) t_0 = Float64(y * Float64(z / Float64(z - y))) tmp = 0.0 if (y <= -8.6e+132) tmp = Float64(-z); elseif (y <= -7e-47) tmp = t_0; elseif (y <= 1.85e-78) tmp = Float64(x / Float64(1.0 - Float64(y / z))); elseif (y <= 1.45e+258) tmp = t_0; else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (z / (z - y)); tmp = 0.0; if (y <= -8.6e+132) tmp = -z; elseif (y <= -7e-47) tmp = t_0; elseif (y <= 1.85e-78) tmp = x / (1.0 - (y / z)); elseif (y <= 1.45e+258) tmp = t_0; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(z / N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -8.6e+132], (-z), If[LessEqual[y, -7e-47], t$95$0, If[LessEqual[y, 1.85e-78], N[(x / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.45e+258], t$95$0, (-z)]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \frac{z}{z - y}\\
\mathbf{if}\;y \leq -8.6 \cdot 10^{+132}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -7 \cdot 10^{-47}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.85 \cdot 10^{-78}:\\
\;\;\;\;\frac{x}{1 - \frac{y}{z}}\\
\mathbf{elif}\;y \leq 1.45 \cdot 10^{+258}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -8.59999999999999964e132 or 1.4500000000000001e258 < y Initial program 53.5%
Taylor expanded in y around inf 84.4%
neg-mul-184.4%
Simplified84.4%
if -8.59999999999999964e132 < y < -6.9999999999999996e-47 or 1.85000000000000003e-78 < y < 1.4500000000000001e258Initial program 92.6%
Taylor expanded in x around 0 68.2%
clear-num68.1%
associate-/r/68.1%
*-inverses68.1%
div-sub68.1%
clear-num68.6%
Applied egg-rr68.6%
if -6.9999999999999996e-47 < y < 1.85000000000000003e-78Initial program 99.9%
Taylor expanded in x around inf 85.2%
Final simplification78.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (/ z (- z y)))))
(if (<= y -2.9e+128)
(- z)
(if (<= y -3.4e-43)
t_0
(if (<= y 1.55e+18) (+ x y) (if (<= y 1.4e+258) t_0 (- z)))))))
double code(double x, double y, double z) {
double t_0 = y * (z / (z - y));
double tmp;
if (y <= -2.9e+128) {
tmp = -z;
} else if (y <= -3.4e-43) {
tmp = t_0;
} else if (y <= 1.55e+18) {
tmp = x + y;
} else if (y <= 1.4e+258) {
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 = y * (z / (z - y))
if (y <= (-2.9d+128)) then
tmp = -z
else if (y <= (-3.4d-43)) then
tmp = t_0
else if (y <= 1.55d+18) then
tmp = x + y
else if (y <= 1.4d+258) 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 = y * (z / (z - y));
double tmp;
if (y <= -2.9e+128) {
tmp = -z;
} else if (y <= -3.4e-43) {
tmp = t_0;
} else if (y <= 1.55e+18) {
tmp = x + y;
} else if (y <= 1.4e+258) {
tmp = t_0;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): t_0 = y * (z / (z - y)) tmp = 0 if y <= -2.9e+128: tmp = -z elif y <= -3.4e-43: tmp = t_0 elif y <= 1.55e+18: tmp = x + y elif y <= 1.4e+258: tmp = t_0 else: tmp = -z return tmp
function code(x, y, z) t_0 = Float64(y * Float64(z / Float64(z - y))) tmp = 0.0 if (y <= -2.9e+128) tmp = Float64(-z); elseif (y <= -3.4e-43) tmp = t_0; elseif (y <= 1.55e+18) tmp = Float64(x + y); elseif (y <= 1.4e+258) tmp = t_0; else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (z / (z - y)); tmp = 0.0; if (y <= -2.9e+128) tmp = -z; elseif (y <= -3.4e-43) tmp = t_0; elseif (y <= 1.55e+18) tmp = x + y; elseif (y <= 1.4e+258) tmp = t_0; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(z / N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.9e+128], (-z), If[LessEqual[y, -3.4e-43], t$95$0, If[LessEqual[y, 1.55e+18], N[(x + y), $MachinePrecision], If[LessEqual[y, 1.4e+258], t$95$0, (-z)]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \frac{z}{z - y}\\
\mathbf{if}\;y \leq -2.9 \cdot 10^{+128}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -3.4 \cdot 10^{-43}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.55 \cdot 10^{+18}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;y \leq 1.4 \cdot 10^{+258}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -2.9e128 or 1.39999999999999991e258 < y Initial program 53.5%
Taylor expanded in y around inf 84.4%
neg-mul-184.4%
Simplified84.4%
if -2.9e128 < y < -3.4000000000000001e-43 or 1.55e18 < y < 1.39999999999999991e258Initial program 90.9%
Taylor expanded in x around 0 68.9%
clear-num68.8%
associate-/r/68.8%
*-inverses68.8%
div-sub68.8%
clear-num69.3%
Applied egg-rr69.3%
if -3.4000000000000001e-43 < y < 1.55e18Initial program 99.9%
Taylor expanded in z around inf 75.2%
+-commutative75.2%
Simplified75.2%
Final simplification75.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (/ (- (- y) x) y))))
(if (<= y -2.22e-41)
t_0
(if (<= y 8.6e-79)
(/ x (- 1.0 (/ y z)))
(if (<= y 7.8e+39) (* y (/ z (- z y))) t_0)))))
double code(double x, double y, double z) {
double t_0 = z * ((-y - x) / y);
double tmp;
if (y <= -2.22e-41) {
tmp = t_0;
} else if (y <= 8.6e-79) {
tmp = x / (1.0 - (y / z));
} else if (y <= 7.8e+39) {
tmp = y * (z / (z - y));
} 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 = z * ((-y - x) / y)
if (y <= (-2.22d-41)) then
tmp = t_0
else if (y <= 8.6d-79) then
tmp = x / (1.0d0 - (y / z))
else if (y <= 7.8d+39) then
tmp = y * (z / (z - y))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * ((-y - x) / y);
double tmp;
if (y <= -2.22e-41) {
tmp = t_0;
} else if (y <= 8.6e-79) {
tmp = x / (1.0 - (y / z));
} else if (y <= 7.8e+39) {
tmp = y * (z / (z - y));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * ((-y - x) / y) tmp = 0 if y <= -2.22e-41: tmp = t_0 elif y <= 8.6e-79: tmp = x / (1.0 - (y / z)) elif y <= 7.8e+39: tmp = y * (z / (z - y)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(Float64(Float64(-y) - x) / y)) tmp = 0.0 if (y <= -2.22e-41) tmp = t_0; elseif (y <= 8.6e-79) tmp = Float64(x / Float64(1.0 - Float64(y / z))); elseif (y <= 7.8e+39) tmp = Float64(y * Float64(z / Float64(z - y))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * ((-y - x) / y); tmp = 0.0; if (y <= -2.22e-41) tmp = t_0; elseif (y <= 8.6e-79) tmp = x / (1.0 - (y / z)); elseif (y <= 7.8e+39) tmp = y * (z / (z - y)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(N[((-y) - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.22e-41], t$95$0, If[LessEqual[y, 8.6e-79], N[(x / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7.8e+39], N[(y * N[(z / N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \frac{\left(-y\right) - x}{y}\\
\mathbf{if}\;y \leq -2.22 \cdot 10^{-41}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 8.6 \cdot 10^{-79}:\\
\;\;\;\;\frac{x}{1 - \frac{y}{z}}\\
\mathbf{elif}\;y \leq 7.8 \cdot 10^{+39}:\\
\;\;\;\;y \cdot \frac{z}{z - y}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -2.2200000000000001e-41 or 7.8000000000000002e39 < y Initial program 75.2%
Taylor expanded in z around 0 63.7%
mul-1-neg63.7%
associate-/l*78.0%
distribute-rgt-neg-in78.0%
distribute-neg-frac278.0%
+-commutative78.0%
Simplified78.0%
if -2.2200000000000001e-41 < y < 8.59999999999999963e-79Initial program 99.9%
Taylor expanded in x around inf 84.3%
if 8.59999999999999963e-79 < y < 7.8000000000000002e39Initial program 99.9%
Taylor expanded in x around 0 73.5%
clear-num73.6%
associate-/r/73.4%
*-inverses73.4%
div-sub73.4%
clear-num73.6%
Applied egg-rr73.6%
Final simplification80.1%
(FPCore (x y z) :precision binary64 (if (<= y -2.85e-41) (- z) (if (<= y 6e-31) x (if (<= y 10000.0) y (- z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.85e-41) {
tmp = -z;
} else if (y <= 6e-31) {
tmp = x;
} else if (y <= 10000.0) {
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.85d-41)) then
tmp = -z
else if (y <= 6d-31) then
tmp = x
else if (y <= 10000.0d0) 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.85e-41) {
tmp = -z;
} else if (y <= 6e-31) {
tmp = x;
} else if (y <= 10000.0) {
tmp = y;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.85e-41: tmp = -z elif y <= 6e-31: tmp = x elif y <= 10000.0: tmp = y else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.85e-41) tmp = Float64(-z); elseif (y <= 6e-31) tmp = x; elseif (y <= 10000.0) tmp = y; else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.85e-41) tmp = -z; elseif (y <= 6e-31) tmp = x; elseif (y <= 10000.0) tmp = y; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.85e-41], (-z), If[LessEqual[y, 6e-31], x, If[LessEqual[y, 10000.0], y, (-z)]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.85 \cdot 10^{-41}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq 6 \cdot 10^{-31}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 10000:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -2.85000000000000023e-41 or 1e4 < y Initial program 76.6%
Taylor expanded in y around inf 63.4%
neg-mul-163.4%
Simplified63.4%
if -2.85000000000000023e-41 < y < 5.99999999999999962e-31Initial program 99.9%
Taylor expanded in y around 0 65.4%
if 5.99999999999999962e-31 < y < 1e4Initial program 100.0%
Taylor expanded in z around inf 83.8%
+-commutative83.8%
Simplified83.8%
Taylor expanded in y around inf 68.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -1e+76) (not (<= y 1.5e+18))) (- z) (+ x y)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1e+76) || !(y <= 1.5e+18)) {
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 <= (-1d+76)) .or. (.not. (y <= 1.5d+18))) 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 <= -1e+76) || !(y <= 1.5e+18)) {
tmp = -z;
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1e+76) or not (y <= 1.5e+18): tmp = -z else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1e+76) || !(y <= 1.5e+18)) tmp = Float64(-z); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1e+76) || ~((y <= 1.5e+18))) tmp = -z; else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1e+76], N[Not[LessEqual[y, 1.5e+18]], $MachinePrecision]], (-z), N[(x + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \cdot 10^{+76} \lor \neg \left(y \leq 1.5 \cdot 10^{+18}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if y < -1e76 or 1.5e18 < y Initial program 73.1%
Taylor expanded in y around inf 67.2%
neg-mul-167.2%
Simplified67.2%
if -1e76 < y < 1.5e18Initial program 99.9%
Taylor expanded in z around inf 71.8%
+-commutative71.8%
Simplified71.8%
Final simplification69.7%
(FPCore (x y z) :precision binary64 (if (<= x -1.5e-137) x (if (<= x 5.8e-144) y x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.5e-137) {
tmp = x;
} else if (x <= 5.8e-144) {
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.5d-137)) then
tmp = x
else if (x <= 5.8d-144) 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.5e-137) {
tmp = x;
} else if (x <= 5.8e-144) {
tmp = y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.5e-137: tmp = x elif x <= 5.8e-144: tmp = y else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.5e-137) tmp = x; elseif (x <= 5.8e-144) tmp = y; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.5e-137) tmp = x; elseif (x <= 5.8e-144) tmp = y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.5e-137], x, If[LessEqual[x, 5.8e-144], y, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.5 \cdot 10^{-137}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 5.8 \cdot 10^{-144}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1.4999999999999999e-137 or 5.8000000000000004e-144 < x Initial program 87.5%
Taylor expanded in y around 0 46.6%
if -1.4999999999999999e-137 < x < 5.8000000000000004e-144Initial program 87.1%
Taylor expanded in z around inf 43.2%
+-commutative43.2%
Simplified43.2%
Taylor expanded in y around inf 38.3%
(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 34.6%
(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 2024137
(FPCore (x y z)
:name "Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, A"
:precision binary64
:alt
(! :herbie-platform default (if (< y -3742931076268985600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (* (/ (+ y x) (- y)) z) (if (< y 3553466245608673400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (/ (+ x y) (- 1 (/ y z))) (* (/ (+ y x) (- y)) z))))
(/ (+ x y) (- 1.0 (/ y z))))