
(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%
(FPCore (x y)
:precision binary64
(if (<= x -0.00186)
-1.0
(if (<= x 6.3e-153)
1.0
(if (<= x 1.5e-14) (/ x 2.0) (if (<= x 2.4e+101) 1.0 -1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -0.00186) {
tmp = -1.0;
} else if (x <= 6.3e-153) {
tmp = 1.0;
} else if (x <= 1.5e-14) {
tmp = x / 2.0;
} else if (x <= 2.4e+101) {
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 <= (-0.00186d0)) then
tmp = -1.0d0
else if (x <= 6.3d-153) then
tmp = 1.0d0
else if (x <= 1.5d-14) then
tmp = x / 2.0d0
else if (x <= 2.4d+101) 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 <= -0.00186) {
tmp = -1.0;
} else if (x <= 6.3e-153) {
tmp = 1.0;
} else if (x <= 1.5e-14) {
tmp = x / 2.0;
} else if (x <= 2.4e+101) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -0.00186: tmp = -1.0 elif x <= 6.3e-153: tmp = 1.0 elif x <= 1.5e-14: tmp = x / 2.0 elif x <= 2.4e+101: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -0.00186) tmp = -1.0; elseif (x <= 6.3e-153) tmp = 1.0; elseif (x <= 1.5e-14) tmp = Float64(x / 2.0); elseif (x <= 2.4e+101) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -0.00186) tmp = -1.0; elseif (x <= 6.3e-153) tmp = 1.0; elseif (x <= 1.5e-14) tmp = x / 2.0; elseif (x <= 2.4e+101) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -0.00186], -1.0, If[LessEqual[x, 6.3e-153], 1.0, If[LessEqual[x, 1.5e-14], N[(x / 2.0), $MachinePrecision], If[LessEqual[x, 2.4e+101], 1.0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.00186:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 6.3 \cdot 10^{-153}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 1.5 \cdot 10^{-14}:\\
\;\;\;\;\frac{x}{2}\\
\mathbf{elif}\;x \leq 2.4 \cdot 10^{+101}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -0.0018600000000000001 or 2.39999999999999988e101 < 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 86.5%
if -0.0018600000000000001 < x < 6.3000000000000004e-153 or 1.4999999999999999e-14 < x < 2.39999999999999988e101Initial 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 52.5%
if 6.3000000000000004e-153 < x < 1.4999999999999999e-14Initial 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 55.4%
mul-1-neg55.4%
distribute-neg-frac255.4%
neg-sub055.4%
associate-+l-55.4%
neg-sub055.4%
+-commutative55.4%
unsub-neg55.4%
Simplified55.4%
Taylor expanded in x around 0 55.2%
(FPCore (x y) :precision binary64 (if (or (<= x -2.0) (not (<= x 2.0))) (/ 1.0 (/ (+ x y) (- y x))) (/ (- y x) (- y 2.0))))
double code(double x, double y) {
double tmp;
if ((x <= -2.0) || !(x <= 2.0)) {
tmp = 1.0 / ((x + y) / (y - 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 <= (-2.0d0)) .or. (.not. (x <= 2.0d0))) then
tmp = 1.0d0 / ((x + y) / (y - 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 <= -2.0) || !(x <= 2.0)) {
tmp = 1.0 / ((x + y) / (y - x));
} else {
tmp = (y - x) / (y - 2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -2.0) or not (x <= 2.0): tmp = 1.0 / ((x + y) / (y - x)) else: tmp = (y - x) / (y - 2.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -2.0) || !(x <= 2.0)) tmp = Float64(1.0 / Float64(Float64(x + y) / Float64(y - 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 <= -2.0) || ~((x <= 2.0))) tmp = 1.0 / ((x + y) / (y - x)); else tmp = (y - x) / (y - 2.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -2.0], N[Not[LessEqual[x, 2.0]], $MachinePrecision]], N[(1.0 / N[(N[(x + y), $MachinePrecision] / N[(y - 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 -2 \lor \neg \left(x \leq 2\right):\\
\;\;\;\;\frac{1}{\frac{x + y}{y - x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{y - x}{y - 2}\\
\end{array}
\end{array}
if x < -2 or 2 < 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%
clear-num100.0%
inv-pow100.0%
+-commutative100.0%
associate-+l+100.0%
Applied egg-rr100.0%
unpow-1100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 98.6%
if -2 < x < 2Initial 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 99.0%
Final simplification98.8%
(FPCore (x y) :precision binary64 (if (<= x -1.02e-6) (/ (- x) (+ x (+ y -2.0))) (if (<= x 2.7e+25) (/ (- y x) (- y 2.0)) (/ (- y x) x))))
double code(double x, double y) {
double tmp;
if (x <= -1.02e-6) {
tmp = -x / (x + (y + -2.0));
} else if (x <= 2.7e+25) {
tmp = (y - x) / (y - 2.0);
} else {
tmp = (y - x) / 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.02d-6)) then
tmp = -x / (x + (y + (-2.0d0)))
else if (x <= 2.7d+25) then
tmp = (y - x) / (y - 2.0d0)
else
tmp = (y - x) / x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.02e-6) {
tmp = -x / (x + (y + -2.0));
} else if (x <= 2.7e+25) {
tmp = (y - x) / (y - 2.0);
} else {
tmp = (y - x) / x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.02e-6: tmp = -x / (x + (y + -2.0)) elif x <= 2.7e+25: tmp = (y - x) / (y - 2.0) else: tmp = (y - x) / x return tmp
function code(x, y) tmp = 0.0 if (x <= -1.02e-6) tmp = Float64(Float64(-x) / Float64(x + Float64(y + -2.0))); elseif (x <= 2.7e+25) tmp = Float64(Float64(y - x) / Float64(y - 2.0)); else tmp = Float64(Float64(y - x) / x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.02e-6) tmp = -x / (x + (y + -2.0)); elseif (x <= 2.7e+25) tmp = (y - x) / (y - 2.0); else tmp = (y - x) / x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.02e-6], N[((-x) / N[(x + N[(y + -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.7e+25], N[(N[(y - x), $MachinePrecision] / N[(y - 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(y - x), $MachinePrecision] / x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.02 \cdot 10^{-6}:\\
\;\;\;\;\frac{-x}{x + \left(y + -2\right)}\\
\mathbf{elif}\;x \leq 2.7 \cdot 10^{+25}:\\
\;\;\;\;\frac{y - x}{y - 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{y - x}{x}\\
\end{array}
\end{array}
if x < -1.02e-6Initial 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 87.6%
neg-mul-187.6%
Simplified87.6%
if -1.02e-6 < x < 2.7e25Initial 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.1%
if 2.7e25 < 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 78.2%
(FPCore (x y) :precision binary64 (if (<= x -0.00186) (/ x (- 2.0 x)) (if (<= x 1.1e+24) (/ (- y x) (- y 2.0)) (/ (- y x) x))))
double code(double x, double y) {
double tmp;
if (x <= -0.00186) {
tmp = x / (2.0 - x);
} else if (x <= 1.1e+24) {
tmp = (y - x) / (y - 2.0);
} else {
tmp = (y - x) / x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-0.00186d0)) then
tmp = x / (2.0d0 - x)
else if (x <= 1.1d+24) then
tmp = (y - x) / (y - 2.0d0)
else
tmp = (y - x) / x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -0.00186) {
tmp = x / (2.0 - x);
} else if (x <= 1.1e+24) {
tmp = (y - x) / (y - 2.0);
} else {
tmp = (y - x) / x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -0.00186: tmp = x / (2.0 - x) elif x <= 1.1e+24: tmp = (y - x) / (y - 2.0) else: tmp = (y - x) / x return tmp
function code(x, y) tmp = 0.0 if (x <= -0.00186) tmp = Float64(x / Float64(2.0 - x)); elseif (x <= 1.1e+24) tmp = Float64(Float64(y - x) / Float64(y - 2.0)); else tmp = Float64(Float64(y - x) / x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -0.00186) tmp = x / (2.0 - x); elseif (x <= 1.1e+24) tmp = (y - x) / (y - 2.0); else tmp = (y - x) / x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -0.00186], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.1e+24], N[(N[(y - x), $MachinePrecision] / N[(y - 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(y - x), $MachinePrecision] / x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.00186:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{elif}\;x \leq 1.1 \cdot 10^{+24}:\\
\;\;\;\;\frac{y - x}{y - 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{y - x}{x}\\
\end{array}
\end{array}
if x < -0.0018600000000000001Initial 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 87.5%
mul-1-neg87.5%
distribute-neg-frac287.5%
neg-sub087.5%
associate-+l-87.5%
neg-sub087.5%
+-commutative87.5%
unsub-neg87.5%
Simplified87.5%
if -0.0018600000000000001 < x < 1.10000000000000001e24Initial 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.1%
if 1.10000000000000001e24 < 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 78.2%
(FPCore (x y) :precision binary64 (if (or (<= x -1.05e-6) (not (<= x 2.3e-48))) (/ x (- 2.0 x)) (/ y (- y 2.0))))
double code(double x, double y) {
double tmp;
if ((x <= -1.05e-6) || !(x <= 2.3e-48)) {
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.05d-6)) .or. (.not. (x <= 2.3d-48))) 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.05e-6) || !(x <= 2.3e-48)) {
tmp = x / (2.0 - x);
} else {
tmp = y / (y - 2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.05e-6) or not (x <= 2.3e-48): tmp = x / (2.0 - x) else: tmp = y / (y - 2.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.05e-6) || !(x <= 2.3e-48)) 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.05e-6) || ~((x <= 2.3e-48))) tmp = x / (2.0 - x); else tmp = y / (y - 2.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.05e-6], N[Not[LessEqual[x, 2.3e-48]], $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.05 \cdot 10^{-6} \lor \neg \left(x \leq 2.3 \cdot 10^{-48}\right):\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y - 2}\\
\end{array}
\end{array}
if x < -1.0499999999999999e-6 or 2.3000000000000001e-48 < 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 79.1%
mul-1-neg79.1%
distribute-neg-frac279.1%
neg-sub079.1%
associate-+l-79.1%
neg-sub079.1%
+-commutative79.1%
unsub-neg79.1%
Simplified79.1%
if -1.0499999999999999e-6 < x < 2.3000000000000001e-48Initial 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 79.2%
Final simplification79.2%
(FPCore (x y) :precision binary64 (if (<= y -3.5e+88) 1.0 (if (<= y 66000000000000.0) (/ x (- 2.0 x)) 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -3.5e+88) {
tmp = 1.0;
} else if (y <= 66000000000000.0) {
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.5d+88)) then
tmp = 1.0d0
else if (y <= 66000000000000.0d0) 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.5e+88) {
tmp = 1.0;
} else if (y <= 66000000000000.0) {
tmp = x / (2.0 - x);
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -3.5e+88: tmp = 1.0 elif y <= 66000000000000.0: tmp = x / (2.0 - x) else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -3.5e+88) tmp = 1.0; elseif (y <= 66000000000000.0) 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.5e+88) tmp = 1.0; elseif (y <= 66000000000000.0) tmp = x / (2.0 - x); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -3.5e+88], 1.0, If[LessEqual[y, 66000000000000.0], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.5 \cdot 10^{+88}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 66000000000000:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -3.4999999999999998e88 or 6.6e13 < 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 73.0%
if -3.4999999999999998e88 < y < 6.6e13Initial 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 68.6%
mul-1-neg68.6%
distribute-neg-frac268.6%
neg-sub068.6%
associate-+l-68.6%
neg-sub068.6%
+-commutative68.6%
unsub-neg68.6%
Simplified68.6%
(FPCore (x y) :precision binary64 (if (<= x -0.00186) -1.0 (if (<= x 2.3e+101) 1.0 -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -0.00186) {
tmp = -1.0;
} else if (x <= 2.3e+101) {
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 <= (-0.00186d0)) then
tmp = -1.0d0
else if (x <= 2.3d+101) 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 <= -0.00186) {
tmp = -1.0;
} else if (x <= 2.3e+101) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -0.00186: tmp = -1.0 elif x <= 2.3e+101: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -0.00186) tmp = -1.0; elseif (x <= 2.3e+101) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -0.00186) tmp = -1.0; elseif (x <= 2.3e+101) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -0.00186], -1.0, If[LessEqual[x, 2.3e+101], 1.0, -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.00186:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 2.3 \cdot 10^{+101}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -0.0018600000000000001 or 2.3000000000000001e101 < 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 86.5%
if -0.0018600000000000001 < x < 2.3000000000000001e101Initial 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 47.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 39.3%
(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 2024137
(FPCore (x y)
:name "Data.Colour.RGB:hslsv from colour-2.3.3, C"
:precision binary64
:alt
(! :herbie-platform default (- (/ x (- 2 (+ x y))) (/ y (- 2 (+ x y)))))
(/ (- x y) (- 2.0 (+ x y))))