
(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 (if (<= x -6.5e-100) (/ x (- 2.0 x)) (if (<= x 7e+63) (/ y (+ y -2.0)) (* (- x y) (/ -1.0 x)))))
double code(double x, double y) {
double tmp;
if (x <= -6.5e-100) {
tmp = x / (2.0 - x);
} else if (x <= 7e+63) {
tmp = y / (y + -2.0);
} else {
tmp = (x - y) * (-1.0 / x);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-6.5d-100)) then
tmp = x / (2.0d0 - x)
else if (x <= 7d+63) then
tmp = y / (y + (-2.0d0))
else
tmp = (x - y) * ((-1.0d0) / x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -6.5e-100) {
tmp = x / (2.0 - x);
} else if (x <= 7e+63) {
tmp = y / (y + -2.0);
} else {
tmp = (x - y) * (-1.0 / x);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -6.5e-100: tmp = x / (2.0 - x) elif x <= 7e+63: tmp = y / (y + -2.0) else: tmp = (x - y) * (-1.0 / x) return tmp
function code(x, y) tmp = 0.0 if (x <= -6.5e-100) tmp = Float64(x / Float64(2.0 - x)); elseif (x <= 7e+63) tmp = Float64(y / Float64(y + -2.0)); else tmp = Float64(Float64(x - y) * Float64(-1.0 / x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -6.5e-100) tmp = x / (2.0 - x); elseif (x <= 7e+63) tmp = y / (y + -2.0); else tmp = (x - y) * (-1.0 / x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -6.5e-100], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 7e+63], N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision], N[(N[(x - y), $MachinePrecision] * N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.5 \cdot 10^{-100}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{elif}\;x \leq 7 \cdot 10^{+63}:\\
\;\;\;\;\frac{y}{y + -2}\\
\mathbf{else}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{-1}{x}\\
\end{array}
\end{array}
if x < -6.50000000000000013e-100Initial program 99.9%
Taylor expanded in y around 0 75.5%
if -6.50000000000000013e-100 < x < 7.00000000000000059e63Initial program 100.0%
Taylor expanded in x around 0 77.5%
mul-1-neg77.5%
distribute-neg-frac77.5%
Simplified77.5%
frac-2neg77.5%
div-inv77.4%
remove-double-neg77.4%
sub-neg77.4%
distribute-neg-in77.4%
metadata-eval77.4%
remove-double-neg77.4%
Applied egg-rr77.4%
associate-*r/77.5%
*-rgt-identity77.5%
+-commutative77.5%
Simplified77.5%
if 7.00000000000000059e63 < x Initial program 100.0%
clear-num99.9%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 78.8%
Final simplification77.1%
(FPCore (x y) :precision binary64 (if (<= y -240.0) (/ y (+ y -2.0)) (if (<= y 1.8e+59) (/ x (- 2.0 x)) (- 1.0 (* 2.0 (/ x y))))))
double code(double x, double y) {
double tmp;
if (y <= -240.0) {
tmp = y / (y + -2.0);
} else if (y <= 1.8e+59) {
tmp = x / (2.0 - x);
} else {
tmp = 1.0 - (2.0 * (x / y));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-240.0d0)) then
tmp = y / (y + (-2.0d0))
else if (y <= 1.8d+59) then
tmp = x / (2.0d0 - x)
else
tmp = 1.0d0 - (2.0d0 * (x / y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -240.0) {
tmp = y / (y + -2.0);
} else if (y <= 1.8e+59) {
tmp = x / (2.0 - x);
} else {
tmp = 1.0 - (2.0 * (x / y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -240.0: tmp = y / (y + -2.0) elif y <= 1.8e+59: tmp = x / (2.0 - x) else: tmp = 1.0 - (2.0 * (x / y)) return tmp
function code(x, y) tmp = 0.0 if (y <= -240.0) tmp = Float64(y / Float64(y + -2.0)); elseif (y <= 1.8e+59) tmp = Float64(x / Float64(2.0 - x)); else tmp = Float64(1.0 - Float64(2.0 * Float64(x / y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -240.0) tmp = y / (y + -2.0); elseif (y <= 1.8e+59) tmp = x / (2.0 - x); else tmp = 1.0 - (2.0 * (x / y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -240.0], N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.8e+59], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(2.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -240:\\
\;\;\;\;\frac{y}{y + -2}\\
\mathbf{elif}\;y \leq 1.8 \cdot 10^{+59}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;1 - 2 \cdot \frac{x}{y}\\
\end{array}
\end{array}
if y < -240Initial program 100.0%
Taylor expanded in x around 0 72.6%
mul-1-neg72.6%
distribute-neg-frac72.6%
Simplified72.6%
frac-2neg72.6%
div-inv72.3%
remove-double-neg72.3%
sub-neg72.3%
distribute-neg-in72.3%
metadata-eval72.3%
remove-double-neg72.3%
Applied egg-rr72.3%
associate-*r/72.6%
*-rgt-identity72.6%
+-commutative72.6%
Simplified72.6%
if -240 < y < 1.7999999999999999e59Initial program 100.0%
Taylor expanded in y around 0 78.7%
if 1.7999999999999999e59 < y Initial program 99.9%
flip--30.1%
associate-/r/30.0%
metadata-eval30.0%
pow230.0%
Applied egg-rr30.0%
associate-*l/27.8%
associate-+r+27.8%
+-commutative27.8%
Simplified27.8%
Taylor expanded in y around -inf 78.7%
mul-1-neg78.7%
unsub-neg78.7%
cancel-sign-sub-inv78.7%
distribute-rgt1-in78.7%
metadata-eval78.7%
mul0-lft78.7%
metadata-eval78.7%
metadata-eval78.7%
metadata-eval78.7%
Simplified78.7%
Taylor expanded in x around inf 78.7%
Final simplification77.2%
(FPCore (x y) :precision binary64 (if (<= y -26000.0) (- 1.0 (/ (+ -2.0 (* x 2.0)) y)) (if (<= y 2.3e+56) (/ x (- 2.0 x)) (- 1.0 (* 2.0 (/ x y))))))
double code(double x, double y) {
double tmp;
if (y <= -26000.0) {
tmp = 1.0 - ((-2.0 + (x * 2.0)) / y);
} else if (y <= 2.3e+56) {
tmp = x / (2.0 - x);
} else {
tmp = 1.0 - (2.0 * (x / y));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-26000.0d0)) then
tmp = 1.0d0 - (((-2.0d0) + (x * 2.0d0)) / y)
else if (y <= 2.3d+56) then
tmp = x / (2.0d0 - x)
else
tmp = 1.0d0 - (2.0d0 * (x / y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -26000.0) {
tmp = 1.0 - ((-2.0 + (x * 2.0)) / y);
} else if (y <= 2.3e+56) {
tmp = x / (2.0 - x);
} else {
tmp = 1.0 - (2.0 * (x / y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -26000.0: tmp = 1.0 - ((-2.0 + (x * 2.0)) / y) elif y <= 2.3e+56: tmp = x / (2.0 - x) else: tmp = 1.0 - (2.0 * (x / y)) return tmp
function code(x, y) tmp = 0.0 if (y <= -26000.0) tmp = Float64(1.0 - Float64(Float64(-2.0 + Float64(x * 2.0)) / y)); elseif (y <= 2.3e+56) tmp = Float64(x / Float64(2.0 - x)); else tmp = Float64(1.0 - Float64(2.0 * Float64(x / y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -26000.0) tmp = 1.0 - ((-2.0 + (x * 2.0)) / y); elseif (y <= 2.3e+56) tmp = x / (2.0 - x); else tmp = 1.0 - (2.0 * (x / y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -26000.0], N[(1.0 - N[(N[(-2.0 + N[(x * 2.0), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.3e+56], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(2.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -26000:\\
\;\;\;\;1 - \frac{-2 + x \cdot 2}{y}\\
\mathbf{elif}\;y \leq 2.3 \cdot 10^{+56}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;1 - 2 \cdot \frac{x}{y}\\
\end{array}
\end{array}
if y < -26000Initial program 100.0%
flip--50.7%
associate-/r/50.5%
metadata-eval50.5%
pow250.5%
Applied egg-rr50.5%
associate-*l/49.2%
associate-+r+49.2%
+-commutative49.2%
Simplified49.2%
Taylor expanded in y around -inf 73.5%
mul-1-neg73.5%
unsub-neg73.5%
cancel-sign-sub-inv73.5%
distribute-rgt1-in73.5%
metadata-eval73.5%
mul0-lft73.5%
metadata-eval73.5%
metadata-eval73.5%
metadata-eval73.5%
Simplified73.5%
if -26000 < y < 2.30000000000000015e56Initial program 100.0%
Taylor expanded in y around 0 78.7%
if 2.30000000000000015e56 < y Initial program 99.9%
flip--30.1%
associate-/r/30.0%
metadata-eval30.0%
pow230.0%
Applied egg-rr30.0%
associate-*l/27.8%
associate-+r+27.8%
+-commutative27.8%
Simplified27.8%
Taylor expanded in y around -inf 78.7%
mul-1-neg78.7%
unsub-neg78.7%
cancel-sign-sub-inv78.7%
distribute-rgt1-in78.7%
metadata-eval78.7%
mul0-lft78.7%
metadata-eval78.7%
metadata-eval78.7%
metadata-eval78.7%
Simplified78.7%
Taylor expanded in x around inf 78.7%
Final simplification77.4%
(FPCore (x y) :precision binary64 (if (<= x -59000000.0) -1.0 (if (<= x 1.75e+64) (- 1.0 (/ x y)) -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -59000000.0) {
tmp = -1.0;
} else if (x <= 1.75e+64) {
tmp = 1.0 - (x / y);
} 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 <= (-59000000.0d0)) then
tmp = -1.0d0
else if (x <= 1.75d+64) then
tmp = 1.0d0 - (x / y)
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -59000000.0) {
tmp = -1.0;
} else if (x <= 1.75e+64) {
tmp = 1.0 - (x / y);
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -59000000.0: tmp = -1.0 elif x <= 1.75e+64: tmp = 1.0 - (x / y) else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -59000000.0) tmp = -1.0; elseif (x <= 1.75e+64) tmp = Float64(1.0 - Float64(x / y)); else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -59000000.0) tmp = -1.0; elseif (x <= 1.75e+64) tmp = 1.0 - (x / y); else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -59000000.0], -1.0, If[LessEqual[x, 1.75e+64], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -59000000:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 1.75 \cdot 10^{+64}:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -5.9e7 or 1.7499999999999999e64 < x Initial program 100.0%
Taylor expanded in x around inf 78.5%
if -5.9e7 < x < 1.7499999999999999e64Initial program 100.0%
clear-num99.8%
associate-/r/99.8%
Applied egg-rr99.8%
Taylor expanded in y around inf 52.9%
Taylor expanded in y around 0 53.0%
mul-1-neg53.0%
unsub-neg53.0%
Simplified53.0%
Final simplification64.6%
(FPCore (x y) :precision binary64 (if (<= y -210000.0) (- 1.0 (/ -2.0 y)) (if (<= y 5.2e+56) (/ x (- 2.0 x)) (- 1.0 (/ x y)))))
double code(double x, double y) {
double tmp;
if (y <= -210000.0) {
tmp = 1.0 - (-2.0 / y);
} else if (y <= 5.2e+56) {
tmp = x / (2.0 - x);
} else {
tmp = 1.0 - (x / y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-210000.0d0)) then
tmp = 1.0d0 - ((-2.0d0) / y)
else if (y <= 5.2d+56) then
tmp = x / (2.0d0 - x)
else
tmp = 1.0d0 - (x / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -210000.0) {
tmp = 1.0 - (-2.0 / y);
} else if (y <= 5.2e+56) {
tmp = x / (2.0 - x);
} else {
tmp = 1.0 - (x / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -210000.0: tmp = 1.0 - (-2.0 / y) elif y <= 5.2e+56: tmp = x / (2.0 - x) else: tmp = 1.0 - (x / y) return tmp
function code(x, y) tmp = 0.0 if (y <= -210000.0) tmp = Float64(1.0 - Float64(-2.0 / y)); elseif (y <= 5.2e+56) tmp = Float64(x / Float64(2.0 - x)); else tmp = Float64(1.0 - Float64(x / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -210000.0) tmp = 1.0 - (-2.0 / y); elseif (y <= 5.2e+56) tmp = x / (2.0 - x); else tmp = 1.0 - (x / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -210000.0], N[(1.0 - N[(-2.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5.2e+56], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -210000:\\
\;\;\;\;1 - \frac{-2}{y}\\
\mathbf{elif}\;y \leq 5.2 \cdot 10^{+56}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{y}\\
\end{array}
\end{array}
if y < -2.1e5Initial program 100.0%
flip--50.7%
associate-/r/50.5%
metadata-eval50.5%
pow250.5%
Applied egg-rr50.5%
associate-*l/49.2%
associate-+r+49.2%
+-commutative49.2%
Simplified49.2%
Taylor expanded in y around -inf 73.5%
mul-1-neg73.5%
unsub-neg73.5%
cancel-sign-sub-inv73.5%
distribute-rgt1-in73.5%
metadata-eval73.5%
mul0-lft73.5%
metadata-eval73.5%
metadata-eval73.5%
metadata-eval73.5%
Simplified73.5%
Taylor expanded in x around 0 71.9%
if -2.1e5 < y < 5.20000000000000022e56Initial program 100.0%
Taylor expanded in y around 0 78.7%
if 5.20000000000000022e56 < y Initial program 99.9%
clear-num99.9%
associate-/r/99.8%
Applied egg-rr99.8%
Taylor expanded in y around inf 77.4%
Taylor expanded in y around 0 77.6%
mul-1-neg77.6%
unsub-neg77.6%
Simplified77.6%
Final simplification76.8%
(FPCore (x y) :precision binary64 (if (<= x -8e-100) (/ x (- 2.0 x)) (if (<= x 5.5e+63) (/ y (+ y -2.0)) -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -8e-100) {
tmp = x / (2.0 - x);
} else if (x <= 5.5e+63) {
tmp = y / (y + -2.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 <= (-8d-100)) then
tmp = x / (2.0d0 - x)
else if (x <= 5.5d+63) then
tmp = y / (y + (-2.0d0))
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -8e-100) {
tmp = x / (2.0 - x);
} else if (x <= 5.5e+63) {
tmp = y / (y + -2.0);
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -8e-100: tmp = x / (2.0 - x) elif x <= 5.5e+63: tmp = y / (y + -2.0) else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -8e-100) tmp = Float64(x / Float64(2.0 - x)); elseif (x <= 5.5e+63) tmp = Float64(y / Float64(y + -2.0)); else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -8e-100) tmp = x / (2.0 - x); elseif (x <= 5.5e+63) tmp = y / (y + -2.0); else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -8e-100], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.5e+63], N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision], -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8 \cdot 10^{-100}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{+63}:\\
\;\;\;\;\frac{y}{y + -2}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -8.0000000000000002e-100Initial program 99.9%
Taylor expanded in y around 0 75.5%
if -8.0000000000000002e-100 < x < 5.50000000000000004e63Initial program 100.0%
Taylor expanded in x around 0 77.5%
mul-1-neg77.5%
distribute-neg-frac77.5%
Simplified77.5%
frac-2neg77.5%
div-inv77.4%
remove-double-neg77.4%
sub-neg77.4%
distribute-neg-in77.4%
metadata-eval77.4%
remove-double-neg77.4%
Applied egg-rr77.4%
associate-*r/77.5%
*-rgt-identity77.5%
+-commutative77.5%
Simplified77.5%
if 5.50000000000000004e63 < x Initial program 100.0%
Taylor expanded in x around inf 78.2%
Final simplification77.0%
(FPCore (x y) :precision binary64 (if (<= x -2300000.0) -1.0 (if (<= x 1.4e+64) 1.0 -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -2300000.0) {
tmp = -1.0;
} else if (x <= 1.4e+64) {
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 <= (-2300000.0d0)) then
tmp = -1.0d0
else if (x <= 1.4d+64) 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 <= -2300000.0) {
tmp = -1.0;
} else if (x <= 1.4e+64) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2300000.0: tmp = -1.0 elif x <= 1.4e+64: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -2300000.0) tmp = -1.0; elseif (x <= 1.4e+64) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2300000.0) tmp = -1.0; elseif (x <= 1.4e+64) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2300000.0], -1.0, If[LessEqual[x, 1.4e+64], 1.0, -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2300000:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{+64}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -2.3e6 or 1.40000000000000012e64 < x Initial program 100.0%
Taylor expanded in x around inf 78.5%
if -2.3e6 < x < 1.40000000000000012e64Initial program 100.0%
Taylor expanded in y around inf 53.0%
Final simplification64.6%
(FPCore (x y) :precision binary64 -1.0)
double code(double x, double y) {
return -1.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = -1.0d0
end function
public static double code(double x, double y) {
return -1.0;
}
def code(x, y): return -1.0
function code(x, y) return -1.0 end
function tmp = code(x, y) tmp = -1.0; end
code[x_, y_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 100.0%
Taylor expanded in x around inf 38.6%
Final simplification38.6%
(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 2023340
(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))))