
(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 (/ x (- 2.0 x))))
(if (<= y -2.1e+49)
1.0
(if (<= y -6.8e-6)
t_0
(if (<= y -7e-44)
(* y -0.5)
(if (<= y 1.3e-120)
t_0
(if (<= y 2e-83)
(* y -0.5)
(if (<= y 9.2e-59)
t_0
(if (<= y 3.5e-16)
(* y -0.5)
(if (<= y 1.1e+14) -1.0 1.0))))))))))
double code(double x, double y) {
double t_0 = x / (2.0 - x);
double tmp;
if (y <= -2.1e+49) {
tmp = 1.0;
} else if (y <= -6.8e-6) {
tmp = t_0;
} else if (y <= -7e-44) {
tmp = y * -0.5;
} else if (y <= 1.3e-120) {
tmp = t_0;
} else if (y <= 2e-83) {
tmp = y * -0.5;
} else if (y <= 9.2e-59) {
tmp = t_0;
} else if (y <= 3.5e-16) {
tmp = y * -0.5;
} else if (y <= 1.1e+14) {
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) :: t_0
real(8) :: tmp
t_0 = x / (2.0d0 - x)
if (y <= (-2.1d+49)) then
tmp = 1.0d0
else if (y <= (-6.8d-6)) then
tmp = t_0
else if (y <= (-7d-44)) then
tmp = y * (-0.5d0)
else if (y <= 1.3d-120) then
tmp = t_0
else if (y <= 2d-83) then
tmp = y * (-0.5d0)
else if (y <= 9.2d-59) then
tmp = t_0
else if (y <= 3.5d-16) then
tmp = y * (-0.5d0)
else if (y <= 1.1d+14) then
tmp = -1.0d0
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 <= -2.1e+49) {
tmp = 1.0;
} else if (y <= -6.8e-6) {
tmp = t_0;
} else if (y <= -7e-44) {
tmp = y * -0.5;
} else if (y <= 1.3e-120) {
tmp = t_0;
} else if (y <= 2e-83) {
tmp = y * -0.5;
} else if (y <= 9.2e-59) {
tmp = t_0;
} else if (y <= 3.5e-16) {
tmp = y * -0.5;
} else if (y <= 1.1e+14) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): t_0 = x / (2.0 - x) tmp = 0 if y <= -2.1e+49: tmp = 1.0 elif y <= -6.8e-6: tmp = t_0 elif y <= -7e-44: tmp = y * -0.5 elif y <= 1.3e-120: tmp = t_0 elif y <= 2e-83: tmp = y * -0.5 elif y <= 9.2e-59: tmp = t_0 elif y <= 3.5e-16: tmp = y * -0.5 elif y <= 1.1e+14: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) t_0 = Float64(x / Float64(2.0 - x)) tmp = 0.0 if (y <= -2.1e+49) tmp = 1.0; elseif (y <= -6.8e-6) tmp = t_0; elseif (y <= -7e-44) tmp = Float64(y * -0.5); elseif (y <= 1.3e-120) tmp = t_0; elseif (y <= 2e-83) tmp = Float64(y * -0.5); elseif (y <= 9.2e-59) tmp = t_0; elseif (y <= 3.5e-16) tmp = Float64(y * -0.5); elseif (y <= 1.1e+14) tmp = -1.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 <= -2.1e+49) tmp = 1.0; elseif (y <= -6.8e-6) tmp = t_0; elseif (y <= -7e-44) tmp = y * -0.5; elseif (y <= 1.3e-120) tmp = t_0; elseif (y <= 2e-83) tmp = y * -0.5; elseif (y <= 9.2e-59) tmp = t_0; elseif (y <= 3.5e-16) tmp = y * -0.5; elseif (y <= 1.1e+14) tmp = -1.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, -2.1e+49], 1.0, If[LessEqual[y, -6.8e-6], t$95$0, If[LessEqual[y, -7e-44], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 1.3e-120], t$95$0, If[LessEqual[y, 2e-83], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 9.2e-59], t$95$0, If[LessEqual[y, 3.5e-16], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 1.1e+14], -1.0, 1.0]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{2 - x}\\
\mathbf{if}\;y \leq -2.1 \cdot 10^{+49}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -6.8 \cdot 10^{-6}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -7 \cdot 10^{-44}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 1.3 \cdot 10^{-120}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 2 \cdot 10^{-83}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 9.2 \cdot 10^{-59}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 3.5 \cdot 10^{-16}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{+14}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -2.10000000000000011e49 or 1.1e14 < y Initial program 100.0%
Taylor expanded in y around inf 76.8%
if -2.10000000000000011e49 < y < -6.80000000000000012e-6 or -6.9999999999999995e-44 < y < 1.3000000000000001e-120 or 2.0000000000000001e-83 < y < 9.19999999999999918e-59Initial program 100.0%
Taylor expanded in y around 0 77.3%
if -6.80000000000000012e-6 < y < -6.9999999999999995e-44 or 1.3000000000000001e-120 < y < 2.0000000000000001e-83 or 9.19999999999999918e-59 < y < 3.50000000000000017e-16Initial program 99.9%
Taylor expanded in x around 0 80.7%
mul-1-neg80.7%
distribute-neg-frac80.7%
Simplified80.7%
Taylor expanded in y around 0 77.1%
*-commutative77.1%
Simplified77.1%
if 3.50000000000000017e-16 < y < 1.1e14Initial program 100.0%
Taylor expanded in x around inf 42.7%
Final simplification76.4%
(FPCore (x y)
:precision binary64
(if (<= x -4e+35)
-1.0
(if (<= x -4.6e-65)
1.0
(if (<= x -2e-171)
(* x 0.5)
(if (<= x -4.9e-204)
1.0
(if (<= x 8e-306) (* y -0.5) (if (<= x 2.5e+35) 1.0 -1.0)))))))
double code(double x, double y) {
double tmp;
if (x <= -4e+35) {
tmp = -1.0;
} else if (x <= -4.6e-65) {
tmp = 1.0;
} else if (x <= -2e-171) {
tmp = x * 0.5;
} else if (x <= -4.9e-204) {
tmp = 1.0;
} else if (x <= 8e-306) {
tmp = y * -0.5;
} else if (x <= 2.5e+35) {
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 <= (-4d+35)) then
tmp = -1.0d0
else if (x <= (-4.6d-65)) then
tmp = 1.0d0
else if (x <= (-2d-171)) then
tmp = x * 0.5d0
else if (x <= (-4.9d-204)) then
tmp = 1.0d0
else if (x <= 8d-306) then
tmp = y * (-0.5d0)
else if (x <= 2.5d+35) 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 <= -4e+35) {
tmp = -1.0;
} else if (x <= -4.6e-65) {
tmp = 1.0;
} else if (x <= -2e-171) {
tmp = x * 0.5;
} else if (x <= -4.9e-204) {
tmp = 1.0;
} else if (x <= 8e-306) {
tmp = y * -0.5;
} else if (x <= 2.5e+35) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -4e+35: tmp = -1.0 elif x <= -4.6e-65: tmp = 1.0 elif x <= -2e-171: tmp = x * 0.5 elif x <= -4.9e-204: tmp = 1.0 elif x <= 8e-306: tmp = y * -0.5 elif x <= 2.5e+35: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -4e+35) tmp = -1.0; elseif (x <= -4.6e-65) tmp = 1.0; elseif (x <= -2e-171) tmp = Float64(x * 0.5); elseif (x <= -4.9e-204) tmp = 1.0; elseif (x <= 8e-306) tmp = Float64(y * -0.5); elseif (x <= 2.5e+35) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -4e+35) tmp = -1.0; elseif (x <= -4.6e-65) tmp = 1.0; elseif (x <= -2e-171) tmp = x * 0.5; elseif (x <= -4.9e-204) tmp = 1.0; elseif (x <= 8e-306) tmp = y * -0.5; elseif (x <= 2.5e+35) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -4e+35], -1.0, If[LessEqual[x, -4.6e-65], 1.0, If[LessEqual[x, -2e-171], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, -4.9e-204], 1.0, If[LessEqual[x, 8e-306], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 2.5e+35], 1.0, -1.0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{+35}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -4.6 \cdot 10^{-65}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -2 \cdot 10^{-171}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq -4.9 \cdot 10^{-204}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 8 \cdot 10^{-306}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{+35}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -3.9999999999999999e35 or 2.50000000000000011e35 < x Initial program 100.0%
Taylor expanded in x around inf 79.0%
if -3.9999999999999999e35 < x < -4.5999999999999999e-65 or -2e-171 < x < -4.90000000000000009e-204 or 8.00000000000000022e-306 < x < 2.50000000000000011e35Initial program 100.0%
Taylor expanded in y around inf 57.4%
if -4.5999999999999999e-65 < x < -2e-171Initial program 100.0%
Taylor expanded in y around 0 60.4%
Taylor expanded in x around 0 60.4%
*-commutative60.4%
Simplified60.4%
if -4.90000000000000009e-204 < x < 8.00000000000000022e-306Initial program 100.0%
Taylor expanded in x around 0 95.7%
mul-1-neg95.7%
distribute-neg-frac95.7%
Simplified95.7%
Taylor expanded in y around 0 67.6%
*-commutative67.6%
Simplified67.6%
Final simplification68.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ y (+ y -2.0))))
(if (<= x -1.2e+32)
-1.0
(if (<= x -1.8e-68)
t_0
(if (<= x -3.5e-142) (* x 0.5) (if (<= x 6.5e+52) t_0 -1.0))))))
double code(double x, double y) {
double t_0 = y / (y + -2.0);
double tmp;
if (x <= -1.2e+32) {
tmp = -1.0;
} else if (x <= -1.8e-68) {
tmp = t_0;
} else if (x <= -3.5e-142) {
tmp = x * 0.5;
} else if (x <= 6.5e+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.2d+32)) then
tmp = -1.0d0
else if (x <= (-1.8d-68)) then
tmp = t_0
else if (x <= (-3.5d-142)) then
tmp = x * 0.5d0
else if (x <= 6.5d+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.2e+32) {
tmp = -1.0;
} else if (x <= -1.8e-68) {
tmp = t_0;
} else if (x <= -3.5e-142) {
tmp = x * 0.5;
} else if (x <= 6.5e+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.2e+32: tmp = -1.0 elif x <= -1.8e-68: tmp = t_0 elif x <= -3.5e-142: tmp = x * 0.5 elif x <= 6.5e+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.2e+32) tmp = -1.0; elseif (x <= -1.8e-68) tmp = t_0; elseif (x <= -3.5e-142) tmp = Float64(x * 0.5); elseif (x <= 6.5e+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.2e+32) tmp = -1.0; elseif (x <= -1.8e-68) tmp = t_0; elseif (x <= -3.5e-142) tmp = x * 0.5; elseif (x <= 6.5e+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.2e+32], -1.0, If[LessEqual[x, -1.8e-68], t$95$0, If[LessEqual[x, -3.5e-142], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 6.5e+52], t$95$0, -1.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{y + -2}\\
\mathbf{if}\;x \leq -1.2 \cdot 10^{+32}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -1.8 \cdot 10^{-68}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -3.5 \cdot 10^{-142}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 6.5 \cdot 10^{+52}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -1.19999999999999996e32 or 6.49999999999999996e52 < x Initial program 100.0%
Taylor expanded in x around inf 79.5%
if -1.19999999999999996e32 < x < -1.80000000000000004e-68 or -3.50000000000000015e-142 < x < 6.49999999999999996e52Initial program 100.0%
Taylor expanded in x around 0 82.0%
mul-1-neg82.0%
distribute-neg-frac82.0%
Simplified82.0%
frac-2neg82.0%
div-inv81.9%
remove-double-neg81.9%
sub-neg81.9%
distribute-neg-in81.9%
metadata-eval81.9%
remove-double-neg81.9%
Applied egg-rr81.9%
associate-*r/82.0%
*-rgt-identity82.0%
+-commutative82.0%
Simplified82.0%
if -1.80000000000000004e-68 < x < -3.50000000000000015e-142Initial program 100.0%
Taylor expanded in y around 0 67.3%
Taylor expanded in x around 0 67.3%
*-commutative67.3%
Simplified67.3%
Final simplification80.3%
(FPCore (x y)
:precision binary64
(if (<= x -5e+27)
-1.0
(if (<= x -1.8e-67)
1.0
(if (<= x -2.2e-171) (* x 0.5) (if (<= x 2.35e+35) 1.0 -1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -5e+27) {
tmp = -1.0;
} else if (x <= -1.8e-67) {
tmp = 1.0;
} else if (x <= -2.2e-171) {
tmp = x * 0.5;
} else if (x <= 2.35e+35) {
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 <= (-5d+27)) then
tmp = -1.0d0
else if (x <= (-1.8d-67)) then
tmp = 1.0d0
else if (x <= (-2.2d-171)) then
tmp = x * 0.5d0
else if (x <= 2.35d+35) 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 <= -5e+27) {
tmp = -1.0;
} else if (x <= -1.8e-67) {
tmp = 1.0;
} else if (x <= -2.2e-171) {
tmp = x * 0.5;
} else if (x <= 2.35e+35) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -5e+27: tmp = -1.0 elif x <= -1.8e-67: tmp = 1.0 elif x <= -2.2e-171: tmp = x * 0.5 elif x <= 2.35e+35: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -5e+27) tmp = -1.0; elseif (x <= -1.8e-67) tmp = 1.0; elseif (x <= -2.2e-171) tmp = Float64(x * 0.5); elseif (x <= 2.35e+35) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -5e+27) tmp = -1.0; elseif (x <= -1.8e-67) tmp = 1.0; elseif (x <= -2.2e-171) tmp = x * 0.5; elseif (x <= 2.35e+35) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -5e+27], -1.0, If[LessEqual[x, -1.8e-67], 1.0, If[LessEqual[x, -2.2e-171], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 2.35e+35], 1.0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{+27}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -1.8 \cdot 10^{-67}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -2.2 \cdot 10^{-171}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 2.35 \cdot 10^{+35}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -4.99999999999999979e27 or 2.35000000000000017e35 < x Initial program 100.0%
Taylor expanded in x around inf 79.0%
if -4.99999999999999979e27 < x < -1.8e-67 or -2.2000000000000001e-171 < x < 2.35000000000000017e35Initial program 100.0%
Taylor expanded in y around inf 51.4%
if -1.8e-67 < x < -2.2000000000000001e-171Initial program 100.0%
Taylor expanded in y around 0 60.4%
Taylor expanded in x around 0 60.4%
*-commutative60.4%
Simplified60.4%
Final simplification63.8%
(FPCore (x y) :precision binary64 (if (<= x -6.4e+27) -1.0 (if (<= x 2.9e+35) 1.0 -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -6.4e+27) {
tmp = -1.0;
} else if (x <= 2.9e+35) {
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 <= (-6.4d+27)) then
tmp = -1.0d0
else if (x <= 2.9d+35) 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 <= -6.4e+27) {
tmp = -1.0;
} else if (x <= 2.9e+35) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -6.4e+27: tmp = -1.0 elif x <= 2.9e+35: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -6.4e+27) tmp = -1.0; elseif (x <= 2.9e+35) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -6.4e+27) tmp = -1.0; elseif (x <= 2.9e+35) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -6.4e+27], -1.0, If[LessEqual[x, 2.9e+35], 1.0, -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.4 \cdot 10^{+27}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 2.9 \cdot 10^{+35}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -6.4000000000000003e27 or 2.89999999999999995e35 < x Initial program 100.0%
Taylor expanded in x around inf 79.0%
if -6.4000000000000003e27 < x < 2.89999999999999995e35Initial program 100.0%
Taylor expanded in y around inf 48.4%
Final simplification61.6%
(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.1%
Final simplification36.1%
(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 2024017
(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))))