
(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 8 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-224) (not (<= t_0 0.0))) t_0 (- (- z) (/ z (/ y x))))))
double code(double x, double y, double z) {
double t_0 = (x + y) / (1.0 - (y / z));
double tmp;
if ((t_0 <= -5e-224) || !(t_0 <= 0.0)) {
tmp = t_0;
} else {
tmp = -z - (z / (y / 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) :: t_0
real(8) :: tmp
t_0 = (x + y) / (1.0d0 - (y / z))
if ((t_0 <= (-5d-224)) .or. (.not. (t_0 <= 0.0d0))) then
tmp = t_0
else
tmp = -z - (z / (y / x))
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-224) || !(t_0 <= 0.0)) {
tmp = t_0;
} else {
tmp = -z - (z / (y / x));
}
return tmp;
}
def code(x, y, z): t_0 = (x + y) / (1.0 - (y / z)) tmp = 0 if (t_0 <= -5e-224) or not (t_0 <= 0.0): tmp = t_0 else: tmp = -z - (z / (y / x)) 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-224) || !(t_0 <= 0.0)) tmp = t_0; else tmp = Float64(Float64(-z) - Float64(z / Float64(y / x))); 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-224) || ~((t_0 <= 0.0))) tmp = t_0; else tmp = -z - (z / (y / x)); 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-224], N[Not[LessEqual[t$95$0, 0.0]], $MachinePrecision]], t$95$0, N[((-z) - N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + y}{1 - \frac{y}{z}}\\
\mathbf{if}\;t_0 \leq -5 \cdot 10^{-224} \lor \neg \left(t_0 \leq 0\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - \frac{z}{\frac{y}{x}}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < -4.9999999999999999e-224 or -0.0 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) Initial program 99.9%
if -4.9999999999999999e-224 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < -0.0Initial program 12.4%
Taylor expanded in z around 0 95.0%
associate-*r/95.0%
+-commutative95.0%
*-commutative95.0%
associate-*r*95.0%
mul-1-neg95.0%
+-commutative95.0%
Simplified95.0%
Taylor expanded in y around 0 100.0%
neg-mul-1100.0%
unsub-neg100.0%
mul-1-neg100.0%
associate-/l*100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ y z)))
(t_1 (/ x t_0))
(t_2 (- (- z) (/ z (/ y x))))
(t_3 (/ y t_0)))
(if (<= y -6.2e+33)
t_2
(if (<= y -1.05e-58)
t_1
(if (<= y -7e-86)
t_3
(if (<= y 32500000.0)
t_1
(if (<= y 2.7e+34) t_3 (if (<= y 1.55e+43) (+ x y) t_2))))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double t_1 = x / t_0;
double t_2 = -z - (z / (y / x));
double t_3 = y / t_0;
double tmp;
if (y <= -6.2e+33) {
tmp = t_2;
} else if (y <= -1.05e-58) {
tmp = t_1;
} else if (y <= -7e-86) {
tmp = t_3;
} else if (y <= 32500000.0) {
tmp = t_1;
} else if (y <= 2.7e+34) {
tmp = t_3;
} else if (y <= 1.55e+43) {
tmp = x + y;
} else {
tmp = t_2;
}
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) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = 1.0d0 - (y / z)
t_1 = x / t_0
t_2 = -z - (z / (y / x))
t_3 = y / t_0
if (y <= (-6.2d+33)) then
tmp = t_2
else if (y <= (-1.05d-58)) then
tmp = t_1
else if (y <= (-7d-86)) then
tmp = t_3
else if (y <= 32500000.0d0) then
tmp = t_1
else if (y <= 2.7d+34) then
tmp = t_3
else if (y <= 1.55d+43) then
tmp = x + y
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double t_1 = x / t_0;
double t_2 = -z - (z / (y / x));
double t_3 = y / t_0;
double tmp;
if (y <= -6.2e+33) {
tmp = t_2;
} else if (y <= -1.05e-58) {
tmp = t_1;
} else if (y <= -7e-86) {
tmp = t_3;
} else if (y <= 32500000.0) {
tmp = t_1;
} else if (y <= 2.7e+34) {
tmp = t_3;
} else if (y <= 1.55e+43) {
tmp = x + y;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (y / z) t_1 = x / t_0 t_2 = -z - (z / (y / x)) t_3 = y / t_0 tmp = 0 if y <= -6.2e+33: tmp = t_2 elif y <= -1.05e-58: tmp = t_1 elif y <= -7e-86: tmp = t_3 elif y <= 32500000.0: tmp = t_1 elif y <= 2.7e+34: tmp = t_3 elif y <= 1.55e+43: tmp = x + y else: tmp = t_2 return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(y / z)) t_1 = Float64(x / t_0) t_2 = Float64(Float64(-z) - Float64(z / Float64(y / x))) t_3 = Float64(y / t_0) tmp = 0.0 if (y <= -6.2e+33) tmp = t_2; elseif (y <= -1.05e-58) tmp = t_1; elseif (y <= -7e-86) tmp = t_3; elseif (y <= 32500000.0) tmp = t_1; elseif (y <= 2.7e+34) tmp = t_3; elseif (y <= 1.55e+43) tmp = Float64(x + y); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (y / z); t_1 = x / t_0; t_2 = -z - (z / (y / x)); t_3 = y / t_0; tmp = 0.0; if (y <= -6.2e+33) tmp = t_2; elseif (y <= -1.05e-58) tmp = t_1; elseif (y <= -7e-86) tmp = t_3; elseif (y <= 32500000.0) tmp = t_1; elseif (y <= 2.7e+34) tmp = t_3; elseif (y <= 1.55e+43) tmp = x + y; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x / t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[((-z) - N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(y / t$95$0), $MachinePrecision]}, If[LessEqual[y, -6.2e+33], t$95$2, If[LessEqual[y, -1.05e-58], t$95$1, If[LessEqual[y, -7e-86], t$95$3, If[LessEqual[y, 32500000.0], t$95$1, If[LessEqual[y, 2.7e+34], t$95$3, If[LessEqual[y, 1.55e+43], N[(x + y), $MachinePrecision], t$95$2]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{y}{z}\\
t_1 := \frac{x}{t_0}\\
t_2 := \left(-z\right) - \frac{z}{\frac{y}{x}}\\
t_3 := \frac{y}{t_0}\\
\mathbf{if}\;y \leq -6.2 \cdot 10^{+33}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;y \leq -1.05 \cdot 10^{-58}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -7 \cdot 10^{-86}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;y \leq 32500000:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 2.7 \cdot 10^{+34}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;y \leq 1.55 \cdot 10^{+43}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if y < -6.2e33 or 1.5500000000000001e43 < y Initial program 72.7%
Taylor expanded in z around 0 71.5%
associate-*r/71.5%
+-commutative71.5%
*-commutative71.5%
associate-*r*71.5%
mul-1-neg71.5%
+-commutative71.5%
Simplified71.5%
Taylor expanded in y around 0 77.4%
neg-mul-177.4%
unsub-neg77.4%
mul-1-neg77.4%
associate-/l*82.3%
Simplified82.3%
if -6.2e33 < y < -1.04999999999999994e-58 or -7.00000000000000041e-86 < y < 3.25e7Initial program 99.9%
Taylor expanded in x around inf 80.8%
if -1.04999999999999994e-58 < y < -7.00000000000000041e-86 or 3.25e7 < y < 2.7e34Initial program 99.9%
Taylor expanded in x around 0 99.9%
if 2.7e34 < y < 1.5500000000000001e43Initial program 100.0%
Taylor expanded in z around inf 100.0%
Final simplification82.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ y z)))
(t_1 (/ x t_0))
(t_2 (* z (- -1.0 (/ x y))))
(t_3 (/ y t_0)))
(if (<= y -5.8e+33)
t_2
(if (<= y -2.6e-57)
t_1
(if (<= y -2.8e-83)
t_3
(if (<= y 22000000.0)
t_1
(if (<= y 7e+32) t_3 (if (<= y 2.1e+43) (+ x y) t_2))))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double t_1 = x / t_0;
double t_2 = z * (-1.0 - (x / y));
double t_3 = y / t_0;
double tmp;
if (y <= -5.8e+33) {
tmp = t_2;
} else if (y <= -2.6e-57) {
tmp = t_1;
} else if (y <= -2.8e-83) {
tmp = t_3;
} else if (y <= 22000000.0) {
tmp = t_1;
} else if (y <= 7e+32) {
tmp = t_3;
} else if (y <= 2.1e+43) {
tmp = x + y;
} else {
tmp = t_2;
}
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) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = 1.0d0 - (y / z)
t_1 = x / t_0
t_2 = z * ((-1.0d0) - (x / y))
t_3 = y / t_0
if (y <= (-5.8d+33)) then
tmp = t_2
else if (y <= (-2.6d-57)) then
tmp = t_1
else if (y <= (-2.8d-83)) then
tmp = t_3
else if (y <= 22000000.0d0) then
tmp = t_1
else if (y <= 7d+32) then
tmp = t_3
else if (y <= 2.1d+43) then
tmp = x + y
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double t_1 = x / t_0;
double t_2 = z * (-1.0 - (x / y));
double t_3 = y / t_0;
double tmp;
if (y <= -5.8e+33) {
tmp = t_2;
} else if (y <= -2.6e-57) {
tmp = t_1;
} else if (y <= -2.8e-83) {
tmp = t_3;
} else if (y <= 22000000.0) {
tmp = t_1;
} else if (y <= 7e+32) {
tmp = t_3;
} else if (y <= 2.1e+43) {
tmp = x + y;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (y / z) t_1 = x / t_0 t_2 = z * (-1.0 - (x / y)) t_3 = y / t_0 tmp = 0 if y <= -5.8e+33: tmp = t_2 elif y <= -2.6e-57: tmp = t_1 elif y <= -2.8e-83: tmp = t_3 elif y <= 22000000.0: tmp = t_1 elif y <= 7e+32: tmp = t_3 elif y <= 2.1e+43: tmp = x + y else: tmp = t_2 return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(y / z)) t_1 = Float64(x / t_0) t_2 = Float64(z * Float64(-1.0 - Float64(x / y))) t_3 = Float64(y / t_0) tmp = 0.0 if (y <= -5.8e+33) tmp = t_2; elseif (y <= -2.6e-57) tmp = t_1; elseif (y <= -2.8e-83) tmp = t_3; elseif (y <= 22000000.0) tmp = t_1; elseif (y <= 7e+32) tmp = t_3; elseif (y <= 2.1e+43) tmp = Float64(x + y); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (y / z); t_1 = x / t_0; t_2 = z * (-1.0 - (x / y)); t_3 = y / t_0; tmp = 0.0; if (y <= -5.8e+33) tmp = t_2; elseif (y <= -2.6e-57) tmp = t_1; elseif (y <= -2.8e-83) tmp = t_3; elseif (y <= 22000000.0) tmp = t_1; elseif (y <= 7e+32) tmp = t_3; elseif (y <= 2.1e+43) tmp = x + y; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x / t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(z * N[(-1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(y / t$95$0), $MachinePrecision]}, If[LessEqual[y, -5.8e+33], t$95$2, If[LessEqual[y, -2.6e-57], t$95$1, If[LessEqual[y, -2.8e-83], t$95$3, If[LessEqual[y, 22000000.0], t$95$1, If[LessEqual[y, 7e+32], t$95$3, If[LessEqual[y, 2.1e+43], N[(x + y), $MachinePrecision], t$95$2]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{y}{z}\\
t_1 := \frac{x}{t_0}\\
t_2 := z \cdot \left(-1 - \frac{x}{y}\right)\\
t_3 := \frac{y}{t_0}\\
\mathbf{if}\;y \leq -5.8 \cdot 10^{+33}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;y \leq -2.6 \cdot 10^{-57}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -2.8 \cdot 10^{-83}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;y \leq 22000000:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 7 \cdot 10^{+32}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;y \leq 2.1 \cdot 10^{+43}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if y < -5.80000000000000049e33 or 2.10000000000000002e43 < y Initial program 72.7%
Taylor expanded in y around inf 74.6%
mul-1-neg74.6%
unsub-neg74.6%
mul-1-neg74.6%
associate-/l*75.6%
associate-/r/73.1%
unpow273.1%
associate-/l*79.6%
Simplified79.6%
Taylor expanded in z around 0 82.3%
mul-1-neg82.3%
*-commutative82.3%
distribute-rgt-neg-in82.3%
mul-1-neg82.3%
distribute-lft-in82.3%
metadata-eval82.3%
associate-*r/82.3%
neg-mul-182.3%
Simplified82.3%
if -5.80000000000000049e33 < y < -2.59999999999999985e-57 or -2.8000000000000001e-83 < y < 2.2e7Initial program 99.9%
Taylor expanded in x around inf 80.8%
if -2.59999999999999985e-57 < y < -2.8000000000000001e-83 or 2.2e7 < y < 7.0000000000000002e32Initial program 99.9%
Taylor expanded in x around 0 99.9%
if 7.0000000000000002e32 < y < 2.10000000000000002e43Initial program 100.0%
Taylor expanded in z around inf 100.0%
Final simplification82.5%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- 1.0 (/ y z)))) (if (or (<= x -1.2e-52) (not (<= x 2.55e-70))) (/ x t_0) (/ y t_0))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double tmp;
if ((x <= -1.2e-52) || !(x <= 2.55e-70)) {
tmp = x / t_0;
} else {
tmp = y / 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 = 1.0d0 - (y / z)
if ((x <= (-1.2d-52)) .or. (.not. (x <= 2.55d-70))) then
tmp = x / t_0
else
tmp = y / t_0
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 ((x <= -1.2e-52) || !(x <= 2.55e-70)) {
tmp = x / t_0;
} else {
tmp = y / t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (y / z) tmp = 0 if (x <= -1.2e-52) or not (x <= 2.55e-70): tmp = x / t_0 else: tmp = y / t_0 return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(y / z)) tmp = 0.0 if ((x <= -1.2e-52) || !(x <= 2.55e-70)) tmp = Float64(x / t_0); else tmp = Float64(y / t_0); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (y / z); tmp = 0.0; if ((x <= -1.2e-52) || ~((x <= 2.55e-70))) tmp = x / t_0; else tmp = y / t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[x, -1.2e-52], N[Not[LessEqual[x, 2.55e-70]], $MachinePrecision]], N[(x / t$95$0), $MachinePrecision], N[(y / t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{y}{z}\\
\mathbf{if}\;x \leq -1.2 \cdot 10^{-52} \lor \neg \left(x \leq 2.55 \cdot 10^{-70}\right):\\
\;\;\;\;\frac{x}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{t_0}\\
\end{array}
\end{array}
if x < -1.2000000000000001e-52 or 2.55000000000000013e-70 < x Initial program 88.9%
Taylor expanded in x around inf 74.0%
if -1.2000000000000001e-52 < x < 2.55000000000000013e-70Initial program 89.2%
Taylor expanded in x around 0 70.8%
Final simplification72.6%
(FPCore (x y z) :precision binary64 (if (<= y -6.4e+37) (- z) (if (<= y 2.35e+48) (+ x y) (- z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -6.4e+37) {
tmp = -z;
} else if (y <= 2.35e+48) {
tmp = x + y;
} else {
tmp = -z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-6.4d+37)) then
tmp = -z
else if (y <= 2.35d+48) then
tmp = x + y
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -6.4e+37) {
tmp = -z;
} else if (y <= 2.35e+48) {
tmp = x + y;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -6.4e+37: tmp = -z elif y <= 2.35e+48: tmp = x + y else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -6.4e+37) tmp = Float64(-z); elseif (y <= 2.35e+48) tmp = Float64(x + y); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -6.4e+37) tmp = -z; elseif (y <= 2.35e+48) tmp = x + y; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -6.4e+37], (-z), If[LessEqual[y, 2.35e+48], N[(x + y), $MachinePrecision], (-z)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.4 \cdot 10^{+37}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq 2.35 \cdot 10^{+48}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -6.40000000000000027e37 or 2.35000000000000006e48 < y Initial program 72.8%
Taylor expanded in y around inf 70.5%
mul-1-neg70.5%
Simplified70.5%
if -6.40000000000000027e37 < y < 2.35000000000000006e48Initial program 99.3%
Taylor expanded in z around inf 75.6%
Final simplification73.6%
(FPCore (x y z) :precision binary64 (if (<= y -5e+25) (- z) (if (<= y 1.5e+44) x (- z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -5e+25) {
tmp = -z;
} else if (y <= 1.5e+44) {
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 <= (-5d+25)) then
tmp = -z
else if (y <= 1.5d+44) 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 <= -5e+25) {
tmp = -z;
} else if (y <= 1.5e+44) {
tmp = x;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5e+25: tmp = -z elif y <= 1.5e+44: tmp = x else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5e+25) tmp = Float64(-z); elseif (y <= 1.5e+44) tmp = x; else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -5e+25) tmp = -z; elseif (y <= 1.5e+44) tmp = x; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5e+25], (-z), If[LessEqual[y, 1.5e+44], x, (-z)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{+25}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq 1.5 \cdot 10^{+44}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -5.00000000000000024e25 or 1.49999999999999993e44 < y Initial program 73.2%
Taylor expanded in y around inf 69.1%
mul-1-neg69.1%
Simplified69.1%
if -5.00000000000000024e25 < y < 1.49999999999999993e44Initial program 99.9%
Taylor expanded in y around 0 60.4%
Final simplification64.0%
(FPCore (x y z) :precision binary64 (if (<= x -2.15e-76) x (if (<= x 9.5e-77) y x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -2.15e-76) {
tmp = x;
} else if (x <= 9.5e-77) {
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 <= (-2.15d-76)) then
tmp = x
else if (x <= 9.5d-77) 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 <= -2.15e-76) {
tmp = x;
} else if (x <= 9.5e-77) {
tmp = y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -2.15e-76: tmp = x elif x <= 9.5e-77: tmp = y else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -2.15e-76) tmp = x; elseif (x <= 9.5e-77) tmp = y; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -2.15e-76) tmp = x; elseif (x <= 9.5e-77) tmp = y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -2.15e-76], x, If[LessEqual[x, 9.5e-77], y, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.15 \cdot 10^{-76}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{-77}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -2.15e-76 or 9.5000000000000005e-77 < x Initial program 88.6%
Taylor expanded in y around 0 53.8%
if -2.15e-76 < x < 9.5000000000000005e-77Initial program 89.6%
Taylor expanded in x around 0 71.2%
Taylor expanded in y around 0 31.8%
Final simplification44.6%
(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 89.0%
Taylor expanded in y around 0 38.8%
Final simplification38.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 2023224
(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))))