
(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-299) (not (<= t_0 0.0))) 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-299) || !(t_0 <= 0.0)) {
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-299)) .or. (.not. (t_0 <= 0.0d0))) 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-299) || !(t_0 <= 0.0)) {
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-299) or not (t_0 <= 0.0): 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-299) || !(t_0 <= 0.0)) tmp = t_0; else tmp = Float64(Float64(z * Float64(Float64(-y) - 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-299) || ~((t_0 <= 0.0))) 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-299], N[Not[LessEqual[t$95$0, 0.0]], $MachinePrecision]], t$95$0, N[(N[(z * N[((-y) - x), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + y}{1 - \frac{y}{z}}\\
\mathbf{if}\;t_0 \leq -5 \cdot 10^{-299} \lor \neg \left(t_0 \leq 0\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{z \cdot \left(\left(-y\right) - x\right)}{y}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < -4.99999999999999956e-299 or 0.0 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) Initial program 99.9%
if -4.99999999999999956e-299 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < 0.0Initial program 6.3%
Taylor expanded in z around 0 99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(if (<= y -1.9e+147)
(- z)
(if (<= y -1e+102)
(+ x y)
(if (<= y -1.15e+48)
(* z (- 1.0 (/ x y)))
(if (<= y -8.5e+41)
(* y (+ 1.0 (/ y z)))
(if (<= y 1.1e+120) (/ x (- 1.0 (/ y z))) (- z)))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.9e+147) {
tmp = -z;
} else if (y <= -1e+102) {
tmp = x + y;
} else if (y <= -1.15e+48) {
tmp = z * (1.0 - (x / y));
} else if (y <= -8.5e+41) {
tmp = y * (1.0 + (y / z));
} else if (y <= 1.1e+120) {
tmp = x / (1.0 - (y / z));
} else {
tmp = -z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-1.9d+147)) then
tmp = -z
else if (y <= (-1d+102)) then
tmp = x + y
else if (y <= (-1.15d+48)) then
tmp = z * (1.0d0 - (x / y))
else if (y <= (-8.5d+41)) then
tmp = y * (1.0d0 + (y / z))
else if (y <= 1.1d+120) then
tmp = x / (1.0d0 - (y / z))
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.9e+147) {
tmp = -z;
} else if (y <= -1e+102) {
tmp = x + y;
} else if (y <= -1.15e+48) {
tmp = z * (1.0 - (x / y));
} else if (y <= -8.5e+41) {
tmp = y * (1.0 + (y / z));
} else if (y <= 1.1e+120) {
tmp = x / (1.0 - (y / z));
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.9e+147: tmp = -z elif y <= -1e+102: tmp = x + y elif y <= -1.15e+48: tmp = z * (1.0 - (x / y)) elif y <= -8.5e+41: tmp = y * (1.0 + (y / z)) elif y <= 1.1e+120: tmp = x / (1.0 - (y / z)) else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.9e+147) tmp = Float64(-z); elseif (y <= -1e+102) tmp = Float64(x + y); elseif (y <= -1.15e+48) tmp = Float64(z * Float64(1.0 - Float64(x / y))); elseif (y <= -8.5e+41) tmp = Float64(y * Float64(1.0 + Float64(y / z))); elseif (y <= 1.1e+120) tmp = Float64(x / Float64(1.0 - Float64(y / z))); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.9e+147) tmp = -z; elseif (y <= -1e+102) tmp = x + y; elseif (y <= -1.15e+48) tmp = z * (1.0 - (x / y)); elseif (y <= -8.5e+41) tmp = y * (1.0 + (y / z)); elseif (y <= 1.1e+120) tmp = x / (1.0 - (y / z)); else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.9e+147], (-z), If[LessEqual[y, -1e+102], N[(x + y), $MachinePrecision], If[LessEqual[y, -1.15e+48], N[(z * N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -8.5e+41], N[(y * N[(1.0 + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.1e+120], N[(x / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-z)]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.9 \cdot 10^{+147}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -1 \cdot 10^{+102}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;y \leq -1.15 \cdot 10^{+48}:\\
\;\;\;\;z \cdot \left(1 - \frac{x}{y}\right)\\
\mathbf{elif}\;y \leq -8.5 \cdot 10^{+41}:\\
\;\;\;\;y \cdot \left(1 + \frac{y}{z}\right)\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{+120}:\\
\;\;\;\;\frac{x}{1 - \frac{y}{z}}\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -1.89999999999999985e147 or 1.1000000000000001e120 < y Initial program 69.0%
Taylor expanded in y around inf 75.0%
mul-1-neg75.0%
Simplified75.0%
if -1.89999999999999985e147 < y < -9.99999999999999977e101Initial program 99.9%
Taylor expanded in z around inf 61.7%
+-commutative61.7%
Simplified61.7%
if -9.99999999999999977e101 < y < -1.15e48Initial program 71.3%
Taylor expanded in z around 0 80.5%
mul-1-neg80.5%
associate-/l*80.4%
associate-/r/57.3%
distribute-rgt-neg-in57.3%
+-commutative57.3%
distribute-neg-in57.3%
sub-neg57.3%
Simplified57.3%
sub-neg57.3%
distribute-lft-in57.3%
add-sqr-sqrt57.3%
sqrt-unprod57.3%
sqr-neg57.3%
sqrt-unprod0.0%
add-sqr-sqrt39.8%
Applied egg-rr39.8%
distribute-lft-out39.8%
sub-neg39.8%
associate-*l/53.6%
associate-*r/53.7%
div-sub53.7%
*-inverses53.7%
Simplified53.7%
if -1.15e48 < y < -8.49999999999999938e41Initial program 76.9%
Taylor expanded in z around inf 75.4%
associate-+r+75.4%
*-lft-identity75.4%
associate-/l*75.4%
associate-/r/75.4%
distribute-rgt-in75.4%
+-commutative75.4%
Simplified75.4%
Taylor expanded in x around 0 75.4%
if -8.49999999999999938e41 < y < 1.1000000000000001e120Initial program 98.8%
Taylor expanded in x around inf 73.6%
Final simplification72.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (- z) (/ y (+ x y)))))
(if (<= y -1.8e+22)
t_0
(if (<= y 2.25e-70)
(/ x (- 1.0 (/ y z)))
(if (<= y 4e+15)
(* (+ x y) (- (/ z y)))
(if (<= y 7.5e+56) (+ x y) t_0))))))
double code(double x, double y, double z) {
double t_0 = -z / (y / (x + y));
double tmp;
if (y <= -1.8e+22) {
tmp = t_0;
} else if (y <= 2.25e-70) {
tmp = x / (1.0 - (y / z));
} else if (y <= 4e+15) {
tmp = (x + y) * -(z / y);
} else if (y <= 7.5e+56) {
tmp = x + y;
} 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 = -z / (y / (x + y))
if (y <= (-1.8d+22)) then
tmp = t_0
else if (y <= 2.25d-70) then
tmp = x / (1.0d0 - (y / z))
else if (y <= 4d+15) then
tmp = (x + y) * -(z / y)
else if (y <= 7.5d+56) then
tmp = x + y
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = -z / (y / (x + y));
double tmp;
if (y <= -1.8e+22) {
tmp = t_0;
} else if (y <= 2.25e-70) {
tmp = x / (1.0 - (y / z));
} else if (y <= 4e+15) {
tmp = (x + y) * -(z / y);
} else if (y <= 7.5e+56) {
tmp = x + y;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -z / (y / (x + y)) tmp = 0 if y <= -1.8e+22: tmp = t_0 elif y <= 2.25e-70: tmp = x / (1.0 - (y / z)) elif y <= 4e+15: tmp = (x + y) * -(z / y) elif y <= 7.5e+56: tmp = x + y else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(-z) / Float64(y / Float64(x + y))) tmp = 0.0 if (y <= -1.8e+22) tmp = t_0; elseif (y <= 2.25e-70) tmp = Float64(x / Float64(1.0 - Float64(y / z))); elseif (y <= 4e+15) tmp = Float64(Float64(x + y) * Float64(-Float64(z / y))); elseif (y <= 7.5e+56) tmp = Float64(x + y); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -z / (y / (x + y)); tmp = 0.0; if (y <= -1.8e+22) tmp = t_0; elseif (y <= 2.25e-70) tmp = x / (1.0 - (y / z)); elseif (y <= 4e+15) tmp = (x + y) * -(z / y); elseif (y <= 7.5e+56) tmp = x + y; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[((-z) / N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.8e+22], t$95$0, If[LessEqual[y, 2.25e-70], N[(x / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4e+15], N[(N[(x + y), $MachinePrecision] * (-N[(z / y), $MachinePrecision])), $MachinePrecision], If[LessEqual[y, 7.5e+56], N[(x + y), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-z}{\frac{y}{x + y}}\\
\mathbf{if}\;y \leq -1.8 \cdot 10^{+22}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 2.25 \cdot 10^{-70}:\\
\;\;\;\;\frac{x}{1 - \frac{y}{z}}\\
\mathbf{elif}\;y \leq 4 \cdot 10^{+15}:\\
\;\;\;\;\left(x + y\right) \cdot \left(-\frac{z}{y}\right)\\
\mathbf{elif}\;y \leq 7.5 \cdot 10^{+56}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -1.8e22 or 7.4999999999999999e56 < y Initial program 76.8%
Taylor expanded in z around 0 60.4%
mul-1-neg60.4%
associate-/l*78.1%
distribute-neg-frac78.1%
+-commutative78.1%
Simplified78.1%
if -1.8e22 < y < 2.25000000000000011e-70Initial program 99.9%
Taylor expanded in x around inf 82.4%
if 2.25000000000000011e-70 < y < 4e15Initial program 99.8%
Taylor expanded in z around 0 66.9%
mul-1-neg66.9%
associate-/l*70.7%
associate-/r/70.7%
distribute-rgt-neg-in70.7%
+-commutative70.7%
distribute-neg-in70.7%
sub-neg70.7%
Simplified70.7%
if 4e15 < y < 7.4999999999999999e56Initial program 84.9%
Taylor expanded in z around inf 75.8%
+-commutative75.8%
Simplified75.8%
Final simplification79.1%
(FPCore (x y z)
:precision binary64
(if (<= y -1.9e+147)
(- z)
(if (<= y -2e+94)
(+ x y)
(if (<= y -4.2e+49)
(- (* z (/ x y)))
(if (<= y -2.4e+47)
(* y (+ 1.0 (/ y z)))
(if (<= y 1.02e+115) (+ x y) (- z)))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.9e+147) {
tmp = -z;
} else if (y <= -2e+94) {
tmp = x + y;
} else if (y <= -4.2e+49) {
tmp = -(z * (x / y));
} else if (y <= -2.4e+47) {
tmp = y * (1.0 + (y / z));
} else if (y <= 1.02e+115) {
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 <= (-1.9d+147)) then
tmp = -z
else if (y <= (-2d+94)) then
tmp = x + y
else if (y <= (-4.2d+49)) then
tmp = -(z * (x / y))
else if (y <= (-2.4d+47)) then
tmp = y * (1.0d0 + (y / z))
else if (y <= 1.02d+115) 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 <= -1.9e+147) {
tmp = -z;
} else if (y <= -2e+94) {
tmp = x + y;
} else if (y <= -4.2e+49) {
tmp = -(z * (x / y));
} else if (y <= -2.4e+47) {
tmp = y * (1.0 + (y / z));
} else if (y <= 1.02e+115) {
tmp = x + y;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.9e+147: tmp = -z elif y <= -2e+94: tmp = x + y elif y <= -4.2e+49: tmp = -(z * (x / y)) elif y <= -2.4e+47: tmp = y * (1.0 + (y / z)) elif y <= 1.02e+115: tmp = x + y else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.9e+147) tmp = Float64(-z); elseif (y <= -2e+94) tmp = Float64(x + y); elseif (y <= -4.2e+49) tmp = Float64(-Float64(z * Float64(x / y))); elseif (y <= -2.4e+47) tmp = Float64(y * Float64(1.0 + Float64(y / z))); elseif (y <= 1.02e+115) tmp = Float64(x + y); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.9e+147) tmp = -z; elseif (y <= -2e+94) tmp = x + y; elseif (y <= -4.2e+49) tmp = -(z * (x / y)); elseif (y <= -2.4e+47) tmp = y * (1.0 + (y / z)); elseif (y <= 1.02e+115) tmp = x + y; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.9e+147], (-z), If[LessEqual[y, -2e+94], N[(x + y), $MachinePrecision], If[LessEqual[y, -4.2e+49], (-N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]), If[LessEqual[y, -2.4e+47], N[(y * N[(1.0 + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.02e+115], N[(x + y), $MachinePrecision], (-z)]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.9 \cdot 10^{+147}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -2 \cdot 10^{+94}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;y \leq -4.2 \cdot 10^{+49}:\\
\;\;\;\;-z \cdot \frac{x}{y}\\
\mathbf{elif}\;y \leq -2.4 \cdot 10^{+47}:\\
\;\;\;\;y \cdot \left(1 + \frac{y}{z}\right)\\
\mathbf{elif}\;y \leq 1.02 \cdot 10^{+115}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -1.89999999999999985e147 or 1.02e115 < y Initial program 70.6%
Taylor expanded in y around inf 72.7%
mul-1-neg72.7%
Simplified72.7%
if -1.89999999999999985e147 < y < -2e94 or -2.40000000000000019e47 < y < 1.02e115Initial program 98.3%
Taylor expanded in z around inf 69.0%
+-commutative69.0%
Simplified69.0%
if -2e94 < y < -4.20000000000000022e49Initial program 71.3%
Taylor expanded in x around inf 33.3%
Taylor expanded in y around inf 52.6%
associate-*r/38.7%
associate-*l*38.7%
neg-mul-138.7%
Simplified38.7%
Taylor expanded in x around 0 52.6%
neg-mul-152.6%
associate-*l/52.6%
*-commutative52.6%
distribute-rgt-neg-in52.6%
distribute-neg-frac52.6%
Simplified52.6%
if -4.20000000000000022e49 < y < -2.40000000000000019e47Initial program 99.2%
Taylor expanded in z around inf 100.0%
associate-+r+100.0%
*-lft-identity100.0%
associate-/l*100.0%
associate-/r/100.0%
distribute-rgt-in100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Final simplification69.8%
(FPCore (x y z)
:precision binary64
(if (<= y -2.15e+147)
(- z)
(if (<= y -1.05e+95)
(+ x y)
(if (<= y -3.1e+49)
(* z (- 1.0 (/ x y)))
(if (<= y -2.4e+47)
(* y (+ 1.0 (/ y z)))
(if (<= y 1.95e+108) (+ x y) (- z)))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.15e+147) {
tmp = -z;
} else if (y <= -1.05e+95) {
tmp = x + y;
} else if (y <= -3.1e+49) {
tmp = z * (1.0 - (x / y));
} else if (y <= -2.4e+47) {
tmp = y * (1.0 + (y / z));
} else if (y <= 1.95e+108) {
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 <= (-2.15d+147)) then
tmp = -z
else if (y <= (-1.05d+95)) then
tmp = x + y
else if (y <= (-3.1d+49)) then
tmp = z * (1.0d0 - (x / y))
else if (y <= (-2.4d+47)) then
tmp = y * (1.0d0 + (y / z))
else if (y <= 1.95d+108) 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 <= -2.15e+147) {
tmp = -z;
} else if (y <= -1.05e+95) {
tmp = x + y;
} else if (y <= -3.1e+49) {
tmp = z * (1.0 - (x / y));
} else if (y <= -2.4e+47) {
tmp = y * (1.0 + (y / z));
} else if (y <= 1.95e+108) {
tmp = x + y;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.15e+147: tmp = -z elif y <= -1.05e+95: tmp = x + y elif y <= -3.1e+49: tmp = z * (1.0 - (x / y)) elif y <= -2.4e+47: tmp = y * (1.0 + (y / z)) elif y <= 1.95e+108: tmp = x + y else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.15e+147) tmp = Float64(-z); elseif (y <= -1.05e+95) tmp = Float64(x + y); elseif (y <= -3.1e+49) tmp = Float64(z * Float64(1.0 - Float64(x / y))); elseif (y <= -2.4e+47) tmp = Float64(y * Float64(1.0 + Float64(y / z))); elseif (y <= 1.95e+108) tmp = Float64(x + y); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.15e+147) tmp = -z; elseif (y <= -1.05e+95) tmp = x + y; elseif (y <= -3.1e+49) tmp = z * (1.0 - (x / y)); elseif (y <= -2.4e+47) tmp = y * (1.0 + (y / z)); elseif (y <= 1.95e+108) tmp = x + y; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.15e+147], (-z), If[LessEqual[y, -1.05e+95], N[(x + y), $MachinePrecision], If[LessEqual[y, -3.1e+49], N[(z * N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -2.4e+47], N[(y * N[(1.0 + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.95e+108], N[(x + y), $MachinePrecision], (-z)]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.15 \cdot 10^{+147}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -1.05 \cdot 10^{+95}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;y \leq -3.1 \cdot 10^{+49}:\\
\;\;\;\;z \cdot \left(1 - \frac{x}{y}\right)\\
\mathbf{elif}\;y \leq -2.4 \cdot 10^{+47}:\\
\;\;\;\;y \cdot \left(1 + \frac{y}{z}\right)\\
\mathbf{elif}\;y \leq 1.95 \cdot 10^{+108}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -2.1499999999999999e147 or 1.94999999999999992e108 < y Initial program 70.6%
Taylor expanded in y around inf 72.7%
mul-1-neg72.7%
Simplified72.7%
if -2.1499999999999999e147 < y < -1.05e95 or -2.40000000000000019e47 < y < 1.94999999999999992e108Initial program 98.3%
Taylor expanded in z around inf 69.0%
+-commutative69.0%
Simplified69.0%
if -1.05e95 < y < -3.09999999999999992e49Initial program 71.3%
Taylor expanded in z around 0 80.5%
mul-1-neg80.5%
associate-/l*80.4%
associate-/r/57.3%
distribute-rgt-neg-in57.3%
+-commutative57.3%
distribute-neg-in57.3%
sub-neg57.3%
Simplified57.3%
sub-neg57.3%
distribute-lft-in57.3%
add-sqr-sqrt57.3%
sqrt-unprod57.3%
sqr-neg57.3%
sqrt-unprod0.0%
add-sqr-sqrt39.8%
Applied egg-rr39.8%
distribute-lft-out39.8%
sub-neg39.8%
associate-*l/53.6%
associate-*r/53.7%
div-sub53.7%
*-inverses53.7%
Simplified53.7%
if -3.09999999999999992e49 < y < -2.40000000000000019e47Initial program 99.2%
Taylor expanded in z around inf 100.0%
associate-+r+100.0%
*-lft-identity100.0%
associate-/l*100.0%
associate-/r/100.0%
distribute-rgt-in100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Final simplification69.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ y z))) (t_1 (/ x t_0)))
(if (<= x -4.2e-63)
t_1
(if (<= x 7.5e-146)
(/ y t_0)
(if (<= x 8e-81) (+ x y) (if (<= x 2.2e+133) (- z) t_1))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double t_1 = x / t_0;
double tmp;
if (x <= -4.2e-63) {
tmp = t_1;
} else if (x <= 7.5e-146) {
tmp = y / t_0;
} else if (x <= 8e-81) {
tmp = x + y;
} else if (x <= 2.2e+133) {
tmp = -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 = x / t_0
if (x <= (-4.2d-63)) then
tmp = t_1
else if (x <= 7.5d-146) then
tmp = y / t_0
else if (x <= 8d-81) then
tmp = x + y
else if (x <= 2.2d+133) then
tmp = -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 = x / t_0;
double tmp;
if (x <= -4.2e-63) {
tmp = t_1;
} else if (x <= 7.5e-146) {
tmp = y / t_0;
} else if (x <= 8e-81) {
tmp = x + y;
} else if (x <= 2.2e+133) {
tmp = -z;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (y / z) t_1 = x / t_0 tmp = 0 if x <= -4.2e-63: tmp = t_1 elif x <= 7.5e-146: tmp = y / t_0 elif x <= 8e-81: tmp = x + y elif x <= 2.2e+133: tmp = -z else: tmp = t_1 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 (x <= -4.2e-63) tmp = t_1; elseif (x <= 7.5e-146) tmp = Float64(y / t_0); elseif (x <= 8e-81) tmp = Float64(x + y); elseif (x <= 2.2e+133) tmp = Float64(-z); else tmp = t_1; 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 (x <= -4.2e-63) tmp = t_1; elseif (x <= 7.5e-146) tmp = y / t_0; elseif (x <= 8e-81) tmp = x + y; elseif (x <= 2.2e+133) tmp = -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[(x / t$95$0), $MachinePrecision]}, If[LessEqual[x, -4.2e-63], t$95$1, If[LessEqual[x, 7.5e-146], N[(y / t$95$0), $MachinePrecision], If[LessEqual[x, 8e-81], N[(x + y), $MachinePrecision], If[LessEqual[x, 2.2e+133], (-z), t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{y}{z}\\
t_1 := \frac{x}{t_0}\\
\mathbf{if}\;x \leq -4.2 \cdot 10^{-63}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{-146}:\\
\;\;\;\;\frac{y}{t_0}\\
\mathbf{elif}\;x \leq 8 \cdot 10^{-81}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;x \leq 2.2 \cdot 10^{+133}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if x < -4.2e-63 or 2.2e133 < x Initial program 91.3%
Taylor expanded in x around inf 79.1%
if -4.2e-63 < x < 7.49999999999999981e-146Initial program 86.0%
Taylor expanded in x around 0 68.5%
if 7.49999999999999981e-146 < x < 7.9999999999999997e-81Initial program 90.4%
Taylor expanded in z around inf 77.8%
+-commutative77.8%
Simplified77.8%
if 7.9999999999999997e-81 < x < 2.2e133Initial program 85.1%
Taylor expanded in y around inf 58.0%
mul-1-neg58.0%
Simplified58.0%
Final simplification72.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.15e+147) (not (<= y 1e+105))) (- z) (+ x y)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.15e+147) || !(y <= 1e+105)) {
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 <= (-2.15d+147)) .or. (.not. (y <= 1d+105))) 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 <= -2.15e+147) || !(y <= 1e+105)) {
tmp = -z;
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.15e+147) or not (y <= 1e+105): tmp = -z else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.15e+147) || !(y <= 1e+105)) tmp = Float64(-z); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -2.15e+147) || ~((y <= 1e+105))) tmp = -z; else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.15e+147], N[Not[LessEqual[y, 1e+105]], $MachinePrecision]], (-z), N[(x + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.15 \cdot 10^{+147} \lor \neg \left(y \leq 10^{+105}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if y < -2.1499999999999999e147 or 9.9999999999999994e104 < y Initial program 70.6%
Taylor expanded in y around inf 72.7%
mul-1-neg72.7%
Simplified72.7%
if -2.1499999999999999e147 < y < 9.9999999999999994e104Initial program 96.7%
Taylor expanded in z around inf 66.1%
+-commutative66.1%
Simplified66.1%
Final simplification68.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -5200000.0) (not (<= y 2.8e-76))) (- z) x))
double code(double x, double y, double z) {
double tmp;
if ((y <= -5200000.0) || !(y <= 2.8e-76)) {
tmp = -z;
} 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 ((y <= (-5200000.0d0)) .or. (.not. (y <= 2.8d-76))) then
tmp = -z
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -5200000.0) || !(y <= 2.8e-76)) {
tmp = -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -5200000.0) or not (y <= 2.8e-76): tmp = -z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -5200000.0) || !(y <= 2.8e-76)) tmp = Float64(-z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -5200000.0) || ~((y <= 2.8e-76))) tmp = -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -5200000.0], N[Not[LessEqual[y, 2.8e-76]], $MachinePrecision]], (-z), x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5200000 \lor \neg \left(y \leq 2.8 \cdot 10^{-76}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -5.2e6 or 2.8000000000000001e-76 < y Initial program 81.0%
Taylor expanded in y around inf 52.4%
mul-1-neg52.4%
Simplified52.4%
if -5.2e6 < y < 2.8000000000000001e-76Initial program 99.9%
Taylor expanded in y around 0 67.9%
Final simplification58.6%
(FPCore (x y z) :precision binary64 (if (<= x -3.8e-259) x (if (<= x 2.7e-184) y x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -3.8e-259) {
tmp = x;
} else if (x <= 2.7e-184) {
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 <= (-3.8d-259)) then
tmp = x
else if (x <= 2.7d-184) 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 <= -3.8e-259) {
tmp = x;
} else if (x <= 2.7e-184) {
tmp = y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -3.8e-259: tmp = x elif x <= 2.7e-184: tmp = y else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -3.8e-259) tmp = x; elseif (x <= 2.7e-184) tmp = y; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -3.8e-259) tmp = x; elseif (x <= 2.7e-184) tmp = y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -3.8e-259], x, If[LessEqual[x, 2.7e-184], y, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.8 \cdot 10^{-259}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 2.7 \cdot 10^{-184}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -3.8e-259 or 2.7000000000000001e-184 < x Initial program 89.4%
Taylor expanded in y around 0 41.5%
if -3.8e-259 < x < 2.7000000000000001e-184Initial program 84.2%
Taylor expanded in x around 0 78.3%
Taylor expanded in y around 0 44.5%
Final simplification42.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 88.6%
Taylor expanded in y around 0 36.1%
Final simplification36.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (/ (+ y x) (- y)) z)))
(if (< y -3.7429310762689856e+171)
t_0
(if (< y 3.5534662456086734e+168) (/ (+ x y) (- 1.0 (/ y z))) t_0))))
double code(double x, double y, double z) {
double t_0 = ((y + x) / -y) * z;
double tmp;
if (y < -3.7429310762689856e+171) {
tmp = t_0;
} else if (y < 3.5534662456086734e+168) {
tmp = (x + y) / (1.0 - (y / z));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = ((y + x) / -y) * z
if (y < (-3.7429310762689856d+171)) then
tmp = t_0
else if (y < 3.5534662456086734d+168) then
tmp = (x + y) / (1.0d0 - (y / z))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = ((y + x) / -y) * z;
double tmp;
if (y < -3.7429310762689856e+171) {
tmp = t_0;
} else if (y < 3.5534662456086734e+168) {
tmp = (x + y) / (1.0 - (y / z));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = ((y + x) / -y) * z tmp = 0 if y < -3.7429310762689856e+171: tmp = t_0 elif y < 3.5534662456086734e+168: tmp = (x + y) / (1.0 - (y / z)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(y + x) / Float64(-y)) * z) tmp = 0.0 if (y < -3.7429310762689856e+171) tmp = t_0; elseif (y < 3.5534662456086734e+168) tmp = Float64(Float64(x + y) / Float64(1.0 - Float64(y / z))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = ((y + x) / -y) * z; tmp = 0.0; if (y < -3.7429310762689856e+171) tmp = t_0; elseif (y < 3.5534662456086734e+168) tmp = (x + y) / (1.0 - (y / z)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(y + x), $MachinePrecision] / (-y)), $MachinePrecision] * z), $MachinePrecision]}, If[Less[y, -3.7429310762689856e+171], t$95$0, If[Less[y, 3.5534662456086734e+168], N[(N[(x + y), $MachinePrecision] / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y + x}{-y} \cdot z\\
\mathbf{if}\;y < -3.7429310762689856 \cdot 10^{+171}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y < 3.5534662456086734 \cdot 10^{+168}:\\
\;\;\;\;\frac{x + y}{1 - \frac{y}{z}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
herbie shell --seed 2023310
(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))))