
(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 -1e-289) (not (<= t_0 3.5e-288)))
t_0
(- (- (- z) (* z (/ x y))) (/ 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 <= -1e-289) || !(t_0 <= 3.5e-288)) {
tmp = t_0;
} else {
tmp = (-z - (z * (x / y))) - (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 <= (-1d-289)) .or. (.not. (t_0 <= 3.5d-288))) then
tmp = t_0
else
tmp = (-z - (z * (x / y))) - (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 <= -1e-289) || !(t_0 <= 3.5e-288)) {
tmp = t_0;
} else {
tmp = (-z - (z * (x / y))) - (z / (y / z));
}
return tmp;
}
def code(x, y, z): t_0 = (x + y) / (1.0 - (y / z)) tmp = 0 if (t_0 <= -1e-289) or not (t_0 <= 3.5e-288): tmp = t_0 else: tmp = (-z - (z * (x / y))) - (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 <= -1e-289) || !(t_0 <= 3.5e-288)) tmp = t_0; else tmp = Float64(Float64(Float64(-z) - Float64(z * Float64(x / y))) - Float64(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 <= -1e-289) || ~((t_0 <= 3.5e-288))) tmp = t_0; else tmp = (-z - (z * (x / y))) - (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, -1e-289], N[Not[LessEqual[t$95$0, 3.5e-288]], $MachinePrecision]], t$95$0, N[(N[((-z) - N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + y}{1 - \frac{y}{z}}\\
\mathbf{if}\;t_0 \leq -1 \cdot 10^{-289} \lor \neg \left(t_0 \leq 3.5 \cdot 10^{-288}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-z\right) - z \cdot \frac{x}{y}\right) - \frac{z}{\frac{y}{z}}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < -1e-289 or 3.5000000000000003e-288 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) Initial program 99.9%
if -1e-289 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < 3.5000000000000003e-288Initial program 12.7%
Taylor expanded in y around inf 100.0%
mul-1-neg100.0%
unsub-neg100.0%
mul-1-neg100.0%
associate-/l*84.9%
associate-/r/100.0%
unpow2100.0%
associate-/l*100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (+ x y) (- 1.0 (/ y z)))))
(if (or (<= t_0 -1e-289) (not (<= t_0 3.5e-288)))
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 <= -1e-289) || !(t_0 <= 3.5e-288)) {
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 <= (-1d-289)) .or. (.not. (t_0 <= 3.5d-288))) 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 <= -1e-289) || !(t_0 <= 3.5e-288)) {
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 <= -1e-289) or not (t_0 <= 3.5e-288): 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 <= -1e-289) || !(t_0 <= 3.5e-288)) 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 <= -1e-289) || ~((t_0 <= 3.5e-288))) 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, -1e-289], N[Not[LessEqual[t$95$0, 3.5e-288]], $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 -1 \cdot 10^{-289} \lor \neg \left(t_0 \leq 3.5 \cdot 10^{-288}\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))) < -1e-289 or 3.5000000000000003e-288 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) Initial program 99.9%
if -1e-289 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < 3.5000000000000003e-288Initial program 12.7%
Taylor expanded in z around 0 94.8%
associate-/l*100.0%
associate-*r/100.0%
mul-1-neg100.0%
+-commutative100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(if (<= z -16000000000000.0)
(+ x y)
(if (<= z -7.6e-14)
(- z)
(if (<= z -1.3e-95)
(+ x y)
(if (<= z 5.5e-272)
(- z)
(if (<= z 1.35e-202)
(/ x (- 1.0 (/ y z)))
(if (<= z 1.8e-75) (- z) (+ x y))))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -16000000000000.0) {
tmp = x + y;
} else if (z <= -7.6e-14) {
tmp = -z;
} else if (z <= -1.3e-95) {
tmp = x + y;
} else if (z <= 5.5e-272) {
tmp = -z;
} else if (z <= 1.35e-202) {
tmp = x / (1.0 - (y / z));
} else if (z <= 1.8e-75) {
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 (z <= (-16000000000000.0d0)) then
tmp = x + y
else if (z <= (-7.6d-14)) then
tmp = -z
else if (z <= (-1.3d-95)) then
tmp = x + y
else if (z <= 5.5d-272) then
tmp = -z
else if (z <= 1.35d-202) then
tmp = x / (1.0d0 - (y / z))
else if (z <= 1.8d-75) 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 (z <= -16000000000000.0) {
tmp = x + y;
} else if (z <= -7.6e-14) {
tmp = -z;
} else if (z <= -1.3e-95) {
tmp = x + y;
} else if (z <= 5.5e-272) {
tmp = -z;
} else if (z <= 1.35e-202) {
tmp = x / (1.0 - (y / z));
} else if (z <= 1.8e-75) {
tmp = -z;
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -16000000000000.0: tmp = x + y elif z <= -7.6e-14: tmp = -z elif z <= -1.3e-95: tmp = x + y elif z <= 5.5e-272: tmp = -z elif z <= 1.35e-202: tmp = x / (1.0 - (y / z)) elif z <= 1.8e-75: tmp = -z else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if (z <= -16000000000000.0) tmp = Float64(x + y); elseif (z <= -7.6e-14) tmp = Float64(-z); elseif (z <= -1.3e-95) tmp = Float64(x + y); elseif (z <= 5.5e-272) tmp = Float64(-z); elseif (z <= 1.35e-202) tmp = Float64(x / Float64(1.0 - Float64(y / z))); elseif (z <= 1.8e-75) tmp = Float64(-z); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -16000000000000.0) tmp = x + y; elseif (z <= -7.6e-14) tmp = -z; elseif (z <= -1.3e-95) tmp = x + y; elseif (z <= 5.5e-272) tmp = -z; elseif (z <= 1.35e-202) tmp = x / (1.0 - (y / z)); elseif (z <= 1.8e-75) tmp = -z; else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -16000000000000.0], N[(x + y), $MachinePrecision], If[LessEqual[z, -7.6e-14], (-z), If[LessEqual[z, -1.3e-95], N[(x + y), $MachinePrecision], If[LessEqual[z, 5.5e-272], (-z), If[LessEqual[z, 1.35e-202], N[(x / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.8e-75], (-z), N[(x + y), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -16000000000000:\\
\;\;\;\;x + y\\
\mathbf{elif}\;z \leq -7.6 \cdot 10^{-14}:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq -1.3 \cdot 10^{-95}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;z \leq 5.5 \cdot 10^{-272}:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq 1.35 \cdot 10^{-202}:\\
\;\;\;\;\frac{x}{1 - \frac{y}{z}}\\
\mathbf{elif}\;z \leq 1.8 \cdot 10^{-75}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if z < -1.6e13 or -7.6000000000000004e-14 < z < -1.3e-95 or 1.8e-75 < z Initial program 98.8%
Taylor expanded in z around inf 76.1%
+-commutative76.1%
Simplified76.1%
if -1.6e13 < z < -7.6000000000000004e-14 or -1.3e-95 < z < 5.4999999999999999e-272 or 1.3499999999999999e-202 < z < 1.8e-75Initial program 71.4%
Taylor expanded in y around inf 66.4%
mul-1-neg66.4%
Simplified66.4%
if 5.4999999999999999e-272 < z < 1.3499999999999999e-202Initial program 72.0%
Taylor expanded in x around inf 66.4%
Final simplification72.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ y z))) (t_1 (/ (- z) (/ y (+ x y)))))
(if (<= y -3.7e+68)
t_1
(if (<= y -42.0)
(/ y t_0)
(if (<= y -1.24e-116)
(/ x t_0)
(if (<= y 3e-47) (* (+ x y) (+ 1.0 (/ y z))) t_1))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double t_1 = -z / (y / (x + y));
double tmp;
if (y <= -3.7e+68) {
tmp = t_1;
} else if (y <= -42.0) {
tmp = y / t_0;
} else if (y <= -1.24e-116) {
tmp = x / t_0;
} else if (y <= 3e-47) {
tmp = (x + y) * (1.0 + (y / z));
} 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) :: tmp
t_0 = 1.0d0 - (y / z)
t_1 = -z / (y / (x + y))
if (y <= (-3.7d+68)) then
tmp = t_1
else if (y <= (-42.0d0)) then
tmp = y / t_0
else if (y <= (-1.24d-116)) then
tmp = x / t_0
else if (y <= 3d-47) then
tmp = (x + y) * (1.0d0 + (y / z))
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 / (y / (x + y));
double tmp;
if (y <= -3.7e+68) {
tmp = t_1;
} else if (y <= -42.0) {
tmp = y / t_0;
} else if (y <= -1.24e-116) {
tmp = x / t_0;
} else if (y <= 3e-47) {
tmp = (x + y) * (1.0 + (y / z));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (y / z) t_1 = -z / (y / (x + y)) tmp = 0 if y <= -3.7e+68: tmp = t_1 elif y <= -42.0: tmp = y / t_0 elif y <= -1.24e-116: tmp = x / t_0 elif y <= 3e-47: tmp = (x + y) * (1.0 + (y / z)) else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(y / z)) t_1 = Float64(Float64(-z) / Float64(y / Float64(x + y))) tmp = 0.0 if (y <= -3.7e+68) tmp = t_1; elseif (y <= -42.0) tmp = Float64(y / t_0); elseif (y <= -1.24e-116) tmp = Float64(x / t_0); elseif (y <= 3e-47) tmp = Float64(Float64(x + y) * Float64(1.0 + Float64(y / z))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (y / z); t_1 = -z / (y / (x + y)); tmp = 0.0; if (y <= -3.7e+68) tmp = t_1; elseif (y <= -42.0) tmp = y / t_0; elseif (y <= -1.24e-116) tmp = x / t_0; elseif (y <= 3e-47) tmp = (x + y) * (1.0 + (y / z)); 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[(y / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -3.7e+68], t$95$1, If[LessEqual[y, -42.0], N[(y / t$95$0), $MachinePrecision], If[LessEqual[y, -1.24e-116], N[(x / t$95$0), $MachinePrecision], If[LessEqual[y, 3e-47], N[(N[(x + y), $MachinePrecision] * N[(1.0 + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{y}{z}\\
t_1 := \frac{-z}{\frac{y}{x + y}}\\
\mathbf{if}\;y \leq -3.7 \cdot 10^{+68}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -42:\\
\;\;\;\;\frac{y}{t_0}\\
\mathbf{elif}\;y \leq -1.24 \cdot 10^{-116}:\\
\;\;\;\;\frac{x}{t_0}\\
\mathbf{elif}\;y \leq 3 \cdot 10^{-47}:\\
\;\;\;\;\left(x + y\right) \cdot \left(1 + \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if y < -3.69999999999999998e68 or 3.00000000000000017e-47 < y Initial program 75.9%
Taylor expanded in z around 0 63.1%
associate-/l*76.1%
associate-*r/76.1%
mul-1-neg76.1%
+-commutative76.1%
Simplified76.1%
if -3.69999999999999998e68 < y < -42Initial program 100.0%
Taylor expanded in x around 0 86.2%
if -42 < y < -1.24000000000000004e-116Initial program 99.9%
Taylor expanded in x around inf 68.3%
if -1.24000000000000004e-116 < y < 3.00000000000000017e-47Initial program 99.9%
Taylor expanded in z around inf 89.6%
associate-+r+89.6%
*-lft-identity89.6%
associate-*l/90.1%
distribute-rgt-in90.1%
+-commutative90.1%
Simplified90.1%
Final simplification80.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ y (- 1.0 (/ y z)))))
(if (<= y -4.6e+141)
(- z)
(if (<= y -11800000000.0)
t_0
(if (<= y 5.3e-17)
(+ x y)
(if (<= y 3e+178) t_0 (- (- z) (* z (/ z y)))))))))
double code(double x, double y, double z) {
double t_0 = y / (1.0 - (y / z));
double tmp;
if (y <= -4.6e+141) {
tmp = -z;
} else if (y <= -11800000000.0) {
tmp = t_0;
} else if (y <= 5.3e-17) {
tmp = x + y;
} else if (y <= 3e+178) {
tmp = t_0;
} else {
tmp = -z - (z * (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) :: t_0
real(8) :: tmp
t_0 = y / (1.0d0 - (y / z))
if (y <= (-4.6d+141)) then
tmp = -z
else if (y <= (-11800000000.0d0)) then
tmp = t_0
else if (y <= 5.3d-17) then
tmp = x + y
else if (y <= 3d+178) then
tmp = t_0
else
tmp = -z - (z * (z / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y / (1.0 - (y / z));
double tmp;
if (y <= -4.6e+141) {
tmp = -z;
} else if (y <= -11800000000.0) {
tmp = t_0;
} else if (y <= 5.3e-17) {
tmp = x + y;
} else if (y <= 3e+178) {
tmp = t_0;
} else {
tmp = -z - (z * (z / y));
}
return tmp;
}
def code(x, y, z): t_0 = y / (1.0 - (y / z)) tmp = 0 if y <= -4.6e+141: tmp = -z elif y <= -11800000000.0: tmp = t_0 elif y <= 5.3e-17: tmp = x + y elif y <= 3e+178: tmp = t_0 else: tmp = -z - (z * (z / y)) return tmp
function code(x, y, z) t_0 = Float64(y / Float64(1.0 - Float64(y / z))) tmp = 0.0 if (y <= -4.6e+141) tmp = Float64(-z); elseif (y <= -11800000000.0) tmp = t_0; elseif (y <= 5.3e-17) tmp = Float64(x + y); elseif (y <= 3e+178) tmp = t_0; else tmp = Float64(Float64(-z) - Float64(z * Float64(z / y))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y / (1.0 - (y / z)); tmp = 0.0; if (y <= -4.6e+141) tmp = -z; elseif (y <= -11800000000.0) tmp = t_0; elseif (y <= 5.3e-17) tmp = x + y; elseif (y <= 3e+178) tmp = t_0; else tmp = -z - (z * (z / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4.6e+141], (-z), If[LessEqual[y, -11800000000.0], t$95$0, If[LessEqual[y, 5.3e-17], N[(x + y), $MachinePrecision], If[LessEqual[y, 3e+178], t$95$0, N[((-z) - N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{1 - \frac{y}{z}}\\
\mathbf{if}\;y \leq -4.6 \cdot 10^{+141}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -11800000000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 5.3 \cdot 10^{-17}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;y \leq 3 \cdot 10^{+178}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - z \cdot \frac{z}{y}\\
\end{array}
\end{array}
if y < -4.6000000000000003e141Initial program 53.9%
Taylor expanded in y around inf 74.3%
mul-1-neg74.3%
Simplified74.3%
if -4.6000000000000003e141 < y < -1.18e10 or 5.2999999999999998e-17 < y < 3.00000000000000016e178Initial program 90.7%
Taylor expanded in x around 0 67.1%
if -1.18e10 < y < 5.2999999999999998e-17Initial program 99.9%
Taylor expanded in z around inf 80.2%
+-commutative80.2%
Simplified80.2%
if 3.00000000000000016e178 < y Initial program 73.1%
Taylor expanded in x around 0 67.3%
Taylor expanded in y around inf 88.3%
distribute-lft-in88.3%
mul-1-neg88.3%
unpow288.3%
associate-*r/94.2%
Simplified94.2%
Final simplification76.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ y z))) (t_1 (/ (- z) (/ y (+ x y)))))
(if (<= y -4.3e+70)
t_1
(if (<= y -70.0)
(/ y t_0)
(if (<= y -4.4e-115) (/ x t_0) (if (<= y 2.9e-47) (+ x y) t_1))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double t_1 = -z / (y / (x + y));
double tmp;
if (y <= -4.3e+70) {
tmp = t_1;
} else if (y <= -70.0) {
tmp = y / t_0;
} else if (y <= -4.4e-115) {
tmp = x / t_0;
} else if (y <= 2.9e-47) {
tmp = x + y;
} 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) :: tmp
t_0 = 1.0d0 - (y / z)
t_1 = -z / (y / (x + y))
if (y <= (-4.3d+70)) then
tmp = t_1
else if (y <= (-70.0d0)) then
tmp = y / t_0
else if (y <= (-4.4d-115)) then
tmp = x / t_0
else if (y <= 2.9d-47) then
tmp = x + y
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 / (y / (x + y));
double tmp;
if (y <= -4.3e+70) {
tmp = t_1;
} else if (y <= -70.0) {
tmp = y / t_0;
} else if (y <= -4.4e-115) {
tmp = x / t_0;
} else if (y <= 2.9e-47) {
tmp = x + y;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (y / z) t_1 = -z / (y / (x + y)) tmp = 0 if y <= -4.3e+70: tmp = t_1 elif y <= -70.0: tmp = y / t_0 elif y <= -4.4e-115: tmp = x / t_0 elif y <= 2.9e-47: tmp = x + y else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(y / z)) t_1 = Float64(Float64(-z) / Float64(y / Float64(x + y))) tmp = 0.0 if (y <= -4.3e+70) tmp = t_1; elseif (y <= -70.0) tmp = Float64(y / t_0); elseif (y <= -4.4e-115) tmp = Float64(x / t_0); elseif (y <= 2.9e-47) tmp = Float64(x + y); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (y / z); t_1 = -z / (y / (x + y)); tmp = 0.0; if (y <= -4.3e+70) tmp = t_1; elseif (y <= -70.0) tmp = y / t_0; elseif (y <= -4.4e-115) tmp = x / t_0; elseif (y <= 2.9e-47) tmp = x + y; 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[(y / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4.3e+70], t$95$1, If[LessEqual[y, -70.0], N[(y / t$95$0), $MachinePrecision], If[LessEqual[y, -4.4e-115], N[(x / t$95$0), $MachinePrecision], If[LessEqual[y, 2.9e-47], N[(x + y), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{y}{z}\\
t_1 := \frac{-z}{\frac{y}{x + y}}\\
\mathbf{if}\;y \leq -4.3 \cdot 10^{+70}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -70:\\
\;\;\;\;\frac{y}{t_0}\\
\mathbf{elif}\;y \leq -4.4 \cdot 10^{-115}:\\
\;\;\;\;\frac{x}{t_0}\\
\mathbf{elif}\;y \leq 2.9 \cdot 10^{-47}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if y < -4.3000000000000001e70 or 2.9e-47 < y Initial program 75.9%
Taylor expanded in z around 0 63.1%
associate-/l*76.1%
associate-*r/76.1%
mul-1-neg76.1%
+-commutative76.1%
Simplified76.1%
if -4.3000000000000001e70 < y < -70Initial program 100.0%
Taylor expanded in x around 0 86.2%
if -70 < y < -4.3999999999999999e-115Initial program 99.9%
Taylor expanded in x around inf 68.3%
if -4.3999999999999999e-115 < y < 2.9e-47Initial program 99.9%
Taylor expanded in z around inf 89.7%
+-commutative89.7%
Simplified89.7%
Final simplification80.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ y (- 1.0 (/ y z)))))
(if (<= y -2.1e+140)
(- z)
(if (<= y -1750000.0)
t_0
(if (<= y 7e-17) (+ x y) (if (<= y 4.6e+177) t_0 (- z)))))))
double code(double x, double y, double z) {
double t_0 = y / (1.0 - (y / z));
double tmp;
if (y <= -2.1e+140) {
tmp = -z;
} else if (y <= -1750000.0) {
tmp = t_0;
} else if (y <= 7e-17) {
tmp = x + y;
} else if (y <= 4.6e+177) {
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 = y / (1.0d0 - (y / z))
if (y <= (-2.1d+140)) then
tmp = -z
else if (y <= (-1750000.0d0)) then
tmp = t_0
else if (y <= 7d-17) then
tmp = x + y
else if (y <= 4.6d+177) 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 = y / (1.0 - (y / z));
double tmp;
if (y <= -2.1e+140) {
tmp = -z;
} else if (y <= -1750000.0) {
tmp = t_0;
} else if (y <= 7e-17) {
tmp = x + y;
} else if (y <= 4.6e+177) {
tmp = t_0;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): t_0 = y / (1.0 - (y / z)) tmp = 0 if y <= -2.1e+140: tmp = -z elif y <= -1750000.0: tmp = t_0 elif y <= 7e-17: tmp = x + y elif y <= 4.6e+177: tmp = t_0 else: tmp = -z return tmp
function code(x, y, z) t_0 = Float64(y / Float64(1.0 - Float64(y / z))) tmp = 0.0 if (y <= -2.1e+140) tmp = Float64(-z); elseif (y <= -1750000.0) tmp = t_0; elseif (y <= 7e-17) tmp = Float64(x + y); elseif (y <= 4.6e+177) tmp = t_0; else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y / (1.0 - (y / z)); tmp = 0.0; if (y <= -2.1e+140) tmp = -z; elseif (y <= -1750000.0) tmp = t_0; elseif (y <= 7e-17) tmp = x + y; elseif (y <= 4.6e+177) tmp = t_0; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.1e+140], (-z), If[LessEqual[y, -1750000.0], t$95$0, If[LessEqual[y, 7e-17], N[(x + y), $MachinePrecision], If[LessEqual[y, 4.6e+177], t$95$0, (-z)]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{1 - \frac{y}{z}}\\
\mathbf{if}\;y \leq -2.1 \cdot 10^{+140}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -1750000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 7 \cdot 10^{-17}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;y \leq 4.6 \cdot 10^{+177}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -2.1000000000000002e140 or 4.5999999999999998e177 < y Initial program 59.8%
Taylor expanded in y around inf 79.8%
mul-1-neg79.8%
Simplified79.8%
if -2.1000000000000002e140 < y < -1.75e6 or 7.0000000000000003e-17 < y < 4.5999999999999998e177Initial program 90.7%
Taylor expanded in x around 0 67.1%
if -1.75e6 < y < 7.0000000000000003e-17Initial program 99.9%
Taylor expanded in z around inf 80.2%
+-commutative80.2%
Simplified80.2%
Final simplification76.6%
(FPCore (x y z)
:precision binary64
(if (<= z -1.2e+17)
(+ x y)
(if (or (<= z -8e-14) (and (not (<= z -7.8e-94)) (<= z 2.1e-69)))
(- z)
(+ x y))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.2e+17) {
tmp = x + y;
} else if ((z <= -8e-14) || (!(z <= -7.8e-94) && (z <= 2.1e-69))) {
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 (z <= (-1.2d+17)) then
tmp = x + y
else if ((z <= (-8d-14)) .or. (.not. (z <= (-7.8d-94))) .and. (z <= 2.1d-69)) 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 (z <= -1.2e+17) {
tmp = x + y;
} else if ((z <= -8e-14) || (!(z <= -7.8e-94) && (z <= 2.1e-69))) {
tmp = -z;
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.2e+17: tmp = x + y elif (z <= -8e-14) or (not (z <= -7.8e-94) and (z <= 2.1e-69)): tmp = -z else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.2e+17) tmp = Float64(x + y); elseif ((z <= -8e-14) || (!(z <= -7.8e-94) && (z <= 2.1e-69))) tmp = Float64(-z); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.2e+17) tmp = x + y; elseif ((z <= -8e-14) || (~((z <= -7.8e-94)) && (z <= 2.1e-69))) tmp = -z; else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.2e+17], N[(x + y), $MachinePrecision], If[Or[LessEqual[z, -8e-14], And[N[Not[LessEqual[z, -7.8e-94]], $MachinePrecision], LessEqual[z, 2.1e-69]]], (-z), N[(x + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.2 \cdot 10^{+17}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;z \leq -8 \cdot 10^{-14} \lor \neg \left(z \leq -7.8 \cdot 10^{-94}\right) \land z \leq 2.1 \cdot 10^{-69}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if z < -1.2e17 or -7.99999999999999999e-14 < z < -7.8000000000000004e-94 or 2.1e-69 < z Initial program 98.8%
Taylor expanded in z around inf 76.1%
+-commutative76.1%
Simplified76.1%
if -1.2e17 < z < -7.99999999999999999e-14 or -7.8000000000000004e-94 < z < 2.1e-69Initial program 71.5%
Taylor expanded in y around inf 59.3%
mul-1-neg59.3%
Simplified59.3%
Final simplification69.9%
(FPCore (x y z) :precision binary64 (if (<= x -1.5e-162) x (if (<= x 1.12e-212) y (if (<= x 1e-143) x (if (<= x 7.2e-90) y x)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.5e-162) {
tmp = x;
} else if (x <= 1.12e-212) {
tmp = y;
} else if (x <= 1e-143) {
tmp = x;
} else if (x <= 7.2e-90) {
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 <= (-1.5d-162)) then
tmp = x
else if (x <= 1.12d-212) then
tmp = y
else if (x <= 1d-143) then
tmp = x
else if (x <= 7.2d-90) 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 <= -1.5e-162) {
tmp = x;
} else if (x <= 1.12e-212) {
tmp = y;
} else if (x <= 1e-143) {
tmp = x;
} else if (x <= 7.2e-90) {
tmp = y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.5e-162: tmp = x elif x <= 1.12e-212: tmp = y elif x <= 1e-143: tmp = x elif x <= 7.2e-90: tmp = y else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.5e-162) tmp = x; elseif (x <= 1.12e-212) tmp = y; elseif (x <= 1e-143) tmp = x; elseif (x <= 7.2e-90) tmp = y; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.5e-162) tmp = x; elseif (x <= 1.12e-212) tmp = y; elseif (x <= 1e-143) tmp = x; elseif (x <= 7.2e-90) tmp = y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.5e-162], x, If[LessEqual[x, 1.12e-212], y, If[LessEqual[x, 1e-143], x, If[LessEqual[x, 7.2e-90], y, x]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.5 \cdot 10^{-162}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1.12 \cdot 10^{-212}:\\
\;\;\;\;y\\
\mathbf{elif}\;x \leq 10^{-143}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 7.2 \cdot 10^{-90}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1.49999999999999999e-162 or 1.12e-212 < x < 9.9999999999999995e-144 or 7.19999999999999961e-90 < x Initial program 88.8%
Taylor expanded in y around 0 47.1%
if -1.49999999999999999e-162 < x < 1.12e-212 or 9.9999999999999995e-144 < x < 7.19999999999999961e-90Initial program 88.3%
Taylor expanded in x around 0 79.9%
Taylor expanded in y around 0 45.7%
Final simplification46.7%
(FPCore (x y z) :precision binary64 (if (<= y -35.0) (- z) (if (<= y 5e-18) x (- z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -35.0) {
tmp = -z;
} else if (y <= 5e-18) {
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 <= (-35.0d0)) then
tmp = -z
else if (y <= 5d-18) 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 <= -35.0) {
tmp = -z;
} else if (y <= 5e-18) {
tmp = x;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -35.0: tmp = -z elif y <= 5e-18: tmp = x else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -35.0) tmp = Float64(-z); elseif (y <= 5e-18) tmp = x; else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -35.0) tmp = -z; elseif (y <= 5e-18) tmp = x; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -35.0], (-z), If[LessEqual[y, 5e-18], x, (-z)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -35:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq 5 \cdot 10^{-18}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -35 or 5.00000000000000036e-18 < y Initial program 77.0%
Taylor expanded in y around inf 60.4%
mul-1-neg60.4%
Simplified60.4%
if -35 < y < 5.00000000000000036e-18Initial program 99.9%
Taylor expanded in y around 0 64.4%
Final simplification62.4%
(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 88.6%
Taylor expanded in y around 0 37.3%
Final simplification37.3%
(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 2023297
(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))))