
(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 -2e-267) (not (<= t_0 0.0))) t_0 (* z (- -1.0 (/ x y))))))
double code(double x, double y, double z) {
double t_0 = (x + y) / (1.0 - (y / z));
double tmp;
if ((t_0 <= -2e-267) || !(t_0 <= 0.0)) {
tmp = t_0;
} else {
tmp = z * (-1.0 - (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 <= (-2d-267)) .or. (.not. (t_0 <= 0.0d0))) then
tmp = t_0
else
tmp = z * ((-1.0d0) - (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 <= -2e-267) || !(t_0 <= 0.0)) {
tmp = t_0;
} else {
tmp = z * (-1.0 - (x / y));
}
return tmp;
}
def code(x, y, z): t_0 = (x + y) / (1.0 - (y / z)) tmp = 0 if (t_0 <= -2e-267) or not (t_0 <= 0.0): tmp = t_0 else: tmp = z * (-1.0 - (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 <= -2e-267) || !(t_0 <= 0.0)) tmp = t_0; else tmp = Float64(z * Float64(-1.0 - 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 <= -2e-267) || ~((t_0 <= 0.0))) tmp = t_0; else tmp = z * (-1.0 - (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, -2e-267], N[Not[LessEqual[t$95$0, 0.0]], $MachinePrecision]], t$95$0, N[(z * N[(-1.0 - 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 -2 \cdot 10^{-267} \lor \neg \left(t_0 \leq 0\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(-1 - \frac{x}{y}\right)\\
\end{array}
\end{array}
if (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < -2e-267 or -0.0 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) Initial program 99.8%
if -2e-267 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < -0.0Initial program 15.5%
Taylor expanded in y around inf 99.9%
associate--l+99.9%
+-commutative99.9%
associate-*r/99.9%
div-sub99.9%
sub-neg99.9%
mul-1-neg99.9%
distribute-neg-out99.9%
*-lft-identity99.9%
metadata-eval99.9%
cancel-sign-sub-inv99.9%
distribute-neg-frac99.9%
mul-1-neg99.9%
mul-1-neg99.9%
unsub-neg99.9%
Simplified99.9%
Taylor expanded in z around 0 99.9%
Taylor expanded in x around 0 99.9%
mul-1-neg99.9%
+-commutative99.9%
associate-*l/99.9%
associate-*r*99.9%
mul-1-neg99.9%
distribute-rgt-in99.9%
+-commutative99.9%
mul-1-neg99.9%
unsub-neg99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (- z) (/ (* x z) y))) (t_1 (* (+ x y) (+ 1.0 (/ y z)))))
(if (<= z -5e+21)
t_1
(if (<= z 1.55e-158)
t_0
(if (<= z 5.4e-99)
(/ x (- 1.0 (/ y z)))
(if (<= z 2.8e+101) t_0 t_1))))))
double code(double x, double y, double z) {
double t_0 = -z - ((x * z) / y);
double t_1 = (x + y) * (1.0 + (y / z));
double tmp;
if (z <= -5e+21) {
tmp = t_1;
} else if (z <= 1.55e-158) {
tmp = t_0;
} else if (z <= 5.4e-99) {
tmp = x / (1.0 - (y / z));
} else if (z <= 2.8e+101) {
tmp = t_0;
} 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 = -z - ((x * z) / y)
t_1 = (x + y) * (1.0d0 + (y / z))
if (z <= (-5d+21)) then
tmp = t_1
else if (z <= 1.55d-158) then
tmp = t_0
else if (z <= 5.4d-99) then
tmp = x / (1.0d0 - (y / z))
else if (z <= 2.8d+101) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = -z - ((x * z) / y);
double t_1 = (x + y) * (1.0 + (y / z));
double tmp;
if (z <= -5e+21) {
tmp = t_1;
} else if (z <= 1.55e-158) {
tmp = t_0;
} else if (z <= 5.4e-99) {
tmp = x / (1.0 - (y / z));
} else if (z <= 2.8e+101) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = -z - ((x * z) / y) t_1 = (x + y) * (1.0 + (y / z)) tmp = 0 if z <= -5e+21: tmp = t_1 elif z <= 1.55e-158: tmp = t_0 elif z <= 5.4e-99: tmp = x / (1.0 - (y / z)) elif z <= 2.8e+101: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(Float64(-z) - Float64(Float64(x * z) / y)) t_1 = Float64(Float64(x + y) * Float64(1.0 + Float64(y / z))) tmp = 0.0 if (z <= -5e+21) tmp = t_1; elseif (z <= 1.55e-158) tmp = t_0; elseif (z <= 5.4e-99) tmp = Float64(x / Float64(1.0 - Float64(y / z))); elseif (z <= 2.8e+101) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -z - ((x * z) / y); t_1 = (x + y) * (1.0 + (y / z)); tmp = 0.0; if (z <= -5e+21) tmp = t_1; elseif (z <= 1.55e-158) tmp = t_0; elseif (z <= 5.4e-99) tmp = x / (1.0 - (y / z)); elseif (z <= 2.8e+101) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[((-z) - N[(N[(x * z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x + y), $MachinePrecision] * N[(1.0 + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -5e+21], t$95$1, If[LessEqual[z, 1.55e-158], t$95$0, If[LessEqual[z, 5.4e-99], N[(x / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.8e+101], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-z\right) - \frac{x \cdot z}{y}\\
t_1 := \left(x + y\right) \cdot \left(1 + \frac{y}{z}\right)\\
\mathbf{if}\;z \leq -5 \cdot 10^{+21}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 1.55 \cdot 10^{-158}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 5.4 \cdot 10^{-99}:\\
\;\;\;\;\frac{x}{1 - \frac{y}{z}}\\
\mathbf{elif}\;z \leq 2.8 \cdot 10^{+101}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if z < -5e21 or 2.79999999999999981e101 < z Initial program 100.0%
Taylor expanded in z around inf 73.0%
associate-+r+73.0%
*-lft-identity73.0%
associate-/l*83.9%
associate-/r/83.9%
distribute-rgt-in83.8%
+-commutative83.8%
Simplified83.8%
if -5e21 < z < 1.55000000000000009e-158 or 5.4e-99 < z < 2.79999999999999981e101Initial program 76.1%
Taylor expanded in y around inf 77.6%
associate--l+77.6%
+-commutative77.6%
associate-*r/77.6%
div-sub77.6%
sub-neg77.6%
mul-1-neg77.6%
distribute-neg-out77.6%
*-lft-identity77.6%
metadata-eval77.6%
cancel-sign-sub-inv77.6%
distribute-neg-frac77.6%
mul-1-neg77.6%
mul-1-neg77.6%
unsub-neg77.6%
Simplified77.6%
Taylor expanded in z around 0 77.8%
associate-*r/77.8%
mul-1-neg77.8%
distribute-rgt-neg-in77.8%
Simplified77.8%
if 1.55000000000000009e-158 < z < 5.4e-99Initial program 99.9%
Taylor expanded in x around inf 94.1%
Final simplification81.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (- z) (/ (* x z) y))))
(if (<= z -7.8e+21)
(+ x y)
(if (<= z 1.55e-158)
t_0
(if (<= z 5.4e-99)
(/ x (- 1.0 (/ y z)))
(if (<= z 1.15e+90) t_0 (+ x y)))))))
double code(double x, double y, double z) {
double t_0 = -z - ((x * z) / y);
double tmp;
if (z <= -7.8e+21) {
tmp = x + y;
} else if (z <= 1.55e-158) {
tmp = t_0;
} else if (z <= 5.4e-99) {
tmp = x / (1.0 - (y / z));
} else if (z <= 1.15e+90) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = -z - ((x * z) / y)
if (z <= (-7.8d+21)) then
tmp = x + y
else if (z <= 1.55d-158) then
tmp = t_0
else if (z <= 5.4d-99) then
tmp = x / (1.0d0 - (y / z))
else if (z <= 1.15d+90) then
tmp = t_0
else
tmp = x + y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = -z - ((x * z) / y);
double tmp;
if (z <= -7.8e+21) {
tmp = x + y;
} else if (z <= 1.55e-158) {
tmp = t_0;
} else if (z <= 5.4e-99) {
tmp = x / (1.0 - (y / z));
} else if (z <= 1.15e+90) {
tmp = t_0;
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): t_0 = -z - ((x * z) / y) tmp = 0 if z <= -7.8e+21: tmp = x + y elif z <= 1.55e-158: tmp = t_0 elif z <= 5.4e-99: tmp = x / (1.0 - (y / z)) elif z <= 1.15e+90: tmp = t_0 else: tmp = x + y return tmp
function code(x, y, z) t_0 = Float64(Float64(-z) - Float64(Float64(x * z) / y)) tmp = 0.0 if (z <= -7.8e+21) tmp = Float64(x + y); elseif (z <= 1.55e-158) tmp = t_0; elseif (z <= 5.4e-99) tmp = Float64(x / Float64(1.0 - Float64(y / z))); elseif (z <= 1.15e+90) tmp = t_0; else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) t_0 = -z - ((x * z) / y); tmp = 0.0; if (z <= -7.8e+21) tmp = x + y; elseif (z <= 1.55e-158) tmp = t_0; elseif (z <= 5.4e-99) tmp = x / (1.0 - (y / z)); elseif (z <= 1.15e+90) tmp = t_0; else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[((-z) - N[(N[(x * z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -7.8e+21], N[(x + y), $MachinePrecision], If[LessEqual[z, 1.55e-158], t$95$0, If[LessEqual[z, 5.4e-99], N[(x / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.15e+90], t$95$0, N[(x + y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-z\right) - \frac{x \cdot z}{y}\\
\mathbf{if}\;z \leq -7.8 \cdot 10^{+21}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;z \leq 1.55 \cdot 10^{-158}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 5.4 \cdot 10^{-99}:\\
\;\;\;\;\frac{x}{1 - \frac{y}{z}}\\
\mathbf{elif}\;z \leq 1.15 \cdot 10^{+90}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if z < -7.8e21 or 1.15e90 < z Initial program 99.9%
Taylor expanded in z around inf 82.5%
+-commutative82.5%
Simplified82.5%
if -7.8e21 < z < 1.55000000000000009e-158 or 5.4e-99 < z < 1.15e90Initial program 75.8%
Taylor expanded in y around inf 78.0%
associate--l+78.0%
+-commutative78.0%
associate-*r/78.0%
div-sub78.0%
sub-neg78.0%
mul-1-neg78.0%
distribute-neg-out78.0%
*-lft-identity78.0%
metadata-eval78.0%
cancel-sign-sub-inv78.0%
distribute-neg-frac78.0%
mul-1-neg78.0%
mul-1-neg78.0%
unsub-neg78.0%
Simplified78.0%
Taylor expanded in z around 0 78.2%
associate-*r/78.2%
mul-1-neg78.2%
distribute-rgt-neg-in78.2%
Simplified78.2%
if 1.55000000000000009e-158 < z < 5.4e-99Initial program 99.9%
Taylor expanded in x around inf 94.1%
Final simplification80.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (- -1.0 (/ x y)))))
(if (<= y -7.5e+62)
t_0
(if (<= y -4.2e-166)
(+ x y)
(if (<= y 59000000000000.0) (/ x (- 1.0 (/ y z))) t_0)))))
double code(double x, double y, double z) {
double t_0 = z * (-1.0 - (x / y));
double tmp;
if (y <= -7.5e+62) {
tmp = t_0;
} else if (y <= -4.2e-166) {
tmp = x + y;
} else if (y <= 59000000000000.0) {
tmp = x / (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 = z * ((-1.0d0) - (x / y))
if (y <= (-7.5d+62)) then
tmp = t_0
else if (y <= (-4.2d-166)) then
tmp = x + y
else if (y <= 59000000000000.0d0) then
tmp = x / (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 = z * (-1.0 - (x / y));
double tmp;
if (y <= -7.5e+62) {
tmp = t_0;
} else if (y <= -4.2e-166) {
tmp = x + y;
} else if (y <= 59000000000000.0) {
tmp = x / (1.0 - (y / z));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * (-1.0 - (x / y)) tmp = 0 if y <= -7.5e+62: tmp = t_0 elif y <= -4.2e-166: tmp = x + y elif y <= 59000000000000.0: tmp = x / (1.0 - (y / z)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(-1.0 - Float64(x / y))) tmp = 0.0 if (y <= -7.5e+62) tmp = t_0; elseif (y <= -4.2e-166) tmp = Float64(x + y); elseif (y <= 59000000000000.0) tmp = Float64(x / Float64(1.0 - Float64(y / z))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * (-1.0 - (x / y)); tmp = 0.0; if (y <= -7.5e+62) tmp = t_0; elseif (y <= -4.2e-166) tmp = x + y; elseif (y <= 59000000000000.0) tmp = x / (1.0 - (y / z)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(-1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -7.5e+62], t$95$0, If[LessEqual[y, -4.2e-166], N[(x + y), $MachinePrecision], If[LessEqual[y, 59000000000000.0], N[(x / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(-1 - \frac{x}{y}\right)\\
\mathbf{if}\;y \leq -7.5 \cdot 10^{+62}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -4.2 \cdot 10^{-166}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;y \leq 59000000000000:\\
\;\;\;\;\frac{x}{1 - \frac{y}{z}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -7.49999999999999998e62 or 5.9e13 < y Initial program 71.7%
Taylor expanded in y around inf 71.3%
associate--l+71.3%
+-commutative71.3%
associate-*r/71.3%
div-sub71.3%
sub-neg71.3%
mul-1-neg71.3%
distribute-neg-out71.3%
*-lft-identity71.3%
metadata-eval71.3%
cancel-sign-sub-inv71.3%
distribute-neg-frac71.3%
mul-1-neg71.3%
mul-1-neg71.3%
unsub-neg71.3%
Simplified71.4%
Taylor expanded in z around 0 80.3%
Taylor expanded in x around 0 75.6%
mul-1-neg75.6%
+-commutative75.6%
associate-*l/80.3%
associate-*r*80.3%
mul-1-neg80.3%
distribute-rgt-in80.3%
+-commutative80.3%
mul-1-neg80.3%
unsub-neg80.3%
Simplified80.3%
if -7.49999999999999998e62 < y < -4.1999999999999999e-166Initial program 99.9%
Taylor expanded in z around inf 68.4%
+-commutative68.4%
Simplified68.4%
if -4.1999999999999999e-166 < y < 5.9e13Initial program 99.8%
Taylor expanded in x around inf 80.6%
Final simplification78.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -4.2e+67) (not (<= y 3000000000000.0))) (* z (- -1.0 (/ x y))) (+ x y)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -4.2e+67) || !(y <= 3000000000000.0)) {
tmp = z * (-1.0 - (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 ((y <= (-4.2d+67)) .or. (.not. (y <= 3000000000000.0d0))) then
tmp = z * ((-1.0d0) - (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 ((y <= -4.2e+67) || !(y <= 3000000000000.0)) {
tmp = z * (-1.0 - (x / y));
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -4.2e+67) or not (y <= 3000000000000.0): tmp = z * (-1.0 - (x / y)) else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -4.2e+67) || !(y <= 3000000000000.0)) tmp = Float64(z * Float64(-1.0 - Float64(x / y))); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -4.2e+67) || ~((y <= 3000000000000.0))) tmp = z * (-1.0 - (x / y)); else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -4.2e+67], N[Not[LessEqual[y, 3000000000000.0]], $MachinePrecision]], N[(z * N[(-1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.2 \cdot 10^{+67} \lor \neg \left(y \leq 3000000000000\right):\\
\;\;\;\;z \cdot \left(-1 - \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if y < -4.2000000000000003e67 or 3e12 < y Initial program 71.7%
Taylor expanded in y around inf 71.3%
associate--l+71.3%
+-commutative71.3%
associate-*r/71.3%
div-sub71.3%
sub-neg71.3%
mul-1-neg71.3%
distribute-neg-out71.3%
*-lft-identity71.3%
metadata-eval71.3%
cancel-sign-sub-inv71.3%
distribute-neg-frac71.3%
mul-1-neg71.3%
mul-1-neg71.3%
unsub-neg71.3%
Simplified71.4%
Taylor expanded in z around 0 80.3%
Taylor expanded in x around 0 75.6%
mul-1-neg75.6%
+-commutative75.6%
associate-*l/80.3%
associate-*r*80.3%
mul-1-neg80.3%
distribute-rgt-in80.3%
+-commutative80.3%
mul-1-neg80.3%
unsub-neg80.3%
Simplified80.3%
if -4.2000000000000003e67 < y < 3e12Initial program 99.8%
Taylor expanded in z around inf 73.0%
+-commutative73.0%
Simplified73.0%
Final simplification76.3%
(FPCore (x y z) :precision binary64 (if (<= y -1.6e+55) (- z) (if (<= y -2.85e-64) y (if (<= y 480000000.0) x (- z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.6e+55) {
tmp = -z;
} else if (y <= -2.85e-64) {
tmp = y;
} else if (y <= 480000000.0) {
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.6d+55)) then
tmp = -z
else if (y <= (-2.85d-64)) then
tmp = y
else if (y <= 480000000.0d0) 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.6e+55) {
tmp = -z;
} else if (y <= -2.85e-64) {
tmp = y;
} else if (y <= 480000000.0) {
tmp = x;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.6e+55: tmp = -z elif y <= -2.85e-64: tmp = y elif y <= 480000000.0: tmp = x else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.6e+55) tmp = Float64(-z); elseif (y <= -2.85e-64) tmp = y; elseif (y <= 480000000.0) tmp = x; else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.6e+55) tmp = -z; elseif (y <= -2.85e-64) tmp = y; elseif (y <= 480000000.0) tmp = x; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.6e+55], (-z), If[LessEqual[y, -2.85e-64], y, If[LessEqual[y, 480000000.0], x, (-z)]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.6 \cdot 10^{+55}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -2.85 \cdot 10^{-64}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 480000000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -1.6000000000000001e55 or 4.8e8 < y Initial program 72.5%
Taylor expanded in y around inf 63.7%
mul-1-neg63.7%
Simplified63.7%
if -1.6000000000000001e55 < y < -2.8500000000000001e-64Initial program 99.9%
Taylor expanded in x around 0 55.9%
Taylor expanded in y around 0 48.0%
if -2.8500000000000001e-64 < y < 4.8e8Initial program 99.8%
Taylor expanded in y around 0 60.4%
Final simplification60.8%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.6e+59) (not (<= y 4e+14))) (- z) (+ x y)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.6e+59) || !(y <= 4e+14)) {
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 <= (-2.6d+59)) .or. (.not. (y <= 4d+14))) 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 <= -2.6e+59) || !(y <= 4e+14)) {
tmp = -z;
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.6e+59) or not (y <= 4e+14): tmp = -z else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.6e+59) || !(y <= 4e+14)) tmp = Float64(-z); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -2.6e+59) || ~((y <= 4e+14))) tmp = -z; else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.6e+59], N[Not[LessEqual[y, 4e+14]], $MachinePrecision]], (-z), N[(x + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.6 \cdot 10^{+59} \lor \neg \left(y \leq 4 \cdot 10^{+14}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if y < -2.59999999999999999e59 or 4e14 < y Initial program 71.7%
Taylor expanded in y around inf 65.2%
mul-1-neg65.2%
Simplified65.2%
if -2.59999999999999999e59 < y < 4e14Initial program 99.8%
Taylor expanded in z around inf 73.0%
+-commutative73.0%
Simplified73.0%
Final simplification69.5%
(FPCore (x y z) :precision binary64 (if (<= x -4.4e-84) x (if (<= x 2.3e-45) y x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -4.4e-84) {
tmp = x;
} else if (x <= 2.3e-45) {
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 <= (-4.4d-84)) then
tmp = x
else if (x <= 2.3d-45) 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 <= -4.4e-84) {
tmp = x;
} else if (x <= 2.3e-45) {
tmp = y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -4.4e-84: tmp = x elif x <= 2.3e-45: tmp = y else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -4.4e-84) tmp = x; elseif (x <= 2.3e-45) tmp = y; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -4.4e-84) tmp = x; elseif (x <= 2.3e-45) tmp = y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -4.4e-84], x, If[LessEqual[x, 2.3e-45], y, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.4 \cdot 10^{-84}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 2.3 \cdot 10^{-45}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -4.3999999999999998e-84 or 2.29999999999999992e-45 < x Initial program 85.2%
Taylor expanded in y around 0 43.0%
if -4.3999999999999998e-84 < x < 2.29999999999999992e-45Initial program 90.4%
Taylor expanded in x around 0 79.8%
Taylor expanded in y around 0 44.0%
Final simplification43.4%
(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.0%
Taylor expanded in y around 0 33.3%
Final simplification33.3%
(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 2023322
(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))))