
(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 10 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
(let* ((t_0 (+ (/ y x) -1.0)) (t_1 (- 1.0 (/ x y))))
(if (<= x -2.4e+29)
t_0
(if (<= x -1.85e-9)
t_1
(if (<= x -6.5e-165)
(* x 0.5)
(if (<= x -1.7e-293)
t_1
(if (<= x 1.6e-265) (* y -0.5) (if (<= x 4.3e+40) 1.0 t_0))))))))
double code(double x, double y) {
double t_0 = (y / x) + -1.0;
double t_1 = 1.0 - (x / y);
double tmp;
if (x <= -2.4e+29) {
tmp = t_0;
} else if (x <= -1.85e-9) {
tmp = t_1;
} else if (x <= -6.5e-165) {
tmp = x * 0.5;
} else if (x <= -1.7e-293) {
tmp = t_1;
} else if (x <= 1.6e-265) {
tmp = y * -0.5;
} else if (x <= 4.3e+40) {
tmp = 1.0;
} 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) :: t_1
real(8) :: tmp
t_0 = (y / x) + (-1.0d0)
t_1 = 1.0d0 - (x / y)
if (x <= (-2.4d+29)) then
tmp = t_0
else if (x <= (-1.85d-9)) then
tmp = t_1
else if (x <= (-6.5d-165)) then
tmp = x * 0.5d0
else if (x <= (-1.7d-293)) then
tmp = t_1
else if (x <= 1.6d-265) then
tmp = y * (-0.5d0)
else if (x <= 4.3d+40) then
tmp = 1.0d0
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 t_1 = 1.0 - (x / y);
double tmp;
if (x <= -2.4e+29) {
tmp = t_0;
} else if (x <= -1.85e-9) {
tmp = t_1;
} else if (x <= -6.5e-165) {
tmp = x * 0.5;
} else if (x <= -1.7e-293) {
tmp = t_1;
} else if (x <= 1.6e-265) {
tmp = y * -0.5;
} else if (x <= 4.3e+40) {
tmp = 1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (y / x) + -1.0 t_1 = 1.0 - (x / y) tmp = 0 if x <= -2.4e+29: tmp = t_0 elif x <= -1.85e-9: tmp = t_1 elif x <= -6.5e-165: tmp = x * 0.5 elif x <= -1.7e-293: tmp = t_1 elif x <= 1.6e-265: tmp = y * -0.5 elif x <= 4.3e+40: tmp = 1.0 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(y / x) + -1.0) t_1 = Float64(1.0 - Float64(x / y)) tmp = 0.0 if (x <= -2.4e+29) tmp = t_0; elseif (x <= -1.85e-9) tmp = t_1; elseif (x <= -6.5e-165) tmp = Float64(x * 0.5); elseif (x <= -1.7e-293) tmp = t_1; elseif (x <= 1.6e-265) tmp = Float64(y * -0.5); elseif (x <= 4.3e+40) tmp = 1.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (y / x) + -1.0; t_1 = 1.0 - (x / y); tmp = 0.0; if (x <= -2.4e+29) tmp = t_0; elseif (x <= -1.85e-9) tmp = t_1; elseif (x <= -6.5e-165) tmp = x * 0.5; elseif (x <= -1.7e-293) tmp = t_1; elseif (x <= 1.6e-265) tmp = y * -0.5; elseif (x <= 4.3e+40) tmp = 1.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(y / x), $MachinePrecision] + -1.0), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.4e+29], t$95$0, If[LessEqual[x, -1.85e-9], t$95$1, If[LessEqual[x, -6.5e-165], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, -1.7e-293], t$95$1, If[LessEqual[x, 1.6e-265], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 4.3e+40], 1.0, t$95$0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{x} + -1\\
t_1 := 1 - \frac{x}{y}\\
\mathbf{if}\;x \leq -2.4 \cdot 10^{+29}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -1.85 \cdot 10^{-9}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -6.5 \cdot 10^{-165}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq -1.7 \cdot 10^{-293}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{-265}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 4.3 \cdot 10^{+40}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -2.4000000000000001e29 or 4.3000000000000002e40 < x Initial program 100.0%
associate--r+100.0%
Simplified100.0%
clear-num100.0%
associate-/r/99.7%
associate--l-99.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 81.8%
Taylor expanded in x around 0 82.1%
if -2.4000000000000001e29 < x < -1.85e-9 or -6.5000000000000004e-165 < x < -1.7e-293Initial program 99.9%
associate--r+99.9%
Simplified99.9%
clear-num99.8%
associate-/r/99.7%
associate--l-99.7%
Applied egg-rr99.7%
Taylor expanded in y around inf 65.4%
Taylor expanded in y around 0 65.6%
mul-1-neg65.6%
unsub-neg65.6%
Simplified65.6%
if -1.85e-9 < x < -6.5000000000000004e-165Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around 0 62.5%
Taylor expanded in x around 0 60.5%
*-commutative60.5%
Simplified60.5%
if -1.7e-293 < x < 1.6e-265Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 91.7%
mul-1-neg91.7%
distribute-neg-frac91.7%
Simplified91.7%
Taylor expanded in y around 0 65.9%
*-commutative65.9%
Simplified65.9%
if 1.6e-265 < x < 4.3000000000000002e40Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 67.0%
Final simplification71.7%
(FPCore (x y)
:precision binary64
(if (<= x -7.6e+24)
-1.0
(if (<= x -2.1e-9)
1.0
(if (<= x -4.2e-160)
(* x 0.5)
(if (<= x 3.6e-308)
1.0
(if (<= x 1.85e-265) (* y -0.5) (if (<= x 1.4e+40) 1.0 -1.0)))))))
double code(double x, double y) {
double tmp;
if (x <= -7.6e+24) {
tmp = -1.0;
} else if (x <= -2.1e-9) {
tmp = 1.0;
} else if (x <= -4.2e-160) {
tmp = x * 0.5;
} else if (x <= 3.6e-308) {
tmp = 1.0;
} else if (x <= 1.85e-265) {
tmp = y * -0.5;
} else if (x <= 1.4e+40) {
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.6d+24)) then
tmp = -1.0d0
else if (x <= (-2.1d-9)) then
tmp = 1.0d0
else if (x <= (-4.2d-160)) then
tmp = x * 0.5d0
else if (x <= 3.6d-308) then
tmp = 1.0d0
else if (x <= 1.85d-265) then
tmp = y * (-0.5d0)
else if (x <= 1.4d+40) 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.6e+24) {
tmp = -1.0;
} else if (x <= -2.1e-9) {
tmp = 1.0;
} else if (x <= -4.2e-160) {
tmp = x * 0.5;
} else if (x <= 3.6e-308) {
tmp = 1.0;
} else if (x <= 1.85e-265) {
tmp = y * -0.5;
} else if (x <= 1.4e+40) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -7.6e+24: tmp = -1.0 elif x <= -2.1e-9: tmp = 1.0 elif x <= -4.2e-160: tmp = x * 0.5 elif x <= 3.6e-308: tmp = 1.0 elif x <= 1.85e-265: tmp = y * -0.5 elif x <= 1.4e+40: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -7.6e+24) tmp = -1.0; elseif (x <= -2.1e-9) tmp = 1.0; elseif (x <= -4.2e-160) tmp = Float64(x * 0.5); elseif (x <= 3.6e-308) tmp = 1.0; elseif (x <= 1.85e-265) tmp = Float64(y * -0.5); elseif (x <= 1.4e+40) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -7.6e+24) tmp = -1.0; elseif (x <= -2.1e-9) tmp = 1.0; elseif (x <= -4.2e-160) tmp = x * 0.5; elseif (x <= 3.6e-308) tmp = 1.0; elseif (x <= 1.85e-265) tmp = y * -0.5; elseif (x <= 1.4e+40) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -7.6e+24], -1.0, If[LessEqual[x, -2.1e-9], 1.0, If[LessEqual[x, -4.2e-160], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 3.6e-308], 1.0, If[LessEqual[x, 1.85e-265], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 1.4e+40], 1.0, -1.0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.6 \cdot 10^{+24}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -2.1 \cdot 10^{-9}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -4.2 \cdot 10^{-160}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 3.6 \cdot 10^{-308}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 1.85 \cdot 10^{-265}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{+40}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -7.6000000000000003e24 or 1.4000000000000001e40 < x Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 81.0%
if -7.6000000000000003e24 < x < -2.10000000000000019e-9 or -4.2000000000000001e-160 < x < 3.5999999999999999e-308 or 1.8499999999999999e-265 < x < 1.4000000000000001e40Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 66.8%
if -2.10000000000000019e-9 < x < -4.2000000000000001e-160Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around 0 62.5%
Taylor expanded in x around 0 60.5%
*-commutative60.5%
Simplified60.5%
if 3.5999999999999999e-308 < x < 1.8499999999999999e-265Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 91.7%
mul-1-neg91.7%
distribute-neg-frac91.7%
Simplified91.7%
Taylor expanded in y around 0 65.9%
*-commutative65.9%
Simplified65.9%
Final simplification71.5%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))))
(if (<= x -7.2e+28)
-1.0
(if (<= x -1.85e-9)
t_0
(if (<= x -4.2e-160)
(* x 0.5)
(if (<= x -1.75e-299)
t_0
(if (<= x 1.85e-265) (* y -0.5) (if (<= x 2e+42) 1.0 -1.0))))))))
double code(double x, double y) {
double t_0 = 1.0 - (x / y);
double tmp;
if (x <= -7.2e+28) {
tmp = -1.0;
} else if (x <= -1.85e-9) {
tmp = t_0;
} else if (x <= -4.2e-160) {
tmp = x * 0.5;
} else if (x <= -1.75e-299) {
tmp = t_0;
} else if (x <= 1.85e-265) {
tmp = y * -0.5;
} else if (x <= 2e+42) {
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 = 1.0d0 - (x / y)
if (x <= (-7.2d+28)) then
tmp = -1.0d0
else if (x <= (-1.85d-9)) then
tmp = t_0
else if (x <= (-4.2d-160)) then
tmp = x * 0.5d0
else if (x <= (-1.75d-299)) then
tmp = t_0
else if (x <= 1.85d-265) then
tmp = y * (-0.5d0)
else if (x <= 2d+42) 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 = 1.0 - (x / y);
double tmp;
if (x <= -7.2e+28) {
tmp = -1.0;
} else if (x <= -1.85e-9) {
tmp = t_0;
} else if (x <= -4.2e-160) {
tmp = x * 0.5;
} else if (x <= -1.75e-299) {
tmp = t_0;
} else if (x <= 1.85e-265) {
tmp = y * -0.5;
} else if (x <= 2e+42) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 - (x / y) tmp = 0 if x <= -7.2e+28: tmp = -1.0 elif x <= -1.85e-9: tmp = t_0 elif x <= -4.2e-160: tmp = x * 0.5 elif x <= -1.75e-299: tmp = t_0 elif x <= 1.85e-265: tmp = y * -0.5 elif x <= 2e+42: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) t_0 = Float64(1.0 - Float64(x / y)) tmp = 0.0 if (x <= -7.2e+28) tmp = -1.0; elseif (x <= -1.85e-9) tmp = t_0; elseif (x <= -4.2e-160) tmp = Float64(x * 0.5); elseif (x <= -1.75e-299) tmp = t_0; elseif (x <= 1.85e-265) tmp = Float64(y * -0.5); elseif (x <= 2e+42) tmp = 1.0; 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 <= -7.2e+28) tmp = -1.0; elseif (x <= -1.85e-9) tmp = t_0; elseif (x <= -4.2e-160) tmp = x * 0.5; elseif (x <= -1.75e-299) tmp = t_0; elseif (x <= 1.85e-265) tmp = y * -0.5; elseif (x <= 2e+42) tmp = 1.0; 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, -7.2e+28], -1.0, If[LessEqual[x, -1.85e-9], t$95$0, If[LessEqual[x, -4.2e-160], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, -1.75e-299], t$95$0, If[LessEqual[x, 1.85e-265], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 2e+42], 1.0, -1.0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;x \leq -7.2 \cdot 10^{+28}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -1.85 \cdot 10^{-9}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -4.2 \cdot 10^{-160}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq -1.75 \cdot 10^{-299}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.85 \cdot 10^{-265}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 2 \cdot 10^{+42}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -7.1999999999999999e28 or 2.00000000000000009e42 < x Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 81.7%
if -7.1999999999999999e28 < x < -1.85e-9 or -4.2000000000000001e-160 < x < -1.74999999999999995e-299Initial program 99.9%
associate--r+99.9%
Simplified99.9%
clear-num99.8%
associate-/r/99.7%
associate--l-99.7%
Applied egg-rr99.7%
Taylor expanded in y around inf 65.4%
Taylor expanded in y around 0 65.6%
mul-1-neg65.6%
unsub-neg65.6%
Simplified65.6%
if -1.85e-9 < x < -4.2000000000000001e-160Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around 0 62.5%
Taylor expanded in x around 0 60.5%
*-commutative60.5%
Simplified60.5%
if -1.74999999999999995e-299 < x < 1.8499999999999999e-265Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 91.7%
mul-1-neg91.7%
distribute-neg-frac91.7%
Simplified91.7%
Taylor expanded in y around 0 65.9%
*-commutative65.9%
Simplified65.9%
if 1.8499999999999999e-265 < x < 2.00000000000000009e42Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 67.0%
Final simplification71.6%
(FPCore (x y)
:precision binary64
(if (<= x -4e+27)
-1.0
(if (<= x -1.85e-9)
1.0
(if (<= x -4.2e-160) (* x 0.5) (if (<= x 4.5e+40) 1.0 -1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -4e+27) {
tmp = -1.0;
} else if (x <= -1.85e-9) {
tmp = 1.0;
} else if (x <= -4.2e-160) {
tmp = x * 0.5;
} else if (x <= 4.5e+40) {
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+27)) then
tmp = -1.0d0
else if (x <= (-1.85d-9)) then
tmp = 1.0d0
else if (x <= (-4.2d-160)) then
tmp = x * 0.5d0
else if (x <= 4.5d+40) 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+27) {
tmp = -1.0;
} else if (x <= -1.85e-9) {
tmp = 1.0;
} else if (x <= -4.2e-160) {
tmp = x * 0.5;
} else if (x <= 4.5e+40) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -4e+27: tmp = -1.0 elif x <= -1.85e-9: tmp = 1.0 elif x <= -4.2e-160: tmp = x * 0.5 elif x <= 4.5e+40: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -4e+27) tmp = -1.0; elseif (x <= -1.85e-9) tmp = 1.0; elseif (x <= -4.2e-160) tmp = Float64(x * 0.5); elseif (x <= 4.5e+40) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -4e+27) tmp = -1.0; elseif (x <= -1.85e-9) tmp = 1.0; elseif (x <= -4.2e-160) tmp = x * 0.5; elseif (x <= 4.5e+40) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -4e+27], -1.0, If[LessEqual[x, -1.85e-9], 1.0, If[LessEqual[x, -4.2e-160], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 4.5e+40], 1.0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{+27}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -1.85 \cdot 10^{-9}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -4.2 \cdot 10^{-160}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 4.5 \cdot 10^{+40}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -4.0000000000000001e27 or 4.50000000000000032e40 < x Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 81.0%
if -4.0000000000000001e27 < x < -1.85e-9 or -4.2000000000000001e-160 < x < 4.50000000000000032e40Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 63.4%
if -1.85e-9 < x < -4.2000000000000001e-160Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around 0 62.5%
Taylor expanded in x around 0 60.5%
*-commutative60.5%
Simplified60.5%
Final simplification70.0%
(FPCore (x y) :precision binary64 (if (or (<= y -65000000.0) (not (<= y 45000000000000.0))) (- 1.0 (/ x y)) (/ x (- 2.0 x))))
double code(double x, double y) {
double tmp;
if ((y <= -65000000.0) || !(y <= 45000000000000.0)) {
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 <= (-65000000.0d0)) .or. (.not. (y <= 45000000000000.0d0))) 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 <= -65000000.0) || !(y <= 45000000000000.0)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -65000000.0) or not (y <= 45000000000000.0): tmp = 1.0 - (x / y) else: tmp = x / (2.0 - x) return tmp
function code(x, y) tmp = 0.0 if ((y <= -65000000.0) || !(y <= 45000000000000.0)) 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 <= -65000000.0) || ~((y <= 45000000000000.0))) tmp = 1.0 - (x / y); else tmp = x / (2.0 - x); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -65000000.0], N[Not[LessEqual[y, 45000000000000.0]], $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 -65000000 \lor \neg \left(y \leq 45000000000000\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 - x}\\
\end{array}
\end{array}
if y < -6.5e7 or 4.5e13 < y Initial program 100.0%
associate--r+100.0%
Simplified100.0%
clear-num99.9%
associate-/r/99.8%
associate--l-99.8%
Applied egg-rr99.8%
Taylor expanded in y around inf 80.0%
Taylor expanded in y around 0 80.1%
mul-1-neg80.1%
unsub-neg80.1%
Simplified80.1%
if -6.5e7 < y < 4.5e13Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 78.8%
Final simplification79.5%
(FPCore (x y) :precision binary64 (if (<= y -27000000000.0) (- 1.0 (/ x y)) (if (<= y 2.6e-7) (/ x (- 2.0 x)) (/ y (+ y -2.0)))))
double code(double x, double y) {
double tmp;
if (y <= -27000000000.0) {
tmp = 1.0 - (x / y);
} else if (y <= 2.6e-7) {
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 (y <= (-27000000000.0d0)) then
tmp = 1.0d0 - (x / y)
else if (y <= 2.6d-7) 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 (y <= -27000000000.0) {
tmp = 1.0 - (x / y);
} else if (y <= 2.6e-7) {
tmp = x / (2.0 - x);
} else {
tmp = y / (y + -2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -27000000000.0: tmp = 1.0 - (x / y) elif y <= 2.6e-7: tmp = x / (2.0 - x) else: tmp = y / (y + -2.0) return tmp
function code(x, y) tmp = 0.0 if (y <= -27000000000.0) tmp = Float64(1.0 - Float64(x / y)); elseif (y <= 2.6e-7) 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 (y <= -27000000000.0) tmp = 1.0 - (x / y); elseif (y <= 2.6e-7) tmp = x / (2.0 - x); else tmp = y / (y + -2.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -27000000000.0], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.6e-7], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -27000000000:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{elif}\;y \leq 2.6 \cdot 10^{-7}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y + -2}\\
\end{array}
\end{array}
if y < -2.7e10Initial program 99.9%
associate--r+99.9%
Simplified99.9%
clear-num99.9%
associate-/r/99.8%
associate--l-99.8%
Applied egg-rr99.8%
Taylor expanded in y around inf 80.0%
Taylor expanded in y around 0 80.2%
mul-1-neg80.2%
unsub-neg80.2%
Simplified80.2%
if -2.7e10 < y < 2.59999999999999999e-7Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 79.4%
if 2.59999999999999999e-7 < y Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 79.7%
mul-1-neg79.7%
distribute-neg-frac79.7%
Simplified79.7%
expm1-log1p-u79.7%
expm1-udef79.4%
add-sqr-sqrt0.0%
sqrt-unprod11.6%
sqr-neg11.6%
sqrt-unprod16.8%
add-sqr-sqrt21.9%
frac-2neg21.9%
add-sqr-sqrt0.0%
sqrt-unprod30.1%
sqr-neg30.1%
sqrt-unprod79.2%
add-sqr-sqrt79.4%
sub-neg79.4%
distribute-neg-in79.4%
metadata-eval79.4%
remove-double-neg79.4%
Applied egg-rr79.4%
expm1-def79.7%
expm1-log1p79.7%
+-commutative79.7%
Simplified79.7%
Final simplification79.7%
(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 -2.35e+29) -1.0 (if (<= x 3.5e+39) 1.0 -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -2.35e+29) {
tmp = -1.0;
} else if (x <= 3.5e+39) {
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 <= (-2.35d+29)) then
tmp = -1.0d0
else if (x <= 3.5d+39) 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 <= -2.35e+29) {
tmp = -1.0;
} else if (x <= 3.5e+39) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2.35e+29: tmp = -1.0 elif x <= 3.5e+39: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -2.35e+29) tmp = -1.0; elseif (x <= 3.5e+39) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2.35e+29) tmp = -1.0; elseif (x <= 3.5e+39) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2.35e+29], -1.0, If[LessEqual[x, 3.5e+39], 1.0, -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.35 \cdot 10^{+29}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 3.5 \cdot 10^{+39}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -2.3500000000000001e29 or 3.5000000000000002e39 < x Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 81.7%
if -2.3500000000000001e29 < x < 3.5000000000000002e39Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around inf 56.7%
Final simplification66.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 35.0%
Final simplification35.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 2023222
(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))))