
(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 -5e-271) (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 <= -5e-271) || !(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 <= (-5d-271)) .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 <= -5e-271) || !(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 <= -5e-271) 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 <= -5e-271) || !(t_0 <= 0.0)) tmp = t_0; else tmp = Float64(Float64(Float64(z * Float64(x + z)) / Float64(-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 <= -5e-271) || ~((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, -5e-271], 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 -5 \cdot 10^{-271} \lor \neg \left(t\_0 \leq 0\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{z \cdot \left(x + z\right)}{-y} - z\\
\end{array}
\end{array}
if (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < -5.0000000000000002e-271 or -0.0 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) Initial program 99.9%
if -5.0000000000000002e-271 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < -0.0Initial program 9.1%
Taylor expanded in y around inf 100.0%
associate--l+100.0%
associate-*r/100.0%
div-sub100.0%
remove-double-neg100.0%
mul-1-neg100.0%
neg-mul-1100.0%
distribute-lft-out--100.0%
mul-1-neg100.0%
distribute-neg-frac100.0%
unsub-neg100.0%
mul-1-neg100.0%
cancel-sign-sub-inv100.0%
metadata-eval100.0%
*-lft-identity100.0%
+-commutative100.0%
unpow2100.0%
distribute-rgt-out100.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-305) (not (<= t_0 0.0))) t_0 (/ (* z (- (- x) y)) y))))
double code(double x, double y, double z) {
double t_0 = (x + y) / (1.0 - (y / z));
double tmp;
if ((t_0 <= -1e-305) || !(t_0 <= 0.0)) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = (x + y) / (1.0d0 - (y / z))
if ((t_0 <= (-1d-305)) .or. (.not. (t_0 <= 0.0d0))) then
tmp = t_0
else
tmp = (z * (-x - y)) / 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-305) || !(t_0 <= 0.0)) {
tmp = t_0;
} else {
tmp = (z * (-x - y)) / y;
}
return tmp;
}
def code(x, y, z): t_0 = (x + y) / (1.0 - (y / z)) tmp = 0 if (t_0 <= -1e-305) or not (t_0 <= 0.0): tmp = t_0 else: tmp = (z * (-x - y)) / 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-305) || !(t_0 <= 0.0)) tmp = t_0; else tmp = Float64(Float64(z * Float64(Float64(-x) - y)) / 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-305) || ~((t_0 <= 0.0))) tmp = t_0; else tmp = (z * (-x - y)) / 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-305], N[Not[LessEqual[t$95$0, 0.0]], $MachinePrecision]], t$95$0, N[(N[(z * N[((-x) - y), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + y}{1 - \frac{y}{z}}\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{-305} \lor \neg \left(t\_0 \leq 0\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{z \cdot \left(\left(-x\right) - y\right)}{y}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < -9.99999999999999996e-306 or -0.0 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) Initial program 99.9%
if -9.99999999999999996e-306 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < -0.0Initial program 5.5%
Taylor expanded in z around 0 99.9%
mul-1-neg99.9%
+-commutative99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(if (<= y -1.7e+104)
(- z)
(if (<= y -8.6e+20)
x
(if (<= y -1.55e-13)
(- z)
(if (<= y -1.8e-48)
y
(if (<= y 1.3e-7) x (if (<= y 2.9e+86) y (- z))))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.7e+104) {
tmp = -z;
} else if (y <= -8.6e+20) {
tmp = x;
} else if (y <= -1.55e-13) {
tmp = -z;
} else if (y <= -1.8e-48) {
tmp = y;
} else if (y <= 1.3e-7) {
tmp = x;
} else if (y <= 2.9e+86) {
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 <= (-1.7d+104)) then
tmp = -z
else if (y <= (-8.6d+20)) then
tmp = x
else if (y <= (-1.55d-13)) then
tmp = -z
else if (y <= (-1.8d-48)) then
tmp = y
else if (y <= 1.3d-7) then
tmp = x
else if (y <= 2.9d+86) 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 <= -1.7e+104) {
tmp = -z;
} else if (y <= -8.6e+20) {
tmp = x;
} else if (y <= -1.55e-13) {
tmp = -z;
} else if (y <= -1.8e-48) {
tmp = y;
} else if (y <= 1.3e-7) {
tmp = x;
} else if (y <= 2.9e+86) {
tmp = y;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.7e+104: tmp = -z elif y <= -8.6e+20: tmp = x elif y <= -1.55e-13: tmp = -z elif y <= -1.8e-48: tmp = y elif y <= 1.3e-7: tmp = x elif y <= 2.9e+86: tmp = y else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.7e+104) tmp = Float64(-z); elseif (y <= -8.6e+20) tmp = x; elseif (y <= -1.55e-13) tmp = Float64(-z); elseif (y <= -1.8e-48) tmp = y; elseif (y <= 1.3e-7) tmp = x; elseif (y <= 2.9e+86) tmp = y; else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.7e+104) tmp = -z; elseif (y <= -8.6e+20) tmp = x; elseif (y <= -1.55e-13) tmp = -z; elseif (y <= -1.8e-48) tmp = y; elseif (y <= 1.3e-7) tmp = x; elseif (y <= 2.9e+86) tmp = y; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.7e+104], (-z), If[LessEqual[y, -8.6e+20], x, If[LessEqual[y, -1.55e-13], (-z), If[LessEqual[y, -1.8e-48], y, If[LessEqual[y, 1.3e-7], x, If[LessEqual[y, 2.9e+86], y, (-z)]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.7 \cdot 10^{+104}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -8.6 \cdot 10^{+20}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq -1.55 \cdot 10^{-13}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -1.8 \cdot 10^{-48}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 1.3 \cdot 10^{-7}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 2.9 \cdot 10^{+86}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -1.6999999999999998e104 or -8.6e20 < y < -1.55e-13 or 2.8999999999999999e86 < y Initial program 76.0%
Taylor expanded in y around inf 70.4%
mul-1-neg70.4%
Simplified70.4%
if -1.6999999999999998e104 < y < -8.6e20 or -1.8000000000000001e-48 < y < 1.29999999999999999e-7Initial program 99.2%
Taylor expanded in y around 0 60.3%
if -1.55e-13 < y < -1.8000000000000001e-48 or 1.29999999999999999e-7 < y < 2.8999999999999999e86Initial program 96.7%
Taylor expanded in x around 0 70.2%
Taylor expanded in y around 0 52.7%
Final simplification63.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (+ x y) (+ 1.0 (/ y z)))))
(if (<= z -1.72e+56)
t_0
(if (<= z 3.5e+16)
(* z (- -1.0 (/ x y)))
(if (<= z 6.2e+83)
(+ x y)
(if (<= z 6.7e+125) (/ y (- 1.0 (/ y z))) t_0))))))
double code(double x, double y, double z) {
double t_0 = (x + y) * (1.0 + (y / z));
double tmp;
if (z <= -1.72e+56) {
tmp = t_0;
} else if (z <= 3.5e+16) {
tmp = z * (-1.0 - (x / y));
} else if (z <= 6.2e+83) {
tmp = x + y;
} else if (z <= 6.7e+125) {
tmp = 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 = (x + y) * (1.0d0 + (y / z))
if (z <= (-1.72d+56)) then
tmp = t_0
else if (z <= 3.5d+16) then
tmp = z * ((-1.0d0) - (x / y))
else if (z <= 6.2d+83) then
tmp = x + y
else if (z <= 6.7d+125) then
tmp = 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 = (x + y) * (1.0 + (y / z));
double tmp;
if (z <= -1.72e+56) {
tmp = t_0;
} else if (z <= 3.5e+16) {
tmp = z * (-1.0 - (x / y));
} else if (z <= 6.2e+83) {
tmp = x + y;
} else if (z <= 6.7e+125) {
tmp = y / (1.0 - (y / z));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (x + y) * (1.0 + (y / z)) tmp = 0 if z <= -1.72e+56: tmp = t_0 elif z <= 3.5e+16: tmp = z * (-1.0 - (x / y)) elif z <= 6.2e+83: tmp = x + y elif z <= 6.7e+125: tmp = y / (1.0 - (y / z)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(x + y) * Float64(1.0 + Float64(y / z))) tmp = 0.0 if (z <= -1.72e+56) tmp = t_0; elseif (z <= 3.5e+16) tmp = Float64(z * Float64(-1.0 - Float64(x / y))); elseif (z <= 6.2e+83) tmp = Float64(x + y); elseif (z <= 6.7e+125) tmp = Float64(y / Float64(1.0 - Float64(y / z))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x + y) * (1.0 + (y / z)); tmp = 0.0; if (z <= -1.72e+56) tmp = t_0; elseif (z <= 3.5e+16) tmp = z * (-1.0 - (x / y)); elseif (z <= 6.2e+83) tmp = x + y; elseif (z <= 6.7e+125) tmp = y / (1.0 - (y / z)); else tmp = t_0; 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[LessEqual[z, -1.72e+56], t$95$0, If[LessEqual[z, 3.5e+16], N[(z * N[(-1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 6.2e+83], N[(x + y), $MachinePrecision], If[LessEqual[z, 6.7e+125], N[(y / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x + y\right) \cdot \left(1 + \frac{y}{z}\right)\\
\mathbf{if}\;z \leq -1.72 \cdot 10^{+56}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 3.5 \cdot 10^{+16}:\\
\;\;\;\;z \cdot \left(-1 - \frac{x}{y}\right)\\
\mathbf{elif}\;z \leq 6.2 \cdot 10^{+83}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;z \leq 6.7 \cdot 10^{+125}:\\
\;\;\;\;\frac{y}{1 - \frac{y}{z}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.72e56 or 6.7000000000000003e125 < z Initial program 99.9%
Taylor expanded in z around inf 74.3%
associate-+r+74.3%
*-rgt-identity74.3%
*-commutative74.3%
associate-/l*87.9%
distribute-lft-in87.9%
+-commutative87.9%
Simplified87.9%
if -1.72e56 < z < 3.5e16Initial program 81.7%
clear-num81.5%
inv-pow81.5%
Applied egg-rr81.5%
Taylor expanded in z around 0 70.2%
mul-1-neg70.2%
+-commutative70.2%
distribute-frac-neg270.2%
mul-1-neg70.2%
*-commutative70.2%
associate-/l/70.2%
associate-/l*70.2%
metadata-eval70.2%
distribute-neg-frac270.2%
/-rgt-identity70.2%
+-commutative70.2%
Simplified70.2%
Taylor expanded in x around 0 72.4%
*-commutative72.4%
fma-define72.4%
mul-1-neg72.4%
*-commutative72.4%
associate-*r/70.9%
fma-neg70.9%
distribute-lft-out--70.9%
Simplified70.9%
if 3.5e16 < z < 6.19999999999999984e83Initial program 100.0%
Taylor expanded in z around inf 91.0%
+-commutative91.0%
Simplified91.0%
if 6.19999999999999984e83 < z < 6.7000000000000003e125Initial program 99.9%
Taylor expanded in x around 0 82.6%
Final simplification79.1%
(FPCore (x y z)
:precision binary64
(if (<= z -1.25e+58)
(+ x y)
(if (<= z 4.2e+22)
(* z (- -1.0 (/ x y)))
(if (or (<= z 3.1e+83) (not (<= z 1.5e+123)))
(+ x y)
(/ y (- 1.0 (/ y z)))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.25e+58) {
tmp = x + y;
} else if (z <= 4.2e+22) {
tmp = z * (-1.0 - (x / y));
} else if ((z <= 3.1e+83) || !(z <= 1.5e+123)) {
tmp = x + y;
} else {
tmp = y / (1.0 - (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) :: tmp
if (z <= (-1.25d+58)) then
tmp = x + y
else if (z <= 4.2d+22) then
tmp = z * ((-1.0d0) - (x / y))
else if ((z <= 3.1d+83) .or. (.not. (z <= 1.5d+123))) then
tmp = x + y
else
tmp = y / (1.0d0 - (y / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.25e+58) {
tmp = x + y;
} else if (z <= 4.2e+22) {
tmp = z * (-1.0 - (x / y));
} else if ((z <= 3.1e+83) || !(z <= 1.5e+123)) {
tmp = x + y;
} else {
tmp = y / (1.0 - (y / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.25e+58: tmp = x + y elif z <= 4.2e+22: tmp = z * (-1.0 - (x / y)) elif (z <= 3.1e+83) or not (z <= 1.5e+123): tmp = x + y else: tmp = y / (1.0 - (y / z)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.25e+58) tmp = Float64(x + y); elseif (z <= 4.2e+22) tmp = Float64(z * Float64(-1.0 - Float64(x / y))); elseif ((z <= 3.1e+83) || !(z <= 1.5e+123)) tmp = Float64(x + y); else tmp = Float64(y / Float64(1.0 - Float64(y / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.25e+58) tmp = x + y; elseif (z <= 4.2e+22) tmp = z * (-1.0 - (x / y)); elseif ((z <= 3.1e+83) || ~((z <= 1.5e+123))) tmp = x + y; else tmp = y / (1.0 - (y / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.25e+58], N[(x + y), $MachinePrecision], If[LessEqual[z, 4.2e+22], N[(z * N[(-1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[z, 3.1e+83], N[Not[LessEqual[z, 1.5e+123]], $MachinePrecision]], N[(x + y), $MachinePrecision], N[(y / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.25 \cdot 10^{+58}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;z \leq 4.2 \cdot 10^{+22}:\\
\;\;\;\;z \cdot \left(-1 - \frac{x}{y}\right)\\
\mathbf{elif}\;z \leq 3.1 \cdot 10^{+83} \lor \neg \left(z \leq 1.5 \cdot 10^{+123}\right):\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{1 - \frac{y}{z}}\\
\end{array}
\end{array}
if z < -1.24999999999999996e58 or 4.1999999999999996e22 < z < 3.09999999999999992e83 or 1.50000000000000004e123 < z Initial program 99.9%
Taylor expanded in z around inf 87.8%
+-commutative87.8%
Simplified87.8%
if -1.24999999999999996e58 < z < 4.1999999999999996e22Initial program 81.7%
clear-num81.5%
inv-pow81.5%
Applied egg-rr81.5%
Taylor expanded in z around 0 70.2%
mul-1-neg70.2%
+-commutative70.2%
distribute-frac-neg270.2%
mul-1-neg70.2%
*-commutative70.2%
associate-/l/70.2%
associate-/l*70.2%
metadata-eval70.2%
distribute-neg-frac270.2%
/-rgt-identity70.2%
+-commutative70.2%
Simplified70.2%
Taylor expanded in x around 0 72.4%
*-commutative72.4%
fma-define72.4%
mul-1-neg72.4%
*-commutative72.4%
associate-*r/70.9%
fma-neg70.9%
distribute-lft-out--70.9%
Simplified70.9%
if 3.09999999999999992e83 < z < 1.50000000000000004e123Initial program 99.9%
Taylor expanded in x around 0 82.6%
Final simplification78.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.9e+52) (not (<= z 1.72e+16))) (+ x y) (* z (- -1.0 (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.9e+52) || !(z <= 1.72e+16)) {
tmp = x + y;
} 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) :: tmp
if ((z <= (-1.9d+52)) .or. (.not. (z <= 1.72d+16))) then
tmp = x + y
else
tmp = z * ((-1.0d0) - (x / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.9e+52) || !(z <= 1.72e+16)) {
tmp = x + y;
} else {
tmp = z * (-1.0 - (x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.9e+52) or not (z <= 1.72e+16): tmp = x + y else: tmp = z * (-1.0 - (x / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.9e+52) || !(z <= 1.72e+16)) tmp = Float64(x + y); else tmp = Float64(z * Float64(-1.0 - Float64(x / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.9e+52) || ~((z <= 1.72e+16))) tmp = x + y; else tmp = z * (-1.0 - (x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.9e+52], N[Not[LessEqual[z, 1.72e+16]], $MachinePrecision]], N[(x + y), $MachinePrecision], N[(z * N[(-1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.9 \cdot 10^{+52} \lor \neg \left(z \leq 1.72 \cdot 10^{+16}\right):\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(-1 - \frac{x}{y}\right)\\
\end{array}
\end{array}
if z < -1.9e52 or 1.72e16 < z Initial program 99.9%
Taylor expanded in z around inf 81.9%
+-commutative81.9%
Simplified81.9%
if -1.9e52 < z < 1.72e16Initial program 81.7%
clear-num81.5%
inv-pow81.5%
Applied egg-rr81.5%
Taylor expanded in z around 0 70.2%
mul-1-neg70.2%
+-commutative70.2%
distribute-frac-neg270.2%
mul-1-neg70.2%
*-commutative70.2%
associate-/l/70.2%
associate-/l*70.2%
metadata-eval70.2%
distribute-neg-frac270.2%
/-rgt-identity70.2%
+-commutative70.2%
Simplified70.2%
Taylor expanded in x around 0 72.4%
*-commutative72.4%
fma-define72.4%
mul-1-neg72.4%
*-commutative72.4%
associate-*r/70.9%
fma-neg70.9%
distribute-lft-out--70.9%
Simplified70.9%
Final simplification76.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -4.2e+105) (not (<= y 5.9e+85))) (- z) (+ x y)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -4.2e+105) || !(y <= 5.9e+85)) {
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 <= (-4.2d+105)) .or. (.not. (y <= 5.9d+85))) 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 <= -4.2e+105) || !(y <= 5.9e+85)) {
tmp = -z;
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -4.2e+105) or not (y <= 5.9e+85): tmp = -z else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -4.2e+105) || !(y <= 5.9e+85)) tmp = Float64(-z); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -4.2e+105) || ~((y <= 5.9e+85))) tmp = -z; else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -4.2e+105], N[Not[LessEqual[y, 5.9e+85]], $MachinePrecision]], (-z), N[(x + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.2 \cdot 10^{+105} \lor \neg \left(y \leq 5.9 \cdot 10^{+85}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if y < -4.2000000000000002e105 or 5.9e85 < y Initial program 74.6%
Taylor expanded in y around inf 69.8%
mul-1-neg69.8%
Simplified69.8%
if -4.2000000000000002e105 < y < 5.9e85Initial program 98.8%
Taylor expanded in z around inf 71.3%
+-commutative71.3%
Simplified71.3%
Final simplification70.8%
(FPCore (x y z) :precision binary64 (if (<= x -3.8e-155) x (if (<= x 1.7e-149) y x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -3.8e-155) {
tmp = x;
} else if (x <= 1.7e-149) {
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 <= (-3.8d-155)) then
tmp = x
else if (x <= 1.7d-149) 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 <= -3.8e-155) {
tmp = x;
} else if (x <= 1.7e-149) {
tmp = y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -3.8e-155: tmp = x elif x <= 1.7e-149: tmp = y else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -3.8e-155) tmp = x; elseif (x <= 1.7e-149) tmp = y; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -3.8e-155) tmp = x; elseif (x <= 1.7e-149) tmp = y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -3.8e-155], x, If[LessEqual[x, 1.7e-149], y, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.8 \cdot 10^{-155}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1.7 \cdot 10^{-149}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -3.7999999999999998e-155 or 1.6999999999999999e-149 < x Initial program 91.6%
Taylor expanded in y around 0 45.6%
if -3.7999999999999998e-155 < x < 1.6999999999999999e-149Initial program 88.4%
Taylor expanded in x around 0 78.2%
Taylor expanded in y around 0 46.4%
Final simplification45.8%
(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 90.7%
Taylor expanded in y around 0 35.8%
Final simplification35.8%
(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 2024081
(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))))