
(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%
(FPCore (x y) :precision binary64 (let* ((t_0 (+ (/ (+ (* y 2.0) -2.0) x) -1.0))) (if (<= x -1.35e+18) t_0 (if (<= x 1.55e+47) (/ (- 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 <= -1.35e+18) {
tmp = t_0;
} else if (x <= 1.55e+47) {
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 <= (-1.35d+18)) then
tmp = t_0
else if (x <= 1.55d+47) 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 <= -1.35e+18) {
tmp = t_0;
} else if (x <= 1.55e+47) {
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 <= -1.35e+18: tmp = t_0 elif x <= 1.55e+47: 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 <= -1.35e+18) tmp = t_0; elseif (x <= 1.55e+47) 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 <= -1.35e+18) tmp = t_0; elseif (x <= 1.55e+47) 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, -1.35e+18], t$95$0, If[LessEqual[x, 1.55e+47], 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 -1.35 \cdot 10^{+18}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.55 \cdot 10^{+47}:\\
\;\;\;\;\frac{x - y}{2 - y}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.35e18 or 1.55e47 < x Initial program 100.0%
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-eval85.9%
Simplified85.9%
if -1.35e18 < x < 1.55e47Initial program 100.0%
Taylor expanded in x around 0
--lowering--.f6496.3%
Simplified96.3%
(FPCore (x y) :precision binary64 (if (<= x -2.5e+17) (/ (- x y) (- 2.0 x)) (if (<= x 1e+44) (/ (- x y) (- 2.0 y)) (/ x (- 2.0 (+ x y))))))
double code(double x, double y) {
double tmp;
if (x <= -2.5e+17) {
tmp = (x - y) / (2.0 - x);
} else if (x <= 1e+44) {
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 <= (-2.5d+17)) then
tmp = (x - y) / (2.0d0 - x)
else if (x <= 1d+44) 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 <= -2.5e+17) {
tmp = (x - y) / (2.0 - x);
} else if (x <= 1e+44) {
tmp = (x - y) / (2.0 - y);
} else {
tmp = x / (2.0 - (x + y));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2.5e+17: tmp = (x - y) / (2.0 - x) elif x <= 1e+44: tmp = (x - y) / (2.0 - y) else: tmp = x / (2.0 - (x + y)) return tmp
function code(x, y) tmp = 0.0 if (x <= -2.5e+17) tmp = Float64(Float64(x - y) / Float64(2.0 - x)); elseif (x <= 1e+44) 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 <= -2.5e+17) tmp = (x - y) / (2.0 - x); elseif (x <= 1e+44) tmp = (x - y) / (2.0 - y); else tmp = x / (2.0 - (x + y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2.5e+17], N[(N[(x - y), $MachinePrecision] / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1e+44], 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 -2.5 \cdot 10^{+17}:\\
\;\;\;\;\frac{x - y}{2 - x}\\
\mathbf{elif}\;x \leq 10^{+44}:\\
\;\;\;\;\frac{x - y}{2 - y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 - \left(x + y\right)}\\
\end{array}
\end{array}
if x < -2.5e17Initial program 99.9%
Taylor expanded in y around 0
--lowering--.f6481.9%
Simplified81.9%
if -2.5e17 < x < 1.0000000000000001e44Initial program 100.0%
Taylor expanded in x around 0
--lowering--.f6496.3%
Simplified96.3%
if 1.0000000000000001e44 < x Initial program 100.0%
Taylor expanded in x around inf
Simplified88.5%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- 1.0 (/ (* x 2.0) y))))
(if (<= y -16000000000000.0)
t_0
(if (<= y 10500000000.0) (/ (- x y) (- 2.0 x)) t_0))))
double code(double x, double y) {
double t_0 = 1.0 - ((x * 2.0) / y);
double tmp;
if (y <= -16000000000000.0) {
tmp = t_0;
} else if (y <= 10500000000.0) {
tmp = (x - y) / (2.0 - x);
} 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 = 1.0d0 - ((x * 2.0d0) / y)
if (y <= (-16000000000000.0d0)) then
tmp = t_0
else if (y <= 10500000000.0d0) then
tmp = (x - y) / (2.0d0 - x)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 - ((x * 2.0) / y);
double tmp;
if (y <= -16000000000000.0) {
tmp = t_0;
} else if (y <= 10500000000.0) {
tmp = (x - y) / (2.0 - x);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 - ((x * 2.0) / y) tmp = 0 if y <= -16000000000000.0: tmp = t_0 elif y <= 10500000000.0: tmp = (x - y) / (2.0 - x) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 - Float64(Float64(x * 2.0) / y)) tmp = 0.0 if (y <= -16000000000000.0) tmp = t_0; elseif (y <= 10500000000.0) tmp = Float64(Float64(x - y) / Float64(2.0 - x)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 - ((x * 2.0) / y); tmp = 0.0; if (y <= -16000000000000.0) tmp = t_0; elseif (y <= 10500000000.0) tmp = (x - y) / (2.0 - x); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 - N[(N[(x * 2.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -16000000000000.0], t$95$0, If[LessEqual[y, 10500000000.0], N[(N[(x - y), $MachinePrecision] / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x \cdot 2}{y}\\
\mathbf{if}\;y \leq -16000000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 10500000000:\\
\;\;\;\;\frac{x - y}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1.6e13 or 1.05e10 < y Initial program 99.9%
clear-numN/A
associate-/r/N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
+-lowering-+.f64N/A
--lowering--.f6499.8%
Applied egg-rr99.8%
Taylor expanded in y around -inf
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
/-lowering-/.f64N/A
sub-negN/A
metadata-evalN/A
+-lowering-+.f64N/A
*-lowering-*.f6477.1%
Simplified77.1%
Taylor expanded in x around inf
associate-*r/N/A
/-lowering-/.f64N/A
*-lowering-*.f6477.1%
Simplified77.1%
if -1.6e13 < y < 1.05e10Initial program 100.0%
Taylor expanded in y around 0
--lowering--.f6499.9%
Simplified99.9%
Final simplification89.6%
(FPCore (x y) :precision binary64 (let* ((t_0 (/ x (- 2.0 (+ x y))))) (if (<= x -1.15e+16) t_0 (if (<= x 3.2e+44) (/ y (+ y -2.0)) t_0))))
double code(double x, double y) {
double t_0 = x / (2.0 - (x + y));
double tmp;
if (x <= -1.15e+16) {
tmp = t_0;
} else if (x <= 3.2e+44) {
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 <= (-1.15d+16)) then
tmp = t_0
else if (x <= 3.2d+44) 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 <= -1.15e+16) {
tmp = t_0;
} else if (x <= 3.2e+44) {
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 <= -1.15e+16: tmp = t_0 elif x <= 3.2e+44: 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 <= -1.15e+16) tmp = t_0; elseif (x <= 3.2e+44) 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 <= -1.15e+16) tmp = t_0; elseif (x <= 3.2e+44) 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, -1.15e+16], t$95$0, If[LessEqual[x, 3.2e+44], 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 -1.15 \cdot 10^{+16}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 3.2 \cdot 10^{+44}:\\
\;\;\;\;\frac{y}{y + -2}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.15e16 or 3.20000000000000004e44 < x Initial program 100.0%
Taylor expanded in x around inf
Simplified85.1%
if -1.15e16 < x < 3.20000000000000004e44Initial 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-eval75.9%
Simplified75.9%
(FPCore (x y) :precision binary64 (if (<= x -2.9e+17) -1.0 (if (<= x 1.15e+45) (/ y (+ y -2.0)) -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -2.9e+17) {
tmp = -1.0;
} else if (x <= 1.15e+45) {
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 <= (-2.9d+17)) then
tmp = -1.0d0
else if (x <= 1.15d+45) 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 <= -2.9e+17) {
tmp = -1.0;
} else if (x <= 1.15e+45) {
tmp = y / (y + -2.0);
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2.9e+17: tmp = -1.0 elif x <= 1.15e+45: tmp = y / (y + -2.0) else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -2.9e+17) tmp = -1.0; elseif (x <= 1.15e+45) 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 <= -2.9e+17) tmp = -1.0; elseif (x <= 1.15e+45) tmp = y / (y + -2.0); else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2.9e+17], -1.0, If[LessEqual[x, 1.15e+45], N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision], -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.9 \cdot 10^{+17}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 1.15 \cdot 10^{+45}:\\
\;\;\;\;\frac{y}{y + -2}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -2.9e17 or 1.15000000000000006e45 < x Initial program 100.0%
Taylor expanded in x around inf
Simplified84.7%
if -2.9e17 < x < 1.15000000000000006e45Initial 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-eval75.9%
Simplified75.9%
(FPCore (x y) :precision binary64 (if (<= y -1.9e+15) 1.0 (if (<= y 3.2e+20) (/ x (- 2.0 x)) 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -1.9e+15) {
tmp = 1.0;
} else if (y <= 3.2e+20) {
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.9d+15)) then
tmp = 1.0d0
else if (y <= 3.2d+20) 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.9e+15) {
tmp = 1.0;
} else if (y <= 3.2e+20) {
tmp = x / (2.0 - x);
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.9e+15: tmp = 1.0 elif y <= 3.2e+20: tmp = x / (2.0 - x) else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -1.9e+15) tmp = 1.0; elseif (y <= 3.2e+20) 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.9e+15) tmp = 1.0; elseif (y <= 3.2e+20) tmp = x / (2.0 - x); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.9e+15], 1.0, If[LessEqual[y, 3.2e+20], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.9 \cdot 10^{+15}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 3.2 \cdot 10^{+20}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.9e15 or 3.2e20 < y Initial program 99.9%
Taylor expanded in y around inf
Simplified76.1%
if -1.9e15 < y < 3.2e20Initial program 100.0%
Taylor expanded in y around 0
/-lowering-/.f64N/A
--lowering--.f6477.7%
Simplified77.7%
(FPCore (x y) :precision binary64 (if (<= x -7.5e+17) -1.0 (if (<= x 2.5e+45) 1.0 -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -7.5e+17) {
tmp = -1.0;
} else if (x <= 2.5e+45) {
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 <= (-7.5d+17)) then
tmp = -1.0d0
else if (x <= 2.5d+45) 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 <= -7.5e+17) {
tmp = -1.0;
} else if (x <= 2.5e+45) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -7.5e+17: tmp = -1.0 elif x <= 2.5e+45: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -7.5e+17) tmp = -1.0; elseif (x <= 2.5e+45) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -7.5e+17) tmp = -1.0; elseif (x <= 2.5e+45) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -7.5e+17], -1.0, If[LessEqual[x, 2.5e+45], 1.0, -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.5 \cdot 10^{+17}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{+45}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -7.5e17 or 2.5e45 < x Initial program 100.0%
Taylor expanded in x around inf
Simplified84.7%
if -7.5e17 < x < 2.5e45Initial 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 100.0%
Taylor expanded in x around inf
Simplified41.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 2024150
(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))))