
(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 11 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
(let* ((t_0 (+ (/ y x) -1.0)))
(if (<= x -15500000000.0)
t_0
(if (<= x -9.2e-144)
(- 1.0 (/ x y))
(if (<= x 5.1e-263) (/ y -2.0) (if (<= x 2.2e+42) 1.0 t_0))))))
double code(double x, double y) {
double t_0 = (y / x) + -1.0;
double tmp;
if (x <= -15500000000.0) {
tmp = t_0;
} else if (x <= -9.2e-144) {
tmp = 1.0 - (x / y);
} else if (x <= 5.1e-263) {
tmp = y / -2.0;
} else if (x <= 2.2e+42) {
tmp = 1.0;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = (y / x) + (-1.0d0)
if (x <= (-15500000000.0d0)) then
tmp = t_0
else if (x <= (-9.2d-144)) then
tmp = 1.0d0 - (x / y)
else if (x <= 5.1d-263) then
tmp = y / (-2.0d0)
else if (x <= 2.2d+42) then
tmp = 1.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (y / x) + -1.0;
double tmp;
if (x <= -15500000000.0) {
tmp = t_0;
} else if (x <= -9.2e-144) {
tmp = 1.0 - (x / y);
} else if (x <= 5.1e-263) {
tmp = y / -2.0;
} else if (x <= 2.2e+42) {
tmp = 1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (y / x) + -1.0 tmp = 0 if x <= -15500000000.0: tmp = t_0 elif x <= -9.2e-144: tmp = 1.0 - (x / y) elif x <= 5.1e-263: tmp = y / -2.0 elif x <= 2.2e+42: tmp = 1.0 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(y / x) + -1.0) tmp = 0.0 if (x <= -15500000000.0) tmp = t_0; elseif (x <= -9.2e-144) tmp = Float64(1.0 - Float64(x / y)); elseif (x <= 5.1e-263) tmp = Float64(y / -2.0); elseif (x <= 2.2e+42) tmp = 1.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (y / x) + -1.0; tmp = 0.0; if (x <= -15500000000.0) tmp = t_0; elseif (x <= -9.2e-144) tmp = 1.0 - (x / y); elseif (x <= 5.1e-263) tmp = y / -2.0; elseif (x <= 2.2e+42) tmp = 1.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(y / x), $MachinePrecision] + -1.0), $MachinePrecision]}, If[LessEqual[x, -15500000000.0], t$95$0, If[LessEqual[x, -9.2e-144], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.1e-263], N[(y / -2.0), $MachinePrecision], If[LessEqual[x, 2.2e+42], 1.0, t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{x} + -1\\
\mathbf{if}\;x \leq -15500000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -9.2 \cdot 10^{-144}:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{elif}\;x \leq 5.1 \cdot 10^{-263}:\\
\;\;\;\;\frac{y}{-2}\\
\mathbf{elif}\;x \leq 2.2 \cdot 10^{+42}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.55e10 or 2.2000000000000001e42 < x Initial program 100.0%
Taylor expanded in x around inf 83.3%
mul-1-neg83.3%
Simplified83.3%
Taylor expanded in x around inf 83.3%
if -1.55e10 < x < -9.2e-144Initial program 99.8%
Taylor expanded in x around inf 87.7%
Taylor expanded in y around inf 55.7%
neg-mul-155.7%
Simplified55.7%
Taylor expanded in x around 0 55.7%
mul-1-neg55.7%
unsub-neg55.7%
Simplified55.7%
if -9.2e-144 < x < 5.09999999999999971e-263Initial program 100.0%
Taylor expanded in x around 0 81.4%
mul-1-neg81.4%
distribute-neg-frac281.4%
mul-1-neg81.4%
sub-neg81.4%
+-commutative81.4%
distribute-lft-in81.4%
neg-mul-181.4%
remove-double-neg81.4%
metadata-eval81.4%
Simplified81.4%
Taylor expanded in y around 0 52.1%
if 5.09999999999999971e-263 < x < 2.2000000000000001e42Initial program 100.0%
Taylor expanded in y around inf 54.4%
Final simplification66.9%
(FPCore (x y)
:precision binary64
(if (<= x -22000000000.0)
-1.0
(if (<= x -3.8e-142)
(- 1.0 (/ x y))
(if (<= x 3.05e-266) (/ y -2.0) (if (<= x 2.75e+49) 1.0 -1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -22000000000.0) {
tmp = -1.0;
} else if (x <= -3.8e-142) {
tmp = 1.0 - (x / y);
} else if (x <= 3.05e-266) {
tmp = y / -2.0;
} else if (x <= 2.75e+49) {
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 <= (-22000000000.0d0)) then
tmp = -1.0d0
else if (x <= (-3.8d-142)) then
tmp = 1.0d0 - (x / y)
else if (x <= 3.05d-266) then
tmp = y / (-2.0d0)
else if (x <= 2.75d+49) 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 <= -22000000000.0) {
tmp = -1.0;
} else if (x <= -3.8e-142) {
tmp = 1.0 - (x / y);
} else if (x <= 3.05e-266) {
tmp = y / -2.0;
} else if (x <= 2.75e+49) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -22000000000.0: tmp = -1.0 elif x <= -3.8e-142: tmp = 1.0 - (x / y) elif x <= 3.05e-266: tmp = y / -2.0 elif x <= 2.75e+49: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -22000000000.0) tmp = -1.0; elseif (x <= -3.8e-142) tmp = Float64(1.0 - Float64(x / y)); elseif (x <= 3.05e-266) tmp = Float64(y / -2.0); elseif (x <= 2.75e+49) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -22000000000.0) tmp = -1.0; elseif (x <= -3.8e-142) tmp = 1.0 - (x / y); elseif (x <= 3.05e-266) tmp = y / -2.0; elseif (x <= 2.75e+49) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -22000000000.0], -1.0, If[LessEqual[x, -3.8e-142], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.05e-266], N[(y / -2.0), $MachinePrecision], If[LessEqual[x, 2.75e+49], 1.0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -22000000000:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -3.8 \cdot 10^{-142}:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{elif}\;x \leq 3.05 \cdot 10^{-266}:\\
\;\;\;\;\frac{y}{-2}\\
\mathbf{elif}\;x \leq 2.75 \cdot 10^{+49}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -2.2e10 or 2.75000000000000021e49 < x Initial program 100.0%
Taylor expanded in x around inf 83.3%
if -2.2e10 < x < -3.79999999999999972e-142Initial program 99.8%
Taylor expanded in x around inf 87.7%
Taylor expanded in y around inf 55.7%
neg-mul-155.7%
Simplified55.7%
Taylor expanded in x around 0 55.7%
mul-1-neg55.7%
unsub-neg55.7%
Simplified55.7%
if -3.79999999999999972e-142 < x < 3.05e-266Initial program 100.0%
Taylor expanded in x around 0 81.4%
mul-1-neg81.4%
distribute-neg-frac281.4%
mul-1-neg81.4%
sub-neg81.4%
+-commutative81.4%
distribute-lft-in81.4%
neg-mul-181.4%
remove-double-neg81.4%
metadata-eval81.4%
Simplified81.4%
Taylor expanded in y around 0 52.1%
if 3.05e-266 < x < 2.75000000000000021e49Initial program 100.0%
Taylor expanded in y around inf 54.3%
(FPCore (x y)
:precision binary64
(if (<= x -13500000000.0)
-1.0
(if (<= x -1.02e-143)
1.0
(if (<= x 8.2e-265) (/ y -2.0) (if (<= x 2.75e+49) 1.0 -1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -13500000000.0) {
tmp = -1.0;
} else if (x <= -1.02e-143) {
tmp = 1.0;
} else if (x <= 8.2e-265) {
tmp = y / -2.0;
} else if (x <= 2.75e+49) {
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 <= (-13500000000.0d0)) then
tmp = -1.0d0
else if (x <= (-1.02d-143)) then
tmp = 1.0d0
else if (x <= 8.2d-265) then
tmp = y / (-2.0d0)
else if (x <= 2.75d+49) 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 <= -13500000000.0) {
tmp = -1.0;
} else if (x <= -1.02e-143) {
tmp = 1.0;
} else if (x <= 8.2e-265) {
tmp = y / -2.0;
} else if (x <= 2.75e+49) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -13500000000.0: tmp = -1.0 elif x <= -1.02e-143: tmp = 1.0 elif x <= 8.2e-265: tmp = y / -2.0 elif x <= 2.75e+49: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -13500000000.0) tmp = -1.0; elseif (x <= -1.02e-143) tmp = 1.0; elseif (x <= 8.2e-265) tmp = Float64(y / -2.0); elseif (x <= 2.75e+49) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -13500000000.0) tmp = -1.0; elseif (x <= -1.02e-143) tmp = 1.0; elseif (x <= 8.2e-265) tmp = y / -2.0; elseif (x <= 2.75e+49) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -13500000000.0], -1.0, If[LessEqual[x, -1.02e-143], 1.0, If[LessEqual[x, 8.2e-265], N[(y / -2.0), $MachinePrecision], If[LessEqual[x, 2.75e+49], 1.0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -13500000000:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -1.02 \cdot 10^{-143}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 8.2 \cdot 10^{-265}:\\
\;\;\;\;\frac{y}{-2}\\
\mathbf{elif}\;x \leq 2.75 \cdot 10^{+49}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -1.35e10 or 2.75000000000000021e49 < x Initial program 100.0%
Taylor expanded in x around inf 83.3%
if -1.35e10 < x < -1.02e-143 or 8.2e-265 < x < 2.75000000000000021e49Initial program 99.9%
Taylor expanded in y around inf 54.6%
if -1.02e-143 < x < 8.2e-265Initial program 100.0%
Taylor expanded in x around 0 81.4%
mul-1-neg81.4%
distribute-neg-frac281.4%
mul-1-neg81.4%
sub-neg81.4%
+-commutative81.4%
distribute-lft-in81.4%
neg-mul-181.4%
remove-double-neg81.4%
metadata-eval81.4%
Simplified81.4%
Taylor expanded in y around 0 52.1%
(FPCore (x y) :precision binary64 (if (or (<= x -29000000000.0) (not (<= x 2.6))) (/ x (- 2.0 (+ x y))) (/ y (+ y -2.0))))
double code(double x, double y) {
double tmp;
if ((x <= -29000000000.0) || !(x <= 2.6)) {
tmp = x / (2.0 - (x + y));
} 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 <= (-29000000000.0d0)) .or. (.not. (x <= 2.6d0))) then
tmp = x / (2.0d0 - (x + y))
else
tmp = y / (y + (-2.0d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -29000000000.0) || !(x <= 2.6)) {
tmp = x / (2.0 - (x + y));
} else {
tmp = y / (y + -2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -29000000000.0) or not (x <= 2.6): tmp = x / (2.0 - (x + y)) else: tmp = y / (y + -2.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -29000000000.0) || !(x <= 2.6)) tmp = Float64(x / Float64(2.0 - Float64(x + y))); else tmp = Float64(y / Float64(y + -2.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -29000000000.0) || ~((x <= 2.6))) tmp = x / (2.0 - (x + y)); else tmp = y / (y + -2.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -29000000000.0], N[Not[LessEqual[x, 2.6]], $MachinePrecision]], N[(x / N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -29000000000 \lor \neg \left(x \leq 2.6\right):\\
\;\;\;\;\frac{x}{2 - \left(x + y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y + -2}\\
\end{array}
\end{array}
if x < -2.9e10 or 2.60000000000000009 < x Initial program 100.0%
Taylor expanded in x around inf 80.9%
if -2.9e10 < x < 2.60000000000000009Initial program 100.0%
Taylor expanded in x around 0 74.2%
mul-1-neg74.2%
distribute-neg-frac274.2%
mul-1-neg74.2%
sub-neg74.2%
+-commutative74.2%
distribute-lft-in74.2%
neg-mul-174.2%
remove-double-neg74.2%
metadata-eval74.2%
Simplified74.2%
Final simplification77.4%
(FPCore (x y) :precision binary64 (if (<= x -20500000000.0) (/ x (- 2.0 (+ x y))) (if (<= x 0.6) (/ (- x y) (- 2.0 y)) (/ (- x y) (- 2.0 x)))))
double code(double x, double y) {
double tmp;
if (x <= -20500000000.0) {
tmp = x / (2.0 - (x + y));
} else if (x <= 0.6) {
tmp = (x - y) / (2.0 - y);
} else {
tmp = (x - 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 <= (-20500000000.0d0)) then
tmp = x / (2.0d0 - (x + y))
else if (x <= 0.6d0) then
tmp = (x - y) / (2.0d0 - y)
else
tmp = (x - y) / (2.0d0 - x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -20500000000.0) {
tmp = x / (2.0 - (x + y));
} else if (x <= 0.6) {
tmp = (x - y) / (2.0 - y);
} else {
tmp = (x - y) / (2.0 - x);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -20500000000.0: tmp = x / (2.0 - (x + y)) elif x <= 0.6: tmp = (x - y) / (2.0 - y) else: tmp = (x - y) / (2.0 - x) return tmp
function code(x, y) tmp = 0.0 if (x <= -20500000000.0) tmp = Float64(x / Float64(2.0 - Float64(x + y))); elseif (x <= 0.6) tmp = Float64(Float64(x - y) / Float64(2.0 - y)); else tmp = Float64(Float64(x - y) / Float64(2.0 - x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -20500000000.0) tmp = x / (2.0 - (x + y)); elseif (x <= 0.6) tmp = (x - y) / (2.0 - y); else tmp = (x - y) / (2.0 - x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -20500000000.0], N[(x / N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.6], N[(N[(x - y), $MachinePrecision] / N[(2.0 - y), $MachinePrecision]), $MachinePrecision], N[(N[(x - y), $MachinePrecision] / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -20500000000:\\
\;\;\;\;\frac{x}{2 - \left(x + y\right)}\\
\mathbf{elif}\;x \leq 0.6:\\
\;\;\;\;\frac{x - y}{2 - y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x - y}{2 - x}\\
\end{array}
\end{array}
if x < -2.05e10Initial program 100.0%
Taylor expanded in x around inf 85.6%
if -2.05e10 < x < 0.599999999999999978Initial program 100.0%
Taylor expanded in x around 0 98.2%
if 0.599999999999999978 < x Initial program 100.0%
Taylor expanded in y around 0 77.6%
(FPCore (x y) :precision binary64 (if (<= y -5.4e-5) (/ y (+ y -2.0)) (if (<= y 3.2e+58) (/ (- x y) (- 2.0 x)) (- 1.0 (/ x y)))))
double code(double x, double y) {
double tmp;
if (y <= -5.4e-5) {
tmp = y / (y + -2.0);
} else if (y <= 3.2e+58) {
tmp = (x - y) / (2.0 - x);
} else {
tmp = 1.0 - (x / y);
}
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-5)) then
tmp = y / (y + (-2.0d0))
else if (y <= 3.2d+58) then
tmp = (x - y) / (2.0d0 - x)
else
tmp = 1.0d0 - (x / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -5.4e-5) {
tmp = y / (y + -2.0);
} else if (y <= 3.2e+58) {
tmp = (x - y) / (2.0 - x);
} else {
tmp = 1.0 - (x / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -5.4e-5: tmp = y / (y + -2.0) elif y <= 3.2e+58: tmp = (x - y) / (2.0 - x) else: tmp = 1.0 - (x / y) return tmp
function code(x, y) tmp = 0.0 if (y <= -5.4e-5) tmp = Float64(y / Float64(y + -2.0)); elseif (y <= 3.2e+58) tmp = Float64(Float64(x - y) / Float64(2.0 - x)); else tmp = Float64(1.0 - Float64(x / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -5.4e-5) tmp = y / (y + -2.0); elseif (y <= 3.2e+58) tmp = (x - y) / (2.0 - x); else tmp = 1.0 - (x / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -5.4e-5], N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.2e+58], N[(N[(x - y), $MachinePrecision] / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.4 \cdot 10^{-5}:\\
\;\;\;\;\frac{y}{y + -2}\\
\mathbf{elif}\;y \leq 3.2 \cdot 10^{+58}:\\
\;\;\;\;\frac{x - y}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{y}\\
\end{array}
\end{array}
if y < -5.3999999999999998e-5Initial program 100.0%
Taylor expanded in x around 0 74.4%
mul-1-neg74.4%
distribute-neg-frac274.4%
mul-1-neg74.4%
sub-neg74.4%
+-commutative74.4%
distribute-lft-in74.4%
neg-mul-174.4%
remove-double-neg74.4%
metadata-eval74.4%
Simplified74.4%
if -5.3999999999999998e-5 < y < 3.20000000000000015e58Initial program 100.0%
Taylor expanded in y around 0 94.8%
if 3.20000000000000015e58 < y Initial program 99.9%
Taylor expanded in x around inf 65.4%
Taylor expanded in y around inf 77.7%
neg-mul-177.7%
Simplified77.7%
Taylor expanded in x around 0 77.7%
mul-1-neg77.7%
unsub-neg77.7%
Simplified77.7%
(FPCore (x y) :precision binary64 (if (or (<= x -7800000000.0) (not (<= x 3.2))) (/ x (- 2.0 x)) (/ y (+ y -2.0))))
double code(double x, double y) {
double tmp;
if ((x <= -7800000000.0) || !(x <= 3.2)) {
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 <= (-7800000000.0d0)) .or. (.not. (x <= 3.2d0))) 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 <= -7800000000.0) || !(x <= 3.2)) {
tmp = x / (2.0 - x);
} else {
tmp = y / (y + -2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -7800000000.0) or not (x <= 3.2): tmp = x / (2.0 - x) else: tmp = y / (y + -2.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -7800000000.0) || !(x <= 3.2)) 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 <= -7800000000.0) || ~((x <= 3.2))) tmp = x / (2.0 - x); else tmp = y / (y + -2.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -7800000000.0], N[Not[LessEqual[x, 3.2]], $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 -7800000000 \lor \neg \left(x \leq 3.2\right):\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y + -2}\\
\end{array}
\end{array}
if x < -7.8e9 or 3.2000000000000002 < x Initial program 100.0%
Taylor expanded in y around 0 80.5%
if -7.8e9 < x < 3.2000000000000002Initial program 100.0%
Taylor expanded in x around 0 74.2%
mul-1-neg74.2%
distribute-neg-frac274.2%
mul-1-neg74.2%
sub-neg74.2%
+-commutative74.2%
distribute-lft-in74.2%
neg-mul-174.2%
remove-double-neg74.2%
metadata-eval74.2%
Simplified74.2%
Final simplification77.3%
(FPCore (x y) :precision binary64 (if (or (<= y -9e+23) (not (<= y 2.8e+56))) (- 1.0 (/ x y)) (/ x (- 2.0 x))))
double code(double x, double y) {
double tmp;
if ((y <= -9e+23) || !(y <= 2.8e+56)) {
tmp = 1.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 <= (-9d+23)) .or. (.not. (y <= 2.8d+56))) then
tmp = 1.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 <= -9e+23) || !(y <= 2.8e+56)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -9e+23) or not (y <= 2.8e+56): tmp = 1.0 - (x / y) else: tmp = x / (2.0 - x) return tmp
function code(x, y) tmp = 0.0 if ((y <= -9e+23) || !(y <= 2.8e+56)) tmp = Float64(1.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 <= -9e+23) || ~((y <= 2.8e+56))) tmp = 1.0 - (x / y); else tmp = x / (2.0 - x); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -9e+23], N[Not[LessEqual[y, 2.8e+56]], $MachinePrecision]], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9 \cdot 10^{+23} \lor \neg \left(y \leq 2.8 \cdot 10^{+56}\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 - x}\\
\end{array}
\end{array}
if y < -8.99999999999999958e23 or 2.80000000000000008e56 < y Initial program 100.0%
Taylor expanded in x around inf 72.1%
Taylor expanded in y around inf 77.5%
neg-mul-177.5%
Simplified77.5%
Taylor expanded in x around 0 77.5%
mul-1-neg77.5%
unsub-neg77.5%
Simplified77.5%
if -8.99999999999999958e23 < y < 2.80000000000000008e56Initial program 99.9%
Taylor expanded in y around 0 69.4%
Final simplification72.6%
(FPCore (x y) :precision binary64 (if (<= x -10200000000.0) -1.0 (if (<= x 5e+49) 1.0 -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -10200000000.0) {
tmp = -1.0;
} else if (x <= 5e+49) {
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 <= (-10200000000.0d0)) then
tmp = -1.0d0
else if (x <= 5d+49) 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 <= -10200000000.0) {
tmp = -1.0;
} else if (x <= 5e+49) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -10200000000.0: tmp = -1.0 elif x <= 5e+49: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -10200000000.0) tmp = -1.0; elseif (x <= 5e+49) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -10200000000.0) tmp = -1.0; elseif (x <= 5e+49) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -10200000000.0], -1.0, If[LessEqual[x, 5e+49], 1.0, -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -10200000000:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 5 \cdot 10^{+49}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -1.02e10 or 5.0000000000000004e49 < x Initial program 100.0%
Taylor expanded in x around inf 83.3%
if -1.02e10 < x < 5.0000000000000004e49Initial program 100.0%
Taylor expanded in y around inf 47.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%
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 2024172
(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))))