
(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 (<= x -4600000000000.0)
-1.0
(if (<= x 6.8e-224)
1.0
(if (<= x 1.02e-142) (* y -0.5) (if (<= x 1120000000000.0) 1.0 -1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -4600000000000.0) {
tmp = -1.0;
} else if (x <= 6.8e-224) {
tmp = 1.0;
} else if (x <= 1.02e-142) {
tmp = y * -0.5;
} else if (x <= 1120000000000.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 <= (-4600000000000.0d0)) then
tmp = -1.0d0
else if (x <= 6.8d-224) then
tmp = 1.0d0
else if (x <= 1.02d-142) then
tmp = y * (-0.5d0)
else if (x <= 1120000000000.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 <= -4600000000000.0) {
tmp = -1.0;
} else if (x <= 6.8e-224) {
tmp = 1.0;
} else if (x <= 1.02e-142) {
tmp = y * -0.5;
} else if (x <= 1120000000000.0) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -4600000000000.0: tmp = -1.0 elif x <= 6.8e-224: tmp = 1.0 elif x <= 1.02e-142: tmp = y * -0.5 elif x <= 1120000000000.0: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -4600000000000.0) tmp = -1.0; elseif (x <= 6.8e-224) tmp = 1.0; elseif (x <= 1.02e-142) tmp = Float64(y * -0.5); elseif (x <= 1120000000000.0) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -4600000000000.0) tmp = -1.0; elseif (x <= 6.8e-224) tmp = 1.0; elseif (x <= 1.02e-142) tmp = y * -0.5; elseif (x <= 1120000000000.0) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -4600000000000.0], -1.0, If[LessEqual[x, 6.8e-224], 1.0, If[LessEqual[x, 1.02e-142], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 1120000000000.0], 1.0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4600000000000:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 6.8 \cdot 10^{-224}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 1.02 \cdot 10^{-142}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 1120000000000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -4.6e12 or 1.12e12 < x Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 99.9%
if -4.6e12 < x < 6.79999999999999984e-224 or 1.0200000000000001e-142 < x < 1.12e12Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 54.6%
if 6.79999999999999984e-224 < x < 1.0200000000000001e-142Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 75.4%
mul-1-neg75.4%
distribute-neg-frac75.4%
Simplified75.4%
Taylor expanded in y around 0 49.0%
*-commutative49.0%
Simplified49.0%
Final simplification67.9%
(FPCore (x y)
:precision binary64
(if (<= x -7800000000000.0)
-1.0
(if (<= x 7.8e-224)
(- 1.0 (/ x y))
(if (<= x 1.24e-141) (* y -0.5) (if (<= x 2400000000000.0) 1.0 -1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -7800000000000.0) {
tmp = -1.0;
} else if (x <= 7.8e-224) {
tmp = 1.0 - (x / y);
} else if (x <= 1.24e-141) {
tmp = y * -0.5;
} else if (x <= 2400000000000.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 <= (-7800000000000.0d0)) then
tmp = -1.0d0
else if (x <= 7.8d-224) then
tmp = 1.0d0 - (x / y)
else if (x <= 1.24d-141) then
tmp = y * (-0.5d0)
else if (x <= 2400000000000.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 <= -7800000000000.0) {
tmp = -1.0;
} else if (x <= 7.8e-224) {
tmp = 1.0 - (x / y);
} else if (x <= 1.24e-141) {
tmp = y * -0.5;
} else if (x <= 2400000000000.0) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -7800000000000.0: tmp = -1.0 elif x <= 7.8e-224: tmp = 1.0 - (x / y) elif x <= 1.24e-141: tmp = y * -0.5 elif x <= 2400000000000.0: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -7800000000000.0) tmp = -1.0; elseif (x <= 7.8e-224) tmp = Float64(1.0 - Float64(x / y)); elseif (x <= 1.24e-141) tmp = Float64(y * -0.5); elseif (x <= 2400000000000.0) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -7800000000000.0) tmp = -1.0; elseif (x <= 7.8e-224) tmp = 1.0 - (x / y); elseif (x <= 1.24e-141) tmp = y * -0.5; elseif (x <= 2400000000000.0) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -7800000000000.0], -1.0, If[LessEqual[x, 7.8e-224], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.24e-141], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 2400000000000.0], 1.0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7800000000000:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 7.8 \cdot 10^{-224}:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{elif}\;x \leq 1.24 \cdot 10^{-141}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 2400000000000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -7.8e12 or 2.4e12 < x Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 99.9%
if -7.8e12 < x < 7.7999999999999996e-224Initial program 100.0%
associate--r+100.0%
Simplified100.0%
clear-num99.7%
associate-/r/99.8%
associate--l-99.8%
Applied egg-rr99.8%
Taylor expanded in y around inf 55.3%
Taylor expanded in y around 0 55.5%
mul-1-neg55.5%
unsub-neg55.5%
Simplified55.5%
if 7.7999999999999996e-224 < x < 1.24e-141Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 75.4%
mul-1-neg75.4%
distribute-neg-frac75.4%
Simplified75.4%
Taylor expanded in y around 0 49.0%
*-commutative49.0%
Simplified49.0%
if 1.24e-141 < x < 2.4e12Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 52.8%
Final simplification68.0%
(FPCore (x y) :precision binary64 (if (<= y -90000000000000.0) (- 1.0 (/ x y)) (if (<= y 7.5) (/ x (- 2.0 x)) 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -90000000000000.0) {
tmp = 1.0 - (x / y);
} else if (y <= 7.5) {
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 <= (-90000000000000.0d0)) then
tmp = 1.0d0 - (x / y)
else if (y <= 7.5d0) 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 <= -90000000000000.0) {
tmp = 1.0 - (x / y);
} else if (y <= 7.5) {
tmp = x / (2.0 - x);
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -90000000000000.0: tmp = 1.0 - (x / y) elif y <= 7.5: tmp = x / (2.0 - x) else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -90000000000000.0) tmp = Float64(1.0 - Float64(x / y)); elseif (y <= 7.5) 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 <= -90000000000000.0) tmp = 1.0 - (x / y); elseif (y <= 7.5) tmp = x / (2.0 - x); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -90000000000000.0], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7.5], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -90000000000000:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{elif}\;y \leq 7.5:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -9e13Initial 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 y around inf 99.0%
Taylor expanded in y around 0 99.2%
mul-1-neg99.2%
unsub-neg99.2%
Simplified99.2%
if -9e13 < y < 7.5Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 76.1%
if 7.5 < y Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 94.8%
Final simplification83.4%
(FPCore (x y) :precision binary64 (if (<= y -22000000000000.0) (- 1.0 (/ x y)) (if (<= y 0.00058) (/ x (- 2.0 x)) (/ y (+ y -2.0)))))
double code(double x, double y) {
double tmp;
if (y <= -22000000000000.0) {
tmp = 1.0 - (x / y);
} else if (y <= 0.00058) {
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 <= (-22000000000000.0d0)) then
tmp = 1.0d0 - (x / y)
else if (y <= 0.00058d0) 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 <= -22000000000000.0) {
tmp = 1.0 - (x / y);
} else if (y <= 0.00058) {
tmp = x / (2.0 - x);
} else {
tmp = y / (y + -2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -22000000000000.0: tmp = 1.0 - (x / y) elif y <= 0.00058: tmp = x / (2.0 - x) else: tmp = y / (y + -2.0) return tmp
function code(x, y) tmp = 0.0 if (y <= -22000000000000.0) tmp = Float64(1.0 - Float64(x / y)); elseif (y <= 0.00058) 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 <= -22000000000000.0) tmp = 1.0 - (x / y); elseif (y <= 0.00058) tmp = x / (2.0 - x); else tmp = y / (y + -2.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -22000000000000.0], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 0.00058], 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 -22000000000000:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{elif}\;y \leq 0.00058:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y + -2}\\
\end{array}
\end{array}
if y < -2.2e13Initial 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 y around inf 99.0%
Taylor expanded in y around 0 99.2%
mul-1-neg99.2%
unsub-neg99.2%
Simplified99.2%
if -2.2e13 < y < 5.8e-4Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 76.6%
if 5.8e-4 < y Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
mul-1-neg100.0%
distribute-neg-frac100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef99.8%
add-sqr-sqrt0.0%
sqrt-unprod0.6%
sqr-neg0.6%
sqrt-unprod1.1%
add-sqr-sqrt1.4%
frac-2neg1.4%
add-sqr-sqrt0.0%
sqrt-unprod48.7%
sqr-neg48.7%
sqrt-unprod99.6%
add-sqr-sqrt99.8%
sub-neg99.8%
distribute-neg-in99.8%
metadata-eval99.8%
remove-double-neg99.8%
Applied egg-rr99.8%
expm1-def100.0%
expm1-log1p100.0%
+-commutative100.0%
Simplified100.0%
Final simplification84.9%
(FPCore (x y) :precision binary64 (if (<= y -26000000000000.0) (/ (- y x) y) (if (<= y 0.00062) (/ x (- 2.0 x)) (/ y (+ y -2.0)))))
double code(double x, double y) {
double tmp;
if (y <= -26000000000000.0) {
tmp = (y - x) / y;
} else if (y <= 0.00062) {
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 <= (-26000000000000.0d0)) then
tmp = (y - x) / y
else if (y <= 0.00062d0) 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 <= -26000000000000.0) {
tmp = (y - x) / y;
} else if (y <= 0.00062) {
tmp = x / (2.0 - x);
} else {
tmp = y / (y + -2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -26000000000000.0: tmp = (y - x) / y elif y <= 0.00062: tmp = x / (2.0 - x) else: tmp = y / (y + -2.0) return tmp
function code(x, y) tmp = 0.0 if (y <= -26000000000000.0) tmp = Float64(Float64(y - x) / y); elseif (y <= 0.00062) 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 <= -26000000000000.0) tmp = (y - x) / y; elseif (y <= 0.00062) tmp = x / (2.0 - x); else tmp = y / (y + -2.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -26000000000000.0], N[(N[(y - x), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[y, 0.00062], 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 -26000000000000:\\
\;\;\;\;\frac{y - x}{y}\\
\mathbf{elif}\;y \leq 0.00062:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y + -2}\\
\end{array}
\end{array}
if y < -2.6e13Initial 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 y around inf 99.0%
*-commutative99.0%
frac-2neg99.0%
metadata-eval99.0%
un-div-inv99.2%
Applied egg-rr99.2%
Taylor expanded in x around 0 99.2%
mul-1-neg99.2%
unsub-neg99.2%
*-inverses99.2%
div-sub99.2%
Simplified99.2%
if -2.6e13 < y < 6.2e-4Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 76.6%
if 6.2e-4 < y Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
mul-1-neg100.0%
distribute-neg-frac100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef99.8%
add-sqr-sqrt0.0%
sqrt-unprod0.6%
sqr-neg0.6%
sqrt-unprod1.1%
add-sqr-sqrt1.4%
frac-2neg1.4%
add-sqr-sqrt0.0%
sqrt-unprod48.7%
sqr-neg48.7%
sqrt-unprod99.6%
add-sqr-sqrt99.8%
sub-neg99.8%
distribute-neg-in99.8%
metadata-eval99.8%
remove-double-neg99.8%
Applied egg-rr99.8%
expm1-def100.0%
expm1-log1p100.0%
+-commutative100.0%
Simplified100.0%
Final simplification84.9%
(FPCore (x y) :precision binary64 (if (<= x -7800000000000.0) -1.0 (if (<= x 7400000000000.0) 1.0 -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -7800000000000.0) {
tmp = -1.0;
} else if (x <= 7400000000000.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 <= (-7800000000000.0d0)) then
tmp = -1.0d0
else if (x <= 7400000000000.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 <= -7800000000000.0) {
tmp = -1.0;
} else if (x <= 7400000000000.0) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -7800000000000.0: tmp = -1.0 elif x <= 7400000000000.0: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -7800000000000.0) tmp = -1.0; elseif (x <= 7400000000000.0) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -7800000000000.0) tmp = -1.0; elseif (x <= 7400000000000.0) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -7800000000000.0], -1.0, If[LessEqual[x, 7400000000000.0], 1.0, -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7800000000000:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 7400000000000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -7.8e12 or 7.4e12 < x Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 99.9%
if -7.8e12 < x < 7.4e12Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 51.3%
Final simplification66.1%
(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 32.9%
Final simplification32.9%
(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 2023278
(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))))