
(FPCore (x y) :precision binary64 (/ (- x y) (- 2.0 (+ x y))))
double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x - y) / (2.0d0 - (x + y))
end function
public static double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
def code(x, y): return (x - y) / (2.0 - (x + y))
function code(x, y) return Float64(Float64(x - y) / Float64(2.0 - Float64(x + y))) end
function tmp = code(x, y) tmp = (x - y) / (2.0 - (x + y)); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{2 - \left(x + y\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (- x y) (- 2.0 (+ x y))))
double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x - y) / (2.0d0 - (x + y))
end function
public static double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
def code(x, y): return (x - y) / (2.0 - (x + y))
function code(x, y) return Float64(Float64(x - y) / Float64(2.0 - Float64(x + y))) end
function tmp = code(x, y) tmp = (x - y) / (2.0 - (x + y)); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{2 - \left(x + y\right)}
\end{array}
(FPCore (x y) :precision binary64 (let* ((t_0 (- 2.0 (+ x y)))) (- (/ x t_0) (/ y t_0))))
double code(double x, double y) {
double t_0 = 2.0 - (x + y);
return (x / t_0) - (y / t_0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
t_0 = 2.0d0 - (x + y)
code = (x / t_0) - (y / t_0)
end function
public static double code(double x, double y) {
double t_0 = 2.0 - (x + y);
return (x / t_0) - (y / t_0);
}
def code(x, y): t_0 = 2.0 - (x + y) return (x / t_0) - (y / t_0)
function code(x, y) t_0 = Float64(2.0 - Float64(x + y)) return Float64(Float64(x / t_0) - Float64(y / t_0)) end
function tmp = code(x, y) t_0 = 2.0 - (x + y); tmp = (x / t_0) - (y / t_0); end
code[x_, y_] := Block[{t$95$0 = N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]}, N[(N[(x / t$95$0), $MachinePrecision] - N[(y / t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 2 - \left(x + y\right)\\
\frac{x}{t_0} - \frac{y}{t_0}
\end{array}
\end{array}
Initial program 99.9%
div-sub100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))))
(if (<= y -6.3e+15)
t_0
(if (<= y -7.2e-43)
-1.0
(if (<= y -4.8e-158) (* y -0.5) (if (<= y 2.5e+58) -1.0 t_0))))))
double code(double x, double y) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -6.3e+15) {
tmp = t_0;
} else if (y <= -7.2e-43) {
tmp = -1.0;
} else if (y <= -4.8e-158) {
tmp = y * -0.5;
} else if (y <= 2.5e+58) {
tmp = -1.0;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - (x / y)
if (y <= (-6.3d+15)) then
tmp = t_0
else if (y <= (-7.2d-43)) then
tmp = -1.0d0
else if (y <= (-4.8d-158)) then
tmp = y * (-0.5d0)
else if (y <= 2.5d+58) then
tmp = -1.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -6.3e+15) {
tmp = t_0;
} else if (y <= -7.2e-43) {
tmp = -1.0;
} else if (y <= -4.8e-158) {
tmp = y * -0.5;
} else if (y <= 2.5e+58) {
tmp = -1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 - (x / y) tmp = 0 if y <= -6.3e+15: tmp = t_0 elif y <= -7.2e-43: tmp = -1.0 elif y <= -4.8e-158: tmp = y * -0.5 elif y <= 2.5e+58: tmp = -1.0 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 - Float64(x / y)) tmp = 0.0 if (y <= -6.3e+15) tmp = t_0; elseif (y <= -7.2e-43) tmp = -1.0; elseif (y <= -4.8e-158) tmp = Float64(y * -0.5); elseif (y <= 2.5e+58) tmp = -1.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 - (x / y); tmp = 0.0; if (y <= -6.3e+15) tmp = t_0; elseif (y <= -7.2e-43) tmp = -1.0; elseif (y <= -4.8e-158) tmp = y * -0.5; elseif (y <= 2.5e+58) tmp = -1.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -6.3e+15], t$95$0, If[LessEqual[y, -7.2e-43], -1.0, If[LessEqual[y, -4.8e-158], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 2.5e+58], -1.0, t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -6.3 \cdot 10^{+15}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -7.2 \cdot 10^{-43}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq -4.8 \cdot 10^{-158}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{+58}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -6.3e15 or 2.49999999999999993e58 < y Initial program 99.9%
Taylor expanded in y around inf 73.8%
neg-mul-173.8%
Simplified73.8%
Taylor expanded in x around 0 73.8%
mul-1-neg73.8%
unsub-neg73.8%
Simplified73.8%
if -6.3e15 < y < -7.1999999999999998e-43 or -4.80000000000000015e-158 < y < 2.49999999999999993e58Initial program 100.0%
Taylor expanded in x around inf 63.8%
if -7.1999999999999998e-43 < y < -4.80000000000000015e-158Initial program 100.0%
Taylor expanded in x around 0 58.9%
associate-*r/58.9%
neg-mul-158.9%
Simplified58.9%
Taylor expanded in y around 0 58.9%
Final simplification68.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))))
(if (<= y -1.22e+16)
t_0
(if (<= y -3.2e-112)
(+ (/ y x) -1.0)
(if (<= y -4.8e-158) (* y -0.5) (if (<= y 2.5e+60) -1.0 t_0))))))
double code(double x, double y) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -1.22e+16) {
tmp = t_0;
} else if (y <= -3.2e-112) {
tmp = (y / x) + -1.0;
} else if (y <= -4.8e-158) {
tmp = y * -0.5;
} else if (y <= 2.5e+60) {
tmp = -1.0;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - (x / y)
if (y <= (-1.22d+16)) then
tmp = t_0
else if (y <= (-3.2d-112)) then
tmp = (y / x) + (-1.0d0)
else if (y <= (-4.8d-158)) then
tmp = y * (-0.5d0)
else if (y <= 2.5d+60) then
tmp = -1.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -1.22e+16) {
tmp = t_0;
} else if (y <= -3.2e-112) {
tmp = (y / x) + -1.0;
} else if (y <= -4.8e-158) {
tmp = y * -0.5;
} else if (y <= 2.5e+60) {
tmp = -1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 - (x / y) tmp = 0 if y <= -1.22e+16: tmp = t_0 elif y <= -3.2e-112: tmp = (y / x) + -1.0 elif y <= -4.8e-158: tmp = y * -0.5 elif y <= 2.5e+60: tmp = -1.0 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 - Float64(x / y)) tmp = 0.0 if (y <= -1.22e+16) tmp = t_0; elseif (y <= -3.2e-112) tmp = Float64(Float64(y / x) + -1.0); elseif (y <= -4.8e-158) tmp = Float64(y * -0.5); elseif (y <= 2.5e+60) tmp = -1.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 - (x / y); tmp = 0.0; if (y <= -1.22e+16) tmp = t_0; elseif (y <= -3.2e-112) tmp = (y / x) + -1.0; elseif (y <= -4.8e-158) tmp = y * -0.5; elseif (y <= 2.5e+60) tmp = -1.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.22e+16], t$95$0, If[LessEqual[y, -3.2e-112], N[(N[(y / x), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[y, -4.8e-158], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 2.5e+60], -1.0, t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -1.22 \cdot 10^{+16}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -3.2 \cdot 10^{-112}:\\
\;\;\;\;\frac{y}{x} + -1\\
\mathbf{elif}\;y \leq -4.8 \cdot 10^{-158}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{+60}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -1.22e16 or 2.49999999999999987e60 < y Initial program 99.9%
Taylor expanded in y around inf 73.8%
neg-mul-173.8%
Simplified73.8%
Taylor expanded in x around 0 73.8%
mul-1-neg73.8%
unsub-neg73.8%
Simplified73.8%
if -1.22e16 < y < -3.19999999999999993e-112Initial program 100.0%
Taylor expanded in x around inf 59.7%
mul-1-neg59.7%
Simplified59.7%
Taylor expanded in x around 0 59.7%
if -3.19999999999999993e-112 < y < -4.80000000000000015e-158Initial program 100.0%
Taylor expanded in x around 0 67.8%
associate-*r/67.8%
neg-mul-167.8%
Simplified67.8%
Taylor expanded in y around 0 67.8%
if -4.80000000000000015e-158 < y < 2.49999999999999987e60Initial program 100.0%
Taylor expanded in x around inf 63.6%
Final simplification68.1%
(FPCore (x y) :precision binary64 (if (<= x -8.6e+55) (/ (- x y) (- x)) (if (<= x 4e+31) (/ (- x y) (- 2.0 y)) (+ (/ y x) -1.0))))
double code(double x, double y) {
double tmp;
if (x <= -8.6e+55) {
tmp = (x - y) / -x;
} else if (x <= 4e+31) {
tmp = (x - y) / (2.0 - y);
} else {
tmp = (y / x) + -1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-8.6d+55)) then
tmp = (x - y) / -x
else if (x <= 4d+31) then
tmp = (x - y) / (2.0d0 - y)
else
tmp = (y / x) + (-1.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -8.6e+55) {
tmp = (x - y) / -x;
} else if (x <= 4e+31) {
tmp = (x - y) / (2.0 - y);
} else {
tmp = (y / x) + -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -8.6e+55: tmp = (x - y) / -x elif x <= 4e+31: tmp = (x - y) / (2.0 - y) else: tmp = (y / x) + -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -8.6e+55) tmp = Float64(Float64(x - y) / Float64(-x)); elseif (x <= 4e+31) tmp = Float64(Float64(x - y) / Float64(2.0 - y)); else tmp = Float64(Float64(y / x) + -1.0); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -8.6e+55) tmp = (x - y) / -x; elseif (x <= 4e+31) tmp = (x - y) / (2.0 - y); else tmp = (y / x) + -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -8.6e+55], N[(N[(x - y), $MachinePrecision] / (-x)), $MachinePrecision], If[LessEqual[x, 4e+31], N[(N[(x - y), $MachinePrecision] / N[(2.0 - y), $MachinePrecision]), $MachinePrecision], N[(N[(y / x), $MachinePrecision] + -1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.6 \cdot 10^{+55}:\\
\;\;\;\;\frac{x - y}{-x}\\
\mathbf{elif}\;x \leq 4 \cdot 10^{+31}:\\
\;\;\;\;\frac{x - y}{2 - y}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{x} + -1\\
\end{array}
\end{array}
if x < -8.5999999999999998e55Initial program 100.0%
Taylor expanded in x around inf 83.5%
mul-1-neg83.5%
Simplified83.5%
if -8.5999999999999998e55 < x < 3.9999999999999999e31Initial program 100.0%
Taylor expanded in x around 0 93.1%
if 3.9999999999999999e31 < x Initial program 99.9%
Taylor expanded in x around inf 75.9%
mul-1-neg75.9%
Simplified75.9%
Taylor expanded in x around 0 75.9%
Final simplification86.3%
(FPCore (x y)
:precision binary64
(if (<= y -8.4e+15)
1.0
(if (<= y -9e-43)
-1.0
(if (<= y -4.8e-158) (* y -0.5) (if (<= y 1.6e+53) -1.0 1.0)))))
double code(double x, double y) {
double tmp;
if (y <= -8.4e+15) {
tmp = 1.0;
} else if (y <= -9e-43) {
tmp = -1.0;
} else if (y <= -4.8e-158) {
tmp = y * -0.5;
} else if (y <= 1.6e+53) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-8.4d+15)) then
tmp = 1.0d0
else if (y <= (-9d-43)) then
tmp = -1.0d0
else if (y <= (-4.8d-158)) then
tmp = y * (-0.5d0)
else if (y <= 1.6d+53) then
tmp = -1.0d0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -8.4e+15) {
tmp = 1.0;
} else if (y <= -9e-43) {
tmp = -1.0;
} else if (y <= -4.8e-158) {
tmp = y * -0.5;
} else if (y <= 1.6e+53) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -8.4e+15: tmp = 1.0 elif y <= -9e-43: tmp = -1.0 elif y <= -4.8e-158: tmp = y * -0.5 elif y <= 1.6e+53: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -8.4e+15) tmp = 1.0; elseif (y <= -9e-43) tmp = -1.0; elseif (y <= -4.8e-158) tmp = Float64(y * -0.5); elseif (y <= 1.6e+53) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -8.4e+15) tmp = 1.0; elseif (y <= -9e-43) tmp = -1.0; elseif (y <= -4.8e-158) tmp = y * -0.5; elseif (y <= 1.6e+53) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -8.4e+15], 1.0, If[LessEqual[y, -9e-43], -1.0, If[LessEqual[y, -4.8e-158], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 1.6e+53], -1.0, 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.4 \cdot 10^{+15}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -9 \cdot 10^{-43}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq -4.8 \cdot 10^{-158}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 1.6 \cdot 10^{+53}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -8.4e15 or 1.6e53 < y Initial program 99.9%
Taylor expanded in y around inf 73.0%
if -8.4e15 < y < -9.0000000000000005e-43 or -4.80000000000000015e-158 < y < 1.6e53Initial program 100.0%
Taylor expanded in x around inf 63.8%
if -9.0000000000000005e-43 < y < -4.80000000000000015e-158Initial program 100.0%
Taylor expanded in x around 0 58.9%
associate-*r/58.9%
neg-mul-158.9%
Simplified58.9%
Taylor expanded in y around 0 58.9%
Final simplification67.6%
(FPCore (x y)
:precision binary64
(if (<= y -1.4e+16)
(+ 1.0 (/ 2.0 y))
(if (<= y -5.6e-41)
-1.0
(if (<= y -3.3e-158) (* y -0.5) (if (<= y 4e+47) -1.0 1.0)))))
double code(double x, double y) {
double tmp;
if (y <= -1.4e+16) {
tmp = 1.0 + (2.0 / y);
} else if (y <= -5.6e-41) {
tmp = -1.0;
} else if (y <= -3.3e-158) {
tmp = y * -0.5;
} else if (y <= 4e+47) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-1.4d+16)) then
tmp = 1.0d0 + (2.0d0 / y)
else if (y <= (-5.6d-41)) then
tmp = -1.0d0
else if (y <= (-3.3d-158)) then
tmp = y * (-0.5d0)
else if (y <= 4d+47) then
tmp = -1.0d0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.4e+16) {
tmp = 1.0 + (2.0 / y);
} else if (y <= -5.6e-41) {
tmp = -1.0;
} else if (y <= -3.3e-158) {
tmp = y * -0.5;
} else if (y <= 4e+47) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.4e+16: tmp = 1.0 + (2.0 / y) elif y <= -5.6e-41: tmp = -1.0 elif y <= -3.3e-158: tmp = y * -0.5 elif y <= 4e+47: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -1.4e+16) tmp = Float64(1.0 + Float64(2.0 / y)); elseif (y <= -5.6e-41) tmp = -1.0; elseif (y <= -3.3e-158) tmp = Float64(y * -0.5); elseif (y <= 4e+47) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.4e+16) tmp = 1.0 + (2.0 / y); elseif (y <= -5.6e-41) tmp = -1.0; elseif (y <= -3.3e-158) tmp = y * -0.5; elseif (y <= 4e+47) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.4e+16], N[(1.0 + N[(2.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -5.6e-41], -1.0, If[LessEqual[y, -3.3e-158], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 4e+47], -1.0, 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.4 \cdot 10^{+16}:\\
\;\;\;\;1 + \frac{2}{y}\\
\mathbf{elif}\;y \leq -5.6 \cdot 10^{-41}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq -3.3 \cdot 10^{-158}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 4 \cdot 10^{+47}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.4e16Initial program 99.9%
Taylor expanded in y around -inf 71.9%
Taylor expanded in x around 0 70.7%
associate-*r/70.7%
metadata-eval70.7%
Simplified70.7%
if -1.4e16 < y < -5.6000000000000003e-41 or -3.3000000000000002e-158 < y < 4.0000000000000002e47Initial program 100.0%
Taylor expanded in x around inf 63.8%
if -5.6000000000000003e-41 < y < -3.3000000000000002e-158Initial program 100.0%
Taylor expanded in x around 0 58.9%
associate-*r/58.9%
neg-mul-158.9%
Simplified58.9%
Taylor expanded in y around 0 58.9%
if 4.0000000000000002e47 < y Initial program 99.8%
Taylor expanded in y around inf 76.0%
Final simplification67.7%
(FPCore (x y) :precision binary64 (if (or (<= y -1.15e+16) (not (<= y 8.2e+50))) (- 1.0 (/ x y)) (/ x (- 2.0 x))))
double code(double x, double y) {
double tmp;
if ((y <= -1.15e+16) || !(y <= 8.2e+50)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= (-1.15d+16)) .or. (.not. (y <= 8.2d+50))) then
tmp = 1.0d0 - (x / y)
else
tmp = x / (2.0d0 - x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -1.15e+16) || !(y <= 8.2e+50)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.15e+16) or not (y <= 8.2e+50): tmp = 1.0 - (x / y) else: tmp = x / (2.0 - x) return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.15e+16) || !(y <= 8.2e+50)) tmp = Float64(1.0 - Float64(x / y)); else tmp = Float64(x / Float64(2.0 - x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -1.15e+16) || ~((y <= 8.2e+50))) tmp = 1.0 - (x / y); else tmp = x / (2.0 - x); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1.15e+16], N[Not[LessEqual[y, 8.2e+50]], $MachinePrecision]], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.15 \cdot 10^{+16} \lor \neg \left(y \leq 8.2 \cdot 10^{+50}\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 - x}\\
\end{array}
\end{array}
if y < -1.15e16 or 8.2000000000000002e50 < y Initial program 99.9%
Taylor expanded in y around inf 73.8%
neg-mul-173.8%
Simplified73.8%
Taylor expanded in x around 0 73.8%
mul-1-neg73.8%
unsub-neg73.8%
Simplified73.8%
if -1.15e16 < y < 8.2000000000000002e50Initial program 100.0%
Taylor expanded in y around 0 77.6%
Final simplification75.9%
(FPCore (x y) :precision binary64 (if (or (<= x -1e+56) (not (<= x 3.05e+31))) (+ (/ y x) -1.0) (/ y (+ y -2.0))))
double code(double x, double y) {
double tmp;
if ((x <= -1e+56) || !(x <= 3.05e+31)) {
tmp = (y / x) + -1.0;
} else {
tmp = y / (y + -2.0);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-1d+56)) .or. (.not. (x <= 3.05d+31))) then
tmp = (y / x) + (-1.0d0)
else
tmp = y / (y + (-2.0d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -1e+56) || !(x <= 3.05e+31)) {
tmp = (y / x) + -1.0;
} else {
tmp = y / (y + -2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1e+56) or not (x <= 3.05e+31): tmp = (y / x) + -1.0 else: tmp = y / (y + -2.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1e+56) || !(x <= 3.05e+31)) tmp = Float64(Float64(y / x) + -1.0); else tmp = Float64(y / Float64(y + -2.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1e+56) || ~((x <= 3.05e+31))) tmp = (y / x) + -1.0; else tmp = y / (y + -2.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1e+56], N[Not[LessEqual[x, 3.05e+31]], $MachinePrecision]], N[(N[(y / x), $MachinePrecision] + -1.0), $MachinePrecision], N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{+56} \lor \neg \left(x \leq 3.05 \cdot 10^{+31}\right):\\
\;\;\;\;\frac{y}{x} + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y + -2}\\
\end{array}
\end{array}
if x < -1.00000000000000009e56 or 3.05000000000000005e31 < x Initial program 99.9%
Taylor expanded in x around inf 79.8%
mul-1-neg79.8%
Simplified79.8%
Taylor expanded in x around 0 79.8%
if -1.00000000000000009e56 < x < 3.05000000000000005e31Initial program 100.0%
Taylor expanded in x around 0 74.3%
associate-*r/74.3%
neg-mul-174.3%
Simplified74.3%
expm1-log1p-u74.2%
expm1-udef52.7%
add-sqr-sqrt28.4%
sqrt-unprod17.2%
sqr-neg17.2%
sqrt-unprod1.2%
add-sqr-sqrt2.9%
frac-2neg2.9%
add-sqr-sqrt1.5%
sqrt-unprod12.6%
sqr-neg12.6%
sqrt-unprod24.2%
add-sqr-sqrt52.7%
sub-neg52.7%
distribute-neg-in52.7%
metadata-eval52.7%
remove-double-neg52.7%
Applied egg-rr52.7%
expm1-def74.2%
expm1-log1p74.3%
+-commutative74.3%
Simplified74.3%
Final simplification77.1%
(FPCore (x y) :precision binary64 (if (<= x -5.8e+55) (/ (- x y) (- x)) (if (<= x 5.1e+31) (/ y (+ y -2.0)) (+ (/ y x) -1.0))))
double code(double x, double y) {
double tmp;
if (x <= -5.8e+55) {
tmp = (x - y) / -x;
} else if (x <= 5.1e+31) {
tmp = y / (y + -2.0);
} else {
tmp = (y / x) + -1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-5.8d+55)) then
tmp = (x - y) / -x
else if (x <= 5.1d+31) then
tmp = y / (y + (-2.0d0))
else
tmp = (y / x) + (-1.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -5.8e+55) {
tmp = (x - y) / -x;
} else if (x <= 5.1e+31) {
tmp = y / (y + -2.0);
} else {
tmp = (y / x) + -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -5.8e+55: tmp = (x - y) / -x elif x <= 5.1e+31: tmp = y / (y + -2.0) else: tmp = (y / x) + -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -5.8e+55) tmp = Float64(Float64(x - y) / Float64(-x)); elseif (x <= 5.1e+31) tmp = Float64(y / Float64(y + -2.0)); else tmp = Float64(Float64(y / x) + -1.0); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -5.8e+55) tmp = (x - y) / -x; elseif (x <= 5.1e+31) tmp = y / (y + -2.0); else tmp = (y / x) + -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -5.8e+55], N[(N[(x - y), $MachinePrecision] / (-x)), $MachinePrecision], If[LessEqual[x, 5.1e+31], N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision], N[(N[(y / x), $MachinePrecision] + -1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.8 \cdot 10^{+55}:\\
\;\;\;\;\frac{x - y}{-x}\\
\mathbf{elif}\;x \leq 5.1 \cdot 10^{+31}:\\
\;\;\;\;\frac{y}{y + -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{x} + -1\\
\end{array}
\end{array}
if x < -5.7999999999999997e55Initial program 100.0%
Taylor expanded in x around inf 83.5%
mul-1-neg83.5%
Simplified83.5%
if -5.7999999999999997e55 < x < 5.0999999999999997e31Initial program 100.0%
Taylor expanded in x around 0 74.3%
associate-*r/74.3%
neg-mul-174.3%
Simplified74.3%
expm1-log1p-u74.2%
expm1-udef52.7%
add-sqr-sqrt28.4%
sqrt-unprod17.2%
sqr-neg17.2%
sqrt-unprod1.2%
add-sqr-sqrt2.9%
frac-2neg2.9%
add-sqr-sqrt1.5%
sqrt-unprod12.6%
sqr-neg12.6%
sqrt-unprod24.2%
add-sqr-sqrt52.7%
sub-neg52.7%
distribute-neg-in52.7%
metadata-eval52.7%
remove-double-neg52.7%
Applied egg-rr52.7%
expm1-def74.2%
expm1-log1p74.3%
+-commutative74.3%
Simplified74.3%
if 5.0999999999999997e31 < x Initial program 99.9%
Taylor expanded in x around inf 75.9%
mul-1-neg75.9%
Simplified75.9%
Taylor expanded in x around 0 75.9%
Final simplification77.1%
(FPCore (x y) :precision binary64 (/ (- x y) (- 2.0 (+ x y))))
double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x - y) / (2.0d0 - (x + y))
end function
public static double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
def code(x, y): return (x - y) / (2.0 - (x + y))
function code(x, y) return Float64(Float64(x - y) / Float64(2.0 - Float64(x + y))) end
function tmp = code(x, y) tmp = (x - y) / (2.0 - (x + y)); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{2 - \left(x + y\right)}
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (<= y -1.15e+16) 1.0 (if (<= y 2e+52) -1.0 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -1.15e+16) {
tmp = 1.0;
} else if (y <= 2e+52) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-1.15d+16)) then
tmp = 1.0d0
else if (y <= 2d+52) then
tmp = -1.0d0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.15e+16) {
tmp = 1.0;
} else if (y <= 2e+52) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.15e+16: tmp = 1.0 elif y <= 2e+52: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -1.15e+16) tmp = 1.0; elseif (y <= 2e+52) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.15e+16) tmp = 1.0; elseif (y <= 2e+52) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.15e+16], 1.0, If[LessEqual[y, 2e+52], -1.0, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.15 \cdot 10^{+16}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 2 \cdot 10^{+52}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.15e16 or 2e52 < y Initial program 99.9%
Taylor expanded in y around inf 73.0%
if -1.15e16 < y < 2e52Initial program 100.0%
Taylor expanded in x around inf 59.6%
Final simplification65.7%
(FPCore (x y) :precision binary64 -1.0)
double code(double x, double y) {
return -1.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = -1.0d0
end function
public static double code(double x, double y) {
return -1.0;
}
def code(x, y): return -1.0
function code(x, y) return -1.0 end
function tmp = code(x, y) tmp = -1.0; end
code[x_, y_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 99.9%
Taylor expanded in x around inf 43.6%
Final simplification43.6%
(FPCore (x y) :precision binary64 (let* ((t_0 (- 2.0 (+ x y)))) (- (/ x t_0) (/ y t_0))))
double code(double x, double y) {
double t_0 = 2.0 - (x + y);
return (x / t_0) - (y / t_0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
t_0 = 2.0d0 - (x + y)
code = (x / t_0) - (y / t_0)
end function
public static double code(double x, double y) {
double t_0 = 2.0 - (x + y);
return (x / t_0) - (y / t_0);
}
def code(x, y): t_0 = 2.0 - (x + y) return (x / t_0) - (y / t_0)
function code(x, y) t_0 = Float64(2.0 - Float64(x + y)) return Float64(Float64(x / t_0) - Float64(y / t_0)) end
function tmp = code(x, y) t_0 = 2.0 - (x + y); tmp = (x / t_0) - (y / t_0); end
code[x_, y_] := Block[{t$95$0 = N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]}, N[(N[(x / t$95$0), $MachinePrecision] - N[(y / t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 2 - \left(x + y\right)\\
\frac{x}{t_0} - \frac{y}{t_0}
\end{array}
\end{array}
herbie shell --seed 2023320
(FPCore (x y)
:name "Data.Colour.RGB:hslsv from colour-2.3.3, C"
:precision binary64
:herbie-target
(- (/ x (- 2.0 (+ x y))) (/ y (- 2.0 (+ x y))))
(/ (- x y) (- 2.0 (+ x y))))