
(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%
(FPCore (x y)
:precision binary64
(if (<= y -1.7e+114)
1.0
(if (<= y -1.12e+80)
-1.0
(if (<= y -2.0)
1.0
(if (<= y -2.2e-56)
(* y -0.5)
(if (<= y 4.5e+141) (/ x (- 2.0 x)) 1.0))))))
double code(double x, double y) {
double tmp;
if (y <= -1.7e+114) {
tmp = 1.0;
} else if (y <= -1.12e+80) {
tmp = -1.0;
} else if (y <= -2.0) {
tmp = 1.0;
} else if (y <= -2.2e-56) {
tmp = y * -0.5;
} else if (y <= 4.5e+141) {
tmp = x / (2.0 - x);
} 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 <= (-1.7d+114)) then
tmp = 1.0d0
else if (y <= (-1.12d+80)) then
tmp = -1.0d0
else if (y <= (-2.0d0)) then
tmp = 1.0d0
else if (y <= (-2.2d-56)) then
tmp = y * (-0.5d0)
else if (y <= 4.5d+141) then
tmp = x / (2.0d0 - x)
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.7e+114) {
tmp = 1.0;
} else if (y <= -1.12e+80) {
tmp = -1.0;
} else if (y <= -2.0) {
tmp = 1.0;
} else if (y <= -2.2e-56) {
tmp = y * -0.5;
} else if (y <= 4.5e+141) {
tmp = x / (2.0 - x);
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.7e+114: tmp = 1.0 elif y <= -1.12e+80: tmp = -1.0 elif y <= -2.0: tmp = 1.0 elif y <= -2.2e-56: tmp = y * -0.5 elif y <= 4.5e+141: tmp = x / (2.0 - x) else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -1.7e+114) tmp = 1.0; elseif (y <= -1.12e+80) tmp = -1.0; elseif (y <= -2.0) tmp = 1.0; elseif (y <= -2.2e-56) tmp = Float64(y * -0.5); elseif (y <= 4.5e+141) tmp = Float64(x / Float64(2.0 - x)); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.7e+114) tmp = 1.0; elseif (y <= -1.12e+80) tmp = -1.0; elseif (y <= -2.0) tmp = 1.0; elseif (y <= -2.2e-56) tmp = y * -0.5; elseif (y <= 4.5e+141) tmp = x / (2.0 - x); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.7e+114], 1.0, If[LessEqual[y, -1.12e+80], -1.0, If[LessEqual[y, -2.0], 1.0, If[LessEqual[y, -2.2e-56], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 4.5e+141], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], 1.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.7 \cdot 10^{+114}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -1.12 \cdot 10^{+80}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq -2:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -2.2 \cdot 10^{-56}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 4.5 \cdot 10^{+141}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.7e114 or -1.12e80 < y < -2 or 4.5000000000000002e141 < y Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 76.0%
if -1.7e114 < y < -1.12e80Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 85.9%
if -2 < y < -2.20000000000000004e-56Initial program 99.9%
remove-double-neg99.9%
+-commutative99.9%
distribute-neg-frac299.9%
distribute-frac-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
metadata-eval99.9%
+-commutative99.9%
+-commutative99.9%
associate-+r+99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around 0 75.3%
Taylor expanded in y around 0 73.5%
*-commutative73.5%
Simplified73.5%
if -2.20000000000000004e-56 < y < 4.5000000000000002e141Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 76.4%
mul-1-neg76.4%
distribute-neg-frac276.4%
neg-sub076.4%
associate-+l-76.4%
neg-sub076.4%
+-commutative76.4%
unsub-neg76.4%
Simplified76.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ y (- y 2.0))))
(if (<= x -4.2e+27)
(- -1.0 (* (/ y x) -2.0))
(if (<= x 2.8e-120)
t_0
(if (<= x 6.8e-105)
(* x 0.5)
(if (<= x 5.8e-74) t_0 (/ x (- 2.0 x))))))))
double code(double x, double y) {
double t_0 = y / (y - 2.0);
double tmp;
if (x <= -4.2e+27) {
tmp = -1.0 - ((y / x) * -2.0);
} else if (x <= 2.8e-120) {
tmp = t_0;
} else if (x <= 6.8e-105) {
tmp = x * 0.5;
} else if (x <= 5.8e-74) {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = y / (y - 2.0d0)
if (x <= (-4.2d+27)) then
tmp = (-1.0d0) - ((y / x) * (-2.0d0))
else if (x <= 2.8d-120) then
tmp = t_0
else if (x <= 6.8d-105) then
tmp = x * 0.5d0
else if (x <= 5.8d-74) then
tmp = t_0
else
tmp = x / (2.0d0 - x)
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 <= -4.2e+27) {
tmp = -1.0 - ((y / x) * -2.0);
} else if (x <= 2.8e-120) {
tmp = t_0;
} else if (x <= 6.8e-105) {
tmp = x * 0.5;
} else if (x <= 5.8e-74) {
tmp = t_0;
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
def code(x, y): t_0 = y / (y - 2.0) tmp = 0 if x <= -4.2e+27: tmp = -1.0 - ((y / x) * -2.0) elif x <= 2.8e-120: tmp = t_0 elif x <= 6.8e-105: tmp = x * 0.5 elif x <= 5.8e-74: tmp = t_0 else: tmp = x / (2.0 - x) return tmp
function code(x, y) t_0 = Float64(y / Float64(y - 2.0)) tmp = 0.0 if (x <= -4.2e+27) tmp = Float64(-1.0 - Float64(Float64(y / x) * -2.0)); elseif (x <= 2.8e-120) tmp = t_0; elseif (x <= 6.8e-105) tmp = Float64(x * 0.5); elseif (x <= 5.8e-74) tmp = t_0; else tmp = Float64(x / Float64(2.0 - x)); end return tmp end
function tmp_2 = code(x, y) t_0 = y / (y - 2.0); tmp = 0.0; if (x <= -4.2e+27) tmp = -1.0 - ((y / x) * -2.0); elseif (x <= 2.8e-120) tmp = t_0; elseif (x <= 6.8e-105) tmp = x * 0.5; elseif (x <= 5.8e-74) tmp = t_0; else tmp = x / (2.0 - x); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y / N[(y - 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -4.2e+27], N[(-1.0 - N[(N[(y / x), $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.8e-120], t$95$0, If[LessEqual[x, 6.8e-105], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 5.8e-74], t$95$0, N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{y - 2}\\
\mathbf{if}\;x \leq -4.2 \cdot 10^{+27}:\\
\;\;\;\;-1 - \frac{y}{x} \cdot -2\\
\mathbf{elif}\;x \leq 2.8 \cdot 10^{-120}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 6.8 \cdot 10^{-105}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 5.8 \cdot 10^{-74}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 - x}\\
\end{array}
\end{array}
if x < -4.19999999999999989e27Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 84.6%
sub-neg84.6%
+-commutative84.6%
distribute-neg-in84.6%
metadata-eval84.6%
mul-1-neg84.6%
remove-double-neg84.6%
associate-+l+84.6%
remove-double-neg84.6%
mul-1-neg84.6%
neg-sub084.6%
associate--r-84.6%
associate-*r/84.6%
sub-neg84.6%
metadata-eval84.6%
+-commutative84.6%
distribute-lft-in84.6%
metadata-eval84.6%
div-sub84.6%
Simplified84.6%
Taylor expanded in y around inf 84.6%
*-commutative84.6%
Simplified84.6%
if -4.19999999999999989e27 < x < 2.79999999999999994e-120 or 6.79999999999999984e-105 < x < 5.8e-74Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 85.5%
if 2.79999999999999994e-120 < x < 6.79999999999999984e-105Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
mul-1-neg100.0%
distribute-neg-frac2100.0%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
+-commutative100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
*-commutative100.0%
Simplified100.0%
if 5.8e-74 < x Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 69.1%
mul-1-neg69.1%
distribute-neg-frac269.1%
neg-sub069.1%
associate-+l-69.1%
neg-sub069.1%
+-commutative69.1%
unsub-neg69.1%
Simplified69.1%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ y (- y 2.0))))
(if (<= x -1.9e+27)
-1.0
(if (<= x 2.8e-120)
t_0
(if (<= x 7.2e-105)
(* x 0.5)
(if (<= x 1.25e-73) t_0 (/ x (- 2.0 x))))))))
double code(double x, double y) {
double t_0 = y / (y - 2.0);
double tmp;
if (x <= -1.9e+27) {
tmp = -1.0;
} else if (x <= 2.8e-120) {
tmp = t_0;
} else if (x <= 7.2e-105) {
tmp = x * 0.5;
} else if (x <= 1.25e-73) {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = y / (y - 2.0d0)
if (x <= (-1.9d+27)) then
tmp = -1.0d0
else if (x <= 2.8d-120) then
tmp = t_0
else if (x <= 7.2d-105) then
tmp = x * 0.5d0
else if (x <= 1.25d-73) then
tmp = t_0
else
tmp = x / (2.0d0 - x)
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.9e+27) {
tmp = -1.0;
} else if (x <= 2.8e-120) {
tmp = t_0;
} else if (x <= 7.2e-105) {
tmp = x * 0.5;
} else if (x <= 1.25e-73) {
tmp = t_0;
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
def code(x, y): t_0 = y / (y - 2.0) tmp = 0 if x <= -1.9e+27: tmp = -1.0 elif x <= 2.8e-120: tmp = t_0 elif x <= 7.2e-105: tmp = x * 0.5 elif x <= 1.25e-73: tmp = t_0 else: tmp = x / (2.0 - x) return tmp
function code(x, y) t_0 = Float64(y / Float64(y - 2.0)) tmp = 0.0 if (x <= -1.9e+27) tmp = -1.0; elseif (x <= 2.8e-120) tmp = t_0; elseif (x <= 7.2e-105) tmp = Float64(x * 0.5); elseif (x <= 1.25e-73) tmp = t_0; else tmp = Float64(x / Float64(2.0 - x)); end return tmp end
function tmp_2 = code(x, y) t_0 = y / (y - 2.0); tmp = 0.0; if (x <= -1.9e+27) tmp = -1.0; elseif (x <= 2.8e-120) tmp = t_0; elseif (x <= 7.2e-105) tmp = x * 0.5; elseif (x <= 1.25e-73) tmp = t_0; else tmp = x / (2.0 - x); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y / N[(y - 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.9e+27], -1.0, If[LessEqual[x, 2.8e-120], t$95$0, If[LessEqual[x, 7.2e-105], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 1.25e-73], t$95$0, N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{y - 2}\\
\mathbf{if}\;x \leq -1.9 \cdot 10^{+27}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 2.8 \cdot 10^{-120}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 7.2 \cdot 10^{-105}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 1.25 \cdot 10^{-73}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 - x}\\
\end{array}
\end{array}
if x < -1.90000000000000011e27Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 83.9%
if -1.90000000000000011e27 < x < 2.79999999999999994e-120 or 7.19999999999999929e-105 < x < 1.25e-73Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 85.5%
if 2.79999999999999994e-120 < x < 7.19999999999999929e-105Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
mul-1-neg100.0%
distribute-neg-frac2100.0%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
+-commutative100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
*-commutative100.0%
Simplified100.0%
if 1.25e-73 < x Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 69.1%
mul-1-neg69.1%
distribute-neg-frac269.1%
neg-sub069.1%
associate-+l-69.1%
neg-sub069.1%
+-commutative69.1%
unsub-neg69.1%
Simplified69.1%
(FPCore (x y)
:precision binary64
(if (<= x -7e+27)
-1.0
(if (<= x 2.8e-120)
1.0
(if (<= x 9.5e-104) (* x 0.5) (if (<= x 8500000.0) 1.0 -1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -7e+27) {
tmp = -1.0;
} else if (x <= 2.8e-120) {
tmp = 1.0;
} else if (x <= 9.5e-104) {
tmp = x * 0.5;
} else if (x <= 8500000.0) {
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 <= (-7d+27)) then
tmp = -1.0d0
else if (x <= 2.8d-120) then
tmp = 1.0d0
else if (x <= 9.5d-104) then
tmp = x * 0.5d0
else if (x <= 8500000.0d0) 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 <= -7e+27) {
tmp = -1.0;
} else if (x <= 2.8e-120) {
tmp = 1.0;
} else if (x <= 9.5e-104) {
tmp = x * 0.5;
} else if (x <= 8500000.0) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -7e+27: tmp = -1.0 elif x <= 2.8e-120: tmp = 1.0 elif x <= 9.5e-104: tmp = x * 0.5 elif x <= 8500000.0: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -7e+27) tmp = -1.0; elseif (x <= 2.8e-120) tmp = 1.0; elseif (x <= 9.5e-104) tmp = Float64(x * 0.5); elseif (x <= 8500000.0) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -7e+27) tmp = -1.0; elseif (x <= 2.8e-120) tmp = 1.0; elseif (x <= 9.5e-104) tmp = x * 0.5; elseif (x <= 8500000.0) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -7e+27], -1.0, If[LessEqual[x, 2.8e-120], 1.0, If[LessEqual[x, 9.5e-104], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 8500000.0], 1.0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7 \cdot 10^{+27}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 2.8 \cdot 10^{-120}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{-104}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 8500000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -7.0000000000000004e27 or 8.5e6 < x Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 77.5%
if -7.0000000000000004e27 < x < 2.79999999999999994e-120 or 9.5000000000000002e-104 < x < 8.5e6Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 52.0%
if 2.79999999999999994e-120 < x < 9.5000000000000002e-104Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
mul-1-neg100.0%
distribute-neg-frac2100.0%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
+-commutative100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
*-commutative100.0%
Simplified100.0%
(FPCore (x y) :precision binary64 (if (<= x -5.2e+27) -1.0 (if (<= x 4.2e+14) 1.0 -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -5.2e+27) {
tmp = -1.0;
} else if (x <= 4.2e+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) :: tmp
if (x <= (-5.2d+27)) then
tmp = -1.0d0
else if (x <= 4.2d+14) 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 <= -5.2e+27) {
tmp = -1.0;
} else if (x <= 4.2e+14) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -5.2e+27: tmp = -1.0 elif x <= 4.2e+14: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -5.2e+27) tmp = -1.0; elseif (x <= 4.2e+14) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -5.2e+27) tmp = -1.0; elseif (x <= 4.2e+14) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -5.2e+27], -1.0, If[LessEqual[x, 4.2e+14], 1.0, -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.2 \cdot 10^{+27}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 4.2 \cdot 10^{+14}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -5.20000000000000018e27 or 4.2e14 < x Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 77.5%
if -5.20000000000000018e27 < x < 4.2e14Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 49.8%
(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%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 40.3%
(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 2024108
(FPCore (x y)
:name "Data.Colour.RGB:hslsv from colour-2.3.3, C"
:precision binary64
:alt
(- (/ x (- 2.0 (+ x y))) (/ y (- 2.0 (+ x y))))
(/ (- x y) (- 2.0 (+ x y))))