
(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 (<= y -1.95e+30)
(- 1.0 (/ x y))
(if (or (<= y -2.55e-55) (and (not (<= y -7.2e-89)) (<= y 8.2e-45)))
(/ x (- 2.0 x))
(/ y (+ y -2.0)))))
double code(double x, double y) {
double tmp;
if (y <= -1.95e+30) {
tmp = 1.0 - (x / y);
} else if ((y <= -2.55e-55) || (!(y <= -7.2e-89) && (y <= 8.2e-45))) {
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 <= (-1.95d+30)) then
tmp = 1.0d0 - (x / y)
else if ((y <= (-2.55d-55)) .or. (.not. (y <= (-7.2d-89))) .and. (y <= 8.2d-45)) 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 <= -1.95e+30) {
tmp = 1.0 - (x / y);
} else if ((y <= -2.55e-55) || (!(y <= -7.2e-89) && (y <= 8.2e-45))) {
tmp = x / (2.0 - x);
} else {
tmp = y / (y + -2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.95e+30: tmp = 1.0 - (x / y) elif (y <= -2.55e-55) or (not (y <= -7.2e-89) and (y <= 8.2e-45)): tmp = x / (2.0 - x) else: tmp = y / (y + -2.0) return tmp
function code(x, y) tmp = 0.0 if (y <= -1.95e+30) tmp = Float64(1.0 - Float64(x / y)); elseif ((y <= -2.55e-55) || (!(y <= -7.2e-89) && (y <= 8.2e-45))) 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 <= -1.95e+30) tmp = 1.0 - (x / y); elseif ((y <= -2.55e-55) || (~((y <= -7.2e-89)) && (y <= 8.2e-45))) tmp = x / (2.0 - x); else tmp = y / (y + -2.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.95e+30], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, -2.55e-55], And[N[Not[LessEqual[y, -7.2e-89]], $MachinePrecision], LessEqual[y, 8.2e-45]]], 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 -1.95 \cdot 10^{+30}:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{elif}\;y \leq -2.55 \cdot 10^{-55} \lor \neg \left(y \leq -7.2 \cdot 10^{-89}\right) \land y \leq 8.2 \cdot 10^{-45}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y + -2}\\
\end{array}
\end{array}
if y < -1.95000000000000005e30Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around inf 75.5%
neg-mul-175.5%
Simplified75.5%
Taylor expanded in x around 0 75.5%
mul-1-neg75.5%
unsub-neg75.5%
Simplified75.5%
if -1.95000000000000005e30 < y < -2.54999999999999998e-55 or -7.20000000000000014e-89 < y < 8.1999999999999998e-45Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 87.6%
if -2.54999999999999998e-55 < y < -7.20000000000000014e-89 or 8.1999999999999998e-45 < y Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 81.9%
Taylor expanded in x around 0 81.3%
metadata-eval81.3%
times-frac81.3%
*-lft-identity81.3%
neg-mul-181.3%
neg-sub081.3%
associate--r-81.3%
metadata-eval81.3%
Simplified81.3%
Final simplification83.2%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ (/ y x) -1.0)))
(if (<= x -245000.0)
t_0
(if (<= x 3.1e-162)
(- 1.0 (/ x y))
(if (<= x 5e-73) (* x 0.5) (if (<= x 18500.0) 1.0 t_0))))))
double code(double x, double y) {
double t_0 = (y / x) + -1.0;
double tmp;
if (x <= -245000.0) {
tmp = t_0;
} else if (x <= 3.1e-162) {
tmp = 1.0 - (x / y);
} else if (x <= 5e-73) {
tmp = x * 0.5;
} else if (x <= 18500.0) {
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 <= (-245000.0d0)) then
tmp = t_0
else if (x <= 3.1d-162) then
tmp = 1.0d0 - (x / y)
else if (x <= 5d-73) then
tmp = x * 0.5d0
else if (x <= 18500.0d0) 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 <= -245000.0) {
tmp = t_0;
} else if (x <= 3.1e-162) {
tmp = 1.0 - (x / y);
} else if (x <= 5e-73) {
tmp = x * 0.5;
} else if (x <= 18500.0) {
tmp = 1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (y / x) + -1.0 tmp = 0 if x <= -245000.0: tmp = t_0 elif x <= 3.1e-162: tmp = 1.0 - (x / y) elif x <= 5e-73: tmp = x * 0.5 elif x <= 18500.0: 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 <= -245000.0) tmp = t_0; elseif (x <= 3.1e-162) tmp = Float64(1.0 - Float64(x / y)); elseif (x <= 5e-73) tmp = Float64(x * 0.5); elseif (x <= 18500.0) 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 <= -245000.0) tmp = t_0; elseif (x <= 3.1e-162) tmp = 1.0 - (x / y); elseif (x <= 5e-73) tmp = x * 0.5; elseif (x <= 18500.0) 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, -245000.0], t$95$0, If[LessEqual[x, 3.1e-162], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5e-73], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 18500.0], 1.0, t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{x} + -1\\
\mathbf{if}\;x \leq -245000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 3.1 \cdot 10^{-162}:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{elif}\;x \leq 5 \cdot 10^{-73}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 18500:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -245000 or 18500 < x Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 85.4%
neg-mul-185.4%
Simplified85.4%
Taylor expanded in x around 0 85.4%
if -245000 < x < 3.0999999999999999e-162Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 56.6%
neg-mul-156.6%
Simplified56.6%
Taylor expanded in x around 0 56.6%
mul-1-neg56.6%
unsub-neg56.6%
Simplified56.6%
if 3.0999999999999999e-162 < x < 4.9999999999999998e-73Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Taylor expanded in y around 0 73.0%
*-commutative73.0%
Simplified73.0%
if 4.9999999999999998e-73 < x < 18500Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 62.2%
Final simplification71.3%
(FPCore (x y) :precision binary64 (if (or (<= x -1200000.0) (not (<= x 1.35e-10))) (/ x (- 2.0 x)) (/ (- x y) (- 2.0 y))))
double code(double x, double y) {
double tmp;
if ((x <= -1200000.0) || !(x <= 1.35e-10)) {
tmp = x / (2.0 - 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 <= (-1200000.0d0)) .or. (.not. (x <= 1.35d-10))) then
tmp = x / (2.0d0 - 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 <= -1200000.0) || !(x <= 1.35e-10)) {
tmp = x / (2.0 - x);
} else {
tmp = (x - y) / (2.0 - y);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1200000.0) or not (x <= 1.35e-10): tmp = x / (2.0 - x) else: tmp = (x - y) / (2.0 - y) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1200000.0) || !(x <= 1.35e-10)) tmp = Float64(x / Float64(2.0 - 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 <= -1200000.0) || ~((x <= 1.35e-10))) tmp = x / (2.0 - x); else tmp = (x - y) / (2.0 - y); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1200000.0], N[Not[LessEqual[x, 1.35e-10]], $MachinePrecision]], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], N[(N[(x - y), $MachinePrecision] / N[(2.0 - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1200000 \lor \neg \left(x \leq 1.35 \cdot 10^{-10}\right):\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x - y}{2 - y}\\
\end{array}
\end{array}
if x < -1.2e6 or 1.35e-10 < x Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 86.2%
if -1.2e6 < x < 1.35e-10Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 99.0%
Final simplification93.0%
(FPCore (x y)
:precision binary64
(if (<= x -2600000.0)
-1.0
(if (<= x 4.8e-141)
1.0
(if (<= x 1e-71) (* x 0.5) (if (<= x 10000.0) 1.0 -1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -2600000.0) {
tmp = -1.0;
} else if (x <= 4.8e-141) {
tmp = 1.0;
} else if (x <= 1e-71) {
tmp = x * 0.5;
} else if (x <= 10000.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 <= (-2600000.0d0)) then
tmp = -1.0d0
else if (x <= 4.8d-141) then
tmp = 1.0d0
else if (x <= 1d-71) then
tmp = x * 0.5d0
else if (x <= 10000.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 <= -2600000.0) {
tmp = -1.0;
} else if (x <= 4.8e-141) {
tmp = 1.0;
} else if (x <= 1e-71) {
tmp = x * 0.5;
} else if (x <= 10000.0) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2600000.0: tmp = -1.0 elif x <= 4.8e-141: tmp = 1.0 elif x <= 1e-71: tmp = x * 0.5 elif x <= 10000.0: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -2600000.0) tmp = -1.0; elseif (x <= 4.8e-141) tmp = 1.0; elseif (x <= 1e-71) tmp = Float64(x * 0.5); elseif (x <= 10000.0) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2600000.0) tmp = -1.0; elseif (x <= 4.8e-141) tmp = 1.0; elseif (x <= 1e-71) tmp = x * 0.5; elseif (x <= 10000.0) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2600000.0], -1.0, If[LessEqual[x, 4.8e-141], 1.0, If[LessEqual[x, 1e-71], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 10000.0], 1.0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2600000:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 4.8 \cdot 10^{-141}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 10^{-71}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 10000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -2.6e6 or 1e4 < x Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 85.0%
if -2.6e6 < x < 4.8000000000000002e-141 or 9.9999999999999992e-72 < x < 1e4Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 57.5%
if 4.8000000000000002e-141 < x < 9.9999999999999992e-72Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Taylor expanded in y around 0 81.4%
*-commutative81.4%
Simplified81.4%
Final simplification71.1%
(FPCore (x y)
:precision binary64
(if (<= x -27000.0)
-1.0
(if (<= x 5.3e-161)
(- 1.0 (/ x y))
(if (<= x 2e-71) (* x 0.5) (if (<= x 13600.0) 1.0 -1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -27000.0) {
tmp = -1.0;
} else if (x <= 5.3e-161) {
tmp = 1.0 - (x / y);
} else if (x <= 2e-71) {
tmp = x * 0.5;
} else if (x <= 13600.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 <= (-27000.0d0)) then
tmp = -1.0d0
else if (x <= 5.3d-161) then
tmp = 1.0d0 - (x / y)
else if (x <= 2d-71) then
tmp = x * 0.5d0
else if (x <= 13600.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 <= -27000.0) {
tmp = -1.0;
} else if (x <= 5.3e-161) {
tmp = 1.0 - (x / y);
} else if (x <= 2e-71) {
tmp = x * 0.5;
} else if (x <= 13600.0) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -27000.0: tmp = -1.0 elif x <= 5.3e-161: tmp = 1.0 - (x / y) elif x <= 2e-71: tmp = x * 0.5 elif x <= 13600.0: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -27000.0) tmp = -1.0; elseif (x <= 5.3e-161) tmp = Float64(1.0 - Float64(x / y)); elseif (x <= 2e-71) tmp = Float64(x * 0.5); elseif (x <= 13600.0) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -27000.0) tmp = -1.0; elseif (x <= 5.3e-161) tmp = 1.0 - (x / y); elseif (x <= 2e-71) tmp = x * 0.5; elseif (x <= 13600.0) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -27000.0], -1.0, If[LessEqual[x, 5.3e-161], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2e-71], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 13600.0], 1.0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -27000:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 5.3 \cdot 10^{-161}:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{elif}\;x \leq 2 \cdot 10^{-71}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 13600:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -27000 or 13600 < x Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 85.0%
if -27000 < x < 5.30000000000000029e-161Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 56.6%
neg-mul-156.6%
Simplified56.6%
Taylor expanded in x around 0 56.6%
mul-1-neg56.6%
unsub-neg56.6%
Simplified56.6%
if 5.30000000000000029e-161 < x < 1.9999999999999998e-71Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Taylor expanded in y around 0 73.0%
*-commutative73.0%
Simplified73.0%
if 1.9999999999999998e-71 < x < 13600Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 62.2%
Final simplification71.1%
(FPCore (x y) :precision binary64 (if (or (<= y -1.7e+32) (not (<= y 1.65e+18))) (- 1.0 (/ x y)) (/ x (- 2.0 x))))
double code(double x, double y) {
double tmp;
if ((y <= -1.7e+32) || !(y <= 1.65e+18)) {
tmp = 1.0 - (x / y);
} 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 ((y <= (-1.7d+32)) .or. (.not. (y <= 1.65d+18))) then
tmp = 1.0d0 - (x / y)
else
tmp = x / (2.0d0 - x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -1.7e+32) || !(y <= 1.65e+18)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.7e+32) or not (y <= 1.65e+18): tmp = 1.0 - (x / y) else: tmp = x / (2.0 - x) return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.7e+32) || !(y <= 1.65e+18)) tmp = Float64(1.0 - Float64(x / y)); else tmp = Float64(x / Float64(2.0 - x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -1.7e+32) || ~((y <= 1.65e+18))) tmp = 1.0 - (x / y); else tmp = x / (2.0 - x); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1.7e+32], N[Not[LessEqual[y, 1.65e+18]], $MachinePrecision]], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.7 \cdot 10^{+32} \lor \neg \left(y \leq 1.65 \cdot 10^{+18}\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 - x}\\
\end{array}
\end{array}
if y < -1.69999999999999989e32 or 1.65e18 < y Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 78.3%
neg-mul-178.3%
Simplified78.3%
Taylor expanded in x around 0 78.3%
mul-1-neg78.3%
unsub-neg78.3%
Simplified78.3%
if -1.69999999999999989e32 < y < 1.65e18Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 79.9%
Final simplification79.2%
(FPCore (x y) :precision binary64 (if (<= x -2600000.0) -1.0 (if (<= x 18500.0) 1.0 -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -2600000.0) {
tmp = -1.0;
} else if (x <= 18500.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 <= (-2600000.0d0)) then
tmp = -1.0d0
else if (x <= 18500.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 <= -2600000.0) {
tmp = -1.0;
} else if (x <= 18500.0) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2600000.0: tmp = -1.0 elif x <= 18500.0: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -2600000.0) tmp = -1.0; elseif (x <= 18500.0) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2600000.0) tmp = -1.0; elseif (x <= 18500.0) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2600000.0], -1.0, If[LessEqual[x, 18500.0], 1.0, -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2600000:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 18500:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -2.6e6 or 18500 < x Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 85.0%
if -2.6e6 < x < 18500Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 54.4%
Final simplification68.5%
(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 40.8%
Final simplification40.8%
(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 2023193
(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))))