
(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
(let* ((t_0 (/ (+ x y) (- 1.0 (/ y z)))))
(if (or (<= t_0 -5e-281) (not (<= t_0 5e-241)))
t_0
(/ (- z) (/ y (+ x y))))))
double code(double x, double y, double z) {
double t_0 = (x + y) / (1.0 - (y / z));
double tmp;
if ((t_0 <= -5e-281) || !(t_0 <= 5e-241)) {
tmp = t_0;
} else {
tmp = -z / (y / (x + y));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (x + y) / (1.0d0 - (y / z))
if ((t_0 <= (-5d-281)) .or. (.not. (t_0 <= 5d-241))) then
tmp = t_0
else
tmp = -z / (y / (x + y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x + y) / (1.0 - (y / z));
double tmp;
if ((t_0 <= -5e-281) || !(t_0 <= 5e-241)) {
tmp = t_0;
} else {
tmp = -z / (y / (x + y));
}
return tmp;
}
def code(x, y, z): t_0 = (x + y) / (1.0 - (y / z)) tmp = 0 if (t_0 <= -5e-281) or not (t_0 <= 5e-241): tmp = t_0 else: tmp = -z / (y / (x + y)) return tmp
function code(x, y, z) t_0 = Float64(Float64(x + y) / Float64(1.0 - Float64(y / z))) tmp = 0.0 if ((t_0 <= -5e-281) || !(t_0 <= 5e-241)) tmp = t_0; else tmp = Float64(Float64(-z) / Float64(y / 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 <= -5e-281) || ~((t_0 <= 5e-241))) tmp = t_0; else tmp = -z / (y / (x + y)); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + y), $MachinePrecision] / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -5e-281], N[Not[LessEqual[t$95$0, 5e-241]], $MachinePrecision]], t$95$0, N[((-z) / N[(y / 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 -5 \cdot 10^{-281} \lor \neg \left(t_0 \leq 5 \cdot 10^{-241}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{-z}{\frac{y}{x + y}}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < -4.9999999999999998e-281 or 4.9999999999999998e-241 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) Initial program 99.9%
if -4.9999999999999998e-281 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < 4.9999999999999998e-241Initial program 19.3%
Taylor expanded in z around 0 92.3%
mul-1-neg92.3%
associate-/l*99.9%
distribute-neg-frac99.9%
+-commutative99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ y z))) (t_1 (/ x t_0)))
(if (<= y -4.9e+129)
(- z)
(if (<= y -4.3e+112)
t_1
(if (<= y -1.42e+91)
(- z)
(if (<= y -3.5e+74)
(* (- z) (/ x y))
(if (<= y -5.9e+62)
t_1
(if (<= y -1.05e-21)
(/ y t_0)
(if (<= y 1.2e+173) (+ x y) (- z))))))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double t_1 = x / t_0;
double tmp;
if (y <= -4.9e+129) {
tmp = -z;
} else if (y <= -4.3e+112) {
tmp = t_1;
} else if (y <= -1.42e+91) {
tmp = -z;
} else if (y <= -3.5e+74) {
tmp = -z * (x / y);
} else if (y <= -5.9e+62) {
tmp = t_1;
} else if (y <= -1.05e-21) {
tmp = y / t_0;
} else if (y <= 1.2e+173) {
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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (y / z)
t_1 = x / t_0
if (y <= (-4.9d+129)) then
tmp = -z
else if (y <= (-4.3d+112)) then
tmp = t_1
else if (y <= (-1.42d+91)) then
tmp = -z
else if (y <= (-3.5d+74)) then
tmp = -z * (x / y)
else if (y <= (-5.9d+62)) then
tmp = t_1
else if (y <= (-1.05d-21)) then
tmp = y / t_0
else if (y <= 1.2d+173) then
tmp = x + y
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double t_1 = x / t_0;
double tmp;
if (y <= -4.9e+129) {
tmp = -z;
} else if (y <= -4.3e+112) {
tmp = t_1;
} else if (y <= -1.42e+91) {
tmp = -z;
} else if (y <= -3.5e+74) {
tmp = -z * (x / y);
} else if (y <= -5.9e+62) {
tmp = t_1;
} else if (y <= -1.05e-21) {
tmp = y / t_0;
} else if (y <= 1.2e+173) {
tmp = x + y;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (y / z) t_1 = x / t_0 tmp = 0 if y <= -4.9e+129: tmp = -z elif y <= -4.3e+112: tmp = t_1 elif y <= -1.42e+91: tmp = -z elif y <= -3.5e+74: tmp = -z * (x / y) elif y <= -5.9e+62: tmp = t_1 elif y <= -1.05e-21: tmp = y / t_0 elif y <= 1.2e+173: tmp = x + y else: tmp = -z return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(y / z)) t_1 = Float64(x / t_0) tmp = 0.0 if (y <= -4.9e+129) tmp = Float64(-z); elseif (y <= -4.3e+112) tmp = t_1; elseif (y <= -1.42e+91) tmp = Float64(-z); elseif (y <= -3.5e+74) tmp = Float64(Float64(-z) * Float64(x / y)); elseif (y <= -5.9e+62) tmp = t_1; elseif (y <= -1.05e-21) tmp = Float64(y / t_0); elseif (y <= 1.2e+173) tmp = Float64(x + y); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (y / z); t_1 = x / t_0; tmp = 0.0; if (y <= -4.9e+129) tmp = -z; elseif (y <= -4.3e+112) tmp = t_1; elseif (y <= -1.42e+91) tmp = -z; elseif (y <= -3.5e+74) tmp = -z * (x / y); elseif (y <= -5.9e+62) tmp = t_1; elseif (y <= -1.05e-21) tmp = y / t_0; elseif (y <= 1.2e+173) tmp = x + y; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x / t$95$0), $MachinePrecision]}, If[LessEqual[y, -4.9e+129], (-z), If[LessEqual[y, -4.3e+112], t$95$1, If[LessEqual[y, -1.42e+91], (-z), If[LessEqual[y, -3.5e+74], N[((-z) * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -5.9e+62], t$95$1, If[LessEqual[y, -1.05e-21], N[(y / t$95$0), $MachinePrecision], If[LessEqual[y, 1.2e+173], N[(x + y), $MachinePrecision], (-z)]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{y}{z}\\
t_1 := \frac{x}{t_0}\\
\mathbf{if}\;y \leq -4.9 \cdot 10^{+129}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -4.3 \cdot 10^{+112}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -1.42 \cdot 10^{+91}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -3.5 \cdot 10^{+74}:\\
\;\;\;\;\left(-z\right) \cdot \frac{x}{y}\\
\mathbf{elif}\;y \leq -5.9 \cdot 10^{+62}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -1.05 \cdot 10^{-21}:\\
\;\;\;\;\frac{y}{t_0}\\
\mathbf{elif}\;y \leq 1.2 \cdot 10^{+173}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -4.9e129 or -4.29999999999999983e112 < y < -1.41999999999999995e91 or 1.2e173 < y Initial program 54.7%
Taylor expanded in y around inf 79.3%
mul-1-neg79.3%
Simplified79.3%
if -4.9e129 < y < -4.29999999999999983e112 or -3.50000000000000014e74 < y < -5.9000000000000003e62Initial program 99.8%
Taylor expanded in x around inf 87.4%
if -1.41999999999999995e91 < y < -3.50000000000000014e74Initial program 52.3%
Taylor expanded in z around 0 99.2%
mul-1-neg99.2%
associate-/l*100.0%
distribute-neg-frac100.0%
+-commutative100.0%
Simplified100.0%
clear-num100.0%
associate-/r/99.2%
Applied egg-rr99.2%
Taylor expanded in y around 0 99.2%
mul-1-neg99.2%
associate-*l/100.0%
*-commutative100.0%
distribute-lft-neg-in100.0%
Simplified100.0%
if -5.9000000000000003e62 < y < -1.05000000000000006e-21Initial program 95.4%
Taylor expanded in x around 0 69.3%
if -1.05000000000000006e-21 < y < 1.2e173Initial program 97.5%
Taylor expanded in z around inf 75.9%
+-commutative75.9%
Simplified75.9%
Final simplification77.1%
(FPCore (x y z)
:precision binary64
(if (<= y -4.9e+129)
(- z)
(if (<= y -3.6e+115)
(/ x (- 1.0 (/ y z)))
(if (<= y -1.6e+87)
(- z)
(if (<= y -4.5e+81)
(* (- z) (/ x y))
(if (<= y -2.1e-23)
(* (/ z y) (- (- x) y))
(if (<= y 6.5e+173) (+ x y) (- z))))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -4.9e+129) {
tmp = -z;
} else if (y <= -3.6e+115) {
tmp = x / (1.0 - (y / z));
} else if (y <= -1.6e+87) {
tmp = -z;
} else if (y <= -4.5e+81) {
tmp = -z * (x / y);
} else if (y <= -2.1e-23) {
tmp = (z / y) * (-x - y);
} else if (y <= 6.5e+173) {
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 <= (-4.9d+129)) then
tmp = -z
else if (y <= (-3.6d+115)) then
tmp = x / (1.0d0 - (y / z))
else if (y <= (-1.6d+87)) then
tmp = -z
else if (y <= (-4.5d+81)) then
tmp = -z * (x / y)
else if (y <= (-2.1d-23)) then
tmp = (z / y) * (-x - y)
else if (y <= 6.5d+173) 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 <= -4.9e+129) {
tmp = -z;
} else if (y <= -3.6e+115) {
tmp = x / (1.0 - (y / z));
} else if (y <= -1.6e+87) {
tmp = -z;
} else if (y <= -4.5e+81) {
tmp = -z * (x / y);
} else if (y <= -2.1e-23) {
tmp = (z / y) * (-x - y);
} else if (y <= 6.5e+173) {
tmp = x + y;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -4.9e+129: tmp = -z elif y <= -3.6e+115: tmp = x / (1.0 - (y / z)) elif y <= -1.6e+87: tmp = -z elif y <= -4.5e+81: tmp = -z * (x / y) elif y <= -2.1e-23: tmp = (z / y) * (-x - y) elif y <= 6.5e+173: tmp = x + y else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -4.9e+129) tmp = Float64(-z); elseif (y <= -3.6e+115) tmp = Float64(x / Float64(1.0 - Float64(y / z))); elseif (y <= -1.6e+87) tmp = Float64(-z); elseif (y <= -4.5e+81) tmp = Float64(Float64(-z) * Float64(x / y)); elseif (y <= -2.1e-23) tmp = Float64(Float64(z / y) * Float64(Float64(-x) - y)); elseif (y <= 6.5e+173) tmp = Float64(x + y); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -4.9e+129) tmp = -z; elseif (y <= -3.6e+115) tmp = x / (1.0 - (y / z)); elseif (y <= -1.6e+87) tmp = -z; elseif (y <= -4.5e+81) tmp = -z * (x / y); elseif (y <= -2.1e-23) tmp = (z / y) * (-x - y); elseif (y <= 6.5e+173) tmp = x + y; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -4.9e+129], (-z), If[LessEqual[y, -3.6e+115], N[(x / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -1.6e+87], (-z), If[LessEqual[y, -4.5e+81], N[((-z) * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -2.1e-23], N[(N[(z / y), $MachinePrecision] * N[((-x) - y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 6.5e+173], N[(x + y), $MachinePrecision], (-z)]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.9 \cdot 10^{+129}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -3.6 \cdot 10^{+115}:\\
\;\;\;\;\frac{x}{1 - \frac{y}{z}}\\
\mathbf{elif}\;y \leq -1.6 \cdot 10^{+87}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -4.5 \cdot 10^{+81}:\\
\;\;\;\;\left(-z\right) \cdot \frac{x}{y}\\
\mathbf{elif}\;y \leq -2.1 \cdot 10^{-23}:\\
\;\;\;\;\frac{z}{y} \cdot \left(\left(-x\right) - y\right)\\
\mathbf{elif}\;y \leq 6.5 \cdot 10^{+173}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -4.9e129 or -3.6000000000000001e115 < y < -1.6e87 or 6.4999999999999997e173 < y Initial program 54.7%
Taylor expanded in y around inf 79.3%
mul-1-neg79.3%
Simplified79.3%
if -4.9e129 < y < -3.6000000000000001e115Initial program 99.7%
Taylor expanded in x around inf 83.2%
if -1.6e87 < y < -4.50000000000000017e81Initial program 52.3%
Taylor expanded in z around 0 99.2%
mul-1-neg99.2%
associate-/l*100.0%
distribute-neg-frac100.0%
+-commutative100.0%
Simplified100.0%
clear-num100.0%
associate-/r/99.2%
Applied egg-rr99.2%
Taylor expanded in y around 0 99.2%
mul-1-neg99.2%
associate-*l/100.0%
*-commutative100.0%
distribute-lft-neg-in100.0%
Simplified100.0%
if -4.50000000000000017e81 < y < -2.1000000000000001e-23Initial program 95.8%
Taylor expanded in z around 0 78.5%
mul-1-neg78.5%
associate-/l*78.5%
associate-/r/74.6%
distribute-rgt-neg-in74.6%
+-commutative74.6%
distribute-neg-in74.6%
sub-neg74.6%
Simplified74.6%
if -2.1000000000000001e-23 < y < 6.4999999999999997e173Initial program 97.5%
Taylor expanded in z around inf 75.9%
+-commutative75.9%
Simplified75.9%
Final simplification77.3%
(FPCore (x y z)
:precision binary64
(if (<= y -5.2e+129)
(- z)
(if (<= y -4.5e+122)
(/ x (- 1.0 (/ y z)))
(if (<= y -1.85e+87)
(- z)
(if (<= y -1.6e+73)
(* (- z) (/ x y))
(if (or (<= y -7e+39) (and (not (<= y -1.55e-22)) (<= y 1.16e+173)))
(+ x y)
(- z)))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -5.2e+129) {
tmp = -z;
} else if (y <= -4.5e+122) {
tmp = x / (1.0 - (y / z));
} else if (y <= -1.85e+87) {
tmp = -z;
} else if (y <= -1.6e+73) {
tmp = -z * (x / y);
} else if ((y <= -7e+39) || (!(y <= -1.55e-22) && (y <= 1.16e+173))) {
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 <= (-5.2d+129)) then
tmp = -z
else if (y <= (-4.5d+122)) then
tmp = x / (1.0d0 - (y / z))
else if (y <= (-1.85d+87)) then
tmp = -z
else if (y <= (-1.6d+73)) then
tmp = -z * (x / y)
else if ((y <= (-7d+39)) .or. (.not. (y <= (-1.55d-22))) .and. (y <= 1.16d+173)) 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 <= -5.2e+129) {
tmp = -z;
} else if (y <= -4.5e+122) {
tmp = x / (1.0 - (y / z));
} else if (y <= -1.85e+87) {
tmp = -z;
} else if (y <= -1.6e+73) {
tmp = -z * (x / y);
} else if ((y <= -7e+39) || (!(y <= -1.55e-22) && (y <= 1.16e+173))) {
tmp = x + y;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5.2e+129: tmp = -z elif y <= -4.5e+122: tmp = x / (1.0 - (y / z)) elif y <= -1.85e+87: tmp = -z elif y <= -1.6e+73: tmp = -z * (x / y) elif (y <= -7e+39) or (not (y <= -1.55e-22) and (y <= 1.16e+173)): tmp = x + y else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5.2e+129) tmp = Float64(-z); elseif (y <= -4.5e+122) tmp = Float64(x / Float64(1.0 - Float64(y / z))); elseif (y <= -1.85e+87) tmp = Float64(-z); elseif (y <= -1.6e+73) tmp = Float64(Float64(-z) * Float64(x / y)); elseif ((y <= -7e+39) || (!(y <= -1.55e-22) && (y <= 1.16e+173))) tmp = Float64(x + y); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -5.2e+129) tmp = -z; elseif (y <= -4.5e+122) tmp = x / (1.0 - (y / z)); elseif (y <= -1.85e+87) tmp = -z; elseif (y <= -1.6e+73) tmp = -z * (x / y); elseif ((y <= -7e+39) || (~((y <= -1.55e-22)) && (y <= 1.16e+173))) tmp = x + y; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5.2e+129], (-z), If[LessEqual[y, -4.5e+122], N[(x / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -1.85e+87], (-z), If[LessEqual[y, -1.6e+73], N[((-z) * N[(x / y), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, -7e+39], And[N[Not[LessEqual[y, -1.55e-22]], $MachinePrecision], LessEqual[y, 1.16e+173]]], N[(x + y), $MachinePrecision], (-z)]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.2 \cdot 10^{+129}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -4.5 \cdot 10^{+122}:\\
\;\;\;\;\frac{x}{1 - \frac{y}{z}}\\
\mathbf{elif}\;y \leq -1.85 \cdot 10^{+87}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -1.6 \cdot 10^{+73}:\\
\;\;\;\;\left(-z\right) \cdot \frac{x}{y}\\
\mathbf{elif}\;y \leq -7 \cdot 10^{+39} \lor \neg \left(y \leq -1.55 \cdot 10^{-22}\right) \land y \leq 1.16 \cdot 10^{+173}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -5.20000000000000024e129 or -4.49999999999999997e122 < y < -1.85000000000000001e87 or -7.0000000000000003e39 < y < -1.55000000000000006e-22 or 1.16e173 < y Initial program 62.9%
Taylor expanded in y around inf 77.6%
mul-1-neg77.6%
Simplified77.6%
if -5.20000000000000024e129 < y < -4.49999999999999997e122Initial program 99.7%
Taylor expanded in x around inf 83.2%
if -1.85000000000000001e87 < y < -1.59999999999999991e73Initial program 52.3%
Taylor expanded in z around 0 99.2%
mul-1-neg99.2%
associate-/l*100.0%
distribute-neg-frac100.0%
+-commutative100.0%
Simplified100.0%
clear-num100.0%
associate-/r/99.2%
Applied egg-rr99.2%
Taylor expanded in y around 0 99.2%
mul-1-neg99.2%
associate-*l/100.0%
*-commutative100.0%
distribute-lft-neg-in100.0%
Simplified100.0%
if -1.59999999999999991e73 < y < -7.0000000000000003e39 or -1.55000000000000006e-22 < y < 1.16e173Initial program 97.6%
Taylor expanded in z around inf 75.9%
+-commutative75.9%
Simplified75.9%
Final simplification77.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -4.1e-24) (not (<= y 1.16e+173))) (- (- z) (* x (/ z y))) (+ x y)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -4.1e-24) || !(y <= 1.16e+173)) {
tmp = -z - (x * (z / 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.1d-24)) .or. (.not. (y <= 1.16d+173))) then
tmp = -z - (x * (z / 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.1e-24) || !(y <= 1.16e+173)) {
tmp = -z - (x * (z / y));
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -4.1e-24) or not (y <= 1.16e+173): tmp = -z - (x * (z / y)) else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -4.1e-24) || !(y <= 1.16e+173)) tmp = Float64(Float64(-z) - Float64(x * Float64(z / y))); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -4.1e-24) || ~((y <= 1.16e+173))) tmp = -z - (x * (z / y)); else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -4.1e-24], N[Not[LessEqual[y, 1.16e+173]], $MachinePrecision]], N[((-z) - N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.1 \cdot 10^{-24} \lor \neg \left(y \leq 1.16 \cdot 10^{+173}\right):\\
\;\;\;\;\left(-z\right) - x \cdot \frac{z}{y}\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if y < -4.10000000000000015e-24 or 1.16e173 < y Initial program 65.9%
Taylor expanded in z around 0 70.4%
mul-1-neg70.4%
associate-/l*86.3%
distribute-neg-frac86.3%
+-commutative86.3%
Simplified86.3%
Taylor expanded in y around 0 79.2%
+-commutative79.2%
mul-1-neg79.2%
unsub-neg79.2%
mul-1-neg79.2%
associate-*r/79.6%
*-commutative79.6%
distribute-rgt-neg-out79.6%
Simplified79.6%
if -4.10000000000000015e-24 < y < 1.16e173Initial program 97.5%
Taylor expanded in z around inf 75.9%
+-commutative75.9%
Simplified75.9%
Final simplification77.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -7.5e-24) (not (<= y 1.16e+173))) (/ (- z) (/ y (+ x y))) (+ x y)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -7.5e-24) || !(y <= 1.16e+173)) {
tmp = -z / (y / (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 <= (-7.5d-24)) .or. (.not. (y <= 1.16d+173))) then
tmp = -z / (y / (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 <= -7.5e-24) || !(y <= 1.16e+173)) {
tmp = -z / (y / (x + y));
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -7.5e-24) or not (y <= 1.16e+173): tmp = -z / (y / (x + y)) else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -7.5e-24) || !(y <= 1.16e+173)) tmp = Float64(Float64(-z) / Float64(y / Float64(x + y))); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -7.5e-24) || ~((y <= 1.16e+173))) tmp = -z / (y / (x + y)); else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -7.5e-24], N[Not[LessEqual[y, 1.16e+173]], $MachinePrecision]], N[((-z) / N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.5 \cdot 10^{-24} \lor \neg \left(y \leq 1.16 \cdot 10^{+173}\right):\\
\;\;\;\;\frac{-z}{\frac{y}{x + y}}\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if y < -7.50000000000000007e-24 or 1.16e173 < y Initial program 65.9%
Taylor expanded in z around 0 70.4%
mul-1-neg70.4%
associate-/l*86.3%
distribute-neg-frac86.3%
+-commutative86.3%
Simplified86.3%
if -7.50000000000000007e-24 < y < 1.16e173Initial program 97.5%
Taylor expanded in z around inf 75.9%
+-commutative75.9%
Simplified75.9%
Final simplification80.3%
(FPCore (x y z)
:precision binary64
(if (<= y -1.9e+192)
(- z)
(if (<= y -5.5e+39)
(* (- z) (/ x y))
(if (or (<= y -1.1e-21) (not (<= y 1.16e+173))) (- z) (+ x y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.9e+192) {
tmp = -z;
} else if (y <= -5.5e+39) {
tmp = -z * (x / y);
} else if ((y <= -1.1e-21) || !(y <= 1.16e+173)) {
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 <= (-1.9d+192)) then
tmp = -z
else if (y <= (-5.5d+39)) then
tmp = -z * (x / y)
else if ((y <= (-1.1d-21)) .or. (.not. (y <= 1.16d+173))) 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 <= -1.9e+192) {
tmp = -z;
} else if (y <= -5.5e+39) {
tmp = -z * (x / y);
} else if ((y <= -1.1e-21) || !(y <= 1.16e+173)) {
tmp = -z;
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.9e+192: tmp = -z elif y <= -5.5e+39: tmp = -z * (x / y) elif (y <= -1.1e-21) or not (y <= 1.16e+173): tmp = -z else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.9e+192) tmp = Float64(-z); elseif (y <= -5.5e+39) tmp = Float64(Float64(-z) * Float64(x / y)); elseif ((y <= -1.1e-21) || !(y <= 1.16e+173)) tmp = Float64(-z); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.9e+192) tmp = -z; elseif (y <= -5.5e+39) tmp = -z * (x / y); elseif ((y <= -1.1e-21) || ~((y <= 1.16e+173))) tmp = -z; else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.9e+192], (-z), If[LessEqual[y, -5.5e+39], N[((-z) * N[(x / y), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, -1.1e-21], N[Not[LessEqual[y, 1.16e+173]], $MachinePrecision]], (-z), N[(x + y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.9 \cdot 10^{+192}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -5.5 \cdot 10^{+39}:\\
\;\;\;\;\left(-z\right) \cdot \frac{x}{y}\\
\mathbf{elif}\;y \leq -1.1 \cdot 10^{-21} \lor \neg \left(y \leq 1.16 \cdot 10^{+173}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if y < -1.9e192 or -5.4999999999999997e39 < y < -1.1e-21 or 1.16e173 < y Initial program 65.7%
Taylor expanded in y around inf 82.8%
mul-1-neg82.8%
Simplified82.8%
if -1.9e192 < y < -5.4999999999999997e39Initial program 66.4%
Taylor expanded in z around 0 68.3%
mul-1-neg68.3%
associate-/l*74.1%
distribute-neg-frac74.1%
+-commutative74.1%
Simplified74.1%
clear-num74.1%
associate-/r/74.0%
Applied egg-rr74.0%
Taylor expanded in y around 0 44.3%
mul-1-neg44.3%
associate-*l/47.6%
*-commutative47.6%
distribute-lft-neg-in47.6%
Simplified47.6%
if -1.1e-21 < y < 1.16e173Initial program 97.5%
Taylor expanded in z around inf 75.9%
+-commutative75.9%
Simplified75.9%
Final simplification74.6%
(FPCore (x y z) :precision binary64 (if (<= y -9.5e-22) (- z) (if (<= y 1.82e-9) x (if (<= y 1.16e+173) y (- z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -9.5e-22) {
tmp = -z;
} else if (y <= 1.82e-9) {
tmp = x;
} else if (y <= 1.16e+173) {
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 <= (-9.5d-22)) then
tmp = -z
else if (y <= 1.82d-9) then
tmp = x
else if (y <= 1.16d+173) 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 <= -9.5e-22) {
tmp = -z;
} else if (y <= 1.82e-9) {
tmp = x;
} else if (y <= 1.16e+173) {
tmp = y;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -9.5e-22: tmp = -z elif y <= 1.82e-9: tmp = x elif y <= 1.16e+173: tmp = y else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -9.5e-22) tmp = Float64(-z); elseif (y <= 1.82e-9) tmp = x; elseif (y <= 1.16e+173) tmp = y; else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -9.5e-22) tmp = -z; elseif (y <= 1.82e-9) tmp = x; elseif (y <= 1.16e+173) tmp = y; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -9.5e-22], (-z), If[LessEqual[y, 1.82e-9], x, If[LessEqual[y, 1.16e+173], y, (-z)]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.5 \cdot 10^{-22}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq 1.82 \cdot 10^{-9}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.16 \cdot 10^{+173}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -9.4999999999999994e-22 or 1.16e173 < y Initial program 65.9%
Taylor expanded in y around inf 67.9%
mul-1-neg67.9%
Simplified67.9%
if -9.4999999999999994e-22 < y < 1.8199999999999999e-9Initial program 99.9%
Taylor expanded in y around 0 65.5%
if 1.8199999999999999e-9 < y < 1.16e173Initial program 88.3%
Taylor expanded in x around 0 67.1%
Taylor expanded in y around 0 48.3%
Final simplification64.4%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.1e-21) (not (<= y 1.16e+173))) (- z) (+ x y)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.1e-21) || !(y <= 1.16e+173)) {
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 <= (-1.1d-21)) .or. (.not. (y <= 1.16d+173))) 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 <= -1.1e-21) || !(y <= 1.16e+173)) {
tmp = -z;
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.1e-21) or not (y <= 1.16e+173): tmp = -z else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.1e-21) || !(y <= 1.16e+173)) tmp = Float64(-z); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.1e-21) || ~((y <= 1.16e+173))) tmp = -z; else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.1e-21], N[Not[LessEqual[y, 1.16e+173]], $MachinePrecision]], (-z), N[(x + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.1 \cdot 10^{-21} \lor \neg \left(y \leq 1.16 \cdot 10^{+173}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if y < -1.1e-21 or 1.16e173 < y Initial program 65.9%
Taylor expanded in y around inf 67.9%
mul-1-neg67.9%
Simplified67.9%
if -1.1e-21 < y < 1.16e173Initial program 97.5%
Taylor expanded in z around inf 75.9%
+-commutative75.9%
Simplified75.9%
Final simplification72.5%
(FPCore (x y z) :precision binary64 (if (<= y -1.38e+25) y (if (<= y 5e-8) x y)))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.38e+25) {
tmp = y;
} else if (y <= 5e-8) {
tmp = x;
} else {
tmp = 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 <= (-1.38d+25)) then
tmp = y
else if (y <= 5d-8) then
tmp = x
else
tmp = y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.38e+25) {
tmp = y;
} else if (y <= 5e-8) {
tmp = x;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.38e+25: tmp = y elif y <= 5e-8: tmp = x else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.38e+25) tmp = y; elseif (y <= 5e-8) tmp = x; else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.38e+25) tmp = y; elseif (y <= 5e-8) tmp = x; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.38e+25], y, If[LessEqual[y, 5e-8], x, y]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.38 \cdot 10^{+25}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 5 \cdot 10^{-8}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if y < -1.3800000000000001e25 or 4.9999999999999998e-8 < y Initial program 67.7%
Taylor expanded in x around 0 53.0%
Taylor expanded in y around 0 20.8%
if -1.3800000000000001e25 < y < 4.9999999999999998e-8Initial program 99.9%
Taylor expanded in y around 0 60.2%
Final simplification40.9%
(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 84.2%
Taylor expanded in y around 0 34.8%
Final simplification34.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 2024010
(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))))