
(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 7 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%
(FPCore (x y)
:precision binary64
(if (<= x -1.12e+118)
(- -1.0 (/ (* y -2.0) x))
(if (<= x -4e+55)
(+ 1.0 (/ (* x -2.0) y))
(if (or (<= x -9.8e-26) (not (<= x 1.25e-29)))
(/ x (- 2.0 x))
(/ y (- y 2.0))))))
double code(double x, double y) {
double tmp;
if (x <= -1.12e+118) {
tmp = -1.0 - ((y * -2.0) / x);
} else if (x <= -4e+55) {
tmp = 1.0 + ((x * -2.0) / y);
} else if ((x <= -9.8e-26) || !(x <= 1.25e-29)) {
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 (x <= (-1.12d+118)) then
tmp = (-1.0d0) - ((y * (-2.0d0)) / x)
else if (x <= (-4d+55)) then
tmp = 1.0d0 + ((x * (-2.0d0)) / y)
else if ((x <= (-9.8d-26)) .or. (.not. (x <= 1.25d-29))) 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 (x <= -1.12e+118) {
tmp = -1.0 - ((y * -2.0) / x);
} else if (x <= -4e+55) {
tmp = 1.0 + ((x * -2.0) / y);
} else if ((x <= -9.8e-26) || !(x <= 1.25e-29)) {
tmp = x / (2.0 - x);
} else {
tmp = y / (y - 2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.12e+118: tmp = -1.0 - ((y * -2.0) / x) elif x <= -4e+55: tmp = 1.0 + ((x * -2.0) / y) elif (x <= -9.8e-26) or not (x <= 1.25e-29): tmp = x / (2.0 - x) else: tmp = y / (y - 2.0) return tmp
function code(x, y) tmp = 0.0 if (x <= -1.12e+118) tmp = Float64(-1.0 - Float64(Float64(y * -2.0) / x)); elseif (x <= -4e+55) tmp = Float64(1.0 + Float64(Float64(x * -2.0) / y)); elseif ((x <= -9.8e-26) || !(x <= 1.25e-29)) 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 (x <= -1.12e+118) tmp = -1.0 - ((y * -2.0) / x); elseif (x <= -4e+55) tmp = 1.0 + ((x * -2.0) / y); elseif ((x <= -9.8e-26) || ~((x <= 1.25e-29))) tmp = x / (2.0 - x); else tmp = y / (y - 2.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.12e+118], N[(-1.0 - N[(N[(y * -2.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -4e+55], N[(1.0 + N[(N[(x * -2.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, -9.8e-26], N[Not[LessEqual[x, 1.25e-29]], $MachinePrecision]], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], N[(y / N[(y - 2.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.12 \cdot 10^{+118}:\\
\;\;\;\;-1 - \frac{y \cdot -2}{x}\\
\mathbf{elif}\;x \leq -4 \cdot 10^{+55}:\\
\;\;\;\;1 + \frac{x \cdot -2}{y}\\
\mathbf{elif}\;x \leq -9.8 \cdot 10^{-26} \lor \neg \left(x \leq 1.25 \cdot 10^{-29}\right):\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y - 2}\\
\end{array}
\end{array}
if x < -1.11999999999999999e118Initial 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 90.1%
sub-neg90.1%
+-commutative90.1%
distribute-neg-in90.1%
metadata-eval90.1%
mul-1-neg90.1%
remove-double-neg90.1%
associate-+l+90.1%
remove-double-neg90.1%
mul-1-neg90.1%
neg-sub090.1%
associate--r-90.1%
associate-*r/90.1%
sub-neg90.1%
metadata-eval90.1%
+-commutative90.1%
distribute-lft-in90.1%
metadata-eval90.1%
div-sub90.1%
Simplified90.1%
Taylor expanded in y around inf 90.1%
associate-*r/90.1%
*-commutative90.1%
Simplified90.1%
if -1.11999999999999999e118 < x < -4.00000000000000004e55Initial 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 83.7%
associate--l+83.7%
+-commutative83.7%
mul-1-neg83.7%
unsub-neg83.7%
associate-*r/83.7%
metadata-eval83.7%
div-sub83.7%
unsub-neg83.7%
mul-1-neg83.7%
div-sub83.7%
mul-1-neg83.7%
associate--l+83.7%
sub-neg83.7%
mul-1-neg83.7%
mul-1-neg83.7%
distribute-rgt-out83.7%
metadata-eval83.7%
Simplified83.7%
Taylor expanded in x around inf 83.7%
associate-*r/83.7%
*-commutative83.7%
Simplified83.7%
if -4.00000000000000004e55 < x < -9.7999999999999998e-26 or 1.24999999999999996e-29 < 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 y around 0 81.0%
mul-1-neg81.0%
distribute-neg-frac281.0%
neg-sub081.0%
associate-+l-81.0%
neg-sub081.0%
+-commutative81.0%
unsub-neg81.0%
Simplified81.0%
if -9.7999999999999998e-26 < x < 1.24999999999999996e-29Initial 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 81.7%
Final simplification83.2%
(FPCore (x y) :precision binary64 (if (<= x -1.12e+118) (- -1.0 (/ (* y -2.0) x)) (if (<= x 2.6e-9) (* (/ 1.0 (- y 2.0)) (- y x)) (/ x (- 2.0 x)))))
double code(double x, double y) {
double tmp;
if (x <= -1.12e+118) {
tmp = -1.0 - ((y * -2.0) / x);
} else if (x <= 2.6e-9) {
tmp = (1.0 / (y - 2.0)) * (y - x);
} 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 (x <= (-1.12d+118)) then
tmp = (-1.0d0) - ((y * (-2.0d0)) / x)
else if (x <= 2.6d-9) then
tmp = (1.0d0 / (y - 2.0d0)) * (y - x)
else
tmp = x / (2.0d0 - x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.12e+118) {
tmp = -1.0 - ((y * -2.0) / x);
} else if (x <= 2.6e-9) {
tmp = (1.0 / (y - 2.0)) * (y - x);
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.12e+118: tmp = -1.0 - ((y * -2.0) / x) elif x <= 2.6e-9: tmp = (1.0 / (y - 2.0)) * (y - x) else: tmp = x / (2.0 - x) return tmp
function code(x, y) tmp = 0.0 if (x <= -1.12e+118) tmp = Float64(-1.0 - Float64(Float64(y * -2.0) / x)); elseif (x <= 2.6e-9) tmp = Float64(Float64(1.0 / Float64(y - 2.0)) * Float64(y - x)); else tmp = Float64(x / Float64(2.0 - x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.12e+118) tmp = -1.0 - ((y * -2.0) / x); elseif (x <= 2.6e-9) tmp = (1.0 / (y - 2.0)) * (y - x); else tmp = x / (2.0 - x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.12e+118], N[(-1.0 - N[(N[(y * -2.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.6e-9], N[(N[(1.0 / N[(y - 2.0), $MachinePrecision]), $MachinePrecision] * N[(y - x), $MachinePrecision]), $MachinePrecision], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.12 \cdot 10^{+118}:\\
\;\;\;\;-1 - \frac{y \cdot -2}{x}\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{-9}:\\
\;\;\;\;\frac{1}{y - 2} \cdot \left(y - x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 - x}\\
\end{array}
\end{array}
if x < -1.11999999999999999e118Initial 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 90.1%
sub-neg90.1%
+-commutative90.1%
distribute-neg-in90.1%
metadata-eval90.1%
mul-1-neg90.1%
remove-double-neg90.1%
associate-+l+90.1%
remove-double-neg90.1%
mul-1-neg90.1%
neg-sub090.1%
associate--r-90.1%
associate-*r/90.1%
sub-neg90.1%
metadata-eval90.1%
+-commutative90.1%
distribute-lft-in90.1%
metadata-eval90.1%
div-sub90.1%
Simplified90.1%
Taylor expanded in y around inf 90.1%
associate-*r/90.1%
*-commutative90.1%
Simplified90.1%
if -1.11999999999999999e118 < x < 2.6000000000000001e-9Initial 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 2.6000000000000001e-9 < 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 y around 0 83.7%
mul-1-neg83.7%
distribute-neg-frac283.7%
neg-sub083.7%
associate-+l-83.7%
neg-sub083.7%
+-commutative83.7%
unsub-neg83.7%
Simplified83.7%
(FPCore (x y) :precision binary64 (if (or (<= x -1.2e-24) (not (<= x 1.1e-29))) (/ x (- 2.0 x)) (/ y (- y 2.0))))
double code(double x, double y) {
double tmp;
if ((x <= -1.2e-24) || !(x <= 1.1e-29)) {
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 ((x <= (-1.2d-24)) .or. (.not. (x <= 1.1d-29))) 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 ((x <= -1.2e-24) || !(x <= 1.1e-29)) {
tmp = x / (2.0 - x);
} else {
tmp = y / (y - 2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.2e-24) or not (x <= 1.1e-29): tmp = x / (2.0 - x) else: tmp = y / (y - 2.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.2e-24) || !(x <= 1.1e-29)) 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 ((x <= -1.2e-24) || ~((x <= 1.1e-29))) tmp = x / (2.0 - x); else tmp = y / (y - 2.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.2e-24], N[Not[LessEqual[x, 1.1e-29]], $MachinePrecision]], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], N[(y / N[(y - 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.2 \cdot 10^{-24} \lor \neg \left(x \leq 1.1 \cdot 10^{-29}\right):\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y - 2}\\
\end{array}
\end{array}
if x < -1.1999999999999999e-24 or 1.09999999999999995e-29 < 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 y around 0 78.7%
mul-1-neg78.7%
distribute-neg-frac278.7%
neg-sub078.7%
associate-+l-78.7%
neg-sub078.7%
+-commutative78.7%
unsub-neg78.7%
Simplified78.7%
if -1.1999999999999999e-24 < x < 1.09999999999999995e-29Initial 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 81.7%
Final simplification79.9%
(FPCore (x y) :precision binary64 (if (<= y -5e+15) 1.0 (if (<= y 6.2e+56) (/ x (- 2.0 x)) 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -5e+15) {
tmp = 1.0;
} else if (y <= 6.2e+56) {
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 <= (-5d+15)) then
tmp = 1.0d0
else if (y <= 6.2d+56) 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 <= -5e+15) {
tmp = 1.0;
} else if (y <= 6.2e+56) {
tmp = x / (2.0 - x);
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -5e+15: tmp = 1.0 elif y <= 6.2e+56: tmp = x / (2.0 - x) else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -5e+15) tmp = 1.0; elseif (y <= 6.2e+56) 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 <= -5e+15) tmp = 1.0; elseif (y <= 6.2e+56) tmp = x / (2.0 - x); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -5e+15], 1.0, If[LessEqual[y, 6.2e+56], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{+15}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 6.2 \cdot 10^{+56}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -5e15 or 6.20000000000000009e56 < 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 74.3%
if -5e15 < y < 6.20000000000000009e56Initial 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.3%
mul-1-neg74.3%
distribute-neg-frac274.3%
neg-sub074.3%
associate-+l-74.3%
neg-sub074.3%
+-commutative74.3%
unsub-neg74.3%
Simplified74.3%
(FPCore (x y) :precision binary64 (if (<= x -1.12e+118) -1.0 (if (<= x 9500000000000.0) 1.0 -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -1.12e+118) {
tmp = -1.0;
} else if (x <= 9500000000000.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 (x <= (-1.12d+118)) then
tmp = -1.0d0
else if (x <= 9500000000000.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 (x <= -1.12e+118) {
tmp = -1.0;
} else if (x <= 9500000000000.0) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.12e+118: tmp = -1.0 elif x <= 9500000000000.0: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.12e+118) tmp = -1.0; elseif (x <= 9500000000000.0) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.12e+118) tmp = -1.0; elseif (x <= 9500000000000.0) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.12e+118], -1.0, If[LessEqual[x, 9500000000000.0], 1.0, -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.12 \cdot 10^{+118}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 9500000000000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -1.11999999999999999e118 or 9.5e12 < 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 87.3%
if -1.11999999999999999e118 < x < 9.5e12Initial 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 48.6%
(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 44.4%
(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 2024106
(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))))