
(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 11 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)) (t_1 (* (- x y) 0.5)))
(if (<= x -2.0)
t_0
(if (<= x -9.5e-82)
t_1
(if (<= x 1.6e-99)
1.0
(if (<= x 4.8e-66) t_1 (if (<= x 7.5e+42) 1.0 t_0)))))))
double code(double x, double y) {
double t_0 = (y / x) + -1.0;
double t_1 = (x - y) * 0.5;
double tmp;
if (x <= -2.0) {
tmp = t_0;
} else if (x <= -9.5e-82) {
tmp = t_1;
} else if (x <= 1.6e-99) {
tmp = 1.0;
} else if (x <= 4.8e-66) {
tmp = t_1;
} else if (x <= 7.5e+42) {
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) :: t_1
real(8) :: tmp
t_0 = (y / x) + (-1.0d0)
t_1 = (x - y) * 0.5d0
if (x <= (-2.0d0)) then
tmp = t_0
else if (x <= (-9.5d-82)) then
tmp = t_1
else if (x <= 1.6d-99) then
tmp = 1.0d0
else if (x <= 4.8d-66) then
tmp = t_1
else if (x <= 7.5d+42) 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 t_1 = (x - y) * 0.5;
double tmp;
if (x <= -2.0) {
tmp = t_0;
} else if (x <= -9.5e-82) {
tmp = t_1;
} else if (x <= 1.6e-99) {
tmp = 1.0;
} else if (x <= 4.8e-66) {
tmp = t_1;
} else if (x <= 7.5e+42) {
tmp = 1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (y / x) + -1.0 t_1 = (x - y) * 0.5 tmp = 0 if x <= -2.0: tmp = t_0 elif x <= -9.5e-82: tmp = t_1 elif x <= 1.6e-99: tmp = 1.0 elif x <= 4.8e-66: tmp = t_1 elif x <= 7.5e+42: tmp = 1.0 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(y / x) + -1.0) t_1 = Float64(Float64(x - y) * 0.5) tmp = 0.0 if (x <= -2.0) tmp = t_0; elseif (x <= -9.5e-82) tmp = t_1; elseif (x <= 1.6e-99) tmp = 1.0; elseif (x <= 4.8e-66) tmp = t_1; elseif (x <= 7.5e+42) tmp = 1.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (y / x) + -1.0; t_1 = (x - y) * 0.5; tmp = 0.0; if (x <= -2.0) tmp = t_0; elseif (x <= -9.5e-82) tmp = t_1; elseif (x <= 1.6e-99) tmp = 1.0; elseif (x <= 4.8e-66) tmp = t_1; elseif (x <= 7.5e+42) 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]}, Block[{t$95$1 = N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[x, -2.0], t$95$0, If[LessEqual[x, -9.5e-82], t$95$1, If[LessEqual[x, 1.6e-99], 1.0, If[LessEqual[x, 4.8e-66], t$95$1, If[LessEqual[x, 7.5e+42], 1.0, t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{x} + -1\\
t_1 := \left(x - y\right) \cdot 0.5\\
\mathbf{if}\;x \leq -2:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -9.5 \cdot 10^{-82}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{-99}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 4.8 \cdot 10^{-66}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{+42}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -2 or 7.50000000000000041e42 < x Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 75.9%
neg-mul-175.9%
Simplified75.9%
Taylor expanded in x around 0 75.9%
if -2 < x < -9.4999999999999996e-82 or 1.6e-99 < x < 4.80000000000000052e-66Initial program 100.0%
associate--r+100.0%
Simplified100.0%
clear-num99.6%
associate-/r/99.9%
associate--l-99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 97.7%
Taylor expanded in y around 0 77.3%
if -9.4999999999999996e-82 < x < 1.6e-99 or 4.80000000000000052e-66 < x < 7.50000000000000041e42Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 58.4%
Final simplification69.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* (- x y) 0.5)))
(if (<= x -2.5)
-1.0
(if (<= x -1.45e-83)
t_0
(if (<= x 7.2e-100)
1.0
(if (<= x 4.5e-66) t_0 (if (<= x 1e+43) 1.0 -1.0)))))))
double code(double x, double y) {
double t_0 = (x - y) * 0.5;
double tmp;
if (x <= -2.5) {
tmp = -1.0;
} else if (x <= -1.45e-83) {
tmp = t_0;
} else if (x <= 7.2e-100) {
tmp = 1.0;
} else if (x <= 4.5e-66) {
tmp = t_0;
} else if (x <= 1e+43) {
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) :: t_0
real(8) :: tmp
t_0 = (x - y) * 0.5d0
if (x <= (-2.5d0)) then
tmp = -1.0d0
else if (x <= (-1.45d-83)) then
tmp = t_0
else if (x <= 7.2d-100) then
tmp = 1.0d0
else if (x <= 4.5d-66) then
tmp = t_0
else if (x <= 1d+43) then
tmp = 1.0d0
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x - y) * 0.5;
double tmp;
if (x <= -2.5) {
tmp = -1.0;
} else if (x <= -1.45e-83) {
tmp = t_0;
} else if (x <= 7.2e-100) {
tmp = 1.0;
} else if (x <= 4.5e-66) {
tmp = t_0;
} else if (x <= 1e+43) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): t_0 = (x - y) * 0.5 tmp = 0 if x <= -2.5: tmp = -1.0 elif x <= -1.45e-83: tmp = t_0 elif x <= 7.2e-100: tmp = 1.0 elif x <= 4.5e-66: tmp = t_0 elif x <= 1e+43: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) t_0 = Float64(Float64(x - y) * 0.5) tmp = 0.0 if (x <= -2.5) tmp = -1.0; elseif (x <= -1.45e-83) tmp = t_0; elseif (x <= 7.2e-100) tmp = 1.0; elseif (x <= 4.5e-66) tmp = t_0; elseif (x <= 1e+43) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) t_0 = (x - y) * 0.5; tmp = 0.0; if (x <= -2.5) tmp = -1.0; elseif (x <= -1.45e-83) tmp = t_0; elseif (x <= 7.2e-100) tmp = 1.0; elseif (x <= 4.5e-66) tmp = t_0; elseif (x <= 1e+43) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[x, -2.5], -1.0, If[LessEqual[x, -1.45e-83], t$95$0, If[LessEqual[x, 7.2e-100], 1.0, If[LessEqual[x, 4.5e-66], t$95$0, If[LessEqual[x, 1e+43], 1.0, -1.0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x - y\right) \cdot 0.5\\
\mathbf{if}\;x \leq -2.5:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -1.45 \cdot 10^{-83}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 7.2 \cdot 10^{-100}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 4.5 \cdot 10^{-66}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 10^{+43}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -2.5 or 1.00000000000000001e43 < x Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 74.9%
if -2.5 < x < -1.45e-83 or 7.1999999999999997e-100 < x < 4.4999999999999998e-66Initial program 100.0%
associate--r+100.0%
Simplified100.0%
clear-num99.6%
associate-/r/99.9%
associate--l-99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 97.7%
Taylor expanded in y around 0 77.3%
if -1.45e-83 < x < 7.1999999999999997e-100 or 4.4999999999999998e-66 < x < 1.00000000000000001e43Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 58.4%
Final simplification68.9%
(FPCore (x y) :precision binary64 (if (<= x -1.6e-5) (/ (- x y) (- 2.0 x)) (if (<= x 7.5e+42) (* (- x y) (/ 1.0 (- 2.0 y))) (+ (/ y x) -1.0))))
double code(double x, double y) {
double tmp;
if (x <= -1.6e-5) {
tmp = (x - y) / (2.0 - x);
} else if (x <= 7.5e+42) {
tmp = (x - y) * (1.0 / (2.0 - y));
} else {
tmp = (y / x) + -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.6d-5)) then
tmp = (x - y) / (2.0d0 - x)
else if (x <= 7.5d+42) then
tmp = (x - y) * (1.0d0 / (2.0d0 - y))
else
tmp = (y / x) + (-1.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.6e-5) {
tmp = (x - y) / (2.0 - x);
} else if (x <= 7.5e+42) {
tmp = (x - y) * (1.0 / (2.0 - y));
} else {
tmp = (y / x) + -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.6e-5: tmp = (x - y) / (2.0 - x) elif x <= 7.5e+42: tmp = (x - y) * (1.0 / (2.0 - y)) else: tmp = (y / x) + -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.6e-5) tmp = Float64(Float64(x - y) / Float64(2.0 - x)); elseif (x <= 7.5e+42) tmp = Float64(Float64(x - y) * Float64(1.0 / Float64(2.0 - y))); else tmp = Float64(Float64(y / x) + -1.0); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.6e-5) tmp = (x - y) / (2.0 - x); elseif (x <= 7.5e+42) tmp = (x - y) * (1.0 / (2.0 - y)); else tmp = (y / x) + -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.6e-5], N[(N[(x - y), $MachinePrecision] / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 7.5e+42], N[(N[(x - y), $MachinePrecision] * N[(1.0 / N[(2.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y / x), $MachinePrecision] + -1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.6 \cdot 10^{-5}:\\
\;\;\;\;\frac{x - y}{2 - x}\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{+42}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{1}{2 - y}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{x} + -1\\
\end{array}
\end{array}
if x < -1.59999999999999993e-5Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 74.0%
if -1.59999999999999993e-5 < x < 7.50000000000000041e42Initial program 100.0%
associate--r+100.0%
Simplified100.0%
clear-num99.7%
associate-/r/99.8%
associate--l-99.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 97.5%
if 7.50000000000000041e42 < x Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 79.6%
neg-mul-179.6%
Simplified79.6%
Taylor expanded in x around 0 79.6%
Final simplification86.3%
(FPCore (x y)
:precision binary64
(if (<= y -9.5e-7)
(* (- x y) (/ 1.0 (- 2.0 y)))
(if (<= y 4200000000.0)
(/ (- x y) (- 2.0 x))
(+ 1.0 (/ (- (- 2.0 x) x) y)))))
double code(double x, double y) {
double tmp;
if (y <= -9.5e-7) {
tmp = (x - y) * (1.0 / (2.0 - y));
} else if (y <= 4200000000.0) {
tmp = (x - y) / (2.0 - x);
} else {
tmp = 1.0 + (((2.0 - x) - 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 <= (-9.5d-7)) then
tmp = (x - y) * (1.0d0 / (2.0d0 - y))
else if (y <= 4200000000.0d0) then
tmp = (x - y) / (2.0d0 - x)
else
tmp = 1.0d0 + (((2.0d0 - x) - x) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -9.5e-7) {
tmp = (x - y) * (1.0 / (2.0 - y));
} else if (y <= 4200000000.0) {
tmp = (x - y) / (2.0 - x);
} else {
tmp = 1.0 + (((2.0 - x) - x) / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -9.5e-7: tmp = (x - y) * (1.0 / (2.0 - y)) elif y <= 4200000000.0: tmp = (x - y) / (2.0 - x) else: tmp = 1.0 + (((2.0 - x) - x) / y) return tmp
function code(x, y) tmp = 0.0 if (y <= -9.5e-7) tmp = Float64(Float64(x - y) * Float64(1.0 / Float64(2.0 - y))); elseif (y <= 4200000000.0) tmp = Float64(Float64(x - y) / Float64(2.0 - x)); else tmp = Float64(1.0 + Float64(Float64(Float64(2.0 - x) - x) / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -9.5e-7) tmp = (x - y) * (1.0 / (2.0 - y)); elseif (y <= 4200000000.0) tmp = (x - y) / (2.0 - x); else tmp = 1.0 + (((2.0 - x) - x) / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -9.5e-7], N[(N[(x - y), $MachinePrecision] * N[(1.0 / N[(2.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4200000000.0], N[(N[(x - y), $MachinePrecision] / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(N[(2.0 - x), $MachinePrecision] - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.5 \cdot 10^{-7}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{1}{2 - y}\\
\mathbf{elif}\;y \leq 4200000000:\\
\;\;\;\;\frac{x - y}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{\left(2 - x\right) - x}{y}\\
\end{array}
\end{array}
if y < -9.5000000000000001e-7Initial program 99.9%
associate--r+99.9%
Simplified99.9%
clear-num99.8%
associate-/r/99.6%
associate--l-99.6%
Applied egg-rr99.6%
Taylor expanded in x around 0 79.8%
if -9.5000000000000001e-7 < y < 4.2e9Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 98.5%
if 4.2e9 < y Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 70.9%
associate--l+70.9%
associate-*r/70.9%
neg-mul-170.9%
associate-*r/70.9%
div-sub70.9%
cancel-sign-sub-inv70.9%
metadata-eval70.9%
*-lft-identity70.9%
+-commutative70.9%
unsub-neg70.9%
Simplified70.9%
Final simplification86.6%
(FPCore (x y)
:precision binary64
(if (<= x -2.0)
-1.0
(if (<= x -5.6e-74)
(* x 0.5)
(if (<= x 3.9e-100)
1.0
(if (<= x 3.1e-62) (* x 0.5) (if (<= x 1e+43) 1.0 -1.0))))))
double code(double x, double y) {
double tmp;
if (x <= -2.0) {
tmp = -1.0;
} else if (x <= -5.6e-74) {
tmp = x * 0.5;
} else if (x <= 3.9e-100) {
tmp = 1.0;
} else if (x <= 3.1e-62) {
tmp = x * 0.5;
} else if (x <= 1e+43) {
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.0d0)) then
tmp = -1.0d0
else if (x <= (-5.6d-74)) then
tmp = x * 0.5d0
else if (x <= 3.9d-100) then
tmp = 1.0d0
else if (x <= 3.1d-62) then
tmp = x * 0.5d0
else if (x <= 1d+43) 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.0) {
tmp = -1.0;
} else if (x <= -5.6e-74) {
tmp = x * 0.5;
} else if (x <= 3.9e-100) {
tmp = 1.0;
} else if (x <= 3.1e-62) {
tmp = x * 0.5;
} else if (x <= 1e+43) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2.0: tmp = -1.0 elif x <= -5.6e-74: tmp = x * 0.5 elif x <= 3.9e-100: tmp = 1.0 elif x <= 3.1e-62: tmp = x * 0.5 elif x <= 1e+43: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -2.0) tmp = -1.0; elseif (x <= -5.6e-74) tmp = Float64(x * 0.5); elseif (x <= 3.9e-100) tmp = 1.0; elseif (x <= 3.1e-62) tmp = Float64(x * 0.5); elseif (x <= 1e+43) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2.0) tmp = -1.0; elseif (x <= -5.6e-74) tmp = x * 0.5; elseif (x <= 3.9e-100) tmp = 1.0; elseif (x <= 3.1e-62) tmp = x * 0.5; elseif (x <= 1e+43) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2.0], -1.0, If[LessEqual[x, -5.6e-74], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 3.9e-100], 1.0, If[LessEqual[x, 3.1e-62], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 1e+43], 1.0, -1.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -5.6 \cdot 10^{-74}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 3.9 \cdot 10^{-100}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 3.1 \cdot 10^{-62}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 10^{+43}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -2 or 1.00000000000000001e43 < x Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 74.9%
if -2 < x < -5.59999999999999976e-74 or 3.89999999999999977e-100 < x < 3.0999999999999999e-62Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 72.4%
Taylor expanded in x around 0 72.4%
*-commutative72.4%
Simplified72.4%
if -5.59999999999999976e-74 < x < 3.89999999999999977e-100 or 3.0999999999999999e-62 < x < 1.00000000000000001e43Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 58.2%
Final simplification68.2%
(FPCore (x y) :precision binary64 (if (<= y -9.5e-7) (/ y (+ y -2.0)) (if (<= y 6e+35) (/ (- x y) (- 2.0 x)) (- 1.0 (/ x y)))))
double code(double x, double y) {
double tmp;
if (y <= -9.5e-7) {
tmp = y / (y + -2.0);
} else if (y <= 6e+35) {
tmp = (x - y) / (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 <= (-9.5d-7)) then
tmp = y / (y + (-2.0d0))
else if (y <= 6d+35) then
tmp = (x - y) / (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 <= -9.5e-7) {
tmp = y / (y + -2.0);
} else if (y <= 6e+35) {
tmp = (x - y) / (2.0 - x);
} else {
tmp = 1.0 - (x / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -9.5e-7: tmp = y / (y + -2.0) elif y <= 6e+35: tmp = (x - y) / (2.0 - x) else: tmp = 1.0 - (x / y) return tmp
function code(x, y) tmp = 0.0 if (y <= -9.5e-7) tmp = Float64(y / Float64(y + -2.0)); elseif (y <= 6e+35) tmp = Float64(Float64(x - y) / 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 <= -9.5e-7) tmp = y / (y + -2.0); elseif (y <= 6e+35) tmp = (x - y) / (2.0 - x); else tmp = 1.0 - (x / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -9.5e-7], N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 6e+35], N[(N[(x - y), $MachinePrecision] / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.5 \cdot 10^{-7}:\\
\;\;\;\;\frac{y}{y + -2}\\
\mathbf{elif}\;y \leq 6 \cdot 10^{+35}:\\
\;\;\;\;\frac{x - y}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{y}\\
\end{array}
\end{array}
if y < -9.5000000000000001e-7Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in x around 0 79.1%
associate-*r/79.1%
neg-mul-179.1%
Simplified79.1%
frac-2neg79.1%
div-inv79.0%
remove-double-neg79.0%
sub-neg79.0%
distribute-neg-in79.0%
metadata-eval79.0%
remove-double-neg79.0%
Applied egg-rr79.0%
associate-*r/79.1%
*-rgt-identity79.1%
+-commutative79.1%
Simplified79.1%
if -9.5000000000000001e-7 < y < 5.99999999999999981e35Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 96.4%
if 5.99999999999999981e35 < y Initial program 100.0%
associate--r+100.0%
Simplified100.0%
clear-num100.0%
associate-/r/99.7%
associate--l-99.7%
Applied egg-rr99.7%
Taylor expanded in y around inf 71.1%
Taylor expanded in y around 0 71.3%
mul-1-neg71.3%
unsub-neg71.3%
Simplified71.3%
Final simplification86.1%
(FPCore (x y) :precision binary64 (if (or (<= y -27000000000000.0) (not (<= y 4.2e+35))) (- 1.0 (/ x y)) (/ x (- 2.0 x))))
double code(double x, double y) {
double tmp;
if ((y <= -27000000000000.0) || !(y <= 4.2e+35)) {
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 <= (-27000000000000.0d0)) .or. (.not. (y <= 4.2d+35))) 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 <= -27000000000000.0) || !(y <= 4.2e+35)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -27000000000000.0) or not (y <= 4.2e+35): tmp = 1.0 - (x / y) else: tmp = x / (2.0 - x) return tmp
function code(x, y) tmp = 0.0 if ((y <= -27000000000000.0) || !(y <= 4.2e+35)) 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 <= -27000000000000.0) || ~((y <= 4.2e+35))) tmp = 1.0 - (x / y); else tmp = x / (2.0 - x); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -27000000000000.0], N[Not[LessEqual[y, 4.2e+35]], $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 -27000000000000 \lor \neg \left(y \leq 4.2 \cdot 10^{+35}\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 - x}\\
\end{array}
\end{array}
if y < -2.7e13 or 4.1999999999999998e35 < y Initial program 100.0%
associate--r+100.0%
Simplified100.0%
clear-num99.9%
associate-/r/99.7%
associate--l-99.7%
Applied egg-rr99.7%
Taylor expanded in y around inf 75.1%
Taylor expanded in y around 0 75.3%
mul-1-neg75.3%
unsub-neg75.3%
Simplified75.3%
if -2.7e13 < y < 4.1999999999999998e35Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 79.8%
Final simplification77.8%
(FPCore (x y) :precision binary64 (if (<= y -8.5e-8) (/ y (+ y -2.0)) (if (<= y 6e+35) (/ x (- 2.0 x)) (- 1.0 (/ x y)))))
double code(double x, double y) {
double tmp;
if (y <= -8.5e-8) {
tmp = y / (y + -2.0);
} else if (y <= 6e+35) {
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 <= (-8.5d-8)) then
tmp = y / (y + (-2.0d0))
else if (y <= 6d+35) 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 <= -8.5e-8) {
tmp = y / (y + -2.0);
} else if (y <= 6e+35) {
tmp = x / (2.0 - x);
} else {
tmp = 1.0 - (x / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -8.5e-8: tmp = y / (y + -2.0) elif y <= 6e+35: tmp = x / (2.0 - x) else: tmp = 1.0 - (x / y) return tmp
function code(x, y) tmp = 0.0 if (y <= -8.5e-8) tmp = Float64(y / Float64(y + -2.0)); elseif (y <= 6e+35) 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 <= -8.5e-8) tmp = y / (y + -2.0); elseif (y <= 6e+35) tmp = x / (2.0 - x); else tmp = 1.0 - (x / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -8.5e-8], N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 6e+35], 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 -8.5 \cdot 10^{-8}:\\
\;\;\;\;\frac{y}{y + -2}\\
\mathbf{elif}\;y \leq 6 \cdot 10^{+35}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{y}\\
\end{array}
\end{array}
if y < -8.49999999999999935e-8Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in x around 0 79.1%
associate-*r/79.1%
neg-mul-179.1%
Simplified79.1%
frac-2neg79.1%
div-inv79.0%
remove-double-neg79.0%
sub-neg79.0%
distribute-neg-in79.0%
metadata-eval79.0%
remove-double-neg79.0%
Applied egg-rr79.0%
associate-*r/79.1%
*-rgt-identity79.1%
+-commutative79.1%
Simplified79.1%
if -8.49999999999999935e-8 < y < 5.99999999999999981e35Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 82.3%
if 5.99999999999999981e35 < y Initial program 100.0%
associate--r+100.0%
Simplified100.0%
clear-num100.0%
associate-/r/99.7%
associate--l-99.7%
Applied egg-rr99.7%
Taylor expanded in y around inf 71.1%
Taylor expanded in y around 0 71.3%
mul-1-neg71.3%
unsub-neg71.3%
Simplified71.3%
Final simplification78.8%
(FPCore (x y) :precision binary64 (if (<= x -1.6e-5) -1.0 (if (<= x 1e+43) 1.0 -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -1.6e-5) {
tmp = -1.0;
} else if (x <= 1e+43) {
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.6d-5)) then
tmp = -1.0d0
else if (x <= 1d+43) 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.6e-5) {
tmp = -1.0;
} else if (x <= 1e+43) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.6e-5: tmp = -1.0 elif x <= 1e+43: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.6e-5) tmp = -1.0; elseif (x <= 1e+43) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.6e-5) tmp = -1.0; elseif (x <= 1e+43) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.6e-5], -1.0, If[LessEqual[x, 1e+43], 1.0, -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.6 \cdot 10^{-5}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 10^{+43}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -1.59999999999999993e-5 or 1.00000000000000001e43 < x Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 74.4%
if -1.59999999999999993e-5 < x < 1.00000000000000001e43Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 50.7%
Final simplification63.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%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 41.0%
Final simplification41.0%
(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 2023268
(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))))