
(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 99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ (/ (+ (* y 2.0) -2.0) x) -1.0)))
(if (<= x -3.3e+25)
t_0
(if (<= x 14500000000000.0) (/ (- x y) (- 2.0 y)) t_0))))
double code(double x, double y) {
double t_0 = (((y * 2.0) + -2.0) / x) + -1.0;
double tmp;
if (x <= -3.3e+25) {
tmp = t_0;
} else if (x <= 14500000000000.0) {
tmp = (x - y) / (2.0 - y);
} 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 * 2.0d0) + (-2.0d0)) / x) + (-1.0d0)
if (x <= (-3.3d+25)) then
tmp = t_0
else if (x <= 14500000000000.0d0) then
tmp = (x - y) / (2.0d0 - y)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (((y * 2.0) + -2.0) / x) + -1.0;
double tmp;
if (x <= -3.3e+25) {
tmp = t_0;
} else if (x <= 14500000000000.0) {
tmp = (x - y) / (2.0 - y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (((y * 2.0) + -2.0) / x) + -1.0 tmp = 0 if x <= -3.3e+25: tmp = t_0 elif x <= 14500000000000.0: tmp = (x - y) / (2.0 - y) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(Float64(Float64(y * 2.0) + -2.0) / x) + -1.0) tmp = 0.0 if (x <= -3.3e+25) tmp = t_0; elseif (x <= 14500000000000.0) tmp = Float64(Float64(x - y) / Float64(2.0 - y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (((y * 2.0) + -2.0) / x) + -1.0; tmp = 0.0; if (x <= -3.3e+25) tmp = t_0; elseif (x <= 14500000000000.0) tmp = (x - y) / (2.0 - y); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(N[(N[(y * 2.0), $MachinePrecision] + -2.0), $MachinePrecision] / x), $MachinePrecision] + -1.0), $MachinePrecision]}, If[LessEqual[x, -3.3e+25], t$95$0, If[LessEqual[x, 14500000000000.0], N[(N[(x - y), $MachinePrecision] / N[(2.0 - y), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y \cdot 2 + -2}{x} + -1\\
\mathbf{if}\;x \leq -3.3 \cdot 10^{+25}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 14500000000000:\\
\;\;\;\;\frac{x - y}{2 - y}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -3.3000000000000001e25 or 1.45e13 < x Initial program 99.9%
Taylor expanded in x around inf
+-commutativeN/A
associate--r+N/A
associate-*r/N/A
associate-*r/N/A
metadata-evalN/A
div-subN/A
sub-negN/A
metadata-evalN/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
sub-negN/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
metadata-eval79.5%
Simplified79.5%
if -3.3000000000000001e25 < x < 1.45e13Initial program 100.0%
Taylor expanded in x around 0
--lowering--.f6498.0%
Simplified98.0%
(FPCore (x y) :precision binary64 (if (<= x -9.3e+17) (/ (- x y) (- 2.0 x)) (if (<= x 1.85e+20) (/ (- x y) (- 2.0 y)) (/ x (- 2.0 (+ x y))))))
double code(double x, double y) {
double tmp;
if (x <= -9.3e+17) {
tmp = (x - y) / (2.0 - x);
} else if (x <= 1.85e+20) {
tmp = (x - y) / (2.0 - y);
} else {
tmp = x / (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 (x <= (-9.3d+17)) then
tmp = (x - y) / (2.0d0 - x)
else if (x <= 1.85d+20) then
tmp = (x - y) / (2.0d0 - y)
else
tmp = x / (2.0d0 - (x + y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -9.3e+17) {
tmp = (x - y) / (2.0 - x);
} else if (x <= 1.85e+20) {
tmp = (x - y) / (2.0 - y);
} else {
tmp = x / (2.0 - (x + y));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -9.3e+17: tmp = (x - y) / (2.0 - x) elif x <= 1.85e+20: tmp = (x - y) / (2.0 - y) else: tmp = x / (2.0 - (x + y)) return tmp
function code(x, y) tmp = 0.0 if (x <= -9.3e+17) tmp = Float64(Float64(x - y) / Float64(2.0 - x)); elseif (x <= 1.85e+20) tmp = Float64(Float64(x - y) / Float64(2.0 - y)); else tmp = Float64(x / Float64(2.0 - Float64(x + y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -9.3e+17) tmp = (x - y) / (2.0 - x); elseif (x <= 1.85e+20) tmp = (x - y) / (2.0 - y); else tmp = x / (2.0 - (x + y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -9.3e+17], N[(N[(x - y), $MachinePrecision] / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.85e+20], N[(N[(x - y), $MachinePrecision] / N[(2.0 - y), $MachinePrecision]), $MachinePrecision], N[(x / N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.3 \cdot 10^{+17}:\\
\;\;\;\;\frac{x - y}{2 - x}\\
\mathbf{elif}\;x \leq 1.85 \cdot 10^{+20}:\\
\;\;\;\;\frac{x - y}{2 - y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 - \left(x + y\right)}\\
\end{array}
\end{array}
if x < -9.3e17Initial program 99.9%
Taylor expanded in y around 0
--lowering--.f6477.3%
Simplified77.3%
if -9.3e17 < x < 1.85e20Initial program 100.0%
Taylor expanded in x around 0
--lowering--.f6498.6%
Simplified98.6%
if 1.85e20 < x Initial program 99.9%
Taylor expanded in x around inf
Simplified78.8%
(FPCore (x y) :precision binary64 (if (<= y -1.32e+23) (+ 1.0 (/ (* x -2.0) y)) (if (<= y 0.38) (/ (- x y) (- 2.0 x)) (/ y (+ y -2.0)))))
double code(double x, double y) {
double tmp;
if (y <= -1.32e+23) {
tmp = 1.0 + ((x * -2.0) / y);
} else if (y <= 0.38) {
tmp = (x - y) / (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 <= (-1.32d+23)) then
tmp = 1.0d0 + ((x * (-2.0d0)) / y)
else if (y <= 0.38d0) then
tmp = (x - y) / (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 <= -1.32e+23) {
tmp = 1.0 + ((x * -2.0) / y);
} else if (y <= 0.38) {
tmp = (x - y) / (2.0 - x);
} else {
tmp = y / (y + -2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.32e+23: tmp = 1.0 + ((x * -2.0) / y) elif y <= 0.38: tmp = (x - y) / (2.0 - x) else: tmp = y / (y + -2.0) return tmp
function code(x, y) tmp = 0.0 if (y <= -1.32e+23) tmp = Float64(1.0 + Float64(Float64(x * -2.0) / y)); elseif (y <= 0.38) tmp = Float64(Float64(x - y) / 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 <= -1.32e+23) tmp = 1.0 + ((x * -2.0) / y); elseif (y <= 0.38) tmp = (x - y) / (2.0 - x); else tmp = y / (y + -2.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.32e+23], N[(1.0 + N[(N[(x * -2.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 0.38], N[(N[(x - y), $MachinePrecision] / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.32 \cdot 10^{+23}:\\
\;\;\;\;1 + \frac{x \cdot -2}{y}\\
\mathbf{elif}\;y \leq 0.38:\\
\;\;\;\;\frac{x - y}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y + -2}\\
\end{array}
\end{array}
if y < -1.3199999999999999e23Initial program 99.9%
clear-numN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
+-lowering-+.f64N/A
--lowering--.f6499.9%
Applied egg-rr99.9%
Taylor expanded in y around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
div-subN/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
+-commutativeN/A
mul-1-negN/A
sub-negN/A
associate--l-N/A
--lowering--.f64N/A
+-lowering-+.f6471.5%
Simplified71.5%
Taylor expanded in x around inf
associate-*r/N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6471.5%
Simplified71.5%
if -1.3199999999999999e23 < y < 0.38Initial program 100.0%
Taylor expanded in y around 0
--lowering--.f6497.1%
Simplified97.1%
if 0.38 < y Initial program 100.0%
Taylor expanded in x around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
/-lowering-/.f64N/A
mul-1-negN/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
mul-1-negN/A
mul-1-negN/A
associate-*r*N/A
metadata-evalN/A
*-lft-identityN/A
+-lowering-+.f64N/A
metadata-eval79.1%
Simplified79.1%
(FPCore (x y) :precision binary64 (let* ((t_0 (/ x (- 2.0 (+ x y))))) (if (<= x -4.5e+19) t_0 (if (<= x 1e-22) (/ y (+ y -2.0)) t_0))))
double code(double x, double y) {
double t_0 = x / (2.0 - (x + y));
double tmp;
if (x <= -4.5e+19) {
tmp = t_0;
} else if (x <= 1e-22) {
tmp = y / (y + -2.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 = x / (2.0d0 - (x + y))
if (x <= (-4.5d+19)) then
tmp = t_0
else if (x <= 1d-22) then
tmp = y / (y + (-2.0d0))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x / (2.0 - (x + y));
double tmp;
if (x <= -4.5e+19) {
tmp = t_0;
} else if (x <= 1e-22) {
tmp = y / (y + -2.0);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = x / (2.0 - (x + y)) tmp = 0 if x <= -4.5e+19: tmp = t_0 elif x <= 1e-22: tmp = y / (y + -2.0) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(x / Float64(2.0 - Float64(x + y))) tmp = 0.0 if (x <= -4.5e+19) tmp = t_0; elseif (x <= 1e-22) tmp = Float64(y / Float64(y + -2.0)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = x / (2.0 - (x + y)); tmp = 0.0; if (x <= -4.5e+19) tmp = t_0; elseif (x <= 1e-22) tmp = y / (y + -2.0); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -4.5e+19], t$95$0, If[LessEqual[x, 1e-22], N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{2 - \left(x + y\right)}\\
\mathbf{if}\;x \leq -4.5 \cdot 10^{+19}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 10^{-22}:\\
\;\;\;\;\frac{y}{y + -2}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -4.5e19 or 1e-22 < x Initial program 99.9%
Taylor expanded in x around inf
Simplified77.2%
if -4.5e19 < x < 1e-22Initial program 100.0%
Taylor expanded in x around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
/-lowering-/.f64N/A
mul-1-negN/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
mul-1-negN/A
mul-1-negN/A
associate-*r*N/A
metadata-evalN/A
*-lft-identityN/A
+-lowering-+.f64N/A
metadata-eval80.6%
Simplified80.6%
(FPCore (x y) :precision binary64 (if (<= x -4.6e+27) -1.0 (if (<= x 1.65e-22) (/ y (+ y -2.0)) (/ x (- 2.0 x)))))
double code(double x, double y) {
double tmp;
if (x <= -4.6e+27) {
tmp = -1.0;
} else if (x <= 1.65e-22) {
tmp = y / (y + -2.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) :: tmp
if (x <= (-4.6d+27)) then
tmp = -1.0d0
else if (x <= 1.65d-22) then
tmp = y / (y + (-2.0d0))
else
tmp = x / (2.0d0 - x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -4.6e+27) {
tmp = -1.0;
} else if (x <= 1.65e-22) {
tmp = y / (y + -2.0);
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -4.6e+27: tmp = -1.0 elif x <= 1.65e-22: tmp = y / (y + -2.0) else: tmp = x / (2.0 - x) return tmp
function code(x, y) tmp = 0.0 if (x <= -4.6e+27) tmp = -1.0; elseif (x <= 1.65e-22) tmp = Float64(y / Float64(y + -2.0)); else tmp = Float64(x / Float64(2.0 - x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -4.6e+27) tmp = -1.0; elseif (x <= 1.65e-22) tmp = y / (y + -2.0); else tmp = x / (2.0 - x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -4.6e+27], -1.0, If[LessEqual[x, 1.65e-22], N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.6 \cdot 10^{+27}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 1.65 \cdot 10^{-22}:\\
\;\;\;\;\frac{y}{y + -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 - x}\\
\end{array}
\end{array}
if x < -4.6000000000000001e27Initial program 99.9%
Taylor expanded in x around inf
Simplified77.3%
if -4.6000000000000001e27 < x < 1.65e-22Initial program 100.0%
Taylor expanded in x around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
/-lowering-/.f64N/A
mul-1-negN/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
mul-1-negN/A
mul-1-negN/A
associate-*r*N/A
metadata-evalN/A
*-lft-identityN/A
+-lowering-+.f64N/A
metadata-eval80.6%
Simplified80.6%
if 1.65e-22 < x Initial program 99.9%
Taylor expanded in y around 0
/-lowering-/.f64N/A
--lowering--.f6476.0%
Simplified76.0%
(FPCore (x y) :precision binary64 (if (<= y -2.1e+22) 1.0 (if (<= y 2.5e+63) (/ x (- 2.0 x)) 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -2.1e+22) {
tmp = 1.0;
} else if (y <= 2.5e+63) {
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 <= (-2.1d+22)) then
tmp = 1.0d0
else if (y <= 2.5d+63) 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 <= -2.1e+22) {
tmp = 1.0;
} else if (y <= 2.5e+63) {
tmp = x / (2.0 - x);
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -2.1e+22: tmp = 1.0 elif y <= 2.5e+63: tmp = x / (2.0 - x) else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -2.1e+22) tmp = 1.0; elseif (y <= 2.5e+63) 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 <= -2.1e+22) tmp = 1.0; elseif (y <= 2.5e+63) tmp = x / (2.0 - x); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -2.1e+22], 1.0, If[LessEqual[y, 2.5e+63], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.1 \cdot 10^{+22}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{+63}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -2.0999999999999998e22 or 2.50000000000000005e63 < y Initial program 99.9%
Taylor expanded in y around inf
Simplified77.9%
if -2.0999999999999998e22 < y < 2.50000000000000005e63Initial program 100.0%
Taylor expanded in y around 0
/-lowering-/.f64N/A
--lowering--.f6469.1%
Simplified69.1%
(FPCore (x y) :precision binary64 (if (<= x -2.5e+22) -1.0 (if (<= x 3.25e+16) 1.0 -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -2.5e+22) {
tmp = -1.0;
} else if (x <= 3.25e+16) {
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.5d+22)) then
tmp = -1.0d0
else if (x <= 3.25d+16) 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.5e+22) {
tmp = -1.0;
} else if (x <= 3.25e+16) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2.5e+22: tmp = -1.0 elif x <= 3.25e+16: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -2.5e+22) tmp = -1.0; elseif (x <= 3.25e+16) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2.5e+22) tmp = -1.0; elseif (x <= 3.25e+16) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2.5e+22], -1.0, If[LessEqual[x, 3.25e+16], 1.0, -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.5 \cdot 10^{+22}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 3.25 \cdot 10^{+16}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -2.4999999999999998e22 or 3.25e16 < x Initial program 99.9%
Taylor expanded in x around inf
Simplified77.7%
if -2.4999999999999998e22 < x < 3.25e16Initial program 100.0%
Taylor expanded in y around inf
Simplified53.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 99.9%
Taylor expanded in x around inf
Simplified36.5%
(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 2024158
(FPCore (x y)
:name "Data.Colour.RGB:hslsv from colour-2.3.3, C"
:precision binary64
:alt
(! :herbie-platform default (- (/ x (- 2 (+ x y))) (/ y (- 2 (+ x y)))))
(/ (- x y) (- 2.0 (+ x y))))