
(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 9 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 (+ (/ y x) -1.0)))
(if (<= x -6.7e+22)
t_0
(if (<= x -4.8e-65)
1.0
(if (<= x -5.8e-267) (* (- x y) 0.5) (if (<= x 5.2e+89) 1.0 t_0))))))
double code(double x, double y) {
double t_0 = (y / x) + -1.0;
double tmp;
if (x <= -6.7e+22) {
tmp = t_0;
} else if (x <= -4.8e-65) {
tmp = 1.0;
} else if (x <= -5.8e-267) {
tmp = (x - y) * 0.5;
} else if (x <= 5.2e+89) {
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) :: tmp
t_0 = (y / x) + (-1.0d0)
if (x <= (-6.7d+22)) then
tmp = t_0
else if (x <= (-4.8d-65)) then
tmp = 1.0d0
else if (x <= (-5.8d-267)) then
tmp = (x - y) * 0.5d0
else if (x <= 5.2d+89) 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 tmp;
if (x <= -6.7e+22) {
tmp = t_0;
} else if (x <= -4.8e-65) {
tmp = 1.0;
} else if (x <= -5.8e-267) {
tmp = (x - y) * 0.5;
} else if (x <= 5.2e+89) {
tmp = 1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (y / x) + -1.0 tmp = 0 if x <= -6.7e+22: tmp = t_0 elif x <= -4.8e-65: tmp = 1.0 elif x <= -5.8e-267: tmp = (x - y) * 0.5 elif x <= 5.2e+89: tmp = 1.0 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(y / x) + -1.0) tmp = 0.0 if (x <= -6.7e+22) tmp = t_0; elseif (x <= -4.8e-65) tmp = 1.0; elseif (x <= -5.8e-267) tmp = Float64(Float64(x - y) * 0.5); elseif (x <= 5.2e+89) tmp = 1.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (y / x) + -1.0; tmp = 0.0; if (x <= -6.7e+22) tmp = t_0; elseif (x <= -4.8e-65) tmp = 1.0; elseif (x <= -5.8e-267) tmp = (x - y) * 0.5; elseif (x <= 5.2e+89) 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]}, If[LessEqual[x, -6.7e+22], t$95$0, If[LessEqual[x, -4.8e-65], 1.0, If[LessEqual[x, -5.8e-267], N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 5.2e+89], 1.0, t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{x} + -1\\
\mathbf{if}\;x \leq -6.7 \cdot 10^{+22}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -4.8 \cdot 10^{-65}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -5.8 \cdot 10^{-267}:\\
\;\;\;\;\left(x - y\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 5.2 \cdot 10^{+89}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -6.7000000000000002e22 or 5.2000000000000001e89 < x Initial program 100.0%
clear-num99.9%
associate-/r/99.8%
associate--r+99.8%
Applied egg-rr99.8%
Taylor expanded in x around inf 85.1%
Taylor expanded in x around 0 85.2%
if -6.7000000000000002e22 < x < -4.8000000000000003e-65 or -5.80000000000000043e-267 < x < 5.2000000000000001e89Initial program 100.0%
Taylor expanded in y around inf 60.5%
if -4.8000000000000003e-65 < x < -5.80000000000000043e-267Initial program 100.0%
clear-num99.7%
associate-/r/99.8%
associate--r+99.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 99.8%
Taylor expanded in y around 0 65.0%
Final simplification70.8%
(FPCore (x y)
:precision binary64
(if (<= x -1.5e+23)
-1.0
(if (<= x -2.1e-65)
1.0
(if (<= x -9.8e-265) (* (- x y) 0.5) (if (<= x 1e+73) 1.0 -1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -1.5e+23) {
tmp = -1.0;
} else if (x <= -2.1e-65) {
tmp = 1.0;
} else if (x <= -9.8e-265) {
tmp = (x - y) * 0.5;
} else if (x <= 1e+73) {
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 <= (-1.5d+23)) then
tmp = -1.0d0
else if (x <= (-2.1d-65)) then
tmp = 1.0d0
else if (x <= (-9.8d-265)) then
tmp = (x - y) * 0.5d0
else if (x <= 1d+73) 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 <= -1.5e+23) {
tmp = -1.0;
} else if (x <= -2.1e-65) {
tmp = 1.0;
} else if (x <= -9.8e-265) {
tmp = (x - y) * 0.5;
} else if (x <= 1e+73) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.5e+23: tmp = -1.0 elif x <= -2.1e-65: tmp = 1.0 elif x <= -9.8e-265: tmp = (x - y) * 0.5 elif x <= 1e+73: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.5e+23) tmp = -1.0; elseif (x <= -2.1e-65) tmp = 1.0; elseif (x <= -9.8e-265) tmp = Float64(Float64(x - y) * 0.5); elseif (x <= 1e+73) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.5e+23) tmp = -1.0; elseif (x <= -2.1e-65) tmp = 1.0; elseif (x <= -9.8e-265) tmp = (x - y) * 0.5; elseif (x <= 1e+73) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.5e+23], -1.0, If[LessEqual[x, -2.1e-65], 1.0, If[LessEqual[x, -9.8e-265], N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 1e+73], 1.0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.5 \cdot 10^{+23}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -2.1 \cdot 10^{-65}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -9.8 \cdot 10^{-265}:\\
\;\;\;\;\left(x - y\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 10^{+73}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -1.5e23 or 9.99999999999999983e72 < x Initial program 100.0%
Taylor expanded in x around inf 84.1%
if -1.5e23 < x < -2.10000000000000003e-65 or -9.79999999999999999e-265 < x < 9.99999999999999983e72Initial program 100.0%
Taylor expanded in y around inf 60.7%
if -2.10000000000000003e-65 < x < -9.79999999999999999e-265Initial program 100.0%
clear-num99.7%
associate-/r/99.8%
associate--r+99.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 99.8%
Taylor expanded in y around 0 65.0%
Final simplification70.6%
(FPCore (x y) :precision binary64 (if (or (<= x -1.45e+23) (not (<= x 5e+97))) (/ (- x y) (- x)) (/ (- x y) (- 2.0 y))))
double code(double x, double y) {
double tmp;
if ((x <= -1.45e+23) || !(x <= 5e+97)) {
tmp = (x - y) / -x;
} else {
tmp = (x - y) / (2.0 - y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-1.45d+23)) .or. (.not. (x <= 5d+97))) then
tmp = (x - y) / -x
else
tmp = (x - y) / (2.0d0 - y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -1.45e+23) || !(x <= 5e+97)) {
tmp = (x - y) / -x;
} else {
tmp = (x - y) / (2.0 - y);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.45e+23) or not (x <= 5e+97): tmp = (x - y) / -x else: tmp = (x - y) / (2.0 - y) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.45e+23) || !(x <= 5e+97)) tmp = Float64(Float64(x - y) / Float64(-x)); else tmp = Float64(Float64(x - y) / Float64(2.0 - y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1.45e+23) || ~((x <= 5e+97))) tmp = (x - y) / -x; else tmp = (x - y) / (2.0 - y); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.45e+23], N[Not[LessEqual[x, 5e+97]], $MachinePrecision]], N[(N[(x - y), $MachinePrecision] / (-x)), $MachinePrecision], N[(N[(x - y), $MachinePrecision] / N[(2.0 - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.45 \cdot 10^{+23} \lor \neg \left(x \leq 5 \cdot 10^{+97}\right):\\
\;\;\;\;\frac{x - y}{-x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x - y}{2 - y}\\
\end{array}
\end{array}
if x < -1.45000000000000006e23 or 4.99999999999999999e97 < x Initial program 100.0%
clear-num99.9%
associate-/r/99.8%
associate--r+99.8%
Applied egg-rr99.8%
Taylor expanded in x around inf 85.7%
expm1-log1p-u83.1%
expm1-udef83.1%
*-commutative83.1%
frac-2neg83.1%
metadata-eval83.1%
un-div-inv83.2%
Applied egg-rr83.2%
expm1-def83.2%
expm1-log1p85.8%
Simplified85.8%
if -1.45000000000000006e23 < x < 4.99999999999999999e97Initial program 100.0%
clear-num99.8%
associate-/r/99.8%
associate--r+99.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 91.5%
Taylor expanded in x around 0 91.6%
+-commutative91.6%
mul-1-neg91.6%
sub-neg91.6%
div-sub91.6%
Simplified91.6%
Final simplification89.4%
(FPCore (x y)
:precision binary64
(if (<= x -2e+23)
-1.0
(if (<= x -3.3e-65)
1.0
(if (<= x -1e-69) (* x 0.5) (if (<= x 7e+72) 1.0 -1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -2e+23) {
tmp = -1.0;
} else if (x <= -3.3e-65) {
tmp = 1.0;
} else if (x <= -1e-69) {
tmp = x * 0.5;
} else if (x <= 7e+72) {
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 <= (-2d+23)) then
tmp = -1.0d0
else if (x <= (-3.3d-65)) then
tmp = 1.0d0
else if (x <= (-1d-69)) then
tmp = x * 0.5d0
else if (x <= 7d+72) 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 <= -2e+23) {
tmp = -1.0;
} else if (x <= -3.3e-65) {
tmp = 1.0;
} else if (x <= -1e-69) {
tmp = x * 0.5;
} else if (x <= 7e+72) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2e+23: tmp = -1.0 elif x <= -3.3e-65: tmp = 1.0 elif x <= -1e-69: tmp = x * 0.5 elif x <= 7e+72: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -2e+23) tmp = -1.0; elseif (x <= -3.3e-65) tmp = 1.0; elseif (x <= -1e-69) tmp = Float64(x * 0.5); elseif (x <= 7e+72) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2e+23) tmp = -1.0; elseif (x <= -3.3e-65) tmp = 1.0; elseif (x <= -1e-69) tmp = x * 0.5; elseif (x <= 7e+72) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2e+23], -1.0, If[LessEqual[x, -3.3e-65], 1.0, If[LessEqual[x, -1e-69], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 7e+72], 1.0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{+23}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -3.3 \cdot 10^{-65}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -1 \cdot 10^{-69}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 7 \cdot 10^{+72}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -1.9999999999999998e23 or 7.0000000000000002e72 < x Initial program 100.0%
Taylor expanded in x around inf 84.1%
if -1.9999999999999998e23 < x < -3.3000000000000001e-65 or -9.9999999999999996e-70 < x < 7.0000000000000002e72Initial program 100.0%
Taylor expanded in y around inf 54.7%
if -3.3000000000000001e-65 < x < -9.9999999999999996e-70Initial program 100.0%
Taylor expanded in y around 0 100.0%
Taylor expanded in x around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification67.1%
(FPCore (x y) :precision binary64 (if (<= y -6.2e-7) 1.0 (if (<= y 4e+46) (/ x (- 2.0 x)) 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -6.2e-7) {
tmp = 1.0;
} else if (y <= 4e+46) {
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 <= (-6.2d-7)) then
tmp = 1.0d0
else if (y <= 4d+46) 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 <= -6.2e-7) {
tmp = 1.0;
} else if (y <= 4e+46) {
tmp = x / (2.0 - x);
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -6.2e-7: tmp = 1.0 elif y <= 4e+46: tmp = x / (2.0 - x) else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -6.2e-7) tmp = 1.0; elseif (y <= 4e+46) 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 <= -6.2e-7) tmp = 1.0; elseif (y <= 4e+46) tmp = x / (2.0 - x); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -6.2e-7], 1.0, If[LessEqual[y, 4e+46], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.2 \cdot 10^{-7}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 4 \cdot 10^{+46}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -6.1999999999999999e-7 or 4e46 < y Initial program 100.0%
Taylor expanded in y around inf 77.1%
if -6.1999999999999999e-7 < y < 4e46Initial program 100.0%
Taylor expanded in y around 0 80.2%
Final simplification78.8%
(FPCore (x y) :precision binary64 (if (<= y -3.2e-7) (/ y (+ y -2.0)) (if (<= y 3.7e+41) (/ x (- 2.0 x)) 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -3.2e-7) {
tmp = y / (y + -2.0);
} else if (y <= 3.7e+41) {
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 <= (-3.2d-7)) then
tmp = y / (y + (-2.0d0))
else if (y <= 3.7d+41) 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 <= -3.2e-7) {
tmp = y / (y + -2.0);
} else if (y <= 3.7e+41) {
tmp = x / (2.0 - x);
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -3.2e-7: tmp = y / (y + -2.0) elif y <= 3.7e+41: tmp = x / (2.0 - x) else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -3.2e-7) tmp = Float64(y / Float64(y + -2.0)); elseif (y <= 3.7e+41) 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 <= -3.2e-7) tmp = y / (y + -2.0); elseif (y <= 3.7e+41) tmp = x / (2.0 - x); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -3.2e-7], N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.7e+41], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.2 \cdot 10^{-7}:\\
\;\;\;\;\frac{y}{y + -2}\\
\mathbf{elif}\;y \leq 3.7 \cdot 10^{+41}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -3.2000000000000001e-7Initial program 100.0%
Taylor expanded in x around 0 74.1%
mul-1-neg74.1%
distribute-neg-frac74.1%
Simplified74.1%
frac-2neg74.1%
div-inv74.0%
remove-double-neg74.0%
sub-neg74.0%
distribute-neg-in74.0%
metadata-eval74.0%
remove-double-neg74.0%
Applied egg-rr74.0%
associate-*r/74.1%
*-rgt-identity74.1%
+-commutative74.1%
Simplified74.1%
if -3.2000000000000001e-7 < y < 3.69999999999999981e41Initial program 100.0%
Taylor expanded in y around 0 80.2%
if 3.69999999999999981e41 < y Initial program 100.0%
Taylor expanded in y around inf 87.5%
Final simplification80.2%
(FPCore (x y) :precision binary64 (if (<= x -1e+23) -1.0 (if (<= x 1.35e+73) 1.0 -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -1e+23) {
tmp = -1.0;
} else if (x <= 1.35e+73) {
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 <= (-1d+23)) then
tmp = -1.0d0
else if (x <= 1.35d+73) 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 <= -1e+23) {
tmp = -1.0;
} else if (x <= 1.35e+73) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1e+23: tmp = -1.0 elif x <= 1.35e+73: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1e+23) tmp = -1.0; elseif (x <= 1.35e+73) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1e+23) tmp = -1.0; elseif (x <= 1.35e+73) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1e+23], -1.0, If[LessEqual[x, 1.35e+73], 1.0, -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{+23}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 1.35 \cdot 10^{+73}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -9.9999999999999992e22 or 1.35e73 < x Initial program 100.0%
Taylor expanded in x around inf 84.1%
if -9.9999999999999992e22 < x < 1.35e73Initial program 100.0%
Taylor expanded in y around inf 53.0%
Final simplification65.2%
(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.7%
Final simplification36.7%
(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 2023221
(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))))