
(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%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ y (- y 2.0))))
(if (<= x -1.8e+124)
-1.0
(if (<= x 4.7e-80)
t_0
(if (<= x 3.1e-21) (* x 0.5) (if (<= x 6.2e+52) t_0 -1.0))))))
double code(double x, double y) {
double t_0 = y / (y - 2.0);
double tmp;
if (x <= -1.8e+124) {
tmp = -1.0;
} else if (x <= 4.7e-80) {
tmp = t_0;
} else if (x <= 3.1e-21) {
tmp = x * 0.5;
} else if (x <= 6.2e+52) {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = y / (y - 2.0d0)
if (x <= (-1.8d+124)) then
tmp = -1.0d0
else if (x <= 4.7d-80) then
tmp = t_0
else if (x <= 3.1d-21) then
tmp = x * 0.5d0
else if (x <= 6.2d+52) then
tmp = t_0
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = y / (y - 2.0);
double tmp;
if (x <= -1.8e+124) {
tmp = -1.0;
} else if (x <= 4.7e-80) {
tmp = t_0;
} else if (x <= 3.1e-21) {
tmp = x * 0.5;
} else if (x <= 6.2e+52) {
tmp = t_0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): t_0 = y / (y - 2.0) tmp = 0 if x <= -1.8e+124: tmp = -1.0 elif x <= 4.7e-80: tmp = t_0 elif x <= 3.1e-21: tmp = x * 0.5 elif x <= 6.2e+52: tmp = t_0 else: tmp = -1.0 return tmp
function code(x, y) t_0 = Float64(y / Float64(y - 2.0)) tmp = 0.0 if (x <= -1.8e+124) tmp = -1.0; elseif (x <= 4.7e-80) tmp = t_0; elseif (x <= 3.1e-21) tmp = Float64(x * 0.5); elseif (x <= 6.2e+52) tmp = t_0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) t_0 = y / (y - 2.0); tmp = 0.0; if (x <= -1.8e+124) tmp = -1.0; elseif (x <= 4.7e-80) tmp = t_0; elseif (x <= 3.1e-21) tmp = x * 0.5; elseif (x <= 6.2e+52) tmp = t_0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y / N[(y - 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.8e+124], -1.0, If[LessEqual[x, 4.7e-80], t$95$0, If[LessEqual[x, 3.1e-21], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 6.2e+52], t$95$0, -1.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{y - 2}\\
\mathbf{if}\;x \leq -1.8 \cdot 10^{+124}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 4.7 \cdot 10^{-80}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 3.1 \cdot 10^{-21}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 6.2 \cdot 10^{+52}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -1.79999999999999993e124 or 6.2e52 < x Initial program 99.9%
+-commutative99.9%
remove-double-neg99.9%
unsub-neg99.9%
distribute-neg-in99.9%
neg-mul-199.9%
*-commutative99.9%
associate-/l*99.9%
+-commutative99.9%
sub-neg99.9%
div-sub99.9%
metadata-eval99.9%
metadata-eval99.9%
sub-neg99.9%
distribute-frac-neg99.9%
neg-mul-199.9%
*-commutative99.9%
associate-/l*99.9%
metadata-eval99.9%
/-rgt-identity99.9%
+-commutative99.9%
+-commutative99.9%
associate-+r+99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around inf 79.4%
if -1.79999999999999993e124 < x < 4.69999999999999973e-80 or 3.0999999999999998e-21 < x < 6.2e52Initial program 100.0%
+-commutative100.0%
remove-double-neg100.0%
unsub-neg100.0%
distribute-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
associate-/l*100.0%
+-commutative100.0%
sub-neg100.0%
div-sub100.0%
metadata-eval100.0%
metadata-eval100.0%
sub-neg100.0%
distribute-frac-neg100.0%
neg-mul-1100.0%
*-commutative100.0%
associate-/l*100.0%
metadata-eval100.0%
/-rgt-identity100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 76.2%
if 4.69999999999999973e-80 < x < 3.0999999999999998e-21Initial program 99.9%
+-commutative99.9%
remove-double-neg99.9%
unsub-neg99.9%
distribute-neg-in99.9%
neg-mul-199.9%
*-commutative99.9%
associate-/l*99.9%
+-commutative99.9%
sub-neg99.9%
div-sub99.9%
metadata-eval99.9%
metadata-eval99.9%
sub-neg99.9%
distribute-frac-neg99.9%
neg-mul-199.9%
*-commutative99.9%
associate-/l*99.9%
metadata-eval99.9%
/-rgt-identity99.9%
+-commutative99.9%
+-commutative99.9%
associate-+r+99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around 0 70.5%
associate-*r/70.5%
mul-1-neg70.5%
sub-neg70.5%
metadata-eval70.5%
Simplified70.5%
Taylor expanded in x around 0 70.5%
*-commutative70.5%
Simplified70.5%
Final simplification76.8%
(FPCore (x y) :precision binary64 (if (or (<= y -2.45e-11) (not (<= y 1.06e-49))) (/ y (- y 2.0)) (/ (- x) (+ x -2.0))))
double code(double x, double y) {
double tmp;
if ((y <= -2.45e-11) || !(y <= 1.06e-49)) {
tmp = y / (y - 2.0);
} else {
tmp = -x / (x + -2.0);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= (-2.45d-11)) .or. (.not. (y <= 1.06d-49))) then
tmp = y / (y - 2.0d0)
else
tmp = -x / (x + (-2.0d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -2.45e-11) || !(y <= 1.06e-49)) {
tmp = y / (y - 2.0);
} else {
tmp = -x / (x + -2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -2.45e-11) or not (y <= 1.06e-49): tmp = y / (y - 2.0) else: tmp = -x / (x + -2.0) return tmp
function code(x, y) tmp = 0.0 if ((y <= -2.45e-11) || !(y <= 1.06e-49)) tmp = Float64(y / Float64(y - 2.0)); else tmp = Float64(Float64(-x) / Float64(x + -2.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -2.45e-11) || ~((y <= 1.06e-49))) tmp = y / (y - 2.0); else tmp = -x / (x + -2.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -2.45e-11], N[Not[LessEqual[y, 1.06e-49]], $MachinePrecision]], N[(y / N[(y - 2.0), $MachinePrecision]), $MachinePrecision], N[((-x) / N[(x + -2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.45 \cdot 10^{-11} \lor \neg \left(y \leq 1.06 \cdot 10^{-49}\right):\\
\;\;\;\;\frac{y}{y - 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-x}{x + -2}\\
\end{array}
\end{array}
if y < -2.4499999999999999e-11 or 1.06000000000000002e-49 < y Initial program 99.9%
+-commutative99.9%
remove-double-neg99.9%
unsub-neg99.9%
distribute-neg-in99.9%
neg-mul-199.9%
*-commutative99.9%
associate-/l*99.9%
+-commutative99.9%
sub-neg99.9%
div-sub99.9%
metadata-eval99.9%
metadata-eval99.9%
sub-neg99.9%
distribute-frac-neg99.9%
neg-mul-199.9%
*-commutative99.9%
associate-/l*99.9%
metadata-eval99.9%
/-rgt-identity99.9%
+-commutative99.9%
+-commutative99.9%
associate-+r+99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around 0 77.6%
if -2.4499999999999999e-11 < y < 1.06000000000000002e-49Initial program 100.0%
+-commutative100.0%
remove-double-neg100.0%
unsub-neg100.0%
distribute-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
associate-/l*100.0%
+-commutative100.0%
sub-neg100.0%
div-sub100.0%
metadata-eval100.0%
metadata-eval100.0%
sub-neg100.0%
distribute-frac-neg100.0%
neg-mul-1100.0%
*-commutative100.0%
associate-/l*100.0%
metadata-eval100.0%
/-rgt-identity100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 83.4%
associate-*r/83.4%
mul-1-neg83.4%
sub-neg83.4%
metadata-eval83.4%
Simplified83.4%
Final simplification79.9%
(FPCore (x y) :precision binary64 (if (<= y -8.8e-12) (/ 1.0 (- 1.0 (/ 2.0 y))) (if (<= y 2.8e-49) (/ (- x) (+ x -2.0)) (/ y (- y 2.0)))))
double code(double x, double y) {
double tmp;
if (y <= -8.8e-12) {
tmp = 1.0 / (1.0 - (2.0 / y));
} else if (y <= 2.8e-49) {
tmp = -x / (x + -2.0);
} else {
tmp = y / (y - 2.0);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-8.8d-12)) then
tmp = 1.0d0 / (1.0d0 - (2.0d0 / y))
else if (y <= 2.8d-49) then
tmp = -x / (x + (-2.0d0))
else
tmp = y / (y - 2.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -8.8e-12) {
tmp = 1.0 / (1.0 - (2.0 / y));
} else if (y <= 2.8e-49) {
tmp = -x / (x + -2.0);
} else {
tmp = y / (y - 2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -8.8e-12: tmp = 1.0 / (1.0 - (2.0 / y)) elif y <= 2.8e-49: tmp = -x / (x + -2.0) else: tmp = y / (y - 2.0) return tmp
function code(x, y) tmp = 0.0 if (y <= -8.8e-12) tmp = Float64(1.0 / Float64(1.0 - Float64(2.0 / y))); elseif (y <= 2.8e-49) tmp = Float64(Float64(-x) / Float64(x + -2.0)); else tmp = Float64(y / Float64(y - 2.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -8.8e-12) tmp = 1.0 / (1.0 - (2.0 / y)); elseif (y <= 2.8e-49) tmp = -x / (x + -2.0); else tmp = y / (y - 2.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -8.8e-12], N[(1.0 / N[(1.0 - N[(2.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.8e-49], N[((-x) / N[(x + -2.0), $MachinePrecision]), $MachinePrecision], N[(y / N[(y - 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.8 \cdot 10^{-12}:\\
\;\;\;\;\frac{1}{1 - \frac{2}{y}}\\
\mathbf{elif}\;y \leq 2.8 \cdot 10^{-49}:\\
\;\;\;\;\frac{-x}{x + -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y - 2}\\
\end{array}
\end{array}
if y < -8.79999999999999966e-12Initial program 99.9%
+-commutative99.9%
remove-double-neg99.9%
unsub-neg99.9%
distribute-neg-in99.9%
neg-mul-199.9%
*-commutative99.9%
associate-/l*99.9%
+-commutative99.9%
sub-neg99.9%
div-sub99.9%
metadata-eval99.9%
metadata-eval99.9%
sub-neg99.9%
distribute-frac-neg99.9%
neg-mul-199.9%
*-commutative99.9%
associate-/l*99.9%
metadata-eval99.9%
/-rgt-identity99.9%
+-commutative99.9%
+-commutative99.9%
associate-+r+99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around 0 84.6%
clear-num84.6%
inv-pow84.6%
sub-neg84.6%
metadata-eval84.6%
Applied egg-rr84.6%
unpow-184.6%
metadata-eval84.6%
sub-neg84.6%
div-sub84.6%
*-inverses84.6%
Simplified84.6%
if -8.79999999999999966e-12 < y < 2.79999999999999997e-49Initial program 100.0%
+-commutative100.0%
remove-double-neg100.0%
unsub-neg100.0%
distribute-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
associate-/l*100.0%
+-commutative100.0%
sub-neg100.0%
div-sub100.0%
metadata-eval100.0%
metadata-eval100.0%
sub-neg100.0%
distribute-frac-neg100.0%
neg-mul-1100.0%
*-commutative100.0%
associate-/l*100.0%
metadata-eval100.0%
/-rgt-identity100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 83.4%
associate-*r/83.4%
mul-1-neg83.4%
sub-neg83.4%
metadata-eval83.4%
Simplified83.4%
if 2.79999999999999997e-49 < y Initial program 99.9%
+-commutative99.9%
remove-double-neg99.9%
unsub-neg99.9%
distribute-neg-in99.9%
neg-mul-199.9%
*-commutative99.9%
associate-/l*99.9%
+-commutative99.9%
sub-neg99.9%
div-sub99.9%
metadata-eval99.9%
metadata-eval99.9%
sub-neg99.9%
distribute-frac-neg99.9%
neg-mul-199.9%
*-commutative99.9%
associate-/l*99.9%
metadata-eval99.9%
/-rgt-identity99.9%
+-commutative99.9%
+-commutative99.9%
associate-+r+99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around 0 69.6%
Final simplification79.9%
(FPCore (x y)
:precision binary64
(if (<= x -1.8e+124)
-1.0
(if (<= x 2e-129)
1.0
(if (<= x 4.5e-21) (* x 0.5) (if (<= x 5e+17) 1.0 -1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -1.8e+124) {
tmp = -1.0;
} else if (x <= 2e-129) {
tmp = 1.0;
} else if (x <= 4.5e-21) {
tmp = x * 0.5;
} else if (x <= 5e+17) {
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.8d+124)) then
tmp = -1.0d0
else if (x <= 2d-129) then
tmp = 1.0d0
else if (x <= 4.5d-21) then
tmp = x * 0.5d0
else if (x <= 5d+17) 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.8e+124) {
tmp = -1.0;
} else if (x <= 2e-129) {
tmp = 1.0;
} else if (x <= 4.5e-21) {
tmp = x * 0.5;
} else if (x <= 5e+17) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.8e+124: tmp = -1.0 elif x <= 2e-129: tmp = 1.0 elif x <= 4.5e-21: tmp = x * 0.5 elif x <= 5e+17: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.8e+124) tmp = -1.0; elseif (x <= 2e-129) tmp = 1.0; elseif (x <= 4.5e-21) tmp = Float64(x * 0.5); elseif (x <= 5e+17) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.8e+124) tmp = -1.0; elseif (x <= 2e-129) tmp = 1.0; elseif (x <= 4.5e-21) tmp = x * 0.5; elseif (x <= 5e+17) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.8e+124], -1.0, If[LessEqual[x, 2e-129], 1.0, If[LessEqual[x, 4.5e-21], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 5e+17], 1.0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.8 \cdot 10^{+124}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 2 \cdot 10^{-129}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 4.5 \cdot 10^{-21}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 5 \cdot 10^{+17}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -1.79999999999999993e124 or 5e17 < x Initial program 99.9%
+-commutative99.9%
remove-double-neg99.9%
unsub-neg99.9%
distribute-neg-in99.9%
neg-mul-199.9%
*-commutative99.9%
associate-/l*99.9%
+-commutative99.9%
sub-neg99.9%
div-sub99.9%
metadata-eval99.9%
metadata-eval99.9%
sub-neg99.9%
distribute-frac-neg99.9%
neg-mul-199.9%
*-commutative99.9%
associate-/l*99.9%
metadata-eval99.9%
/-rgt-identity99.9%
+-commutative99.9%
+-commutative99.9%
associate-+r+99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around inf 78.1%
if -1.79999999999999993e124 < x < 1.9999999999999999e-129 or 4.49999999999999968e-21 < x < 5e17Initial program 100.0%
+-commutative100.0%
remove-double-neg100.0%
unsub-neg100.0%
distribute-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
associate-/l*100.0%
+-commutative100.0%
sub-neg100.0%
div-sub100.0%
metadata-eval100.0%
metadata-eval100.0%
sub-neg100.0%
distribute-frac-neg100.0%
neg-mul-1100.0%
*-commutative100.0%
associate-/l*100.0%
metadata-eval100.0%
/-rgt-identity100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 61.3%
if 1.9999999999999999e-129 < x < 4.49999999999999968e-21Initial program 99.9%
+-commutative99.9%
remove-double-neg99.9%
unsub-neg99.9%
distribute-neg-in99.9%
neg-mul-199.9%
*-commutative99.9%
associate-/l*99.9%
+-commutative99.9%
sub-neg99.9%
div-sub99.9%
metadata-eval99.9%
metadata-eval99.9%
sub-neg99.9%
distribute-frac-neg99.9%
neg-mul-199.9%
*-commutative99.9%
associate-/l*99.9%
metadata-eval99.9%
/-rgt-identity99.9%
+-commutative99.9%
+-commutative99.9%
associate-+r+99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around 0 63.5%
associate-*r/63.5%
mul-1-neg63.5%
sub-neg63.5%
metadata-eval63.5%
Simplified63.5%
Taylor expanded in x around 0 63.5%
*-commutative63.5%
Simplified63.5%
Final simplification67.4%
(FPCore (x y) :precision binary64 (if (<= x -7.2e+130) -1.0 (if (<= x 2e+25) 1.0 -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -7.2e+130) {
tmp = -1.0;
} else if (x <= 2e+25) {
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 <= (-7.2d+130)) then
tmp = -1.0d0
else if (x <= 2d+25) 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 <= -7.2e+130) {
tmp = -1.0;
} else if (x <= 2e+25) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -7.2e+130: tmp = -1.0 elif x <= 2e+25: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -7.2e+130) tmp = -1.0; elseif (x <= 2e+25) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -7.2e+130) tmp = -1.0; elseif (x <= 2e+25) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -7.2e+130], -1.0, If[LessEqual[x, 2e+25], 1.0, -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.2 \cdot 10^{+130}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 2 \cdot 10^{+25}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -7.2000000000000002e130 or 2.00000000000000018e25 < x Initial program 99.9%
+-commutative99.9%
remove-double-neg99.9%
unsub-neg99.9%
distribute-neg-in99.9%
neg-mul-199.9%
*-commutative99.9%
associate-/l*99.9%
+-commutative99.9%
sub-neg99.9%
div-sub99.9%
metadata-eval99.9%
metadata-eval99.9%
sub-neg99.9%
distribute-frac-neg99.9%
neg-mul-199.9%
*-commutative99.9%
associate-/l*99.9%
metadata-eval99.9%
/-rgt-identity99.9%
+-commutative99.9%
+-commutative99.9%
associate-+r+99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around inf 78.1%
if -7.2000000000000002e130 < x < 2.00000000000000018e25Initial program 100.0%
+-commutative100.0%
remove-double-neg100.0%
unsub-neg100.0%
distribute-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
associate-/l*100.0%
+-commutative100.0%
sub-neg100.0%
div-sub100.0%
metadata-eval100.0%
metadata-eval100.0%
sub-neg100.0%
distribute-frac-neg100.0%
neg-mul-1100.0%
*-commutative100.0%
associate-/l*100.0%
metadata-eval100.0%
/-rgt-identity100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 55.9%
Final simplification63.7%
(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%
+-commutative100.0%
remove-double-neg100.0%
unsub-neg100.0%
distribute-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
associate-/l*100.0%
+-commutative100.0%
sub-neg100.0%
div-sub100.0%
metadata-eval100.0%
metadata-eval100.0%
sub-neg100.0%
distribute-frac-neg100.0%
neg-mul-1100.0%
*-commutative100.0%
associate-/l*100.0%
metadata-eval100.0%
/-rgt-identity100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 33.0%
Final simplification33.0%
(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 2023308
(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))))