
(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 8 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 (/ (- 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 100.0%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(if (<= y -2.4e+99)
1.0
(if (or (<= y -6.2e+75) (and (not (<= y -3.2e+26)) (<= y 1.58e+35)))
(/ x (- 2.0 x))
1.0)))
double code(double x, double y) {
double tmp;
if (y <= -2.4e+99) {
tmp = 1.0;
} else if ((y <= -6.2e+75) || (!(y <= -3.2e+26) && (y <= 1.58e+35))) {
tmp = x / (2.0 - x);
} 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 <= (-2.4d+99)) then
tmp = 1.0d0
else if ((y <= (-6.2d+75)) .or. (.not. (y <= (-3.2d+26))) .and. (y <= 1.58d+35)) then
tmp = x / (2.0d0 - x)
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -2.4e+99) {
tmp = 1.0;
} else if ((y <= -6.2e+75) || (!(y <= -3.2e+26) && (y <= 1.58e+35))) {
tmp = x / (2.0 - x);
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -2.4e+99: tmp = 1.0 elif (y <= -6.2e+75) or (not (y <= -3.2e+26) and (y <= 1.58e+35)): tmp = x / (2.0 - x) else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -2.4e+99) tmp = 1.0; elseif ((y <= -6.2e+75) || (!(y <= -3.2e+26) && (y <= 1.58e+35))) tmp = Float64(x / Float64(2.0 - x)); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -2.4e+99) tmp = 1.0; elseif ((y <= -6.2e+75) || (~((y <= -3.2e+26)) && (y <= 1.58e+35))) tmp = x / (2.0 - x); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -2.4e+99], 1.0, If[Or[LessEqual[y, -6.2e+75], And[N[Not[LessEqual[y, -3.2e+26]], $MachinePrecision], LessEqual[y, 1.58e+35]]], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.4 \cdot 10^{+99}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -6.2 \cdot 10^{+75} \lor \neg \left(y \leq -3.2 \cdot 10^{+26}\right) \land y \leq 1.58 \cdot 10^{+35}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -2.4000000000000001e99 or -6.2000000000000002e75 < y < -3.20000000000000029e26 or 1.57999999999999999e35 < y Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 82.1%
if -2.4000000000000001e99 < y < -6.2000000000000002e75 or -3.20000000000000029e26 < y < 1.57999999999999999e35Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 78.1%
mul-1-neg78.1%
distribute-neg-frac278.1%
neg-sub078.1%
associate-+l-78.1%
neg-sub078.1%
+-commutative78.1%
unsub-neg78.1%
Simplified78.1%
Final simplification79.8%
(FPCore (x y)
:precision binary64
(if (<= x -2.15e+30)
-1.0
(if (<= x -1.65e-231)
1.0
(if (<= x 7.5e-167) (* y -0.5) (if (<= x 6.5e+53) 1.0 -1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -2.15e+30) {
tmp = -1.0;
} else if (x <= -1.65e-231) {
tmp = 1.0;
} else if (x <= 7.5e-167) {
tmp = y * -0.5;
} else if (x <= 6.5e+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 (x <= (-2.15d+30)) then
tmp = -1.0d0
else if (x <= (-1.65d-231)) then
tmp = 1.0d0
else if (x <= 7.5d-167) then
tmp = y * (-0.5d0)
else if (x <= 6.5d+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 (x <= -2.15e+30) {
tmp = -1.0;
} else if (x <= -1.65e-231) {
tmp = 1.0;
} else if (x <= 7.5e-167) {
tmp = y * -0.5;
} else if (x <= 6.5e+53) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2.15e+30: tmp = -1.0 elif x <= -1.65e-231: tmp = 1.0 elif x <= 7.5e-167: tmp = y * -0.5 elif x <= 6.5e+53: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -2.15e+30) tmp = -1.0; elseif (x <= -1.65e-231) tmp = 1.0; elseif (x <= 7.5e-167) tmp = Float64(y * -0.5); elseif (x <= 6.5e+53) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2.15e+30) tmp = -1.0; elseif (x <= -1.65e-231) tmp = 1.0; elseif (x <= 7.5e-167) tmp = y * -0.5; elseif (x <= 6.5e+53) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2.15e+30], -1.0, If[LessEqual[x, -1.65e-231], 1.0, If[LessEqual[x, 7.5e-167], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 6.5e+53], 1.0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.15 \cdot 10^{+30}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -1.65 \cdot 10^{-231}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{-167}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 6.5 \cdot 10^{+53}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -2.15e30 or 6.50000000000000017e53 < x Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 83.0%
if -2.15e30 < x < -1.65000000000000014e-231 or 7.5000000000000007e-167 < x < 6.50000000000000017e53Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 65.0%
if -1.65000000000000014e-231 < x < 7.5000000000000007e-167Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 82.1%
Taylor expanded in y around 0 50.5%
Final simplification71.8%
(FPCore (x y) :precision binary64 (if (or (<= x -3e+31) (not (<= x 1.9e+54))) (- -1.0 (* y (/ -2.0 x))) (/ y (- y 2.0))))
double code(double x, double y) {
double tmp;
if ((x <= -3e+31) || !(x <= 1.9e+54)) {
tmp = -1.0 - (y * (-2.0 / x));
} 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 <= (-3d+31)) .or. (.not. (x <= 1.9d+54))) then
tmp = (-1.0d0) - (y * ((-2.0d0) / x))
else
tmp = y / (y - 2.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -3e+31) || !(x <= 1.9e+54)) {
tmp = -1.0 - (y * (-2.0 / x));
} else {
tmp = y / (y - 2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -3e+31) or not (x <= 1.9e+54): tmp = -1.0 - (y * (-2.0 / x)) else: tmp = y / (y - 2.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -3e+31) || !(x <= 1.9e+54)) tmp = Float64(-1.0 - Float64(y * Float64(-2.0 / x))); else tmp = Float64(y / Float64(y - 2.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -3e+31) || ~((x <= 1.9e+54))) tmp = -1.0 - (y * (-2.0 / x)); else tmp = y / (y - 2.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -3e+31], N[Not[LessEqual[x, 1.9e+54]], $MachinePrecision]], N[(-1.0 - N[(y * N[(-2.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y / N[(y - 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3 \cdot 10^{+31} \lor \neg \left(x \leq 1.9 \cdot 10^{+54}\right):\\
\;\;\;\;-1 - y \cdot \frac{-2}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y - 2}\\
\end{array}
\end{array}
if x < -2.99999999999999989e31 or 1.9000000000000001e54 < x Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 83.6%
sub-neg83.6%
+-commutative83.6%
distribute-neg-in83.6%
metadata-eval83.6%
mul-1-neg83.6%
remove-double-neg83.6%
associate-+l+83.6%
remove-double-neg83.6%
mul-1-neg83.6%
neg-sub083.6%
associate--r-83.6%
associate-*r/83.6%
sub-neg83.6%
metadata-eval83.6%
+-commutative83.6%
distribute-lft-in83.6%
metadata-eval83.6%
div-sub83.6%
Simplified83.6%
Taylor expanded in y around inf 83.6%
associate-*r/83.6%
*-commutative83.6%
associate-/l*83.6%
Simplified83.6%
if -2.99999999999999989e31 < x < 1.9000000000000001e54Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 76.8%
Final simplification80.1%
(FPCore (x y) :precision binary64 (if (<= x -1040000000000.0) (- -1.0 (/ (+ 2.0 (* y -2.0)) x)) (if (<= x 1.85e+53) (/ y (- y 2.0)) (- -1.0 (* y (/ -2.0 x))))))
double code(double x, double y) {
double tmp;
if (x <= -1040000000000.0) {
tmp = -1.0 - ((2.0 + (y * -2.0)) / x);
} else if (x <= 1.85e+53) {
tmp = y / (y - 2.0);
} else {
tmp = -1.0 - (y * (-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 (x <= (-1040000000000.0d0)) then
tmp = (-1.0d0) - ((2.0d0 + (y * (-2.0d0))) / x)
else if (x <= 1.85d+53) then
tmp = y / (y - 2.0d0)
else
tmp = (-1.0d0) - (y * ((-2.0d0) / x))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1040000000000.0) {
tmp = -1.0 - ((2.0 + (y * -2.0)) / x);
} else if (x <= 1.85e+53) {
tmp = y / (y - 2.0);
} else {
tmp = -1.0 - (y * (-2.0 / x));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1040000000000.0: tmp = -1.0 - ((2.0 + (y * -2.0)) / x) elif x <= 1.85e+53: tmp = y / (y - 2.0) else: tmp = -1.0 - (y * (-2.0 / x)) return tmp
function code(x, y) tmp = 0.0 if (x <= -1040000000000.0) tmp = Float64(-1.0 - Float64(Float64(2.0 + Float64(y * -2.0)) / x)); elseif (x <= 1.85e+53) tmp = Float64(y / Float64(y - 2.0)); else tmp = Float64(-1.0 - Float64(y * Float64(-2.0 / x))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1040000000000.0) tmp = -1.0 - ((2.0 + (y * -2.0)) / x); elseif (x <= 1.85e+53) tmp = y / (y - 2.0); else tmp = -1.0 - (y * (-2.0 / x)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1040000000000.0], N[(-1.0 - N[(N[(2.0 + N[(y * -2.0), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.85e+53], N[(y / N[(y - 2.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 - N[(y * N[(-2.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1040000000000:\\
\;\;\;\;-1 - \frac{2 + y \cdot -2}{x}\\
\mathbf{elif}\;x \leq 1.85 \cdot 10^{+53}:\\
\;\;\;\;\frac{y}{y - 2}\\
\mathbf{else}:\\
\;\;\;\;-1 - y \cdot \frac{-2}{x}\\
\end{array}
\end{array}
if x < -1.04e12Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 83.3%
sub-neg83.3%
+-commutative83.3%
distribute-neg-in83.3%
metadata-eval83.3%
mul-1-neg83.3%
remove-double-neg83.3%
associate-+l+83.3%
remove-double-neg83.3%
mul-1-neg83.3%
neg-sub083.3%
associate--r-83.3%
associate-*r/83.3%
sub-neg83.3%
metadata-eval83.3%
+-commutative83.3%
distribute-lft-in83.3%
metadata-eval83.3%
div-sub83.3%
Simplified83.3%
if -1.04e12 < x < 1.85e53Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 77.6%
if 1.85e53 < x Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 81.8%
sub-neg81.8%
+-commutative81.8%
distribute-neg-in81.8%
metadata-eval81.8%
mul-1-neg81.8%
remove-double-neg81.8%
associate-+l+81.9%
remove-double-neg81.9%
mul-1-neg81.9%
neg-sub081.9%
associate--r-81.9%
associate-*r/81.9%
sub-neg81.9%
metadata-eval81.9%
+-commutative81.9%
distribute-lft-in81.9%
metadata-eval81.9%
div-sub81.9%
Simplified81.9%
Taylor expanded in y around inf 81.9%
associate-*r/81.9%
*-commutative81.9%
associate-/l*81.9%
Simplified81.9%
Final simplification80.1%
(FPCore (x y) :precision binary64 (if (<= x -9e+29) -1.0 (if (<= x 1.45e+53) (/ y (- y 2.0)) -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -9e+29) {
tmp = -1.0;
} else if (x <= 1.45e+53) {
tmp = y / (y - 2.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 (x <= (-9d+29)) then
tmp = -1.0d0
else if (x <= 1.45d+53) then
tmp = y / (y - 2.0d0)
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -9e+29) {
tmp = -1.0;
} else if (x <= 1.45e+53) {
tmp = y / (y - 2.0);
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -9e+29: tmp = -1.0 elif x <= 1.45e+53: tmp = y / (y - 2.0) else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -9e+29) tmp = -1.0; elseif (x <= 1.45e+53) tmp = Float64(y / Float64(y - 2.0)); else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -9e+29) tmp = -1.0; elseif (x <= 1.45e+53) tmp = y / (y - 2.0); else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -9e+29], -1.0, If[LessEqual[x, 1.45e+53], N[(y / N[(y - 2.0), $MachinePrecision]), $MachinePrecision], -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9 \cdot 10^{+29}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{+53}:\\
\;\;\;\;\frac{y}{y - 2}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -9.0000000000000005e29 or 1.4500000000000001e53 < x Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 83.0%
if -9.0000000000000005e29 < x < 1.4500000000000001e53Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 76.8%
Final simplification79.8%
(FPCore (x y) :precision binary64 (if (<= x -5e+31) -1.0 (if (<= x 2e+54) 1.0 -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -5e+31) {
tmp = -1.0;
} else if (x <= 2e+54) {
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 (x <= (-5d+31)) then
tmp = -1.0d0
else if (x <= 2d+54) 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 (x <= -5e+31) {
tmp = -1.0;
} else if (x <= 2e+54) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -5e+31: tmp = -1.0 elif x <= 2e+54: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -5e+31) tmp = -1.0; elseif (x <= 2e+54) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -5e+31) tmp = -1.0; elseif (x <= 2e+54) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -5e+31], -1.0, If[LessEqual[x, 2e+54], 1.0, -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{+31}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 2 \cdot 10^{+54}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -5.00000000000000027e31 or 2.0000000000000002e54 < x Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 83.0%
if -5.00000000000000027e31 < x < 2.0000000000000002e54Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 56.4%
Final simplification69.2%
(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 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
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 2024053
(FPCore (x y)
:name "Data.Colour.RGB:hslsv from colour-2.3.3, C"
:precision binary64
:alt
(- (/ x (- 2.0 (+ x y))) (/ y (- 2.0 (+ x y))))
(/ (- x y) (- 2.0 (+ x y))))