
(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 99.9%
(FPCore (x y)
:precision binary64
(if (<= y -1e+85)
1.0
(if (<= y -1.25e-278)
-1.0
(if (<= y 1.9e-155) (* x 0.5) (if (<= y 3.25e+31) -1.0 1.0)))))
double code(double x, double y) {
double tmp;
if (y <= -1e+85) {
tmp = 1.0;
} else if (y <= -1.25e-278) {
tmp = -1.0;
} else if (y <= 1.9e-155) {
tmp = x * 0.5;
} else if (y <= 3.25e+31) {
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 <= (-1d+85)) then
tmp = 1.0d0
else if (y <= (-1.25d-278)) then
tmp = -1.0d0
else if (y <= 1.9d-155) then
tmp = x * 0.5d0
else if (y <= 3.25d+31) 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 <= -1e+85) {
tmp = 1.0;
} else if (y <= -1.25e-278) {
tmp = -1.0;
} else if (y <= 1.9e-155) {
tmp = x * 0.5;
} else if (y <= 3.25e+31) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1e+85: tmp = 1.0 elif y <= -1.25e-278: tmp = -1.0 elif y <= 1.9e-155: tmp = x * 0.5 elif y <= 3.25e+31: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -1e+85) tmp = 1.0; elseif (y <= -1.25e-278) tmp = -1.0; elseif (y <= 1.9e-155) tmp = Float64(x * 0.5); elseif (y <= 3.25e+31) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1e+85) tmp = 1.0; elseif (y <= -1.25e-278) tmp = -1.0; elseif (y <= 1.9e-155) tmp = x * 0.5; elseif (y <= 3.25e+31) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1e+85], 1.0, If[LessEqual[y, -1.25e-278], -1.0, If[LessEqual[y, 1.9e-155], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 3.25e+31], -1.0, 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \cdot 10^{+85}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -1.25 \cdot 10^{-278}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 1.9 \cdot 10^{-155}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;y \leq 3.25 \cdot 10^{+31}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1e85 or 3.2500000000000002e31 < y Initial program 99.9%
remove-double-neg99.9%
+-commutative99.9%
distribute-neg-frac299.9%
distribute-frac-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
metadata-eval99.9%
+-commutative99.9%
+-commutative99.9%
associate-+r+99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around inf 79.6%
if -1e85 < y < -1.24999999999999996e-278 or 1.8999999999999999e-155 < y < 3.2500000000000002e31Initial 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 58.9%
if -1.24999999999999996e-278 < y < 1.8999999999999999e-155Initial 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%
clear-num99.6%
inv-pow99.6%
+-commutative99.6%
associate-+l+99.6%
Applied egg-rr99.6%
unpow-199.6%
Applied egg-rr99.6%
Taylor expanded in y around 0 84.0%
associate-*r/84.0%
neg-mul-184.0%
neg-sub084.0%
associate-+l-84.0%
neg-sub084.0%
+-commutative84.0%
sub-neg84.0%
Simplified84.0%
Taylor expanded in x around 0 55.0%
Final simplification66.6%
(FPCore (x y) :precision binary64 (if (or (<= x -6500000.0) (not (<= x 7e+93))) (- -1.0 (/ (+ 2.0 (* y -2.0)) x)) (* (/ 1.0 (- y 2.0)) (- y x))))
double code(double x, double y) {
double tmp;
if ((x <= -6500000.0) || !(x <= 7e+93)) {
tmp = -1.0 - ((2.0 + (y * -2.0)) / x);
} else {
tmp = (1.0 / (y - 2.0)) * (y - x);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-6500000.0d0)) .or. (.not. (x <= 7d+93))) then
tmp = (-1.0d0) - ((2.0d0 + (y * (-2.0d0))) / x)
else
tmp = (1.0d0 / (y - 2.0d0)) * (y - x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -6500000.0) || !(x <= 7e+93)) {
tmp = -1.0 - ((2.0 + (y * -2.0)) / x);
} else {
tmp = (1.0 / (y - 2.0)) * (y - x);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -6500000.0) or not (x <= 7e+93): tmp = -1.0 - ((2.0 + (y * -2.0)) / x) else: tmp = (1.0 / (y - 2.0)) * (y - x) return tmp
function code(x, y) tmp = 0.0 if ((x <= -6500000.0) || !(x <= 7e+93)) tmp = Float64(-1.0 - Float64(Float64(2.0 + Float64(y * -2.0)) / x)); else tmp = Float64(Float64(1.0 / Float64(y - 2.0)) * Float64(y - x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -6500000.0) || ~((x <= 7e+93))) tmp = -1.0 - ((2.0 + (y * -2.0)) / x); else tmp = (1.0 / (y - 2.0)) * (y - x); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -6500000.0], N[Not[LessEqual[x, 7e+93]], $MachinePrecision]], N[(-1.0 - N[(N[(2.0 + N[(y * -2.0), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(y - 2.0), $MachinePrecision]), $MachinePrecision] * N[(y - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6500000 \lor \neg \left(x \leq 7 \cdot 10^{+93}\right):\\
\;\;\;\;-1 - \frac{2 + y \cdot -2}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y - 2} \cdot \left(y - x\right)\\
\end{array}
\end{array}
if x < -6.5e6 or 6.99999999999999996e93 < x Initial program 99.9%
remove-double-neg99.9%
+-commutative99.9%
distribute-neg-frac299.9%
distribute-frac-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
metadata-eval99.9%
+-commutative99.9%
+-commutative99.9%
associate-+r+99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around inf 79.0%
sub-neg79.0%
+-commutative79.0%
distribute-neg-in79.0%
metadata-eval79.0%
mul-1-neg79.0%
remove-double-neg79.0%
associate-+l+79.0%
remove-double-neg79.0%
mul-1-neg79.0%
neg-sub079.0%
associate--r-79.0%
associate-*r/79.0%
sub-neg79.0%
metadata-eval79.0%
+-commutative79.0%
distribute-lft-in79.0%
metadata-eval79.0%
div-sub79.0%
Simplified79.0%
if -6.5e6 < x < 6.99999999999999996e93Initial 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%
clear-num99.8%
associate-/r/99.8%
+-commutative99.8%
associate-+l+99.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 92.3%
Final simplification86.5%
(FPCore (x y)
:precision binary64
(if (<= x -50000.0)
(/ x (- 2.0 x))
(if (<= x 3.2e+107)
(* (/ 1.0 (- y 2.0)) (- y x))
(/ 1.0 (- -1.0 (/ y x))))))
double code(double x, double y) {
double tmp;
if (x <= -50000.0) {
tmp = x / (2.0 - x);
} else if (x <= 3.2e+107) {
tmp = (1.0 / (y - 2.0)) * (y - x);
} else {
tmp = 1.0 / (-1.0 - (y / x));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-50000.0d0)) then
tmp = x / (2.0d0 - x)
else if (x <= 3.2d+107) then
tmp = (1.0d0 / (y - 2.0d0)) * (y - x)
else
tmp = 1.0d0 / ((-1.0d0) - (y / x))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -50000.0) {
tmp = x / (2.0 - x);
} else if (x <= 3.2e+107) {
tmp = (1.0 / (y - 2.0)) * (y - x);
} else {
tmp = 1.0 / (-1.0 - (y / x));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -50000.0: tmp = x / (2.0 - x) elif x <= 3.2e+107: tmp = (1.0 / (y - 2.0)) * (y - x) else: tmp = 1.0 / (-1.0 - (y / x)) return tmp
function code(x, y) tmp = 0.0 if (x <= -50000.0) tmp = Float64(x / Float64(2.0 - x)); elseif (x <= 3.2e+107) tmp = Float64(Float64(1.0 / Float64(y - 2.0)) * Float64(y - x)); else tmp = Float64(1.0 / Float64(-1.0 - Float64(y / x))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -50000.0) tmp = x / (2.0 - x); elseif (x <= 3.2e+107) tmp = (1.0 / (y - 2.0)) * (y - x); else tmp = 1.0 / (-1.0 - (y / x)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -50000.0], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.2e+107], N[(N[(1.0 / N[(y - 2.0), $MachinePrecision]), $MachinePrecision] * N[(y - x), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(-1.0 - N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -50000:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{elif}\;x \leq 3.2 \cdot 10^{+107}:\\
\;\;\;\;\frac{1}{y - 2} \cdot \left(y - x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{-1 - \frac{y}{x}}\\
\end{array}
\end{array}
if x < -5e4Initial program 99.9%
remove-double-neg99.9%
+-commutative99.9%
distribute-neg-frac299.9%
distribute-frac-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
metadata-eval99.9%
+-commutative99.9%
+-commutative99.9%
associate-+r+99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around 0 77.2%
mul-1-neg77.2%
distribute-neg-frac277.2%
neg-sub077.2%
associate-+l-77.2%
neg-sub077.2%
+-commutative77.2%
unsub-neg77.2%
Simplified77.2%
if -5e4 < x < 3.20000000000000029e107Initial 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%
clear-num99.8%
associate-/r/99.8%
+-commutative99.8%
associate-+l+99.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 91.2%
if 3.20000000000000029e107 < x Initial program 99.9%
remove-double-neg99.9%
+-commutative99.9%
distribute-neg-frac299.9%
distribute-frac-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
metadata-eval99.9%
+-commutative99.9%
+-commutative99.9%
associate-+r+99.9%
metadata-eval99.9%
Simplified99.9%
clear-num99.9%
associate-/r/99.7%
+-commutative99.7%
associate-+l+99.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 81.5%
associate-*l/81.6%
*-un-lft-identity81.6%
clear-num81.6%
Applied egg-rr81.6%
Taylor expanded in x around inf 81.9%
sub-neg81.9%
metadata-eval81.9%
+-commutative81.9%
mul-1-neg81.9%
unsub-neg81.9%
Simplified81.9%
(FPCore (x y) :precision binary64 (if (or (<= y -1.15e+75) (not (<= y 6.8e+29))) (+ 1.0 (* -2.0 (/ x y))) (/ x (- 2.0 x))))
double code(double x, double y) {
double tmp;
if ((y <= -1.15e+75) || !(y <= 6.8e+29)) {
tmp = 1.0 + (-2.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+75)) .or. (.not. (y <= 6.8d+29))) then
tmp = 1.0d0 + ((-2.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+75) || !(y <= 6.8e+29)) {
tmp = 1.0 + (-2.0 * (x / y));
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.15e+75) or not (y <= 6.8e+29): tmp = 1.0 + (-2.0 * (x / y)) else: tmp = x / (2.0 - x) return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.15e+75) || !(y <= 6.8e+29)) tmp = Float64(1.0 + Float64(-2.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+75) || ~((y <= 6.8e+29))) tmp = 1.0 + (-2.0 * (x / y)); else tmp = x / (2.0 - x); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1.15e+75], N[Not[LessEqual[y, 6.8e+29]], $MachinePrecision]], N[(1.0 + N[(-2.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.15 \cdot 10^{+75} \lor \neg \left(y \leq 6.8 \cdot 10^{+29}\right):\\
\;\;\;\;1 + -2 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 - x}\\
\end{array}
\end{array}
if y < -1.1499999999999999e75 or 6.79999999999999963e29 < y Initial program 99.9%
remove-double-neg99.9%
+-commutative99.9%
distribute-neg-frac299.9%
distribute-frac-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
metadata-eval99.9%
+-commutative99.9%
+-commutative99.9%
associate-+r+99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around inf 79.8%
associate--l+79.8%
+-commutative79.8%
mul-1-neg79.8%
unsub-neg79.8%
associate-*r/79.8%
metadata-eval79.8%
div-sub79.8%
unsub-neg79.8%
mul-1-neg79.8%
div-sub79.8%
mul-1-neg79.8%
associate--l+79.8%
sub-neg79.8%
mul-1-neg79.8%
mul-1-neg79.8%
distribute-rgt-out79.8%
metadata-eval79.8%
Simplified79.8%
Taylor expanded in x around inf 79.8%
*-commutative79.8%
Simplified79.8%
if -1.1499999999999999e75 < y < 6.79999999999999963e29Initial 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 74.2%
mul-1-neg74.2%
distribute-neg-frac274.2%
neg-sub074.2%
associate-+l-74.2%
neg-sub074.2%
+-commutative74.2%
unsub-neg74.2%
Simplified74.2%
Final simplification76.6%
(FPCore (x y) :precision binary64 (if (<= y -3.5e+84) 1.0 (if (<= y 5.8e+41) (/ x (- 2.0 x)) (/ y (- y 2.0)))))
double code(double x, double y) {
double tmp;
if (y <= -3.5e+84) {
tmp = 1.0;
} else if (y <= 5.8e+41) {
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 <= (-3.5d+84)) then
tmp = 1.0d0
else if (y <= 5.8d+41) 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 <= -3.5e+84) {
tmp = 1.0;
} else if (y <= 5.8e+41) {
tmp = x / (2.0 - x);
} else {
tmp = y / (y - 2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -3.5e+84: tmp = 1.0 elif y <= 5.8e+41: tmp = x / (2.0 - x) else: tmp = y / (y - 2.0) return tmp
function code(x, y) tmp = 0.0 if (y <= -3.5e+84) tmp = 1.0; elseif (y <= 5.8e+41) 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 <= -3.5e+84) tmp = 1.0; elseif (y <= 5.8e+41) tmp = x / (2.0 - x); else tmp = y / (y - 2.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -3.5e+84], 1.0, If[LessEqual[y, 5.8e+41], 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 -3.5 \cdot 10^{+84}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 5.8 \cdot 10^{+41}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y - 2}\\
\end{array}
\end{array}
if y < -3.4999999999999999e84Initial program 99.9%
remove-double-neg99.9%
+-commutative99.9%
distribute-neg-frac299.9%
distribute-frac-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
metadata-eval99.9%
+-commutative99.9%
+-commutative99.9%
associate-+r+99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around inf 81.3%
if -3.4999999999999999e84 < y < 5.79999999999999977e41Initial 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 73.5%
mul-1-neg73.5%
distribute-neg-frac273.5%
neg-sub073.5%
associate-+l-73.5%
neg-sub073.5%
+-commutative73.5%
unsub-neg73.5%
Simplified73.5%
if 5.79999999999999977e41 < y Initial program 99.9%
remove-double-neg99.9%
+-commutative99.9%
distribute-neg-frac299.9%
distribute-frac-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
metadata-eval99.9%
+-commutative99.9%
+-commutative99.9%
associate-+r+99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around 0 77.6%
(FPCore (x y) :precision binary64 (if (<= y -3.6e+84) 1.0 (if (<= y 3.7e+37) (/ x (- 2.0 x)) 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -3.6e+84) {
tmp = 1.0;
} else if (y <= 3.7e+37) {
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 <= (-3.6d+84)) then
tmp = 1.0d0
else if (y <= 3.7d+37) 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 <= -3.6e+84) {
tmp = 1.0;
} else if (y <= 3.7e+37) {
tmp = x / (2.0 - x);
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -3.6e+84: tmp = 1.0 elif y <= 3.7e+37: tmp = x / (2.0 - x) else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -3.6e+84) tmp = 1.0; elseif (y <= 3.7e+37) 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 <= -3.6e+84) tmp = 1.0; elseif (y <= 3.7e+37) tmp = x / (2.0 - x); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -3.6e+84], 1.0, If[LessEqual[y, 3.7e+37], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.6 \cdot 10^{+84}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 3.7 \cdot 10^{+37}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -3.5999999999999999e84 or 3.6999999999999999e37 < y Initial program 99.9%
remove-double-neg99.9%
+-commutative99.9%
distribute-neg-frac299.9%
distribute-frac-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
metadata-eval99.9%
+-commutative99.9%
+-commutative99.9%
associate-+r+99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around inf 79.6%
if -3.5999999999999999e84 < y < 3.6999999999999999e37Initial 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 73.5%
mul-1-neg73.5%
distribute-neg-frac273.5%
neg-sub073.5%
associate-+l-73.5%
neg-sub073.5%
+-commutative73.5%
unsub-neg73.5%
Simplified73.5%
(FPCore (x y) :precision binary64 (if (<= y -3.5e+84) 1.0 (if (<= y 1e+37) -1.0 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -3.5e+84) {
tmp = 1.0;
} else if (y <= 1e+37) {
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 <= (-3.5d+84)) then
tmp = 1.0d0
else if (y <= 1d+37) 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 <= -3.5e+84) {
tmp = 1.0;
} else if (y <= 1e+37) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -3.5e+84: tmp = 1.0 elif y <= 1e+37: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -3.5e+84) tmp = 1.0; elseif (y <= 1e+37) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -3.5e+84) tmp = 1.0; elseif (y <= 1e+37) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -3.5e+84], 1.0, If[LessEqual[y, 1e+37], -1.0, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.5 \cdot 10^{+84}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 10^{+37}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -3.4999999999999999e84 or 9.99999999999999954e36 < y Initial program 99.9%
remove-double-neg99.9%
+-commutative99.9%
distribute-neg-frac299.9%
distribute-frac-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
metadata-eval99.9%
+-commutative99.9%
+-commutative99.9%
associate-+r+99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around inf 79.6%
if -3.4999999999999999e84 < y < 9.99999999999999954e36Initial 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 52.0%
(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%
remove-double-neg99.9%
+-commutative99.9%
distribute-neg-frac299.9%
distribute-frac-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
metadata-eval99.9%
+-commutative99.9%
+-commutative99.9%
associate-+r+99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around inf 38.9%
(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 2024107
(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))))