
(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 9 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 -6.5e+52)
1.0
(if (<= y -1.15e-211)
-1.0
(if (<= y -1.7e-274)
(* x 0.5)
(if (<= y 5.6e-167) -1.0 (if (<= y 2600.0) (* y -0.5) 1.0))))))
double code(double x, double y) {
double tmp;
if (y <= -6.5e+52) {
tmp = 1.0;
} else if (y <= -1.15e-211) {
tmp = -1.0;
} else if (y <= -1.7e-274) {
tmp = x * 0.5;
} else if (y <= 5.6e-167) {
tmp = -1.0;
} else if (y <= 2600.0) {
tmp = y * -0.5;
} 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 <= (-6.5d+52)) then
tmp = 1.0d0
else if (y <= (-1.15d-211)) then
tmp = -1.0d0
else if (y <= (-1.7d-274)) then
tmp = x * 0.5d0
else if (y <= 5.6d-167) then
tmp = -1.0d0
else if (y <= 2600.0d0) then
tmp = y * (-0.5d0)
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -6.5e+52) {
tmp = 1.0;
} else if (y <= -1.15e-211) {
tmp = -1.0;
} else if (y <= -1.7e-274) {
tmp = x * 0.5;
} else if (y <= 5.6e-167) {
tmp = -1.0;
} else if (y <= 2600.0) {
tmp = y * -0.5;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -6.5e+52: tmp = 1.0 elif y <= -1.15e-211: tmp = -1.0 elif y <= -1.7e-274: tmp = x * 0.5 elif y <= 5.6e-167: tmp = -1.0 elif y <= 2600.0: tmp = y * -0.5 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -6.5e+52) tmp = 1.0; elseif (y <= -1.15e-211) tmp = -1.0; elseif (y <= -1.7e-274) tmp = Float64(x * 0.5); elseif (y <= 5.6e-167) tmp = -1.0; elseif (y <= 2600.0) tmp = Float64(y * -0.5); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -6.5e+52) tmp = 1.0; elseif (y <= -1.15e-211) tmp = -1.0; elseif (y <= -1.7e-274) tmp = x * 0.5; elseif (y <= 5.6e-167) tmp = -1.0; elseif (y <= 2600.0) tmp = y * -0.5; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -6.5e+52], 1.0, If[LessEqual[y, -1.15e-211], -1.0, If[LessEqual[y, -1.7e-274], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 5.6e-167], -1.0, If[LessEqual[y, 2600.0], N[(y * -0.5), $MachinePrecision], 1.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.5 \cdot 10^{+52}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -1.15 \cdot 10^{-211}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq -1.7 \cdot 10^{-274}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;y \leq 5.6 \cdot 10^{-167}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 2600:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -6.49999999999999996e52 or 2600 < 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 79.4%
if -6.49999999999999996e52 < y < -1.14999999999999994e-211 or -1.6999999999999999e-274 < y < 5.59999999999999971e-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 inf 61.0%
if -1.14999999999999994e-211 < y < -1.6999999999999999e-274Initial 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 80.8%
Taylor expanded in y around 0 72.9%
if 5.59999999999999971e-167 < y < 2600Initial 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 56.8%
Taylor expanded in y around 0 57.5%
*-commutative57.5%
Simplified57.5%
Final simplification69.5%
(FPCore (x y)
:precision binary64
(if (<= y -5.4e+52)
1.0
(if (<= y -6.5e-212)
-1.0
(if (<= y -2.3e-271) (* x 0.5) (if (<= y 5600.0) -1.0 1.0)))))
double code(double x, double y) {
double tmp;
if (y <= -5.4e+52) {
tmp = 1.0;
} else if (y <= -6.5e-212) {
tmp = -1.0;
} else if (y <= -2.3e-271) {
tmp = x * 0.5;
} else if (y <= 5600.0) {
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 <= (-5.4d+52)) then
tmp = 1.0d0
else if (y <= (-6.5d-212)) then
tmp = -1.0d0
else if (y <= (-2.3d-271)) then
tmp = x * 0.5d0
else if (y <= 5600.0d0) 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 <= -5.4e+52) {
tmp = 1.0;
} else if (y <= -6.5e-212) {
tmp = -1.0;
} else if (y <= -2.3e-271) {
tmp = x * 0.5;
} else if (y <= 5600.0) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -5.4e+52: tmp = 1.0 elif y <= -6.5e-212: tmp = -1.0 elif y <= -2.3e-271: tmp = x * 0.5 elif y <= 5600.0: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -5.4e+52) tmp = 1.0; elseif (y <= -6.5e-212) tmp = -1.0; elseif (y <= -2.3e-271) tmp = Float64(x * 0.5); elseif (y <= 5600.0) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -5.4e+52) tmp = 1.0; elseif (y <= -6.5e-212) tmp = -1.0; elseif (y <= -2.3e-271) tmp = x * 0.5; elseif (y <= 5600.0) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -5.4e+52], 1.0, If[LessEqual[y, -6.5e-212], -1.0, If[LessEqual[y, -2.3e-271], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 5600.0], -1.0, 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.4 \cdot 10^{+52}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -6.5 \cdot 10^{-212}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq -2.3 \cdot 10^{-271}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;y \leq 5600:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -5.4e52 or 5600 < 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 79.4%
if -5.4e52 < y < -6.5e-212 or -2.30000000000000009e-271 < y < 5600Initial 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 54.3%
if -6.5e-212 < y < -2.30000000000000009e-271Initial 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 80.8%
Taylor expanded in y around 0 72.9%
Final simplification66.8%
(FPCore (x y) :precision binary64 (if (<= y -5.5e+52) 1.0 (if (<= y 6.7e-164) (/ x (- 2.0 x)) (if (<= y 2600.0) (* y -0.5) 1.0))))
double code(double x, double y) {
double tmp;
if (y <= -5.5e+52) {
tmp = 1.0;
} else if (y <= 6.7e-164) {
tmp = x / (2.0 - x);
} else if (y <= 2600.0) {
tmp = y * -0.5;
} 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 <= (-5.5d+52)) then
tmp = 1.0d0
else if (y <= 6.7d-164) then
tmp = x / (2.0d0 - x)
else if (y <= 2600.0d0) then
tmp = y * (-0.5d0)
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -5.5e+52) {
tmp = 1.0;
} else if (y <= 6.7e-164) {
tmp = x / (2.0 - x);
} else if (y <= 2600.0) {
tmp = y * -0.5;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -5.5e+52: tmp = 1.0 elif y <= 6.7e-164: tmp = x / (2.0 - x) elif y <= 2600.0: tmp = y * -0.5 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -5.5e+52) tmp = 1.0; elseif (y <= 6.7e-164) tmp = Float64(x / Float64(2.0 - x)); elseif (y <= 2600.0) tmp = Float64(y * -0.5); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -5.5e+52) tmp = 1.0; elseif (y <= 6.7e-164) tmp = x / (2.0 - x); elseif (y <= 2600.0) tmp = y * -0.5; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -5.5e+52], 1.0, If[LessEqual[y, 6.7e-164], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2600.0], N[(y * -0.5), $MachinePrecision], 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.5 \cdot 10^{+52}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 6.7 \cdot 10^{-164}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{elif}\;y \leq 2600:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -5.49999999999999996e52 or 2600 < 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 79.4%
if -5.49999999999999996e52 < y < 6.69999999999999999e-164Initial 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 80.1%
mul-1-neg80.1%
distribute-neg-frac280.1%
sub-neg80.1%
metadata-eval80.1%
distribute-neg-in80.1%
metadata-eval80.1%
+-commutative80.1%
unsub-neg80.1%
Simplified80.1%
if 6.69999999999999999e-164 < y < 2600Initial 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 58.2%
Taylor expanded in y around 0 58.9%
*-commutative58.9%
Simplified58.9%
Final simplification76.6%
(FPCore (x y) :precision binary64 (if (or (<= x -40000000.0) (not (<= x 6.7e+15))) (- -1.0 (* y (/ -2.0 x))) (/ (- y x) (- y 2.0))))
double code(double x, double y) {
double tmp;
if ((x <= -40000000.0) || !(x <= 6.7e+15)) {
tmp = -1.0 - (y * (-2.0 / x));
} else {
tmp = (y - x) / (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 <= (-40000000.0d0)) .or. (.not. (x <= 6.7d+15))) then
tmp = (-1.0d0) - (y * ((-2.0d0) / x))
else
tmp = (y - x) / (y - 2.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -40000000.0) || !(x <= 6.7e+15)) {
tmp = -1.0 - (y * (-2.0 / x));
} else {
tmp = (y - x) / (y - 2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -40000000.0) or not (x <= 6.7e+15): tmp = -1.0 - (y * (-2.0 / x)) else: tmp = (y - x) / (y - 2.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -40000000.0) || !(x <= 6.7e+15)) tmp = Float64(-1.0 - Float64(y * Float64(-2.0 / x))); else tmp = Float64(Float64(y - x) / Float64(y - 2.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -40000000.0) || ~((x <= 6.7e+15))) tmp = -1.0 - (y * (-2.0 / x)); else tmp = (y - x) / (y - 2.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -40000000.0], N[Not[LessEqual[x, 6.7e+15]], $MachinePrecision]], N[(-1.0 - N[(y * N[(-2.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y - x), $MachinePrecision] / N[(y - 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -40000000 \lor \neg \left(x \leq 6.7 \cdot 10^{+15}\right):\\
\;\;\;\;-1 - y \cdot \frac{-2}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y - x}{y - 2}\\
\end{array}
\end{array}
if x < -4e7 or 6.7e15 < 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 77.9%
Simplified77.9%
Taylor expanded in y around inf 77.7%
associate-*r/77.7%
*-commutative77.7%
associate-/l*77.7%
Simplified77.7%
if -4e7 < x < 6.7e15Initial 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 98.4%
Final simplification88.9%
(FPCore (x y) :precision binary64 (if (<= x -3200000000.0) (- -1.0 (/ (+ 2.0 (* y -2.0)) x)) (if (<= x 5.6e+14) (/ (- y x) (- y 2.0)) (- -1.0 (* y (/ -2.0 x))))))
double code(double x, double y) {
double tmp;
if (x <= -3200000000.0) {
tmp = -1.0 - ((2.0 + (y * -2.0)) / x);
} else if (x <= 5.6e+14) {
tmp = (y - x) / (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 <= (-3200000000.0d0)) then
tmp = (-1.0d0) - ((2.0d0 + (y * (-2.0d0))) / x)
else if (x <= 5.6d+14) then
tmp = (y - x) / (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 <= -3200000000.0) {
tmp = -1.0 - ((2.0 + (y * -2.0)) / x);
} else if (x <= 5.6e+14) {
tmp = (y - x) / (y - 2.0);
} else {
tmp = -1.0 - (y * (-2.0 / x));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -3200000000.0: tmp = -1.0 - ((2.0 + (y * -2.0)) / x) elif x <= 5.6e+14: tmp = (y - x) / (y - 2.0) else: tmp = -1.0 - (y * (-2.0 / x)) return tmp
function code(x, y) tmp = 0.0 if (x <= -3200000000.0) tmp = Float64(-1.0 - Float64(Float64(2.0 + Float64(y * -2.0)) / x)); elseif (x <= 5.6e+14) tmp = Float64(Float64(y - x) / 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 <= -3200000000.0) tmp = -1.0 - ((2.0 + (y * -2.0)) / x); elseif (x <= 5.6e+14) tmp = (y - x) / (y - 2.0); else tmp = -1.0 - (y * (-2.0 / x)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -3200000000.0], N[(-1.0 - N[(N[(2.0 + N[(y * -2.0), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.6e+14], N[(N[(y - x), $MachinePrecision] / 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 -3200000000:\\
\;\;\;\;-1 - \frac{2 + y \cdot -2}{x}\\
\mathbf{elif}\;x \leq 5.6 \cdot 10^{+14}:\\
\;\;\;\;\frac{y - x}{y - 2}\\
\mathbf{else}:\\
\;\;\;\;-1 - y \cdot \frac{-2}{x}\\
\end{array}
\end{array}
if x < -3.2e9Initial 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 79.8%
Simplified79.8%
if -3.2e9 < x < 5.6e14Initial 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 98.4%
if 5.6e14 < 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 76.1%
Simplified76.1%
Taylor expanded in y around inf 76.1%
associate-*r/76.1%
*-commutative76.1%
associate-/l*76.1%
Simplified76.1%
Final simplification89.0%
(FPCore (x y) :precision binary64 (if (<= y -6e+52) 1.0 (if (<= y 6.7e-164) (/ x (- 2.0 x)) (/ y (- y 2.0)))))
double code(double x, double y) {
double tmp;
if (y <= -6e+52) {
tmp = 1.0;
} else if (y <= 6.7e-164) {
tmp = x / (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 (y <= (-6d+52)) then
tmp = 1.0d0
else if (y <= 6.7d-164) then
tmp = x / (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 (y <= -6e+52) {
tmp = 1.0;
} else if (y <= 6.7e-164) {
tmp = x / (2.0 - x);
} else {
tmp = y / (y - 2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -6e+52: tmp = 1.0 elif y <= 6.7e-164: tmp = x / (2.0 - x) else: tmp = y / (y - 2.0) return tmp
function code(x, y) tmp = 0.0 if (y <= -6e+52) tmp = 1.0; elseif (y <= 6.7e-164) tmp = Float64(x / 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 (y <= -6e+52) tmp = 1.0; elseif (y <= 6.7e-164) tmp = x / (2.0 - x); else tmp = y / (y - 2.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -6e+52], 1.0, If[LessEqual[y, 6.7e-164], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], N[(y / N[(y - 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6 \cdot 10^{+52}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 6.7 \cdot 10^{-164}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y - 2}\\
\end{array}
\end{array}
if y < -6e52Initial 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 80.9%
if -6e52 < y < 6.69999999999999999e-164Initial 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 80.1%
mul-1-neg80.1%
distribute-neg-frac280.1%
sub-neg80.1%
metadata-eval80.1%
distribute-neg-in80.1%
metadata-eval80.1%
+-commutative80.1%
unsub-neg80.1%
Simplified80.1%
if 6.69999999999999999e-164 < 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 x around 0 71.0%
Final simplification77.0%
(FPCore (x y) :precision binary64 (if (<= y -5.4e+52) 1.0 (if (<= y 5600.0) -1.0 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -5.4e+52) {
tmp = 1.0;
} else if (y <= 5600.0) {
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 <= (-5.4d+52)) then
tmp = 1.0d0
else if (y <= 5600.0d0) 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 <= -5.4e+52) {
tmp = 1.0;
} else if (y <= 5600.0) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -5.4e+52: tmp = 1.0 elif y <= 5600.0: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -5.4e+52) tmp = 1.0; elseif (y <= 5600.0) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -5.4e+52) tmp = 1.0; elseif (y <= 5600.0) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -5.4e+52], 1.0, If[LessEqual[y, 5600.0], -1.0, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.4 \cdot 10^{+52}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 5600:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -5.4e52 or 5600 < 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 79.4%
if -5.4e52 < y < 5600Initial 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 50.9%
Final simplification63.8%
(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 37.0%
Final simplification37.0%
(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 2024048
(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))))