
(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
(let* ((t_0 (/ (- x y) (- x))))
(if (<= x -8.8e+51)
t_0
(if (<= x 9e-24)
(/ y (+ y -2.0))
(if (<= x 5e+45)
(/ x (- 2.0 x))
(if (<= x 7e+66) (+ 1.0 (/ (* x -2.0) y)) t_0))))))
double code(double x, double y) {
double t_0 = (x - y) / -x;
double tmp;
if (x <= -8.8e+51) {
tmp = t_0;
} else if (x <= 9e-24) {
tmp = y / (y + -2.0);
} else if (x <= 5e+45) {
tmp = x / (2.0 - x);
} else if (x <= 7e+66) {
tmp = 1.0 + ((x * -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 = (x - y) / -x
if (x <= (-8.8d+51)) then
tmp = t_0
else if (x <= 9d-24) then
tmp = y / (y + (-2.0d0))
else if (x <= 5d+45) then
tmp = x / (2.0d0 - x)
else if (x <= 7d+66) then
tmp = 1.0d0 + ((x * (-2.0d0)) / y)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x - y) / -x;
double tmp;
if (x <= -8.8e+51) {
tmp = t_0;
} else if (x <= 9e-24) {
tmp = y / (y + -2.0);
} else if (x <= 5e+45) {
tmp = x / (2.0 - x);
} else if (x <= 7e+66) {
tmp = 1.0 + ((x * -2.0) / y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (x - y) / -x tmp = 0 if x <= -8.8e+51: tmp = t_0 elif x <= 9e-24: tmp = y / (y + -2.0) elif x <= 5e+45: tmp = x / (2.0 - x) elif x <= 7e+66: tmp = 1.0 + ((x * -2.0) / y) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(x - y) / Float64(-x)) tmp = 0.0 if (x <= -8.8e+51) tmp = t_0; elseif (x <= 9e-24) tmp = Float64(y / Float64(y + -2.0)); elseif (x <= 5e+45) tmp = Float64(x / Float64(2.0 - x)); elseif (x <= 7e+66) tmp = Float64(1.0 + Float64(Float64(x * -2.0) / y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (x - y) / -x; tmp = 0.0; if (x <= -8.8e+51) tmp = t_0; elseif (x <= 9e-24) tmp = y / (y + -2.0); elseif (x <= 5e+45) tmp = x / (2.0 - x); elseif (x <= 7e+66) tmp = 1.0 + ((x * -2.0) / y); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x - y), $MachinePrecision] / (-x)), $MachinePrecision]}, If[LessEqual[x, -8.8e+51], t$95$0, If[LessEqual[x, 9e-24], N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5e+45], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 7e+66], N[(1.0 + N[(N[(x * -2.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x - y}{-x}\\
\mathbf{if}\;x \leq -8.8 \cdot 10^{+51}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 9 \cdot 10^{-24}:\\
\;\;\;\;\frac{y}{y + -2}\\
\mathbf{elif}\;x \leq 5 \cdot 10^{+45}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{elif}\;x \leq 7 \cdot 10^{+66}:\\
\;\;\;\;1 + \frac{x \cdot -2}{y}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -8.79999999999999967e51 or 6.9999999999999994e66 < x Initial program 99.9%
associate--r+99.9%
Simplified99.9%
flip--35.6%
associate-/r/35.4%
pow235.4%
+-commutative35.4%
Applied egg-rr35.4%
associate-*l/33.9%
associate-/l*35.6%
Simplified35.6%
Taylor expanded in x around inf 85.5%
mul-1-neg85.5%
Simplified85.5%
if -8.79999999999999967e51 < x < 8.9999999999999995e-24Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 84.6%
mul-1-neg84.6%
distribute-neg-frac84.6%
Simplified84.6%
add-log-exp62.2%
*-un-lft-identity62.2%
log-prod62.2%
metadata-eval62.2%
add-log-exp84.6%
frac-2neg84.6%
remove-double-neg84.6%
sub-neg84.6%
distribute-neg-in84.6%
metadata-eval84.6%
remove-double-neg84.6%
Applied egg-rr84.6%
+-lft-identity84.6%
+-commutative84.6%
Simplified84.6%
if 8.9999999999999995e-24 < x < 5e45Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 80.9%
if 5e45 < x < 6.9999999999999994e66Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 86.6%
associate--l+86.9%
associate-*r/86.9%
associate-*r/86.9%
div-sub86.9%
cancel-sign-sub-inv86.9%
metadata-eval86.9%
*-lft-identity86.9%
+-commutative86.9%
mul-1-neg86.9%
unsub-neg86.9%
Simplified86.9%
Taylor expanded in x around inf 86.9%
*-commutative86.9%
Simplified86.9%
Final simplification84.8%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (- x y) (- x))))
(if (<= x -1.9e+52)
t_0
(if (<= x 1.05e-22)
(/ y (+ y -2.0))
(if (<= x 2.35e+44) (/ x (- 2.0 x)) (if (<= x 3.6e+66) 1.0 t_0))))))
double code(double x, double y) {
double t_0 = (x - y) / -x;
double tmp;
if (x <= -1.9e+52) {
tmp = t_0;
} else if (x <= 1.05e-22) {
tmp = y / (y + -2.0);
} else if (x <= 2.35e+44) {
tmp = x / (2.0 - x);
} else if (x <= 3.6e+66) {
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 = (x - y) / -x
if (x <= (-1.9d+52)) then
tmp = t_0
else if (x <= 1.05d-22) then
tmp = y / (y + (-2.0d0))
else if (x <= 2.35d+44) then
tmp = x / (2.0d0 - x)
else if (x <= 3.6d+66) 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 = (x - y) / -x;
double tmp;
if (x <= -1.9e+52) {
tmp = t_0;
} else if (x <= 1.05e-22) {
tmp = y / (y + -2.0);
} else if (x <= 2.35e+44) {
tmp = x / (2.0 - x);
} else if (x <= 3.6e+66) {
tmp = 1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (x - y) / -x tmp = 0 if x <= -1.9e+52: tmp = t_0 elif x <= 1.05e-22: tmp = y / (y + -2.0) elif x <= 2.35e+44: tmp = x / (2.0 - x) elif x <= 3.6e+66: tmp = 1.0 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(x - y) / Float64(-x)) tmp = 0.0 if (x <= -1.9e+52) tmp = t_0; elseif (x <= 1.05e-22) tmp = Float64(y / Float64(y + -2.0)); elseif (x <= 2.35e+44) tmp = Float64(x / Float64(2.0 - x)); elseif (x <= 3.6e+66) tmp = 1.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (x - y) / -x; tmp = 0.0; if (x <= -1.9e+52) tmp = t_0; elseif (x <= 1.05e-22) tmp = y / (y + -2.0); elseif (x <= 2.35e+44) tmp = x / (2.0 - x); elseif (x <= 3.6e+66) tmp = 1.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x - y), $MachinePrecision] / (-x)), $MachinePrecision]}, If[LessEqual[x, -1.9e+52], t$95$0, If[LessEqual[x, 1.05e-22], N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.35e+44], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.6e+66], 1.0, t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x - y}{-x}\\
\mathbf{if}\;x \leq -1.9 \cdot 10^{+52}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.05 \cdot 10^{-22}:\\
\;\;\;\;\frac{y}{y + -2}\\
\mathbf{elif}\;x \leq 2.35 \cdot 10^{+44}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{elif}\;x \leq 3.6 \cdot 10^{+66}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -1.9e52 or 3.6e66 < x Initial program 99.9%
associate--r+99.9%
Simplified99.9%
flip--35.6%
associate-/r/35.4%
pow235.4%
+-commutative35.4%
Applied egg-rr35.4%
associate-*l/33.9%
associate-/l*35.6%
Simplified35.6%
Taylor expanded in x around inf 85.5%
mul-1-neg85.5%
Simplified85.5%
if -1.9e52 < x < 1.05000000000000004e-22Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 84.6%
mul-1-neg84.6%
distribute-neg-frac84.6%
Simplified84.6%
add-log-exp62.2%
*-un-lft-identity62.2%
log-prod62.2%
metadata-eval62.2%
add-log-exp84.6%
frac-2neg84.6%
remove-double-neg84.6%
sub-neg84.6%
distribute-neg-in84.6%
metadata-eval84.6%
remove-double-neg84.6%
Applied egg-rr84.6%
+-lft-identity84.6%
+-commutative84.6%
Simplified84.6%
if 1.05000000000000004e-22 < x < 2.35000000000000009e44Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 80.9%
if 2.35000000000000009e44 < x < 3.6e66Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 84.0%
Final simplification84.8%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (- x y) (- x))))
(if (<= x -2e+52)
t_0
(if (<= x 1.05e-22)
(/ y (+ y -2.0))
(if (<= x 2.5e+45)
(/ x (- 2.0 x))
(if (<= x 1.1e+66) (/ (- x y) (- y)) t_0))))))
double code(double x, double y) {
double t_0 = (x - y) / -x;
double tmp;
if (x <= -2e+52) {
tmp = t_0;
} else if (x <= 1.05e-22) {
tmp = y / (y + -2.0);
} else if (x <= 2.5e+45) {
tmp = x / (2.0 - x);
} else if (x <= 1.1e+66) {
tmp = (x - y) / -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 = (x - y) / -x
if (x <= (-2d+52)) then
tmp = t_0
else if (x <= 1.05d-22) then
tmp = y / (y + (-2.0d0))
else if (x <= 2.5d+45) then
tmp = x / (2.0d0 - x)
else if (x <= 1.1d+66) then
tmp = (x - y) / -y
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x - y) / -x;
double tmp;
if (x <= -2e+52) {
tmp = t_0;
} else if (x <= 1.05e-22) {
tmp = y / (y + -2.0);
} else if (x <= 2.5e+45) {
tmp = x / (2.0 - x);
} else if (x <= 1.1e+66) {
tmp = (x - y) / -y;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (x - y) / -x tmp = 0 if x <= -2e+52: tmp = t_0 elif x <= 1.05e-22: tmp = y / (y + -2.0) elif x <= 2.5e+45: tmp = x / (2.0 - x) elif x <= 1.1e+66: tmp = (x - y) / -y else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(x - y) / Float64(-x)) tmp = 0.0 if (x <= -2e+52) tmp = t_0; elseif (x <= 1.05e-22) tmp = Float64(y / Float64(y + -2.0)); elseif (x <= 2.5e+45) tmp = Float64(x / Float64(2.0 - x)); elseif (x <= 1.1e+66) tmp = Float64(Float64(x - y) / Float64(-y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (x - y) / -x; tmp = 0.0; if (x <= -2e+52) tmp = t_0; elseif (x <= 1.05e-22) tmp = y / (y + -2.0); elseif (x <= 2.5e+45) tmp = x / (2.0 - x); elseif (x <= 1.1e+66) tmp = (x - y) / -y; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x - y), $MachinePrecision] / (-x)), $MachinePrecision]}, If[LessEqual[x, -2e+52], t$95$0, If[LessEqual[x, 1.05e-22], N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.5e+45], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.1e+66], N[(N[(x - y), $MachinePrecision] / (-y)), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x - y}{-x}\\
\mathbf{if}\;x \leq -2 \cdot 10^{+52}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.05 \cdot 10^{-22}:\\
\;\;\;\;\frac{y}{y + -2}\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{+45}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{elif}\;x \leq 1.1 \cdot 10^{+66}:\\
\;\;\;\;\frac{x - y}{-y}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -2e52 or 1.0999999999999999e66 < x Initial program 99.9%
associate--r+99.9%
Simplified99.9%
flip--35.6%
associate-/r/35.4%
pow235.4%
+-commutative35.4%
Applied egg-rr35.4%
associate-*l/33.9%
associate-/l*35.6%
Simplified35.6%
Taylor expanded in x around inf 85.5%
mul-1-neg85.5%
Simplified85.5%
if -2e52 < x < 1.05000000000000004e-22Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 84.6%
mul-1-neg84.6%
distribute-neg-frac84.6%
Simplified84.6%
add-log-exp62.2%
*-un-lft-identity62.2%
log-prod62.2%
metadata-eval62.2%
add-log-exp84.6%
frac-2neg84.6%
remove-double-neg84.6%
sub-neg84.6%
distribute-neg-in84.6%
metadata-eval84.6%
remove-double-neg84.6%
Applied egg-rr84.6%
+-lft-identity84.6%
+-commutative84.6%
Simplified84.6%
if 1.05000000000000004e-22 < x < 2.5e45Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 80.9%
if 2.5e45 < x < 1.0999999999999999e66Initial program 100.0%
associate--r+100.0%
Simplified100.0%
flip--44.4%
associate-/r/44.2%
pow244.2%
+-commutative44.2%
Applied egg-rr44.2%
associate-*l/42.9%
associate-/l*44.4%
Simplified44.4%
Taylor expanded in y around inf 85.2%
neg-mul-185.2%
Simplified85.2%
Final simplification84.8%
(FPCore (x y)
:precision binary64
(if (<= y -6e+90)
1.0
(if (or (<= y -2.3e+64) (and (not (<= y -3.2e+31)) (<= y 3e+15)))
(/ x (- 2.0 x))
1.0)))
double code(double x, double y) {
double tmp;
if (y <= -6e+90) {
tmp = 1.0;
} else if ((y <= -2.3e+64) || (!(y <= -3.2e+31) && (y <= 3e+15))) {
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 <= (-6d+90)) then
tmp = 1.0d0
else if ((y <= (-2.3d+64)) .or. (.not. (y <= (-3.2d+31))) .and. (y <= 3d+15)) 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 <= -6e+90) {
tmp = 1.0;
} else if ((y <= -2.3e+64) || (!(y <= -3.2e+31) && (y <= 3e+15))) {
tmp = x / (2.0 - x);
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -6e+90: tmp = 1.0 elif (y <= -2.3e+64) or (not (y <= -3.2e+31) and (y <= 3e+15)): tmp = x / (2.0 - x) else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -6e+90) tmp = 1.0; elseif ((y <= -2.3e+64) || (!(y <= -3.2e+31) && (y <= 3e+15))) 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 <= -6e+90) tmp = 1.0; elseif ((y <= -2.3e+64) || (~((y <= -3.2e+31)) && (y <= 3e+15))) tmp = x / (2.0 - x); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -6e+90], 1.0, If[Or[LessEqual[y, -2.3e+64], And[N[Not[LessEqual[y, -3.2e+31]], $MachinePrecision], LessEqual[y, 3e+15]]], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6 \cdot 10^{+90}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -2.3 \cdot 10^{+64} \lor \neg \left(y \leq -3.2 \cdot 10^{+31}\right) \land y \leq 3 \cdot 10^{+15}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -5.99999999999999957e90 or -2.3e64 < y < -3.2000000000000001e31 or 3e15 < y Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around inf 78.3%
if -5.99999999999999957e90 < y < -2.3e64 or -3.2000000000000001e31 < y < 3e15Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 72.5%
Final simplification75.2%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ y (+ y -2.0))))
(if (<= x -2.8e+52)
-1.0
(if (<= x 9e-24)
t_0
(if (<= x 5.3e+45) (/ x (- 2.0 x)) (if (<= x 1.25e+72) t_0 -1.0))))))
double code(double x, double y) {
double t_0 = y / (y + -2.0);
double tmp;
if (x <= -2.8e+52) {
tmp = -1.0;
} else if (x <= 9e-24) {
tmp = t_0;
} else if (x <= 5.3e+45) {
tmp = x / (2.0 - x);
} else if (x <= 1.25e+72) {
tmp = t_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 = y / (y + (-2.0d0))
if (x <= (-2.8d+52)) then
tmp = -1.0d0
else if (x <= 9d-24) then
tmp = t_0
else if (x <= 5.3d+45) then
tmp = x / (2.0d0 - x)
else if (x <= 1.25d+72) then
tmp = t_0
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = y / (y + -2.0);
double tmp;
if (x <= -2.8e+52) {
tmp = -1.0;
} else if (x <= 9e-24) {
tmp = t_0;
} else if (x <= 5.3e+45) {
tmp = x / (2.0 - x);
} else if (x <= 1.25e+72) {
tmp = t_0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): t_0 = y / (y + -2.0) tmp = 0 if x <= -2.8e+52: tmp = -1.0 elif x <= 9e-24: tmp = t_0 elif x <= 5.3e+45: tmp = x / (2.0 - x) elif x <= 1.25e+72: tmp = t_0 else: tmp = -1.0 return tmp
function code(x, y) t_0 = Float64(y / Float64(y + -2.0)) tmp = 0.0 if (x <= -2.8e+52) tmp = -1.0; elseif (x <= 9e-24) tmp = t_0; elseif (x <= 5.3e+45) tmp = Float64(x / Float64(2.0 - x)); elseif (x <= 1.25e+72) tmp = t_0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) t_0 = y / (y + -2.0); tmp = 0.0; if (x <= -2.8e+52) tmp = -1.0; elseif (x <= 9e-24) tmp = t_0; elseif (x <= 5.3e+45) tmp = x / (2.0 - x); elseif (x <= 1.25e+72) tmp = t_0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.8e+52], -1.0, If[LessEqual[x, 9e-24], t$95$0, If[LessEqual[x, 5.3e+45], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.25e+72], t$95$0, -1.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{y + -2}\\
\mathbf{if}\;x \leq -2.8 \cdot 10^{+52}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 9 \cdot 10^{-24}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 5.3 \cdot 10^{+45}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{elif}\;x \leq 1.25 \cdot 10^{+72}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -2.8e52 or 1.24999999999999998e72 < x Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in x around inf 85.6%
if -2.8e52 < x < 8.9999999999999995e-24 or 5.29999999999999991e45 < x < 1.24999999999999998e72Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 84.1%
mul-1-neg84.1%
distribute-neg-frac84.1%
Simplified84.1%
add-log-exp63.2%
*-un-lft-identity63.2%
log-prod63.2%
metadata-eval63.2%
add-log-exp84.1%
frac-2neg84.1%
remove-double-neg84.1%
sub-neg84.1%
distribute-neg-in84.1%
metadata-eval84.1%
remove-double-neg84.1%
Applied egg-rr84.1%
+-lft-identity84.1%
+-commutative84.1%
Simplified84.1%
if 8.9999999999999995e-24 < x < 5.29999999999999991e45Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 80.9%
Final simplification84.5%
(FPCore (x y) :precision binary64 (if (<= y -4e+31) (+ 1.0 (/ (* x -2.0) y)) (if (<= y 1.45e+16) (/ (- x y) (- 2.0 x)) (/ (- x y) (- y)))))
double code(double x, double y) {
double tmp;
if (y <= -4e+31) {
tmp = 1.0 + ((x * -2.0) / y);
} else if (y <= 1.45e+16) {
tmp = (x - y) / (2.0 - x);
} else {
tmp = (x - y) / -y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-4d+31)) then
tmp = 1.0d0 + ((x * (-2.0d0)) / y)
else if (y <= 1.45d+16) then
tmp = (x - y) / (2.0d0 - x)
else
tmp = (x - y) / -y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -4e+31) {
tmp = 1.0 + ((x * -2.0) / y);
} else if (y <= 1.45e+16) {
tmp = (x - y) / (2.0 - x);
} else {
tmp = (x - y) / -y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -4e+31: tmp = 1.0 + ((x * -2.0) / y) elif y <= 1.45e+16: tmp = (x - y) / (2.0 - x) else: tmp = (x - y) / -y return tmp
function code(x, y) tmp = 0.0 if (y <= -4e+31) tmp = Float64(1.0 + Float64(Float64(x * -2.0) / y)); elseif (y <= 1.45e+16) tmp = Float64(Float64(x - y) / Float64(2.0 - x)); else tmp = Float64(Float64(x - y) / Float64(-y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -4e+31) tmp = 1.0 + ((x * -2.0) / y); elseif (y <= 1.45e+16) tmp = (x - y) / (2.0 - x); else tmp = (x - y) / -y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -4e+31], N[(1.0 + N[(N[(x * -2.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.45e+16], N[(N[(x - y), $MachinePrecision] / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], N[(N[(x - y), $MachinePrecision] / (-y)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4 \cdot 10^{+31}:\\
\;\;\;\;1 + \frac{x \cdot -2}{y}\\
\mathbf{elif}\;y \leq 1.45 \cdot 10^{+16}:\\
\;\;\;\;\frac{x - y}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x - y}{-y}\\
\end{array}
\end{array}
if y < -3.9999999999999999e31Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around inf 74.4%
associate--l+74.4%
associate-*r/74.4%
associate-*r/74.4%
div-sub74.4%
cancel-sign-sub-inv74.4%
metadata-eval74.4%
*-lft-identity74.4%
+-commutative74.4%
mul-1-neg74.4%
unsub-neg74.4%
Simplified74.4%
Taylor expanded in x around inf 74.4%
*-commutative74.4%
Simplified74.4%
if -3.9999999999999999e31 < y < 1.45e16Initial program 100.0%
associate--r+100.0%
Simplified100.0%
flip--68.9%
associate-/r/68.8%
pow268.8%
+-commutative68.8%
Applied egg-rr68.8%
associate-*l/67.9%
associate-/l*68.9%
Simplified68.9%
Taylor expanded in y around 0 96.5%
if 1.45e16 < y Initial program 99.9%
associate--r+99.9%
Simplified99.9%
flip--49.0%
associate-/r/48.8%
pow248.8%
+-commutative48.8%
Applied egg-rr48.8%
associate-*l/47.8%
associate-/l*49.0%
Simplified49.0%
Taylor expanded in y around inf 77.1%
neg-mul-177.1%
Simplified77.1%
Final simplification86.4%
(FPCore (x y)
:precision binary64
(if (<= x -4e+52)
-1.0
(if (<= x 1860000.0)
1.0
(if (<= x 1e+45) -1.0 (if (<= x 6e+58) 1.0 -1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -4e+52) {
tmp = -1.0;
} else if (x <= 1860000.0) {
tmp = 1.0;
} else if (x <= 1e+45) {
tmp = -1.0;
} else if (x <= 6e+58) {
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 <= (-4d+52)) then
tmp = -1.0d0
else if (x <= 1860000.0d0) then
tmp = 1.0d0
else if (x <= 1d+45) then
tmp = -1.0d0
else if (x <= 6d+58) 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 <= -4e+52) {
tmp = -1.0;
} else if (x <= 1860000.0) {
tmp = 1.0;
} else if (x <= 1e+45) {
tmp = -1.0;
} else if (x <= 6e+58) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -4e+52: tmp = -1.0 elif x <= 1860000.0: tmp = 1.0 elif x <= 1e+45: tmp = -1.0 elif x <= 6e+58: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -4e+52) tmp = -1.0; elseif (x <= 1860000.0) tmp = 1.0; elseif (x <= 1e+45) tmp = -1.0; elseif (x <= 6e+58) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -4e+52) tmp = -1.0; elseif (x <= 1860000.0) tmp = 1.0; elseif (x <= 1e+45) tmp = -1.0; elseif (x <= 6e+58) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -4e+52], -1.0, If[LessEqual[x, 1860000.0], 1.0, If[LessEqual[x, 1e+45], -1.0, If[LessEqual[x, 6e+58], 1.0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{+52}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 1860000:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 10^{+45}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 6 \cdot 10^{+58}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -4e52 or 1.86e6 < x < 9.9999999999999993e44 or 6.0000000000000005e58 < x Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in x around inf 82.9%
if -4e52 < x < 1.86e6 or 9.9999999999999993e44 < x < 6.0000000000000005e58Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 60.9%
Final simplification71.3%
(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 2023227
(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))))