
(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 10 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-233) (not (<= t_0 0.0))) t_0 (- (/ (* 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-233) || !(t_0 <= 0.0)) {
tmp = t_0;
} else {
tmp = ((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-233)) .or. (.not. (t_0 <= 0.0d0))) then
tmp = t_0
else
tmp = ((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-233) || !(t_0 <= 0.0)) {
tmp = t_0;
} else {
tmp = ((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-233) or not (t_0 <= 0.0): tmp = t_0 else: tmp = ((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-233) || !(t_0 <= 0.0)) tmp = t_0; else tmp = Float64(Float64(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-233) || ~((t_0 <= 0.0))) tmp = t_0; else tmp = ((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-233], N[Not[LessEqual[t$95$0, 0.0]], $MachinePrecision]], t$95$0, N[(N[(N[(x * z), $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^{-233} \lor \neg \left(t\_0 \leq 0\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot z}{-y} - z\\
\end{array}
\end{array}
if (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < -5.00000000000000012e-233 or 0.0 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) Initial program 99.9%
if -5.00000000000000012e-233 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < 0.0Initial program 16.6%
Taylor expanded in z around 0 90.2%
mul-1-neg90.2%
associate-/l*99.9%
distribute-rgt-neg-in99.9%
distribute-neg-frac299.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in y around inf 100.0%
mul-1-neg100.0%
unsub-neg100.0%
mul-1-neg100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ y z))) (t_1 (* z (- -1.0 (/ x y)))) (t_2 (/ x t_0)))
(if (<= y -2.5e+229)
t_1
(if (<= y -7e-56)
(/ y t_0)
(if (<= y 5.7e-173)
t_2
(if (<= y 700.0) (+ x y) (if (<= y 2.3e+119) t_2 t_1)))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double t_1 = z * (-1.0 - (x / y));
double t_2 = x / t_0;
double tmp;
if (y <= -2.5e+229) {
tmp = t_1;
} else if (y <= -7e-56) {
tmp = y / t_0;
} else if (y <= 5.7e-173) {
tmp = t_2;
} else if (y <= 700.0) {
tmp = x + y;
} else if (y <= 2.3e+119) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = 1.0d0 - (y / z)
t_1 = z * ((-1.0d0) - (x / y))
t_2 = x / t_0
if (y <= (-2.5d+229)) then
tmp = t_1
else if (y <= (-7d-56)) then
tmp = y / t_0
else if (y <= 5.7d-173) then
tmp = t_2
else if (y <= 700.0d0) then
tmp = x + y
else if (y <= 2.3d+119) then
tmp = t_2
else
tmp = t_1
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 = z * (-1.0 - (x / y));
double t_2 = x / t_0;
double tmp;
if (y <= -2.5e+229) {
tmp = t_1;
} else if (y <= -7e-56) {
tmp = y / t_0;
} else if (y <= 5.7e-173) {
tmp = t_2;
} else if (y <= 700.0) {
tmp = x + y;
} else if (y <= 2.3e+119) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (y / z) t_1 = z * (-1.0 - (x / y)) t_2 = x / t_0 tmp = 0 if y <= -2.5e+229: tmp = t_1 elif y <= -7e-56: tmp = y / t_0 elif y <= 5.7e-173: tmp = t_2 elif y <= 700.0: tmp = x + y elif y <= 2.3e+119: tmp = t_2 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(y / z)) t_1 = Float64(z * Float64(-1.0 - Float64(x / y))) t_2 = Float64(x / t_0) tmp = 0.0 if (y <= -2.5e+229) tmp = t_1; elseif (y <= -7e-56) tmp = Float64(y / t_0); elseif (y <= 5.7e-173) tmp = t_2; elseif (y <= 700.0) tmp = Float64(x + y); elseif (y <= 2.3e+119) tmp = t_2; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (y / z); t_1 = z * (-1.0 - (x / y)); t_2 = x / t_0; tmp = 0.0; if (y <= -2.5e+229) tmp = t_1; elseif (y <= -7e-56) tmp = y / t_0; elseif (y <= 5.7e-173) tmp = t_2; elseif (y <= 700.0) tmp = x + y; elseif (y <= 2.3e+119) tmp = t_2; else tmp = t_1; 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[(z * N[(-1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x / t$95$0), $MachinePrecision]}, If[LessEqual[y, -2.5e+229], t$95$1, If[LessEqual[y, -7e-56], N[(y / t$95$0), $MachinePrecision], If[LessEqual[y, 5.7e-173], t$95$2, If[LessEqual[y, 700.0], N[(x + y), $MachinePrecision], If[LessEqual[y, 2.3e+119], t$95$2, t$95$1]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{y}{z}\\
t_1 := z \cdot \left(-1 - \frac{x}{y}\right)\\
t_2 := \frac{x}{t\_0}\\
\mathbf{if}\;y \leq -2.5 \cdot 10^{+229}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -7 \cdot 10^{-56}:\\
\;\;\;\;\frac{y}{t\_0}\\
\mathbf{elif}\;y \leq 5.7 \cdot 10^{-173}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;y \leq 700:\\
\;\;\;\;x + y\\
\mathbf{elif}\;y \leq 2.3 \cdot 10^{+119}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -2.50000000000000025e229 or 2.3000000000000001e119 < y Initial program 67.1%
Taylor expanded in z around 0 57.7%
mul-1-neg57.7%
associate-/l*84.1%
distribute-rgt-neg-in84.1%
distribute-neg-frac284.1%
+-commutative84.1%
Simplified84.1%
Taylor expanded in y around inf 72.7%
mul-1-neg72.7%
unsub-neg72.7%
mul-1-neg72.7%
Simplified72.7%
Taylor expanded in z around 0 84.0%
mul-1-neg84.0%
distribute-rgt-neg-in84.0%
distribute-neg-in84.0%
metadata-eval84.0%
mul-1-neg84.0%
mul-1-neg84.0%
unsub-neg84.0%
Simplified84.0%
if -2.50000000000000025e229 < y < -6.9999999999999996e-56Initial program 90.6%
Taylor expanded in x around 0 73.6%
if -6.9999999999999996e-56 < y < 5.7000000000000001e-173 or 700 < y < 2.3000000000000001e119Initial program 99.9%
Taylor expanded in x around inf 84.2%
if 5.7000000000000001e-173 < y < 700Initial program 100.0%
Taylor expanded in z around inf 69.9%
+-commutative69.9%
Simplified69.9%
Final simplification80.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ y z))) (t_1 (/ x t_0)))
(if (<= y -1.44e+228)
(* z (/ (+ x y) (- y)))
(if (<= y -3.7e-60)
(/ y t_0)
(if (<= y 2.4e-172)
t_1
(if (<= y 270.0)
(+ x y)
(if (<= y 2.3e+119) t_1 (* z (- -1.0 (/ x y))))))))))
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 <= -1.44e+228) {
tmp = z * ((x + y) / -y);
} else if (y <= -3.7e-60) {
tmp = y / t_0;
} else if (y <= 2.4e-172) {
tmp = t_1;
} else if (y <= 270.0) {
tmp = x + y;
} else if (y <= 2.3e+119) {
tmp = t_1;
} else {
tmp = z * (-1.0 - (x / y));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (y / z)
t_1 = x / t_0
if (y <= (-1.44d+228)) then
tmp = z * ((x + y) / -y)
else if (y <= (-3.7d-60)) then
tmp = y / t_0
else if (y <= 2.4d-172) then
tmp = t_1
else if (y <= 270.0d0) then
tmp = x + y
else if (y <= 2.3d+119) then
tmp = t_1
else
tmp = z * ((-1.0d0) - (x / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double t_1 = x / t_0;
double tmp;
if (y <= -1.44e+228) {
tmp = z * ((x + y) / -y);
} else if (y <= -3.7e-60) {
tmp = y / t_0;
} else if (y <= 2.4e-172) {
tmp = t_1;
} else if (y <= 270.0) {
tmp = x + y;
} else if (y <= 2.3e+119) {
tmp = t_1;
} else {
tmp = z * (-1.0 - (x / y));
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (y / z) t_1 = x / t_0 tmp = 0 if y <= -1.44e+228: tmp = z * ((x + y) / -y) elif y <= -3.7e-60: tmp = y / t_0 elif y <= 2.4e-172: tmp = t_1 elif y <= 270.0: tmp = x + y elif y <= 2.3e+119: tmp = t_1 else: tmp = z * (-1.0 - (x / y)) 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 <= -1.44e+228) tmp = Float64(z * Float64(Float64(x + y) / Float64(-y))); elseif (y <= -3.7e-60) tmp = Float64(y / t_0); elseif (y <= 2.4e-172) tmp = t_1; elseif (y <= 270.0) tmp = Float64(x + y); elseif (y <= 2.3e+119) tmp = t_1; else tmp = Float64(z * Float64(-1.0 - Float64(x / y))); 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 <= -1.44e+228) tmp = z * ((x + y) / -y); elseif (y <= -3.7e-60) tmp = y / t_0; elseif (y <= 2.4e-172) tmp = t_1; elseif (y <= 270.0) tmp = x + y; elseif (y <= 2.3e+119) tmp = t_1; else tmp = z * (-1.0 - (x / y)); 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, -1.44e+228], N[(z * N[(N[(x + y), $MachinePrecision] / (-y)), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -3.7e-60], N[(y / t$95$0), $MachinePrecision], If[LessEqual[y, 2.4e-172], t$95$1, If[LessEqual[y, 270.0], N[(x + y), $MachinePrecision], If[LessEqual[y, 2.3e+119], t$95$1, N[(z * N[(-1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{y}{z}\\
t_1 := \frac{x}{t\_0}\\
\mathbf{if}\;y \leq -1.44 \cdot 10^{+228}:\\
\;\;\;\;z \cdot \frac{x + y}{-y}\\
\mathbf{elif}\;y \leq -3.7 \cdot 10^{-60}:\\
\;\;\;\;\frac{y}{t\_0}\\
\mathbf{elif}\;y \leq 2.4 \cdot 10^{-172}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 270:\\
\;\;\;\;x + y\\
\mathbf{elif}\;y \leq 2.3 \cdot 10^{+119}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(-1 - \frac{x}{y}\right)\\
\end{array}
\end{array}
if y < -1.43999999999999997e228Initial program 61.5%
Taylor expanded in z around 0 49.7%
mul-1-neg49.7%
associate-/l*94.5%
distribute-rgt-neg-in94.5%
distribute-neg-frac294.5%
+-commutative94.5%
Simplified94.5%
if -1.43999999999999997e228 < y < -3.70000000000000025e-60Initial program 90.6%
Taylor expanded in x around 0 73.6%
if -3.70000000000000025e-60 < y < 2.4000000000000001e-172 or 270 < y < 2.3000000000000001e119Initial program 99.9%
Taylor expanded in x around inf 84.2%
if 2.4000000000000001e-172 < y < 270Initial program 100.0%
Taylor expanded in z around inf 69.9%
+-commutative69.9%
Simplified69.9%
if 2.3000000000000001e119 < y Initial program 69.5%
Taylor expanded in z around 0 61.1%
mul-1-neg61.1%
associate-/l*79.6%
distribute-rgt-neg-in79.6%
distribute-neg-frac279.6%
+-commutative79.6%
Simplified79.6%
Taylor expanded in y around inf 70.7%
mul-1-neg70.7%
unsub-neg70.7%
mul-1-neg70.7%
Simplified70.7%
Taylor expanded in z around 0 79.6%
mul-1-neg79.6%
distribute-rgt-neg-in79.6%
distribute-neg-in79.6%
metadata-eval79.6%
mul-1-neg79.6%
mul-1-neg79.6%
unsub-neg79.6%
Simplified79.6%
Final simplification80.0%
(FPCore (x y z)
:precision binary64
(if (<= z -2.4e+175)
(+ x y)
(if (<= z -7.2e+103)
(/ y (- 1.0 (/ y z)))
(if (or (<= z -2.6e-79) (not (<= z 9.5)))
(+ x y)
(- (/ (* x z) (- y)) z)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.4e+175) {
tmp = x + y;
} else if (z <= -7.2e+103) {
tmp = y / (1.0 - (y / z));
} else if ((z <= -2.6e-79) || !(z <= 9.5)) {
tmp = x + y;
} else {
tmp = ((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 (z <= (-2.4d+175)) then
tmp = x + y
else if (z <= (-7.2d+103)) then
tmp = y / (1.0d0 - (y / z))
else if ((z <= (-2.6d-79)) .or. (.not. (z <= 9.5d0))) then
tmp = x + y
else
tmp = ((x * z) / -y) - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -2.4e+175) {
tmp = x + y;
} else if (z <= -7.2e+103) {
tmp = y / (1.0 - (y / z));
} else if ((z <= -2.6e-79) || !(z <= 9.5)) {
tmp = x + y;
} else {
tmp = ((x * z) / -y) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2.4e+175: tmp = x + y elif z <= -7.2e+103: tmp = y / (1.0 - (y / z)) elif (z <= -2.6e-79) or not (z <= 9.5): tmp = x + y else: tmp = ((x * z) / -y) - z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2.4e+175) tmp = Float64(x + y); elseif (z <= -7.2e+103) tmp = Float64(y / Float64(1.0 - Float64(y / z))); elseif ((z <= -2.6e-79) || !(z <= 9.5)) tmp = Float64(x + y); else tmp = Float64(Float64(Float64(x * z) / Float64(-y)) - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -2.4e+175) tmp = x + y; elseif (z <= -7.2e+103) tmp = y / (1.0 - (y / z)); elseif ((z <= -2.6e-79) || ~((z <= 9.5))) tmp = x + y; else tmp = ((x * z) / -y) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2.4e+175], N[(x + y), $MachinePrecision], If[LessEqual[z, -7.2e+103], N[(y / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[z, -2.6e-79], N[Not[LessEqual[z, 9.5]], $MachinePrecision]], N[(x + y), $MachinePrecision], N[(N[(N[(x * z), $MachinePrecision] / (-y)), $MachinePrecision] - z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.4 \cdot 10^{+175}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;z \leq -7.2 \cdot 10^{+103}:\\
\;\;\;\;\frac{y}{1 - \frac{y}{z}}\\
\mathbf{elif}\;z \leq -2.6 \cdot 10^{-79} \lor \neg \left(z \leq 9.5\right):\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot z}{-y} - z\\
\end{array}
\end{array}
if z < -2.4e175 or -7.20000000000000033e103 < z < -2.59999999999999994e-79 or 9.5 < z Initial program 98.6%
Taylor expanded in z around inf 80.3%
+-commutative80.3%
Simplified80.3%
if -2.4e175 < z < -7.20000000000000033e103Initial program 99.9%
Taylor expanded in x around 0 86.2%
if -2.59999999999999994e-79 < z < 9.5Initial program 79.0%
Taylor expanded in z around 0 72.2%
mul-1-neg72.2%
associate-/l*70.7%
distribute-rgt-neg-in70.7%
distribute-neg-frac270.7%
+-commutative70.7%
Simplified70.7%
Taylor expanded in y around inf 75.7%
mul-1-neg75.7%
unsub-neg75.7%
mul-1-neg75.7%
Simplified75.7%
Final simplification78.8%
(FPCore (x y z)
:precision binary64
(if (<= y -7.2e+151)
(- z)
(if (<= y -3.2e+122)
y
(if (<= y -1.3e-13)
(- z)
(if (<= y -1.36e-96) y (if (<= y 2.3e+119) x (- z)))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -7.2e+151) {
tmp = -z;
} else if (y <= -3.2e+122) {
tmp = y;
} else if (y <= -1.3e-13) {
tmp = -z;
} else if (y <= -1.36e-96) {
tmp = y;
} else if (y <= 2.3e+119) {
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 <= (-7.2d+151)) then
tmp = -z
else if (y <= (-3.2d+122)) then
tmp = y
else if (y <= (-1.3d-13)) then
tmp = -z
else if (y <= (-1.36d-96)) then
tmp = y
else if (y <= 2.3d+119) 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 <= -7.2e+151) {
tmp = -z;
} else if (y <= -3.2e+122) {
tmp = y;
} else if (y <= -1.3e-13) {
tmp = -z;
} else if (y <= -1.36e-96) {
tmp = y;
} else if (y <= 2.3e+119) {
tmp = x;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -7.2e+151: tmp = -z elif y <= -3.2e+122: tmp = y elif y <= -1.3e-13: tmp = -z elif y <= -1.36e-96: tmp = y elif y <= 2.3e+119: tmp = x else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -7.2e+151) tmp = Float64(-z); elseif (y <= -3.2e+122) tmp = y; elseif (y <= -1.3e-13) tmp = Float64(-z); elseif (y <= -1.36e-96) tmp = y; elseif (y <= 2.3e+119) tmp = x; else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -7.2e+151) tmp = -z; elseif (y <= -3.2e+122) tmp = y; elseif (y <= -1.3e-13) tmp = -z; elseif (y <= -1.36e-96) tmp = y; elseif (y <= 2.3e+119) tmp = x; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -7.2e+151], (-z), If[LessEqual[y, -3.2e+122], y, If[LessEqual[y, -1.3e-13], (-z), If[LessEqual[y, -1.36e-96], y, If[LessEqual[y, 2.3e+119], x, (-z)]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.2 \cdot 10^{+151}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -3.2 \cdot 10^{+122}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq -1.3 \cdot 10^{-13}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -1.36 \cdot 10^{-96}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 2.3 \cdot 10^{+119}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -7.20000000000000001e151 or -3.20000000000000012e122 < y < -1.3e-13 or 2.3000000000000001e119 < y Initial program 76.5%
Taylor expanded in y around inf 70.0%
mul-1-neg70.0%
Simplified70.0%
if -7.20000000000000001e151 < y < -3.20000000000000012e122 or -1.3e-13 < y < -1.36e-96Initial program 92.1%
Taylor expanded in x around 0 55.7%
Taylor expanded in y around 0 55.5%
if -1.36e-96 < y < 2.3000000000000001e119Initial program 99.9%
Taylor expanded in y around 0 60.2%
Final simplification63.3%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.55e-78) (not (<= z 1.4))) (+ x y) (* z (- -1.0 (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.55e-78) || !(z <= 1.4)) {
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.55d-78)) .or. (.not. (z <= 1.4d0))) 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.55e-78) || !(z <= 1.4)) {
tmp = x + y;
} else {
tmp = z * (-1.0 - (x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.55e-78) or not (z <= 1.4): tmp = x + y else: tmp = z * (-1.0 - (x / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.55e-78) || !(z <= 1.4)) 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.55e-78) || ~((z <= 1.4))) tmp = x + y; else tmp = z * (-1.0 - (x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.55e-78], N[Not[LessEqual[z, 1.4]], $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.55 \cdot 10^{-78} \lor \neg \left(z \leq 1.4\right):\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(-1 - \frac{x}{y}\right)\\
\end{array}
\end{array}
if z < -1.55000000000000009e-78 or 1.3999999999999999 < z Initial program 98.7%
Taylor expanded in z around inf 77.7%
+-commutative77.7%
Simplified77.7%
if -1.55000000000000009e-78 < z < 1.3999999999999999Initial program 79.0%
Taylor expanded in z around 0 72.2%
mul-1-neg72.2%
associate-/l*70.7%
distribute-rgt-neg-in70.7%
distribute-neg-frac270.7%
+-commutative70.7%
Simplified70.7%
Taylor expanded in y around inf 75.7%
mul-1-neg75.7%
unsub-neg75.7%
mul-1-neg75.7%
Simplified75.7%
Taylor expanded in z around 0 70.7%
mul-1-neg70.7%
distribute-rgt-neg-in70.7%
distribute-neg-in70.7%
metadata-eval70.7%
mul-1-neg70.7%
mul-1-neg70.7%
unsub-neg70.7%
Simplified70.7%
Final simplification74.8%
(FPCore (x y z) :precision binary64 (if (or (<= y -3.1e-25) (not (<= y 2.3e+119))) (* z (- -1.0 (/ x y))) (/ x (- 1.0 (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.1e-25) || !(y <= 2.3e+119)) {
tmp = z * (-1.0 - (x / 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 <= (-3.1d-25)) .or. (.not. (y <= 2.3d+119))) then
tmp = z * ((-1.0d0) - (x / 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 <= -3.1e-25) || !(y <= 2.3e+119)) {
tmp = z * (-1.0 - (x / y));
} else {
tmp = x / (1.0 - (y / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3.1e-25) or not (y <= 2.3e+119): tmp = z * (-1.0 - (x / y)) else: tmp = x / (1.0 - (y / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3.1e-25) || !(y <= 2.3e+119)) tmp = Float64(z * Float64(-1.0 - Float64(x / 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 <= -3.1e-25) || ~((y <= 2.3e+119))) tmp = z * (-1.0 - (x / y)); else tmp = x / (1.0 - (y / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.1e-25], N[Not[LessEqual[y, 2.3e+119]], $MachinePrecision]], N[(z * N[(-1.0 - N[(x / 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 -3.1 \cdot 10^{-25} \lor \neg \left(y \leq 2.3 \cdot 10^{+119}\right):\\
\;\;\;\;z \cdot \left(-1 - \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{1 - \frac{y}{z}}\\
\end{array}
\end{array}
if y < -3.09999999999999995e-25 or 2.3000000000000001e119 < y Initial program 76.8%
Taylor expanded in z around 0 53.1%
mul-1-neg53.1%
associate-/l*72.1%
distribute-rgt-neg-in72.1%
distribute-neg-frac272.1%
+-commutative72.1%
Simplified72.1%
Taylor expanded in y around inf 65.5%
mul-1-neg65.5%
unsub-neg65.5%
mul-1-neg65.5%
Simplified65.5%
Taylor expanded in z around 0 72.1%
mul-1-neg72.1%
distribute-rgt-neg-in72.1%
distribute-neg-in72.1%
metadata-eval72.1%
mul-1-neg72.1%
mul-1-neg72.1%
unsub-neg72.1%
Simplified72.1%
if -3.09999999999999995e-25 < y < 2.3000000000000001e119Initial program 99.9%
Taylor expanded in x around inf 75.9%
Final simplification74.4%
(FPCore (x y z) :precision binary64 (if (or (<= y -8.5e+151) (not (<= y 8.2e+121))) (- z) (+ x y)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -8.5e+151) || !(y <= 8.2e+121)) {
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 <= (-8.5d+151)) .or. (.not. (y <= 8.2d+121))) 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 <= -8.5e+151) || !(y <= 8.2e+121)) {
tmp = -z;
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -8.5e+151) or not (y <= 8.2e+121): tmp = -z else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -8.5e+151) || !(y <= 8.2e+121)) tmp = Float64(-z); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -8.5e+151) || ~((y <= 8.2e+121))) tmp = -z; else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -8.5e+151], N[Not[LessEqual[y, 8.2e+121]], $MachinePrecision]], (-z), N[(x + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.5 \cdot 10^{+151} \lor \neg \left(y \leq 8.2 \cdot 10^{+121}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if y < -8.50000000000000051e151 or 8.2e121 < y Initial program 72.0%
Taylor expanded in y around inf 78.3%
mul-1-neg78.3%
Simplified78.3%
if -8.50000000000000051e151 < y < 8.2e121Initial program 97.4%
Taylor expanded in z around inf 68.7%
+-commutative68.7%
Simplified68.7%
Final simplification71.2%
(FPCore (x y z) :precision binary64 (if (<= y -1.36e-96) y (if (<= y 1.4e+112) x y)))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.36e-96) {
tmp = y;
} else if (y <= 1.4e+112) {
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.36d-96)) then
tmp = y
else if (y <= 1.4d+112) 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.36e-96) {
tmp = y;
} else if (y <= 1.4e+112) {
tmp = x;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.36e-96: tmp = y elif y <= 1.4e+112: tmp = x else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.36e-96) tmp = y; elseif (y <= 1.4e+112) tmp = x; else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.36e-96) tmp = y; elseif (y <= 1.4e+112) tmp = x; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.36e-96], y, If[LessEqual[y, 1.4e+112], x, y]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.36 \cdot 10^{-96}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 1.4 \cdot 10^{+112}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if y < -1.36e-96 or 1.4000000000000001e112 < y Initial program 80.1%
Taylor expanded in x around 0 63.1%
Taylor expanded in y around 0 27.1%
if -1.36e-96 < y < 1.4000000000000001e112Initial program 99.9%
Taylor expanded in y around 0 60.3%
Final simplification45.0%
(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.8%
Taylor expanded in y around 0 36.5%
Final simplification36.5%
(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 2024071
(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))))