
(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 8 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 (+ y (+ -2.0 x)))) (- (/ y t_0) (/ x t_0))))
double code(double x, double y) {
double t_0 = y + (-2.0 + x);
return (y / t_0) - (x / t_0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
t_0 = y + ((-2.0d0) + x)
code = (y / t_0) - (x / t_0)
end function
public static double code(double x, double y) {
double t_0 = y + (-2.0 + x);
return (y / t_0) - (x / t_0);
}
def code(x, y): t_0 = y + (-2.0 + x) return (y / t_0) - (x / t_0)
function code(x, y) t_0 = Float64(y + Float64(-2.0 + x)) return Float64(Float64(y / t_0) - Float64(x / t_0)) end
function tmp = code(x, y) t_0 = y + (-2.0 + x); tmp = (y / t_0) - (x / t_0); end
code[x_, y_] := Block[{t$95$0 = N[(y + N[(-2.0 + x), $MachinePrecision]), $MachinePrecision]}, N[(N[(y / t$95$0), $MachinePrecision] - N[(x / t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y + \left(-2 + x\right)\\
\frac{y}{t_0} - \frac{x}{t_0}
\end{array}
\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%
div-sub100.0%
+-commutative100.0%
associate-+l+100.0%
+-commutative100.0%
associate-+l+100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(if (<= x -2e+122)
-1.0
(if (<= x 7.8e-262)
1.0
(if (<= x 4.8e-135)
(* y -0.5)
(if (<= x 70000000.0) 1.0 (+ -1.0 (/ -2.0 x)))))))
double code(double x, double y) {
double tmp;
if (x <= -2e+122) {
tmp = -1.0;
} else if (x <= 7.8e-262) {
tmp = 1.0;
} else if (x <= 4.8e-135) {
tmp = y * -0.5;
} else if (x <= 70000000.0) {
tmp = 1.0;
} else {
tmp = -1.0 + (-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 <= (-2d+122)) then
tmp = -1.0d0
else if (x <= 7.8d-262) then
tmp = 1.0d0
else if (x <= 4.8d-135) then
tmp = y * (-0.5d0)
else if (x <= 70000000.0d0) then
tmp = 1.0d0
else
tmp = (-1.0d0) + ((-2.0d0) / x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -2e+122) {
tmp = -1.0;
} else if (x <= 7.8e-262) {
tmp = 1.0;
} else if (x <= 4.8e-135) {
tmp = y * -0.5;
} else if (x <= 70000000.0) {
tmp = 1.0;
} else {
tmp = -1.0 + (-2.0 / x);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2e+122: tmp = -1.0 elif x <= 7.8e-262: tmp = 1.0 elif x <= 4.8e-135: tmp = y * -0.5 elif x <= 70000000.0: tmp = 1.0 else: tmp = -1.0 + (-2.0 / x) return tmp
function code(x, y) tmp = 0.0 if (x <= -2e+122) tmp = -1.0; elseif (x <= 7.8e-262) tmp = 1.0; elseif (x <= 4.8e-135) tmp = Float64(y * -0.5); elseif (x <= 70000000.0) tmp = 1.0; else tmp = Float64(-1.0 + Float64(-2.0 / x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2e+122) tmp = -1.0; elseif (x <= 7.8e-262) tmp = 1.0; elseif (x <= 4.8e-135) tmp = y * -0.5; elseif (x <= 70000000.0) tmp = 1.0; else tmp = -1.0 + (-2.0 / x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2e+122], -1.0, If[LessEqual[x, 7.8e-262], 1.0, If[LessEqual[x, 4.8e-135], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 70000000.0], 1.0, N[(-1.0 + N[(-2.0 / x), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{+122}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 7.8 \cdot 10^{-262}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 4.8 \cdot 10^{-135}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 70000000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1 + \frac{-2}{x}\\
\end{array}
\end{array}
if x < -2.00000000000000003e122Initial 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 90.1%
if -2.00000000000000003e122 < x < 7.79999999999999967e-262 or 4.7999999999999997e-135 < x < 7e7Initial 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 57.5%
if 7.79999999999999967e-262 < x < 4.7999999999999997e-135Initial 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 75.9%
Taylor expanded in y around 0 61.2%
*-commutative61.2%
Simplified61.2%
if 7e7 < 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 y around 0 81.1%
associate-*r/81.1%
mul-1-neg81.1%
sub-neg81.1%
metadata-eval81.1%
Simplified81.1%
Taylor expanded in x around inf 81.1%
distribute-neg-in81.1%
metadata-eval81.1%
associate-*r/81.1%
metadata-eval81.1%
distribute-neg-frac81.1%
metadata-eval81.1%
Simplified81.1%
Final simplification68.9%
(FPCore (x y) :precision binary64 (if (<= x -3.6e+122) -1.0 (if (<= x 4.4e-39) (/ y (- y 2.0)) (/ (- x) (+ -2.0 x)))))
double code(double x, double y) {
double tmp;
if (x <= -3.6e+122) {
tmp = -1.0;
} else if (x <= 4.4e-39) {
tmp = y / (y - 2.0);
} else {
tmp = -x / (-2.0 + x);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-3.6d+122)) then
tmp = -1.0d0
else if (x <= 4.4d-39) then
tmp = y / (y - 2.0d0)
else
tmp = -x / ((-2.0d0) + x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -3.6e+122) {
tmp = -1.0;
} else if (x <= 4.4e-39) {
tmp = y / (y - 2.0);
} else {
tmp = -x / (-2.0 + x);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -3.6e+122: tmp = -1.0 elif x <= 4.4e-39: tmp = y / (y - 2.0) else: tmp = -x / (-2.0 + x) return tmp
function code(x, y) tmp = 0.0 if (x <= -3.6e+122) tmp = -1.0; elseif (x <= 4.4e-39) tmp = Float64(y / Float64(y - 2.0)); else tmp = Float64(Float64(-x) / Float64(-2.0 + x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -3.6e+122) tmp = -1.0; elseif (x <= 4.4e-39) tmp = y / (y - 2.0); else tmp = -x / (-2.0 + x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -3.6e+122], -1.0, If[LessEqual[x, 4.4e-39], N[(y / N[(y - 2.0), $MachinePrecision]), $MachinePrecision], N[((-x) / N[(-2.0 + x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.6 \cdot 10^{+122}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 4.4 \cdot 10^{-39}:\\
\;\;\;\;\frac{y}{y - 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-x}{-2 + x}\\
\end{array}
\end{array}
if x < -3.6000000000000003e122Initial 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 90.1%
if -3.6000000000000003e122 < x < 4.40000000000000002e-39Initial 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 77.2%
if 4.40000000000000002e-39 < 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 y around 0 77.2%
associate-*r/77.2%
mul-1-neg77.2%
sub-neg77.2%
metadata-eval77.2%
Simplified77.2%
Final simplification79.0%
(FPCore (x y)
:precision binary64
(if (<= x -1e+122)
-1.0
(if (<= x 1.3e-261)
1.0
(if (<= x 2.4e-135) (* y -0.5) (if (<= x 2.5e+20) 1.0 -1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -1e+122) {
tmp = -1.0;
} else if (x <= 1.3e-261) {
tmp = 1.0;
} else if (x <= 2.4e-135) {
tmp = y * -0.5;
} else if (x <= 2.5e+20) {
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+122)) then
tmp = -1.0d0
else if (x <= 1.3d-261) then
tmp = 1.0d0
else if (x <= 2.4d-135) then
tmp = y * (-0.5d0)
else if (x <= 2.5d+20) 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+122) {
tmp = -1.0;
} else if (x <= 1.3e-261) {
tmp = 1.0;
} else if (x <= 2.4e-135) {
tmp = y * -0.5;
} else if (x <= 2.5e+20) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1e+122: tmp = -1.0 elif x <= 1.3e-261: tmp = 1.0 elif x <= 2.4e-135: tmp = y * -0.5 elif x <= 2.5e+20: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1e+122) tmp = -1.0; elseif (x <= 1.3e-261) tmp = 1.0; elseif (x <= 2.4e-135) tmp = Float64(y * -0.5); elseif (x <= 2.5e+20) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1e+122) tmp = -1.0; elseif (x <= 1.3e-261) tmp = 1.0; elseif (x <= 2.4e-135) tmp = y * -0.5; elseif (x <= 2.5e+20) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1e+122], -1.0, If[LessEqual[x, 1.3e-261], 1.0, If[LessEqual[x, 2.4e-135], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 2.5e+20], 1.0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{+122}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 1.3 \cdot 10^{-261}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 2.4 \cdot 10^{-135}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{+20}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -1.00000000000000001e122 or 2.5e20 < 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 85.5%
if -1.00000000000000001e122 < x < 1.3000000000000001e-261 or 2.3999999999999999e-135 < x < 2.5e20Initial 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 57.3%
if 1.3000000000000001e-261 < x < 2.3999999999999999e-135Initial 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 75.9%
Taylor expanded in y around 0 61.2%
*-commutative61.2%
Simplified61.2%
Final simplification68.9%
(FPCore (x y) :precision binary64 (if (<= x -1e+122) -1.0 (if (<= x 2.15e+20) (/ y (- y 2.0)) -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -1e+122) {
tmp = -1.0;
} else if (x <= 2.15e+20) {
tmp = y / (y - 2.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+122)) then
tmp = -1.0d0
else if (x <= 2.15d+20) then
tmp = y / (y - 2.0d0)
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1e+122) {
tmp = -1.0;
} else if (x <= 2.15e+20) {
tmp = y / (y - 2.0);
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1e+122: tmp = -1.0 elif x <= 2.15e+20: tmp = y / (y - 2.0) else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1e+122) tmp = -1.0; elseif (x <= 2.15e+20) tmp = Float64(y / Float64(y - 2.0)); else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1e+122) tmp = -1.0; elseif (x <= 2.15e+20) tmp = y / (y - 2.0); else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1e+122], -1.0, If[LessEqual[x, 2.15e+20], N[(y / N[(y - 2.0), $MachinePrecision]), $MachinePrecision], -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{+122}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 2.15 \cdot 10^{+20}:\\
\;\;\;\;\frac{y}{y - 2}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -1.00000000000000001e122 or 2.15e20 < 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 85.5%
if -1.00000000000000001e122 < x < 2.15e20Initial 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 73.3%
Final simplification78.2%
(FPCore (x y) :precision binary64 (/ (- x y) (- 2.0 (+ y x))))
double code(double x, double y) {
return (x - y) / (2.0 - (y + x));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x - y) / (2.0d0 - (y + x))
end function
public static double code(double x, double y) {
return (x - y) / (2.0 - (y + x));
}
def code(x, y): return (x - y) / (2.0 - (y + x))
function code(x, y) return Float64(Float64(x - y) / Float64(2.0 - Float64(y + x))) end
function tmp = code(x, y) tmp = (x - y) / (2.0 - (y + x)); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(2.0 - N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{2 - \left(y + x\right)}
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y) :precision binary64 (if (<= x -1e+122) -1.0 (if (<= x 2.7e+20) 1.0 -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -1e+122) {
tmp = -1.0;
} else if (x <= 2.7e+20) {
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+122)) then
tmp = -1.0d0
else if (x <= 2.7d+20) 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+122) {
tmp = -1.0;
} else if (x <= 2.7e+20) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1e+122: tmp = -1.0 elif x <= 2.7e+20: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1e+122) tmp = -1.0; elseif (x <= 2.7e+20) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1e+122) tmp = -1.0; elseif (x <= 2.7e+20) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1e+122], -1.0, If[LessEqual[x, 2.7e+20], 1.0, -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{+122}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 2.7 \cdot 10^{+20}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -1.00000000000000001e122 or 2.7e20 < 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 85.5%
if -1.00000000000000001e122 < x < 2.7e20Initial 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 50.1%
Final simplification64.2%
(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 38.4%
Final simplification38.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 2023318
(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))))