
(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 (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}
Initial program 100.0%
associate--r+100.0%
Simplified100.0%
div-sub100.0%
associate--l-100.0%
associate--l-100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(if (<= x -5.4e+34)
-1.0
(if (<= x -0.076)
1.0
(if (<= x -2e-44)
(* x 0.5)
(if (<= x -3e-187)
1.0
(if (<= x 9.5e-280)
(* y -0.5)
(if (<= x 2.15e-145) 1.0 (if (<= x 3.9) (* x 0.5) -1.0))))))))
double code(double x, double y) {
double tmp;
if (x <= -5.4e+34) {
tmp = -1.0;
} else if (x <= -0.076) {
tmp = 1.0;
} else if (x <= -2e-44) {
tmp = x * 0.5;
} else if (x <= -3e-187) {
tmp = 1.0;
} else if (x <= 9.5e-280) {
tmp = y * -0.5;
} else if (x <= 2.15e-145) {
tmp = 1.0;
} else if (x <= 3.9) {
tmp = x * 0.5;
} else {
tmp = -1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-5.4d+34)) then
tmp = -1.0d0
else if (x <= (-0.076d0)) then
tmp = 1.0d0
else if (x <= (-2d-44)) then
tmp = x * 0.5d0
else if (x <= (-3d-187)) then
tmp = 1.0d0
else if (x <= 9.5d-280) then
tmp = y * (-0.5d0)
else if (x <= 2.15d-145) then
tmp = 1.0d0
else if (x <= 3.9d0) then
tmp = x * 0.5d0
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -5.4e+34) {
tmp = -1.0;
} else if (x <= -0.076) {
tmp = 1.0;
} else if (x <= -2e-44) {
tmp = x * 0.5;
} else if (x <= -3e-187) {
tmp = 1.0;
} else if (x <= 9.5e-280) {
tmp = y * -0.5;
} else if (x <= 2.15e-145) {
tmp = 1.0;
} else if (x <= 3.9) {
tmp = x * 0.5;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -5.4e+34: tmp = -1.0 elif x <= -0.076: tmp = 1.0 elif x <= -2e-44: tmp = x * 0.5 elif x <= -3e-187: tmp = 1.0 elif x <= 9.5e-280: tmp = y * -0.5 elif x <= 2.15e-145: tmp = 1.0 elif x <= 3.9: tmp = x * 0.5 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -5.4e+34) tmp = -1.0; elseif (x <= -0.076) tmp = 1.0; elseif (x <= -2e-44) tmp = Float64(x * 0.5); elseif (x <= -3e-187) tmp = 1.0; elseif (x <= 9.5e-280) tmp = Float64(y * -0.5); elseif (x <= 2.15e-145) tmp = 1.0; elseif (x <= 3.9) tmp = Float64(x * 0.5); else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -5.4e+34) tmp = -1.0; elseif (x <= -0.076) tmp = 1.0; elseif (x <= -2e-44) tmp = x * 0.5; elseif (x <= -3e-187) tmp = 1.0; elseif (x <= 9.5e-280) tmp = y * -0.5; elseif (x <= 2.15e-145) tmp = 1.0; elseif (x <= 3.9) tmp = x * 0.5; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -5.4e+34], -1.0, If[LessEqual[x, -0.076], 1.0, If[LessEqual[x, -2e-44], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, -3e-187], 1.0, If[LessEqual[x, 9.5e-280], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 2.15e-145], 1.0, If[LessEqual[x, 3.9], N[(x * 0.5), $MachinePrecision], -1.0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.4 \cdot 10^{+34}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -0.076:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -2 \cdot 10^{-44}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq -3 \cdot 10^{-187}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{-280}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 2.15 \cdot 10^{-145}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 3.9:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -5.4000000000000001e34 or 3.89999999999999991 < x Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 82.3%
if -5.4000000000000001e34 < x < -0.0759999999999999981 or -1.99999999999999991e-44 < x < -3.00000000000000004e-187 or 9.50000000000000082e-280 < x < 2.15e-145Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 65.4%
if -0.0759999999999999981 < x < -1.99999999999999991e-44 or 2.15e-145 < x < 3.89999999999999991Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around 0 63.2%
Taylor expanded in x around 0 58.7%
*-commutative58.7%
Simplified58.7%
if -3.00000000000000004e-187 < x < 9.50000000000000082e-280Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 96.8%
associate-*r/96.8%
neg-mul-196.8%
Simplified96.8%
Taylor expanded in y around 0 60.3%
*-commutative60.3%
Simplified60.3%
Final simplification71.3%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))))
(if (<= x -5.1e+34)
-1.0
(if (<= x -0.076)
t_0
(if (<= x -5.5e-46)
(* x 0.5)
(if (<= x -7.8e-187)
t_0
(if (<= x 9e-280)
(* y -0.5)
(if (<= x 1e-144) 1.0 (if (<= x 9.2) (* x 0.5) -1.0)))))))))
double code(double x, double y) {
double t_0 = 1.0 - (x / y);
double tmp;
if (x <= -5.1e+34) {
tmp = -1.0;
} else if (x <= -0.076) {
tmp = t_0;
} else if (x <= -5.5e-46) {
tmp = x * 0.5;
} else if (x <= -7.8e-187) {
tmp = t_0;
} else if (x <= 9e-280) {
tmp = y * -0.5;
} else if (x <= 1e-144) {
tmp = 1.0;
} else if (x <= 9.2) {
tmp = x * 0.5;
} else {
tmp = -1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - (x / y)
if (x <= (-5.1d+34)) then
tmp = -1.0d0
else if (x <= (-0.076d0)) then
tmp = t_0
else if (x <= (-5.5d-46)) then
tmp = x * 0.5d0
else if (x <= (-7.8d-187)) then
tmp = t_0
else if (x <= 9d-280) then
tmp = y * (-0.5d0)
else if (x <= 1d-144) then
tmp = 1.0d0
else if (x <= 9.2d0) then
tmp = x * 0.5d0
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 - (x / y);
double tmp;
if (x <= -5.1e+34) {
tmp = -1.0;
} else if (x <= -0.076) {
tmp = t_0;
} else if (x <= -5.5e-46) {
tmp = x * 0.5;
} else if (x <= -7.8e-187) {
tmp = t_0;
} else if (x <= 9e-280) {
tmp = y * -0.5;
} else if (x <= 1e-144) {
tmp = 1.0;
} else if (x <= 9.2) {
tmp = x * 0.5;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 - (x / y) tmp = 0 if x <= -5.1e+34: tmp = -1.0 elif x <= -0.076: tmp = t_0 elif x <= -5.5e-46: tmp = x * 0.5 elif x <= -7.8e-187: tmp = t_0 elif x <= 9e-280: tmp = y * -0.5 elif x <= 1e-144: tmp = 1.0 elif x <= 9.2: tmp = x * 0.5 else: tmp = -1.0 return tmp
function code(x, y) t_0 = Float64(1.0 - Float64(x / y)) tmp = 0.0 if (x <= -5.1e+34) tmp = -1.0; elseif (x <= -0.076) tmp = t_0; elseif (x <= -5.5e-46) tmp = Float64(x * 0.5); elseif (x <= -7.8e-187) tmp = t_0; elseif (x <= 9e-280) tmp = Float64(y * -0.5); elseif (x <= 1e-144) tmp = 1.0; elseif (x <= 9.2) tmp = Float64(x * 0.5); else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 - (x / y); tmp = 0.0; if (x <= -5.1e+34) tmp = -1.0; elseif (x <= -0.076) tmp = t_0; elseif (x <= -5.5e-46) tmp = x * 0.5; elseif (x <= -7.8e-187) tmp = t_0; elseif (x <= 9e-280) tmp = y * -0.5; elseif (x <= 1e-144) tmp = 1.0; elseif (x <= 9.2) tmp = x * 0.5; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -5.1e+34], -1.0, If[LessEqual[x, -0.076], t$95$0, If[LessEqual[x, -5.5e-46], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, -7.8e-187], t$95$0, If[LessEqual[x, 9e-280], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 1e-144], 1.0, If[LessEqual[x, 9.2], N[(x * 0.5), $MachinePrecision], -1.0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;x \leq -5.1 \cdot 10^{+34}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -0.076:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -5.5 \cdot 10^{-46}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq -7.8 \cdot 10^{-187}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 9 \cdot 10^{-280}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 10^{-144}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 9.2:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -5.10000000000000036e34 or 9.1999999999999993 < x Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 82.3%
if -5.10000000000000036e34 < x < -0.0759999999999999981 or -5.49999999999999983e-46 < x < -7.7999999999999998e-187Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 69.5%
neg-mul-169.5%
Simplified69.5%
Taylor expanded in x around 0 69.5%
mul-1-neg69.5%
unsub-neg69.5%
Simplified69.5%
if -0.0759999999999999981 < x < -5.49999999999999983e-46 or 9.9999999999999995e-145 < x < 9.1999999999999993Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around 0 63.2%
Taylor expanded in x around 0 58.7%
*-commutative58.7%
Simplified58.7%
if -7.7999999999999998e-187 < x < 8.9999999999999991e-280Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 96.8%
associate-*r/96.8%
neg-mul-196.8%
Simplified96.8%
Taylor expanded in y around 0 60.3%
*-commutative60.3%
Simplified60.3%
if 8.9999999999999991e-280 < x < 9.9999999999999995e-145Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 61.1%
Final simplification71.3%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ (/ y x) -1.0)))
(if (<= x -1.15e+35)
t_0
(if (<= x -3.9e-187)
(- 1.0 (/ x y))
(if (<= x 1e-279)
(* y -0.5)
(if (<= x 9.8e-145) 1.0 (if (<= x 2.2) (* x 0.5) t_0)))))))
double code(double x, double y) {
double t_0 = (y / x) + -1.0;
double tmp;
if (x <= -1.15e+35) {
tmp = t_0;
} else if (x <= -3.9e-187) {
tmp = 1.0 - (x / y);
} else if (x <= 1e-279) {
tmp = y * -0.5;
} else if (x <= 9.8e-145) {
tmp = 1.0;
} else if (x <= 2.2) {
tmp = x * 0.5;
} 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 <= (-1.15d+35)) then
tmp = t_0
else if (x <= (-3.9d-187)) then
tmp = 1.0d0 - (x / y)
else if (x <= 1d-279) then
tmp = y * (-0.5d0)
else if (x <= 9.8d-145) then
tmp = 1.0d0
else if (x <= 2.2d0) then
tmp = x * 0.5d0
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 <= -1.15e+35) {
tmp = t_0;
} else if (x <= -3.9e-187) {
tmp = 1.0 - (x / y);
} else if (x <= 1e-279) {
tmp = y * -0.5;
} else if (x <= 9.8e-145) {
tmp = 1.0;
} else if (x <= 2.2) {
tmp = x * 0.5;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (y / x) + -1.0 tmp = 0 if x <= -1.15e+35: tmp = t_0 elif x <= -3.9e-187: tmp = 1.0 - (x / y) elif x <= 1e-279: tmp = y * -0.5 elif x <= 9.8e-145: tmp = 1.0 elif x <= 2.2: tmp = x * 0.5 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(y / x) + -1.0) tmp = 0.0 if (x <= -1.15e+35) tmp = t_0; elseif (x <= -3.9e-187) tmp = Float64(1.0 - Float64(x / y)); elseif (x <= 1e-279) tmp = Float64(y * -0.5); elseif (x <= 9.8e-145) tmp = 1.0; elseif (x <= 2.2) tmp = Float64(x * 0.5); 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 <= -1.15e+35) tmp = t_0; elseif (x <= -3.9e-187) tmp = 1.0 - (x / y); elseif (x <= 1e-279) tmp = y * -0.5; elseif (x <= 9.8e-145) tmp = 1.0; elseif (x <= 2.2) tmp = x * 0.5; 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, -1.15e+35], t$95$0, If[LessEqual[x, -3.9e-187], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1e-279], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 9.8e-145], 1.0, If[LessEqual[x, 2.2], N[(x * 0.5), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{x} + -1\\
\mathbf{if}\;x \leq -1.15 \cdot 10^{+35}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -3.9 \cdot 10^{-187}:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{elif}\;x \leq 10^{-279}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 9.8 \cdot 10^{-145}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 2.2:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -1.1499999999999999e35 or 2.2000000000000002 < x Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 82.9%
neg-mul-182.9%
Simplified82.9%
Taylor expanded in x around 0 82.9%
if -1.1499999999999999e35 < x < -3.8999999999999999e-187Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around inf 58.4%
neg-mul-158.4%
Simplified58.4%
Taylor expanded in x around 0 58.4%
mul-1-neg58.4%
unsub-neg58.4%
Simplified58.4%
if -3.8999999999999999e-187 < x < 1.00000000000000006e-279Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 96.8%
associate-*r/96.8%
neg-mul-196.8%
Simplified96.8%
Taylor expanded in y around 0 60.3%
*-commutative60.3%
Simplified60.3%
if 1.00000000000000006e-279 < x < 9.79999999999999934e-145Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 61.1%
if 9.79999999999999934e-145 < x < 2.2000000000000002Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 59.3%
Taylor expanded in x around 0 58.3%
*-commutative58.3%
Simplified58.3%
Final simplification69.9%
(FPCore (x y)
:precision binary64
(if (<= x -2e+35)
-1.0
(if (<= x -0.076)
1.0
(if (<= x -5.2e-45)
(* x 0.5)
(if (<= x 3.7e-147) 1.0 (if (<= x 3.3) (* x 0.5) -1.0))))))
double code(double x, double y) {
double tmp;
if (x <= -2e+35) {
tmp = -1.0;
} else if (x <= -0.076) {
tmp = 1.0;
} else if (x <= -5.2e-45) {
tmp = x * 0.5;
} else if (x <= 3.7e-147) {
tmp = 1.0;
} else if (x <= 3.3) {
tmp = x * 0.5;
} else {
tmp = -1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-2d+35)) then
tmp = -1.0d0
else if (x <= (-0.076d0)) then
tmp = 1.0d0
else if (x <= (-5.2d-45)) then
tmp = x * 0.5d0
else if (x <= 3.7d-147) then
tmp = 1.0d0
else if (x <= 3.3d0) then
tmp = x * 0.5d0
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -2e+35) {
tmp = -1.0;
} else if (x <= -0.076) {
tmp = 1.0;
} else if (x <= -5.2e-45) {
tmp = x * 0.5;
} else if (x <= 3.7e-147) {
tmp = 1.0;
} else if (x <= 3.3) {
tmp = x * 0.5;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2e+35: tmp = -1.0 elif x <= -0.076: tmp = 1.0 elif x <= -5.2e-45: tmp = x * 0.5 elif x <= 3.7e-147: tmp = 1.0 elif x <= 3.3: tmp = x * 0.5 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -2e+35) tmp = -1.0; elseif (x <= -0.076) tmp = 1.0; elseif (x <= -5.2e-45) tmp = Float64(x * 0.5); elseif (x <= 3.7e-147) tmp = 1.0; elseif (x <= 3.3) tmp = Float64(x * 0.5); else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2e+35) tmp = -1.0; elseif (x <= -0.076) tmp = 1.0; elseif (x <= -5.2e-45) tmp = x * 0.5; elseif (x <= 3.7e-147) tmp = 1.0; elseif (x <= 3.3) tmp = x * 0.5; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2e+35], -1.0, If[LessEqual[x, -0.076], 1.0, If[LessEqual[x, -5.2e-45], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 3.7e-147], 1.0, If[LessEqual[x, 3.3], N[(x * 0.5), $MachinePrecision], -1.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{+35}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -0.076:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -5.2 \cdot 10^{-45}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 3.7 \cdot 10^{-147}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 3.3:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -1.9999999999999999e35 or 3.2999999999999998 < x Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 82.3%
if -1.9999999999999999e35 < x < -0.0759999999999999981 or -5.19999999999999973e-45 < x < 3.7000000000000002e-147Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 56.5%
if -0.0759999999999999981 < x < -5.19999999999999973e-45 or 3.7000000000000002e-147 < x < 3.2999999999999998Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around 0 63.2%
Taylor expanded in x around 0 58.7%
*-commutative58.7%
Simplified58.7%
Final simplification68.5%
(FPCore (x y) :precision binary64 (if (or (<= x -5.1e+34) (not (<= x 1.1e+29))) (+ (/ y x) -1.0) (/ (- x y) (- 2.0 y))))
double code(double x, double y) {
double tmp;
if ((x <= -5.1e+34) || !(x <= 1.1e+29)) {
tmp = (y / x) + -1.0;
} else {
tmp = (x - y) / (2.0 - y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-5.1d+34)) .or. (.not. (x <= 1.1d+29))) then
tmp = (y / x) + (-1.0d0)
else
tmp = (x - y) / (2.0d0 - y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -5.1e+34) || !(x <= 1.1e+29)) {
tmp = (y / x) + -1.0;
} else {
tmp = (x - y) / (2.0 - y);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -5.1e+34) or not (x <= 1.1e+29): tmp = (y / x) + -1.0 else: tmp = (x - y) / (2.0 - y) return tmp
function code(x, y) tmp = 0.0 if ((x <= -5.1e+34) || !(x <= 1.1e+29)) tmp = Float64(Float64(y / x) + -1.0); else tmp = Float64(Float64(x - y) / Float64(2.0 - y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -5.1e+34) || ~((x <= 1.1e+29))) tmp = (y / x) + -1.0; else tmp = (x - y) / (2.0 - y); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -5.1e+34], N[Not[LessEqual[x, 1.1e+29]], $MachinePrecision]], N[(N[(y / x), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(x - y), $MachinePrecision] / N[(2.0 - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.1 \cdot 10^{+34} \lor \neg \left(x \leq 1.1 \cdot 10^{+29}\right):\\
\;\;\;\;\frac{y}{x} + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{x - y}{2 - y}\\
\end{array}
\end{array}
if x < -5.10000000000000036e34 or 1.1000000000000001e29 < x Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in x around inf 85.8%
neg-mul-185.8%
Simplified85.8%
Taylor expanded in x around 0 85.8%
if -5.10000000000000036e34 < x < 1.1000000000000001e29Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 94.2%
Final simplification90.6%
(FPCore (x y) :precision binary64 (if (or (<= y -7.5e+102) (not (<= y 2.35e+32))) (- 1.0 (/ x y)) (/ x (- 2.0 x))))
double code(double x, double y) {
double tmp;
if ((y <= -7.5e+102) || !(y <= 2.35e+32)) {
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 <= (-7.5d+102)) .or. (.not. (y <= 2.35d+32))) 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 <= -7.5e+102) || !(y <= 2.35e+32)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -7.5e+102) or not (y <= 2.35e+32): tmp = 1.0 - (x / y) else: tmp = x / (2.0 - x) return tmp
function code(x, y) tmp = 0.0 if ((y <= -7.5e+102) || !(y <= 2.35e+32)) 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 <= -7.5e+102) || ~((y <= 2.35e+32))) tmp = 1.0 - (x / y); else tmp = x / (2.0 - x); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -7.5e+102], N[Not[LessEqual[y, 2.35e+32]], $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 -7.5 \cdot 10^{+102} \lor \neg \left(y \leq 2.35 \cdot 10^{+32}\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 - x}\\
\end{array}
\end{array}
if y < -7.5e102 or 2.35000000000000012e32 < y Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 84.6%
neg-mul-184.6%
Simplified84.6%
Taylor expanded in x around 0 84.6%
mul-1-neg84.6%
unsub-neg84.6%
Simplified84.6%
if -7.5e102 < y < 2.35000000000000012e32Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 70.8%
Final simplification75.5%
(FPCore (x y) :precision binary64 (if (or (<= x -2.6e-45) (not (<= x 5.5e-81))) (/ x (- 2.0 x)) (/ y (+ y -2.0))))
double code(double x, double y) {
double tmp;
if ((x <= -2.6e-45) || !(x <= 5.5e-81)) {
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 <= (-2.6d-45)) .or. (.not. (x <= 5.5d-81))) 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 <= -2.6e-45) || !(x <= 5.5e-81)) {
tmp = x / (2.0 - x);
} else {
tmp = y / (y + -2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -2.6e-45) or not (x <= 5.5e-81): tmp = x / (2.0 - x) else: tmp = y / (y + -2.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -2.6e-45) || !(x <= 5.5e-81)) 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 <= -2.6e-45) || ~((x <= 5.5e-81))) tmp = x / (2.0 - x); else tmp = y / (y + -2.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -2.6e-45], N[Not[LessEqual[x, 5.5e-81]], $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 -2.6 \cdot 10^{-45} \lor \neg \left(x \leq 5.5 \cdot 10^{-81}\right):\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y + -2}\\
\end{array}
\end{array}
if x < -2.59999999999999987e-45 or 5.50000000000000026e-81 < x Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around 0 79.0%
if -2.59999999999999987e-45 < x < 5.50000000000000026e-81Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 86.9%
associate-*r/86.9%
neg-mul-186.9%
Simplified86.9%
frac-2neg86.9%
div-inv86.8%
remove-double-neg86.8%
sub-neg86.8%
distribute-neg-in86.8%
metadata-eval86.8%
remove-double-neg86.8%
Applied egg-rr86.8%
associate-*r/86.9%
*-rgt-identity86.9%
+-commutative86.9%
Simplified86.9%
Final simplification82.3%
(FPCore (x y) :precision binary64 (/ (- x y) (- 2.0 (+ x y))))
double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x - y) / (2.0d0 - (x + y))
end function
public static double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
def code(x, y): return (x - y) / (2.0 - (x + y))
function code(x, y) return Float64(Float64(x - y) / Float64(2.0 - Float64(x + y))) end
function tmp = code(x, y) tmp = (x - y) / (2.0 - (x + y)); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{2 - \left(x + y\right)}
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y) :precision binary64 (if (<= x -1e+35) -1.0 (if (<= x 1.4e+28) 1.0 -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -1e+35) {
tmp = -1.0;
} else if (x <= 1.4e+28) {
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 <= (-1d+35)) then
tmp = -1.0d0
else if (x <= 1.4d+28) 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 <= -1e+35) {
tmp = -1.0;
} else if (x <= 1.4e+28) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1e+35: tmp = -1.0 elif x <= 1.4e+28: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1e+35) tmp = -1.0; elseif (x <= 1.4e+28) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1e+35) tmp = -1.0; elseif (x <= 1.4e+28) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1e+35], -1.0, If[LessEqual[x, 1.4e+28], 1.0, -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{+35}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{+28}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -9.9999999999999997e34 or 1.4000000000000001e28 < x Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in x around inf 85.3%
if -9.9999999999999997e34 < x < 1.4000000000000001e28Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 48.7%
Final simplification64.3%
(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%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 39.4%
Final simplification39.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 2023285
(FPCore (x y)
:name "Data.Colour.RGB:hslsv from colour-2.3.3, C"
:precision binary64
:herbie-target
(- (/ x (- 2.0 (+ x y))) (/ y (- 2.0 (+ x y))))
(/ (- x y) (- 2.0 (+ x y))))