
(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
(if (<= y -4.5e+27)
(* (/ (+ y x) y) (- z))
(if (<= y 2.65e+17)
(/ (+ y x) (- 1.0 (/ y z)))
(- (- (- z) (/ z (/ y x))) (/ z (/ y z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -4.5e+27) {
tmp = ((y + x) / y) * -z;
} else if (y <= 2.65e+17) {
tmp = (y + x) / (1.0 - (y / z));
} else {
tmp = (-z - (z / (y / 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) :: tmp
if (y <= (-4.5d+27)) then
tmp = ((y + x) / y) * -z
else if (y <= 2.65d+17) then
tmp = (y + x) / (1.0d0 - (y / z))
else
tmp = (-z - (z / (y / x))) - (z / (y / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -4.5e+27) {
tmp = ((y + x) / y) * -z;
} else if (y <= 2.65e+17) {
tmp = (y + x) / (1.0 - (y / z));
} else {
tmp = (-z - (z / (y / x))) - (z / (y / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -4.5e+27: tmp = ((y + x) / y) * -z elif y <= 2.65e+17: tmp = (y + x) / (1.0 - (y / z)) else: tmp = (-z - (z / (y / x))) - (z / (y / z)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -4.5e+27) tmp = Float64(Float64(Float64(y + x) / y) * Float64(-z)); elseif (y <= 2.65e+17) tmp = Float64(Float64(y + x) / Float64(1.0 - Float64(y / z))); else tmp = Float64(Float64(Float64(-z) - Float64(z / Float64(y / x))) - Float64(z / Float64(y / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -4.5e+27) tmp = ((y + x) / y) * -z; elseif (y <= 2.65e+17) tmp = (y + x) / (1.0 - (y / z)); else tmp = (-z - (z / (y / x))) - (z / (y / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -4.5e+27], N[(N[(N[(y + x), $MachinePrecision] / y), $MachinePrecision] * (-z)), $MachinePrecision], If[LessEqual[y, 2.65e+17], N[(N[(y + x), $MachinePrecision] / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-z) - N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.5 \cdot 10^{+27}:\\
\;\;\;\;\frac{y + x}{y} \cdot \left(-z\right)\\
\mathbf{elif}\;y \leq 2.65 \cdot 10^{+17}:\\
\;\;\;\;\frac{y + x}{1 - \frac{y}{z}}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-z\right) - \frac{z}{\frac{y}{x}}\right) - \frac{z}{\frac{y}{z}}\\
\end{array}
\end{array}
if y < -4.4999999999999999e27Initial program 49.1%
Taylor expanded in z around 0 99.8%
mul-1-neg99.8%
associate-/l*49.1%
+-commutative49.1%
associate-/r/100.0%
distribute-rgt-neg-in100.0%
+-commutative100.0%
Simplified100.0%
if -4.4999999999999999e27 < y < 2.65e17Initial program 99.8%
if 2.65e17 < y Initial program 50.8%
Taylor expanded in y around inf 99.9%
mul-1-neg99.9%
unsub-neg99.9%
mul-1-neg99.9%
associate-/l*99.9%
unpow299.9%
associate-/l*99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (/ (- z) y))))
(if (<= y -5.5e+21)
(- z)
(if (<= y -2.7e-155)
t_0
(if (<= y 3.05e-148) (+ y x) (if (<= y 8e-8) t_0 (- z)))))))
double code(double x, double y, double z) {
double t_0 = x * (-z / y);
double tmp;
if (y <= -5.5e+21) {
tmp = -z;
} else if (y <= -2.7e-155) {
tmp = t_0;
} else if (y <= 3.05e-148) {
tmp = y + x;
} else if (y <= 8e-8) {
tmp = t_0;
} else {
tmp = -z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = x * (-z / y)
if (y <= (-5.5d+21)) then
tmp = -z
else if (y <= (-2.7d-155)) then
tmp = t_0
else if (y <= 3.05d-148) then
tmp = y + x
else if (y <= 8d-8) then
tmp = t_0
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (-z / y);
double tmp;
if (y <= -5.5e+21) {
tmp = -z;
} else if (y <= -2.7e-155) {
tmp = t_0;
} else if (y <= 3.05e-148) {
tmp = y + x;
} else if (y <= 8e-8) {
tmp = t_0;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): t_0 = x * (-z / y) tmp = 0 if y <= -5.5e+21: tmp = -z elif y <= -2.7e-155: tmp = t_0 elif y <= 3.05e-148: tmp = y + x elif y <= 8e-8: tmp = t_0 else: tmp = -z return tmp
function code(x, y, z) t_0 = Float64(x * Float64(Float64(-z) / y)) tmp = 0.0 if (y <= -5.5e+21) tmp = Float64(-z); elseif (y <= -2.7e-155) tmp = t_0; elseif (y <= 3.05e-148) tmp = Float64(y + x); elseif (y <= 8e-8) tmp = t_0; else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (-z / y); tmp = 0.0; if (y <= -5.5e+21) tmp = -z; elseif (y <= -2.7e-155) tmp = t_0; elseif (y <= 3.05e-148) tmp = y + x; elseif (y <= 8e-8) tmp = t_0; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[((-z) / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -5.5e+21], (-z), If[LessEqual[y, -2.7e-155], t$95$0, If[LessEqual[y, 3.05e-148], N[(y + x), $MachinePrecision], If[LessEqual[y, 8e-8], t$95$0, (-z)]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{-z}{y}\\
\mathbf{if}\;y \leq -5.5 \cdot 10^{+21}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -2.7 \cdot 10^{-155}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 3.05 \cdot 10^{-148}:\\
\;\;\;\;y + x\\
\mathbf{elif}\;y \leq 8 \cdot 10^{-8}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -5.5e21 or 8.0000000000000002e-8 < y Initial program 52.5%
Taylor expanded in y around inf 78.2%
mul-1-neg78.2%
Simplified78.2%
if -5.5e21 < y < -2.69999999999999981e-155 or 3.04999999999999988e-148 < y < 8.0000000000000002e-8Initial program 99.7%
Taylor expanded in x around inf 70.2%
Taylor expanded in y around inf 55.9%
mul-1-neg55.9%
*-commutative55.9%
associate-*r/58.6%
distribute-rgt-neg-in58.6%
distribute-frac-neg58.6%
Simplified58.6%
if -2.69999999999999981e-155 < y < 3.04999999999999988e-148Initial program 99.9%
Taylor expanded in z around inf 85.0%
Final simplification74.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ x (/ (- y) z))))
(if (<= y -3.9e+18)
(- z)
(if (<= y -1.1e-151)
t_0
(if (<= y 5e-151) (+ y x) (if (<= y 7.5e-8) t_0 (- z)))))))
double code(double x, double y, double z) {
double t_0 = x / (-y / z);
double tmp;
if (y <= -3.9e+18) {
tmp = -z;
} else if (y <= -1.1e-151) {
tmp = t_0;
} else if (y <= 5e-151) {
tmp = y + x;
} else if (y <= 7.5e-8) {
tmp = t_0;
} else {
tmp = -z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = x / (-y / z)
if (y <= (-3.9d+18)) then
tmp = -z
else if (y <= (-1.1d-151)) then
tmp = t_0
else if (y <= 5d-151) then
tmp = y + x
else if (y <= 7.5d-8) then
tmp = t_0
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x / (-y / z);
double tmp;
if (y <= -3.9e+18) {
tmp = -z;
} else if (y <= -1.1e-151) {
tmp = t_0;
} else if (y <= 5e-151) {
tmp = y + x;
} else if (y <= 7.5e-8) {
tmp = t_0;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): t_0 = x / (-y / z) tmp = 0 if y <= -3.9e+18: tmp = -z elif y <= -1.1e-151: tmp = t_0 elif y <= 5e-151: tmp = y + x elif y <= 7.5e-8: tmp = t_0 else: tmp = -z return tmp
function code(x, y, z) t_0 = Float64(x / Float64(Float64(-y) / z)) tmp = 0.0 if (y <= -3.9e+18) tmp = Float64(-z); elseif (y <= -1.1e-151) tmp = t_0; elseif (y <= 5e-151) tmp = Float64(y + x); elseif (y <= 7.5e-8) tmp = t_0; else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x / (-y / z); tmp = 0.0; if (y <= -3.9e+18) tmp = -z; elseif (y <= -1.1e-151) tmp = t_0; elseif (y <= 5e-151) tmp = y + x; elseif (y <= 7.5e-8) tmp = t_0; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x / N[((-y) / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -3.9e+18], (-z), If[LessEqual[y, -1.1e-151], t$95$0, If[LessEqual[y, 5e-151], N[(y + x), $MachinePrecision], If[LessEqual[y, 7.5e-8], t$95$0, (-z)]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{\frac{-y}{z}}\\
\mathbf{if}\;y \leq -3.9 \cdot 10^{+18}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -1.1 \cdot 10^{-151}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 5 \cdot 10^{-151}:\\
\;\;\;\;y + x\\
\mathbf{elif}\;y \leq 7.5 \cdot 10^{-8}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -3.9e18 or 7.4999999999999997e-8 < y Initial program 52.5%
Taylor expanded in y around inf 78.2%
mul-1-neg78.2%
Simplified78.2%
if -3.9e18 < y < -1.1e-151 or 5.00000000000000003e-151 < y < 7.4999999999999997e-8Initial program 99.7%
Taylor expanded in x around inf 70.2%
Taylor expanded in y around inf 58.7%
mul-1-neg58.7%
distribute-frac-neg58.7%
Simplified58.7%
if -1.1e-151 < y < 5.00000000000000003e-151Initial program 99.9%
Taylor expanded in z around inf 85.0%
Final simplification74.6%
(FPCore (x y z) :precision binary64 (if (<= y -1e+28) (* (/ (+ y x) y) (- z)) (if (<= y 1.45e+14) (/ (+ y x) (- 1.0 (/ y z))) (/ (* (+ y x) (- z)) y))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1e+28) {
tmp = ((y + x) / y) * -z;
} else if (y <= 1.45e+14) {
tmp = (y + x) / (1.0 - (y / z));
} else {
tmp = ((y + x) * -z) / y;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-1d+28)) then
tmp = ((y + x) / y) * -z
else if (y <= 1.45d+14) then
tmp = (y + x) / (1.0d0 - (y / z))
else
tmp = ((y + x) * -z) / y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1e+28) {
tmp = ((y + x) / y) * -z;
} else if (y <= 1.45e+14) {
tmp = (y + x) / (1.0 - (y / z));
} else {
tmp = ((y + x) * -z) / y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1e+28: tmp = ((y + x) / y) * -z elif y <= 1.45e+14: tmp = (y + x) / (1.0 - (y / z)) else: tmp = ((y + x) * -z) / y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1e+28) tmp = Float64(Float64(Float64(y + x) / y) * Float64(-z)); elseif (y <= 1.45e+14) tmp = Float64(Float64(y + x) / Float64(1.0 - Float64(y / z))); else tmp = Float64(Float64(Float64(y + x) * Float64(-z)) / y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1e+28) tmp = ((y + x) / y) * -z; elseif (y <= 1.45e+14) tmp = (y + x) / (1.0 - (y / z)); else tmp = ((y + x) * -z) / y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1e+28], N[(N[(N[(y + x), $MachinePrecision] / y), $MachinePrecision] * (-z)), $MachinePrecision], If[LessEqual[y, 1.45e+14], N[(N[(y + x), $MachinePrecision] / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y + x), $MachinePrecision] * (-z)), $MachinePrecision] / y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \cdot 10^{+28}:\\
\;\;\;\;\frac{y + x}{y} \cdot \left(-z\right)\\
\mathbf{elif}\;y \leq 1.45 \cdot 10^{+14}:\\
\;\;\;\;\frac{y + x}{1 - \frac{y}{z}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(y + x\right) \cdot \left(-z\right)}{y}\\
\end{array}
\end{array}
if y < -9.99999999999999958e27Initial program 49.1%
Taylor expanded in z around 0 99.8%
mul-1-neg99.8%
associate-/l*49.1%
+-commutative49.1%
associate-/r/100.0%
distribute-rgt-neg-in100.0%
+-commutative100.0%
Simplified100.0%
if -9.99999999999999958e27 < y < 1.45e14Initial program 99.8%
if 1.45e14 < y Initial program 50.8%
Taylor expanded in z around 0 99.8%
mul-1-neg99.8%
+-commutative99.8%
*-commutative99.8%
+-commutative99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.1e-64) (not (<= y 5.6e-123))) (- (- z) (* x (/ z y))) (/ x (- 1.0 (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.1e-64) || !(y <= 5.6e-123)) {
tmp = -z - (x * (z / y));
} else {
tmp = x / (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 ((y <= (-2.1d-64)) .or. (.not. (y <= 5.6d-123))) then
tmp = -z - (x * (z / y))
else
tmp = x / (1.0d0 - (y / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -2.1e-64) || !(y <= 5.6e-123)) {
tmp = -z - (x * (z / y));
} else {
tmp = x / (1.0 - (y / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.1e-64) or not (y <= 5.6e-123): tmp = -z - (x * (z / y)) else: tmp = x / (1.0 - (y / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.1e-64) || !(y <= 5.6e-123)) tmp = Float64(Float64(-z) - Float64(x * Float64(z / y))); else tmp = Float64(x / Float64(1.0 - Float64(y / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -2.1e-64) || ~((y <= 5.6e-123))) tmp = -z - (x * (z / y)); else tmp = x / (1.0 - (y / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.1e-64], N[Not[LessEqual[y, 5.6e-123]], $MachinePrecision]], N[((-z) - N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.1 \cdot 10^{-64} \lor \neg \left(y \leq 5.6 \cdot 10^{-123}\right):\\
\;\;\;\;\left(-z\right) - x \cdot \frac{z}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{1 - \frac{y}{z}}\\
\end{array}
\end{array}
if y < -2.10000000000000011e-64 or 5.5999999999999998e-123 < y Initial program 62.0%
Taylor expanded in z around 0 94.3%
mul-1-neg94.3%
+-commutative94.3%
*-commutative94.3%
+-commutative94.3%
Simplified94.3%
Taylor expanded in y around 0 95.4%
associate-*r/94.8%
+-commutative94.8%
*-commutative94.8%
associate-*l/95.4%
associate-*r/91.7%
Simplified91.7%
if -2.10000000000000011e-64 < y < 5.5999999999999998e-123Initial program 99.8%
Taylor expanded in x around inf 84.9%
Final simplification89.6%
(FPCore (x y z) :precision binary64 (if (or (<= y -7.5e-57) (not (<= y 5.6e-123))) (/ (* (+ y x) (- z)) y) (/ x (- 1.0 (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -7.5e-57) || !(y <= 5.6e-123)) {
tmp = ((y + x) * -z) / y;
} else {
tmp = x / (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 ((y <= (-7.5d-57)) .or. (.not. (y <= 5.6d-123))) then
tmp = ((y + x) * -z) / y
else
tmp = x / (1.0d0 - (y / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -7.5e-57) || !(y <= 5.6e-123)) {
tmp = ((y + x) * -z) / y;
} else {
tmp = x / (1.0 - (y / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -7.5e-57) or not (y <= 5.6e-123): tmp = ((y + x) * -z) / y else: tmp = x / (1.0 - (y / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -7.5e-57) || !(y <= 5.6e-123)) tmp = Float64(Float64(Float64(y + x) * Float64(-z)) / y); else tmp = Float64(x / Float64(1.0 - Float64(y / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -7.5e-57) || ~((y <= 5.6e-123))) tmp = ((y + x) * -z) / y; else tmp = x / (1.0 - (y / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -7.5e-57], N[Not[LessEqual[y, 5.6e-123]], $MachinePrecision]], N[(N[(N[(y + x), $MachinePrecision] * (-z)), $MachinePrecision] / y), $MachinePrecision], N[(x / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.5 \cdot 10^{-57} \lor \neg \left(y \leq 5.6 \cdot 10^{-123}\right):\\
\;\;\;\;\frac{\left(y + x\right) \cdot \left(-z\right)}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{1 - \frac{y}{z}}\\
\end{array}
\end{array}
if y < -7.49999999999999973e-57 or 5.5999999999999998e-123 < y Initial program 62.0%
Taylor expanded in z around 0 94.3%
mul-1-neg94.3%
+-commutative94.3%
*-commutative94.3%
+-commutative94.3%
Simplified94.3%
if -7.49999999999999973e-57 < y < 5.5999999999999998e-123Initial program 99.8%
Taylor expanded in x around inf 84.9%
Final simplification91.4%
(FPCore (x y z) :precision binary64 (if (or (<= y -6e-58) (not (<= y 5.6e-123))) (* (/ (+ y x) y) (- z)) (/ x (- 1.0 (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -6e-58) || !(y <= 5.6e-123)) {
tmp = ((y + x) / y) * -z;
} else {
tmp = x / (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 ((y <= (-6d-58)) .or. (.not. (y <= 5.6d-123))) then
tmp = ((y + x) / y) * -z
else
tmp = x / (1.0d0 - (y / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -6e-58) || !(y <= 5.6e-123)) {
tmp = ((y + x) / y) * -z;
} else {
tmp = x / (1.0 - (y / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -6e-58) or not (y <= 5.6e-123): tmp = ((y + x) / y) * -z else: tmp = x / (1.0 - (y / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -6e-58) || !(y <= 5.6e-123)) tmp = Float64(Float64(Float64(y + x) / y) * Float64(-z)); else tmp = Float64(x / Float64(1.0 - Float64(y / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -6e-58) || ~((y <= 5.6e-123))) tmp = ((y + x) / y) * -z; else tmp = x / (1.0 - (y / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -6e-58], N[Not[LessEqual[y, 5.6e-123]], $MachinePrecision]], N[(N[(N[(y + x), $MachinePrecision] / y), $MachinePrecision] * (-z)), $MachinePrecision], N[(x / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6 \cdot 10^{-58} \lor \neg \left(y \leq 5.6 \cdot 10^{-123}\right):\\
\;\;\;\;\frac{y + x}{y} \cdot \left(-z\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{1 - \frac{y}{z}}\\
\end{array}
\end{array}
if y < -6.00000000000000015e-58 or 5.5999999999999998e-123 < y Initial program 62.0%
Taylor expanded in z around 0 94.3%
mul-1-neg94.3%
associate-/l*58.1%
+-commutative58.1%
associate-/r/94.8%
distribute-rgt-neg-in94.8%
+-commutative94.8%
Simplified94.8%
if -6.00000000000000015e-58 < y < 5.5999999999999998e-123Initial program 99.8%
Taylor expanded in x around inf 84.9%
Final simplification91.7%
(FPCore (x y z) :precision binary64 (if (<= y -1.95e+21) (- z) (if (<= y 7.6e-8) (/ x (- 1.0 (/ y z))) (- z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.95e+21) {
tmp = -z;
} else if (y <= 7.6e-8) {
tmp = x / (1.0 - (y / z));
} 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.95d+21)) then
tmp = -z
else if (y <= 7.6d-8) then
tmp = x / (1.0d0 - (y / z))
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.95e+21) {
tmp = -z;
} else if (y <= 7.6e-8) {
tmp = x / (1.0 - (y / z));
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.95e+21: tmp = -z elif y <= 7.6e-8: tmp = x / (1.0 - (y / z)) else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.95e+21) tmp = Float64(-z); elseif (y <= 7.6e-8) tmp = Float64(x / Float64(1.0 - Float64(y / z))); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.95e+21) tmp = -z; elseif (y <= 7.6e-8) tmp = x / (1.0 - (y / z)); else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.95e+21], (-z), If[LessEqual[y, 7.6e-8], N[(x / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-z)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.95 \cdot 10^{+21}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq 7.6 \cdot 10^{-8}:\\
\;\;\;\;\frac{x}{1 - \frac{y}{z}}\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -1.95e21 or 7.60000000000000056e-8 < y Initial program 52.5%
Taylor expanded in y around inf 78.2%
mul-1-neg78.2%
Simplified78.2%
if -1.95e21 < y < 7.60000000000000056e-8Initial program 99.8%
Taylor expanded in x around inf 78.6%
Final simplification78.3%
(FPCore (x y z) :precision binary64 (if (<= y -1.25e-49) (- z) (if (<= y 5.6e-123) (+ y x) (- z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.25e-49) {
tmp = -z;
} else if (y <= 5.6e-123) {
tmp = y + 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.25d-49)) then
tmp = -z
else if (y <= 5.6d-123) then
tmp = y + 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.25e-49) {
tmp = -z;
} else if (y <= 5.6e-123) {
tmp = y + x;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.25e-49: tmp = -z elif y <= 5.6e-123: tmp = y + x else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.25e-49) tmp = Float64(-z); elseif (y <= 5.6e-123) tmp = Float64(y + x); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.25e-49) tmp = -z; elseif (y <= 5.6e-123) tmp = y + x; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.25e-49], (-z), If[LessEqual[y, 5.6e-123], N[(y + x), $MachinePrecision], (-z)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.25 \cdot 10^{-49}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq 5.6 \cdot 10^{-123}:\\
\;\;\;\;y + x\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -1.25e-49 or 5.5999999999999998e-123 < y Initial program 62.0%
Taylor expanded in y around inf 67.8%
mul-1-neg67.8%
Simplified67.8%
if -1.25e-49 < y < 5.5999999999999998e-123Initial program 99.8%
Taylor expanded in z around inf 67.1%
Final simplification67.6%
(FPCore (x y z) :precision binary64 (if (<= y -9.5e-56) (- z) (if (<= y 5.3e-123) x (- z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -9.5e-56) {
tmp = -z;
} else if (y <= 5.3e-123) {
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 <= (-9.5d-56)) then
tmp = -z
else if (y <= 5.3d-123) 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 <= -9.5e-56) {
tmp = -z;
} else if (y <= 5.3e-123) {
tmp = x;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -9.5e-56: tmp = -z elif y <= 5.3e-123: tmp = x else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -9.5e-56) tmp = Float64(-z); elseif (y <= 5.3e-123) tmp = x; else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -9.5e-56) tmp = -z; elseif (y <= 5.3e-123) tmp = x; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -9.5e-56], (-z), If[LessEqual[y, 5.3e-123], x, (-z)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.5 \cdot 10^{-56}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq 5.3 \cdot 10^{-123}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -9.4999999999999991e-56 or 5.29999999999999971e-123 < y Initial program 62.0%
Taylor expanded in y around inf 67.8%
mul-1-neg67.8%
Simplified67.8%
if -9.4999999999999991e-56 < y < 5.29999999999999971e-123Initial program 99.8%
Taylor expanded in y around 0 58.0%
Final simplification64.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 73.7%
Taylor expanded in y around 0 21.1%
Final simplification21.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (/ (+ y x) (- y)) z)))
(if (< y -3.7429310762689856e+171)
t_0
(if (< y 3.5534662456086734e+168) (/ (+ x y) (- 1.0 (/ y z))) t_0))))
double code(double x, double y, double z) {
double t_0 = ((y + x) / -y) * z;
double tmp;
if (y < -3.7429310762689856e+171) {
tmp = t_0;
} else if (y < 3.5534662456086734e+168) {
tmp = (x + y) / (1.0 - (y / z));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = ((y + x) / -y) * z
if (y < (-3.7429310762689856d+171)) then
tmp = t_0
else if (y < 3.5534662456086734d+168) then
tmp = (x + y) / (1.0d0 - (y / z))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = ((y + x) / -y) * z;
double tmp;
if (y < -3.7429310762689856e+171) {
tmp = t_0;
} else if (y < 3.5534662456086734e+168) {
tmp = (x + y) / (1.0 - (y / z));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = ((y + x) / -y) * z tmp = 0 if y < -3.7429310762689856e+171: tmp = t_0 elif y < 3.5534662456086734e+168: tmp = (x + y) / (1.0 - (y / z)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(y + x) / Float64(-y)) * z) tmp = 0.0 if (y < -3.7429310762689856e+171) tmp = t_0; elseif (y < 3.5534662456086734e+168) tmp = Float64(Float64(x + y) / Float64(1.0 - Float64(y / z))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = ((y + x) / -y) * z; tmp = 0.0; if (y < -3.7429310762689856e+171) tmp = t_0; elseif (y < 3.5534662456086734e+168) tmp = (x + y) / (1.0 - (y / z)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(y + x), $MachinePrecision] / (-y)), $MachinePrecision] * z), $MachinePrecision]}, If[Less[y, -3.7429310762689856e+171], t$95$0, If[Less[y, 3.5534662456086734e+168], N[(N[(x + y), $MachinePrecision] / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y + x}{-y} \cdot z\\
\mathbf{if}\;y < -3.7429310762689856 \cdot 10^{+171}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y < 3.5534662456086734 \cdot 10^{+168}:\\
\;\;\;\;\frac{x + y}{1 - \frac{y}{z}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
herbie shell --seed 2023278
(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))))