
(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 (/ (- 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 (<= y -1300000.0)
1.0
(if (<= y -1.95e-113)
-1.0
(if (<= y -3.5e-148)
(* y -0.5)
(if (<= y -3.75e-237)
-1.0
(if (<= y 1.6e-301)
(* x 0.5)
(if (<= y 3.6e-151)
-1.0
(if (<= y 1.5e-16)
(* y -0.5)
(if (<= y 2.65e+28) -1.0 1.0)))))))))
double code(double x, double y) {
double tmp;
if (y <= -1300000.0) {
tmp = 1.0;
} else if (y <= -1.95e-113) {
tmp = -1.0;
} else if (y <= -3.5e-148) {
tmp = y * -0.5;
} else if (y <= -3.75e-237) {
tmp = -1.0;
} else if (y <= 1.6e-301) {
tmp = x * 0.5;
} else if (y <= 3.6e-151) {
tmp = -1.0;
} else if (y <= 1.5e-16) {
tmp = y * -0.5;
} else if (y <= 2.65e+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 (y <= (-1300000.0d0)) then
tmp = 1.0d0
else if (y <= (-1.95d-113)) then
tmp = -1.0d0
else if (y <= (-3.5d-148)) then
tmp = y * (-0.5d0)
else if (y <= (-3.75d-237)) then
tmp = -1.0d0
else if (y <= 1.6d-301) then
tmp = x * 0.5d0
else if (y <= 3.6d-151) then
tmp = -1.0d0
else if (y <= 1.5d-16) then
tmp = y * (-0.5d0)
else if (y <= 2.65d+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 (y <= -1300000.0) {
tmp = 1.0;
} else if (y <= -1.95e-113) {
tmp = -1.0;
} else if (y <= -3.5e-148) {
tmp = y * -0.5;
} else if (y <= -3.75e-237) {
tmp = -1.0;
} else if (y <= 1.6e-301) {
tmp = x * 0.5;
} else if (y <= 3.6e-151) {
tmp = -1.0;
} else if (y <= 1.5e-16) {
tmp = y * -0.5;
} else if (y <= 2.65e+28) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1300000.0: tmp = 1.0 elif y <= -1.95e-113: tmp = -1.0 elif y <= -3.5e-148: tmp = y * -0.5 elif y <= -3.75e-237: tmp = -1.0 elif y <= 1.6e-301: tmp = x * 0.5 elif y <= 3.6e-151: tmp = -1.0 elif y <= 1.5e-16: tmp = y * -0.5 elif y <= 2.65e+28: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -1300000.0) tmp = 1.0; elseif (y <= -1.95e-113) tmp = -1.0; elseif (y <= -3.5e-148) tmp = Float64(y * -0.5); elseif (y <= -3.75e-237) tmp = -1.0; elseif (y <= 1.6e-301) tmp = Float64(x * 0.5); elseif (y <= 3.6e-151) tmp = -1.0; elseif (y <= 1.5e-16) tmp = Float64(y * -0.5); elseif (y <= 2.65e+28) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1300000.0) tmp = 1.0; elseif (y <= -1.95e-113) tmp = -1.0; elseif (y <= -3.5e-148) tmp = y * -0.5; elseif (y <= -3.75e-237) tmp = -1.0; elseif (y <= 1.6e-301) tmp = x * 0.5; elseif (y <= 3.6e-151) tmp = -1.0; elseif (y <= 1.5e-16) tmp = y * -0.5; elseif (y <= 2.65e+28) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1300000.0], 1.0, If[LessEqual[y, -1.95e-113], -1.0, If[LessEqual[y, -3.5e-148], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, -3.75e-237], -1.0, If[LessEqual[y, 1.6e-301], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 3.6e-151], -1.0, If[LessEqual[y, 1.5e-16], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 2.65e+28], -1.0, 1.0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1300000:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -1.95 \cdot 10^{-113}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq -3.5 \cdot 10^{-148}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq -3.75 \cdot 10^{-237}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 1.6 \cdot 10^{-301}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;y \leq 3.6 \cdot 10^{-151}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 1.5 \cdot 10^{-16}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 2.65 \cdot 10^{+28}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.3e6 or 2.6500000000000002e28 < y Initial program 99.9%
Taylor expanded in y around inf 79.3%
if -1.3e6 < y < -1.9499999999999999e-113 or -3.5e-148 < y < -3.75000000000000017e-237 or 1.5999999999999999e-301 < y < 3.60000000000000032e-151 or 1.49999999999999997e-16 < y < 2.6500000000000002e28Initial program 100.0%
Taylor expanded in x around inf 65.9%
if -1.9499999999999999e-113 < y < -3.5e-148 or 3.60000000000000032e-151 < y < 1.49999999999999997e-16Initial program 100.0%
Taylor expanded in x around 0 70.4%
mul-1-neg70.4%
distribute-neg-frac70.4%
Simplified70.4%
Taylor expanded in y around 0 70.4%
*-commutative70.4%
Simplified70.4%
if -3.75000000000000017e-237 < y < 1.5999999999999999e-301Initial program 100.0%
Taylor expanded in y around 0 95.4%
Taylor expanded in x around 0 70.9%
*-commutative70.9%
Simplified70.9%
Final simplification73.1%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (- 2.0 x))))
(if (<= y -320000.0)
1.0
(if (<= y 4.4e-149)
t_0
(if (<= y 3.6e-16) (* y -0.5) (if (<= y 6.6e+78) t_0 1.0))))))
double code(double x, double y) {
double t_0 = x / (2.0 - x);
double tmp;
if (y <= -320000.0) {
tmp = 1.0;
} else if (y <= 4.4e-149) {
tmp = t_0;
} else if (y <= 3.6e-16) {
tmp = y * -0.5;
} else if (y <= 6.6e+78) {
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 = x / (2.0d0 - x)
if (y <= (-320000.0d0)) then
tmp = 1.0d0
else if (y <= 4.4d-149) then
tmp = t_0
else if (y <= 3.6d-16) then
tmp = y * (-0.5d0)
else if (y <= 6.6d+78) 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 = x / (2.0 - x);
double tmp;
if (y <= -320000.0) {
tmp = 1.0;
} else if (y <= 4.4e-149) {
tmp = t_0;
} else if (y <= 3.6e-16) {
tmp = y * -0.5;
} else if (y <= 6.6e+78) {
tmp = t_0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): t_0 = x / (2.0 - x) tmp = 0 if y <= -320000.0: tmp = 1.0 elif y <= 4.4e-149: tmp = t_0 elif y <= 3.6e-16: tmp = y * -0.5 elif y <= 6.6e+78: tmp = t_0 else: tmp = 1.0 return tmp
function code(x, y) t_0 = Float64(x / Float64(2.0 - x)) tmp = 0.0 if (y <= -320000.0) tmp = 1.0; elseif (y <= 4.4e-149) tmp = t_0; elseif (y <= 3.6e-16) tmp = Float64(y * -0.5); elseif (y <= 6.6e+78) tmp = t_0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) t_0 = x / (2.0 - x); tmp = 0.0; if (y <= -320000.0) tmp = 1.0; elseif (y <= 4.4e-149) tmp = t_0; elseif (y <= 3.6e-16) tmp = y * -0.5; elseif (y <= 6.6e+78) tmp = t_0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -320000.0], 1.0, If[LessEqual[y, 4.4e-149], t$95$0, If[LessEqual[y, 3.6e-16], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 6.6e+78], t$95$0, 1.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{2 - x}\\
\mathbf{if}\;y \leq -320000:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 4.4 \cdot 10^{-149}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 3.6 \cdot 10^{-16}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 6.6 \cdot 10^{+78}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -3.2e5 or 6.6e78 < y Initial program 99.9%
Taylor expanded in y around inf 80.8%
if -3.2e5 < y < 4.3999999999999996e-149 or 3.59999999999999983e-16 < y < 6.6e78Initial program 100.0%
Taylor expanded in y around 0 78.3%
if 4.3999999999999996e-149 < y < 3.59999999999999983e-16Initial program 100.0%
Taylor expanded in x around 0 73.9%
mul-1-neg73.9%
distribute-neg-frac73.9%
Simplified73.9%
Taylor expanded in y around 0 73.9%
*-commutative73.9%
Simplified73.9%
Final simplification79.1%
(FPCore (x y)
:precision binary64
(if (<= y -1300000.0)
1.0
(if (<= y -3.65e-236)
-1.0
(if (<= y 1.46e-301) (* x 0.5) (if (<= y 4.9e+27) -1.0 1.0)))))
double code(double x, double y) {
double tmp;
if (y <= -1300000.0) {
tmp = 1.0;
} else if (y <= -3.65e-236) {
tmp = -1.0;
} else if (y <= 1.46e-301) {
tmp = x * 0.5;
} else if (y <= 4.9e+27) {
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 (y <= (-1300000.0d0)) then
tmp = 1.0d0
else if (y <= (-3.65d-236)) then
tmp = -1.0d0
else if (y <= 1.46d-301) then
tmp = x * 0.5d0
else if (y <= 4.9d+27) 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 (y <= -1300000.0) {
tmp = 1.0;
} else if (y <= -3.65e-236) {
tmp = -1.0;
} else if (y <= 1.46e-301) {
tmp = x * 0.5;
} else if (y <= 4.9e+27) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1300000.0: tmp = 1.0 elif y <= -3.65e-236: tmp = -1.0 elif y <= 1.46e-301: tmp = x * 0.5 elif y <= 4.9e+27: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -1300000.0) tmp = 1.0; elseif (y <= -3.65e-236) tmp = -1.0; elseif (y <= 1.46e-301) tmp = Float64(x * 0.5); elseif (y <= 4.9e+27) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1300000.0) tmp = 1.0; elseif (y <= -3.65e-236) tmp = -1.0; elseif (y <= 1.46e-301) tmp = x * 0.5; elseif (y <= 4.9e+27) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1300000.0], 1.0, If[LessEqual[y, -3.65e-236], -1.0, If[LessEqual[y, 1.46e-301], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 4.9e+27], -1.0, 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1300000:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -3.65 \cdot 10^{-236}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 1.46 \cdot 10^{-301}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;y \leq 4.9 \cdot 10^{+27}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.3e6 or 4.90000000000000015e27 < y Initial program 99.9%
Taylor expanded in y around inf 79.3%
if -1.3e6 < y < -3.65000000000000014e-236 or 1.46000000000000002e-301 < y < 4.90000000000000015e27Initial program 100.0%
Taylor expanded in x around inf 55.6%
if -3.65000000000000014e-236 < y < 1.46000000000000002e-301Initial program 100.0%
Taylor expanded in y around 0 95.4%
Taylor expanded in x around 0 70.9%
*-commutative70.9%
Simplified70.9%
Final simplification67.9%
(FPCore (x y) :precision binary64 (if (or (<= x -4.8e+30) (not (<= x 3800000000000.0))) (+ (* 2.0 (/ y x)) -1.0) (/ y (+ y -2.0))))
double code(double x, double y) {
double tmp;
if ((x <= -4.8e+30) || !(x <= 3800000000000.0)) {
tmp = (2.0 * (y / x)) + -1.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 ((x <= (-4.8d+30)) .or. (.not. (x <= 3800000000000.0d0))) then
tmp = (2.0d0 * (y / x)) + (-1.0d0)
else
tmp = y / (y + (-2.0d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -4.8e+30) || !(x <= 3800000000000.0)) {
tmp = (2.0 * (y / x)) + -1.0;
} else {
tmp = y / (y + -2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -4.8e+30) or not (x <= 3800000000000.0): tmp = (2.0 * (y / x)) + -1.0 else: tmp = y / (y + -2.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -4.8e+30) || !(x <= 3800000000000.0)) tmp = Float64(Float64(2.0 * Float64(y / x)) + -1.0); else tmp = Float64(y / Float64(y + -2.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -4.8e+30) || ~((x <= 3800000000000.0))) tmp = (2.0 * (y / x)) + -1.0; else tmp = y / (y + -2.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -4.8e+30], N[Not[LessEqual[x, 3800000000000.0]], $MachinePrecision]], N[(N[(2.0 * N[(y / x), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.8 \cdot 10^{+30} \lor \neg \left(x \leq 3800000000000\right):\\
\;\;\;\;2 \cdot \frac{y}{x} + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y + -2}\\
\end{array}
\end{array}
if x < -4.7999999999999999e30 or 3.8e12 < x Initial program 99.9%
expm1-log1p-u97.3%
expm1-udef97.3%
Applied egg-rr97.3%
log1p-udef97.3%
rem-exp-log100.0%
+-commutative100.0%
+-commutative100.0%
Applied egg-rr100.0%
Taylor expanded in x around -inf 78.8%
Taylor expanded in y around inf 78.8%
if -4.7999999999999999e30 < x < 3.8e12Initial program 100.0%
Taylor expanded in x around 0 78.3%
mul-1-neg78.3%
distribute-neg-frac78.3%
Simplified78.3%
expm1-log1p-u78.2%
expm1-udef54.4%
add-sqr-sqrt30.8%
sqrt-unprod18.3%
sqr-neg18.3%
sqrt-unprod1.0%
add-sqr-sqrt2.7%
frac-2neg2.7%
add-sqr-sqrt1.6%
sqrt-unprod14.8%
sqr-neg14.8%
sqrt-unprod23.5%
add-sqr-sqrt54.4%
sub-neg54.4%
distribute-neg-in54.4%
metadata-eval54.4%
remove-double-neg54.4%
Applied egg-rr54.4%
expm1-def78.2%
expm1-log1p78.3%
+-commutative78.3%
Simplified78.3%
Final simplification78.5%
(FPCore (x y) :precision binary64 (if (<= x -2.35e+32) -1.0 (if (<= x 1.02e-42) (/ y (+ y -2.0)) (/ x (- 2.0 x)))))
double code(double x, double y) {
double tmp;
if (x <= -2.35e+32) {
tmp = -1.0;
} else if (x <= 1.02e-42) {
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 <= (-2.35d+32)) then
tmp = -1.0d0
else if (x <= 1.02d-42) 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 <= -2.35e+32) {
tmp = -1.0;
} else if (x <= 1.02e-42) {
tmp = y / (y + -2.0);
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2.35e+32: tmp = -1.0 elif x <= 1.02e-42: tmp = y / (y + -2.0) else: tmp = x / (2.0 - x) return tmp
function code(x, y) tmp = 0.0 if (x <= -2.35e+32) tmp = -1.0; elseif (x <= 1.02e-42) tmp = Float64(y / Float64(y + -2.0)); else tmp = Float64(x / Float64(2.0 - x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2.35e+32) tmp = -1.0; elseif (x <= 1.02e-42) tmp = y / (y + -2.0); else tmp = x / (2.0 - x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2.35e+32], -1.0, If[LessEqual[x, 1.02e-42], 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 -2.35 \cdot 10^{+32}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 1.02 \cdot 10^{-42}:\\
\;\;\;\;\frac{y}{y + -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 - x}\\
\end{array}
\end{array}
if x < -2.35000000000000012e32Initial program 100.0%
Taylor expanded in x around inf 81.9%
if -2.35000000000000012e32 < x < 1.0199999999999999e-42Initial program 100.0%
Taylor expanded in x around 0 80.4%
mul-1-neg80.4%
distribute-neg-frac80.4%
Simplified80.4%
expm1-log1p-u80.4%
expm1-udef55.0%
add-sqr-sqrt31.3%
sqrt-unprod18.6%
sqr-neg18.6%
sqrt-unprod1.0%
add-sqr-sqrt2.8%
frac-2neg2.8%
add-sqr-sqrt1.6%
sqrt-unprod14.2%
sqr-neg14.2%
sqrt-unprod23.5%
add-sqr-sqrt55.0%
sub-neg55.0%
distribute-neg-in55.0%
metadata-eval55.0%
remove-double-neg55.0%
Applied egg-rr55.0%
expm1-def80.4%
expm1-log1p80.4%
+-commutative80.4%
Simplified80.4%
if 1.0199999999999999e-42 < x Initial program 99.9%
Taylor expanded in y around 0 71.4%
Final simplification78.3%
(FPCore (x y) :precision binary64 (if (<= y -82000.0) 1.0 (if (<= y 2e+34) -1.0 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -82000.0) {
tmp = 1.0;
} else if (y <= 2e+34) {
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 (y <= (-82000.0d0)) then
tmp = 1.0d0
else if (y <= 2d+34) 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 (y <= -82000.0) {
tmp = 1.0;
} else if (y <= 2e+34) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -82000.0: tmp = 1.0 elif y <= 2e+34: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -82000.0) tmp = 1.0; elseif (y <= 2e+34) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -82000.0) tmp = 1.0; elseif (y <= 2e+34) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -82000.0], 1.0, If[LessEqual[y, 2e+34], -1.0, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -82000:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 2 \cdot 10^{+34}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -82000 or 1.99999999999999989e34 < y Initial program 99.9%
Taylor expanded in y around inf 79.3%
if -82000 < y < 1.99999999999999989e34Initial program 100.0%
Taylor expanded in x around inf 51.5%
Final simplification64.5%
(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 36.2%
Final simplification36.2%
(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 2024026
(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))))