
(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 8 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.1e+64)
1.0
(if (<= y -3.8e-37)
-1.0
(if (<= y -4e-137)
(* y -0.5)
(if (<= y -5.5e-298)
-1.0
(if (<= y 1.25e-256)
(* x 0.5)
(if (<= y 4e-36)
-1.0
(if (<= y 0.003) (* y -0.5) (if (<= y 330.0) -1.0 1.0)))))))))
double code(double x, double y) {
double tmp;
if (y <= -1.1e+64) {
tmp = 1.0;
} else if (y <= -3.8e-37) {
tmp = -1.0;
} else if (y <= -4e-137) {
tmp = y * -0.5;
} else if (y <= -5.5e-298) {
tmp = -1.0;
} else if (y <= 1.25e-256) {
tmp = x * 0.5;
} else if (y <= 4e-36) {
tmp = -1.0;
} else if (y <= 0.003) {
tmp = y * -0.5;
} else if (y <= 330.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 (y <= (-1.1d+64)) then
tmp = 1.0d0
else if (y <= (-3.8d-37)) then
tmp = -1.0d0
else if (y <= (-4d-137)) then
tmp = y * (-0.5d0)
else if (y <= (-5.5d-298)) then
tmp = -1.0d0
else if (y <= 1.25d-256) then
tmp = x * 0.5d0
else if (y <= 4d-36) then
tmp = -1.0d0
else if (y <= 0.003d0) then
tmp = y * (-0.5d0)
else if (y <= 330.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 (y <= -1.1e+64) {
tmp = 1.0;
} else if (y <= -3.8e-37) {
tmp = -1.0;
} else if (y <= -4e-137) {
tmp = y * -0.5;
} else if (y <= -5.5e-298) {
tmp = -1.0;
} else if (y <= 1.25e-256) {
tmp = x * 0.5;
} else if (y <= 4e-36) {
tmp = -1.0;
} else if (y <= 0.003) {
tmp = y * -0.5;
} else if (y <= 330.0) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.1e+64: tmp = 1.0 elif y <= -3.8e-37: tmp = -1.0 elif y <= -4e-137: tmp = y * -0.5 elif y <= -5.5e-298: tmp = -1.0 elif y <= 1.25e-256: tmp = x * 0.5 elif y <= 4e-36: tmp = -1.0 elif y <= 0.003: tmp = y * -0.5 elif y <= 330.0: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -1.1e+64) tmp = 1.0; elseif (y <= -3.8e-37) tmp = -1.0; elseif (y <= -4e-137) tmp = Float64(y * -0.5); elseif (y <= -5.5e-298) tmp = -1.0; elseif (y <= 1.25e-256) tmp = Float64(x * 0.5); elseif (y <= 4e-36) tmp = -1.0; elseif (y <= 0.003) tmp = Float64(y * -0.5); elseif (y <= 330.0) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.1e+64) tmp = 1.0; elseif (y <= -3.8e-37) tmp = -1.0; elseif (y <= -4e-137) tmp = y * -0.5; elseif (y <= -5.5e-298) tmp = -1.0; elseif (y <= 1.25e-256) tmp = x * 0.5; elseif (y <= 4e-36) tmp = -1.0; elseif (y <= 0.003) tmp = y * -0.5; elseif (y <= 330.0) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.1e+64], 1.0, If[LessEqual[y, -3.8e-37], -1.0, If[LessEqual[y, -4e-137], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, -5.5e-298], -1.0, If[LessEqual[y, 1.25e-256], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 4e-36], -1.0, If[LessEqual[y, 0.003], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 330.0], -1.0, 1.0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.1 \cdot 10^{+64}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -3.8 \cdot 10^{-37}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq -4 \cdot 10^{-137}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq -5.5 \cdot 10^{-298}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 1.25 \cdot 10^{-256}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;y \leq 4 \cdot 10^{-36}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 0.003:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 330:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.10000000000000001e64 or 330 < y Initial program 100.0%
Taylor expanded in y around inf 80.8%
if -1.10000000000000001e64 < y < -3.8000000000000004e-37 or -3.99999999999999991e-137 < y < -5.4999999999999996e-298 or 1.25e-256 < y < 3.9999999999999998e-36 or 0.0030000000000000001 < y < 330Initial program 100.0%
Taylor expanded in x around inf 60.9%
if -3.8000000000000004e-37 < y < -3.99999999999999991e-137 or 3.9999999999999998e-36 < y < 0.0030000000000000001Initial program 100.0%
Taylor expanded in x around 0 61.5%
mul-1-neg61.5%
distribute-neg-frac61.5%
Simplified61.5%
Taylor expanded in y around 0 57.7%
*-commutative57.7%
Simplified57.7%
if -5.4999999999999996e-298 < y < 1.25e-256Initial program 100.0%
Taylor expanded in y around 0 95.2%
Taylor expanded in x around 0 77.3%
*-commutative77.3%
Simplified77.3%
Final simplification70.3%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (- 2.0 x))))
(if (<= y -1.45e+64)
1.0
(if (<= y 3.8e-38)
t_0
(if (<= y 0.013) (* y -0.5) (if (<= y 330.0) t_0 1.0))))))
double code(double x, double y) {
double t_0 = x / (2.0 - x);
double tmp;
if (y <= -1.45e+64) {
tmp = 1.0;
} else if (y <= 3.8e-38) {
tmp = t_0;
} else if (y <= 0.013) {
tmp = y * -0.5;
} else if (y <= 330.0) {
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 = x / (2.0d0 - x)
if (y <= (-1.45d+64)) then
tmp = 1.0d0
else if (y <= 3.8d-38) then
tmp = t_0
else if (y <= 0.013d0) then
tmp = y * (-0.5d0)
else if (y <= 330.0d0) 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 = x / (2.0 - x);
double tmp;
if (y <= -1.45e+64) {
tmp = 1.0;
} else if (y <= 3.8e-38) {
tmp = t_0;
} else if (y <= 0.013) {
tmp = y * -0.5;
} else if (y <= 330.0) {
tmp = t_0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): t_0 = x / (2.0 - x) tmp = 0 if y <= -1.45e+64: tmp = 1.0 elif y <= 3.8e-38: tmp = t_0 elif y <= 0.013: tmp = y * -0.5 elif y <= 330.0: tmp = t_0 else: tmp = 1.0 return tmp
function code(x, y) t_0 = Float64(x / Float64(2.0 - x)) tmp = 0.0 if (y <= -1.45e+64) tmp = 1.0; elseif (y <= 3.8e-38) tmp = t_0; elseif (y <= 0.013) tmp = Float64(y * -0.5); elseif (y <= 330.0) tmp = t_0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) t_0 = x / (2.0 - x); tmp = 0.0; if (y <= -1.45e+64) tmp = 1.0; elseif (y <= 3.8e-38) tmp = t_0; elseif (y <= 0.013) tmp = y * -0.5; elseif (y <= 330.0) tmp = t_0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.45e+64], 1.0, If[LessEqual[y, 3.8e-38], t$95$0, If[LessEqual[y, 0.013], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 330.0], t$95$0, 1.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{2 - x}\\
\mathbf{if}\;y \leq -1.45 \cdot 10^{+64}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 3.8 \cdot 10^{-38}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 0.013:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 330:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.44999999999999997e64 or 330 < y Initial program 100.0%
Taylor expanded in y around inf 80.8%
if -1.44999999999999997e64 < y < 3.8e-38 or 0.0129999999999999994 < y < 330Initial program 100.0%
Taylor expanded in y around 0 74.4%
if 3.8e-38 < y < 0.0129999999999999994Initial program 100.0%
Taylor expanded in x around 0 88.7%
mul-1-neg88.7%
distribute-neg-frac88.7%
Simplified88.7%
Taylor expanded in y around 0 74.3%
*-commutative74.3%
Simplified74.3%
Final simplification77.2%
(FPCore (x y)
:precision binary64
(if (<= y -1.12e+64)
1.0
(if (<= y -1.9e-296)
-1.0
(if (<= y 1.7e-253) (* x 0.5) (if (<= y 330.0) -1.0 1.0)))))
double code(double x, double y) {
double tmp;
if (y <= -1.12e+64) {
tmp = 1.0;
} else if (y <= -1.9e-296) {
tmp = -1.0;
} else if (y <= 1.7e-253) {
tmp = x * 0.5;
} else if (y <= 330.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 (y <= (-1.12d+64)) then
tmp = 1.0d0
else if (y <= (-1.9d-296)) then
tmp = -1.0d0
else if (y <= 1.7d-253) then
tmp = x * 0.5d0
else if (y <= 330.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 (y <= -1.12e+64) {
tmp = 1.0;
} else if (y <= -1.9e-296) {
tmp = -1.0;
} else if (y <= 1.7e-253) {
tmp = x * 0.5;
} else if (y <= 330.0) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.12e+64: tmp = 1.0 elif y <= -1.9e-296: tmp = -1.0 elif y <= 1.7e-253: tmp = x * 0.5 elif y <= 330.0: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -1.12e+64) tmp = 1.0; elseif (y <= -1.9e-296) tmp = -1.0; elseif (y <= 1.7e-253) tmp = Float64(x * 0.5); elseif (y <= 330.0) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.12e+64) tmp = 1.0; elseif (y <= -1.9e-296) tmp = -1.0; elseif (y <= 1.7e-253) tmp = x * 0.5; elseif (y <= 330.0) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.12e+64], 1.0, If[LessEqual[y, -1.9e-296], -1.0, If[LessEqual[y, 1.7e-253], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 330.0], -1.0, 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.12 \cdot 10^{+64}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -1.9 \cdot 10^{-296}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 1.7 \cdot 10^{-253}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;y \leq 330:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.11999999999999995e64 or 330 < y Initial program 100.0%
Taylor expanded in y around inf 80.8%
if -1.11999999999999995e64 < y < -1.9000000000000001e-296 or 1.69999999999999993e-253 < y < 330Initial program 100.0%
Taylor expanded in x around inf 52.9%
if -1.9000000000000001e-296 < y < 1.69999999999999993e-253Initial program 100.0%
Taylor expanded in y around 0 95.2%
Taylor expanded in x around 0 77.3%
*-commutative77.3%
Simplified77.3%
Final simplification66.8%
(FPCore (x y) :precision binary64 (if (<= y -1.1e+64) 1.0 (if (<= y 4e-36) (/ x (- 2.0 x)) (/ y (+ y -2.0)))))
double code(double x, double y) {
double tmp;
if (y <= -1.1e+64) {
tmp = 1.0;
} else if (y <= 4e-36) {
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.1d+64)) then
tmp = 1.0d0
else if (y <= 4d-36) 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.1e+64) {
tmp = 1.0;
} else if (y <= 4e-36) {
tmp = x / (2.0 - x);
} else {
tmp = y / (y + -2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.1e+64: tmp = 1.0 elif y <= 4e-36: tmp = x / (2.0 - x) else: tmp = y / (y + -2.0) return tmp
function code(x, y) tmp = 0.0 if (y <= -1.1e+64) tmp = 1.0; elseif (y <= 4e-36) 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.1e+64) tmp = 1.0; elseif (y <= 4e-36) tmp = x / (2.0 - x); else tmp = y / (y + -2.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.1e+64], 1.0, If[LessEqual[y, 4e-36], 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.1 \cdot 10^{+64}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 4 \cdot 10^{-36}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y + -2}\\
\end{array}
\end{array}
if y < -1.10000000000000001e64Initial program 100.0%
Taylor expanded in y around inf 81.7%
if -1.10000000000000001e64 < y < 3.9999999999999998e-36Initial program 100.0%
Taylor expanded in y around 0 74.1%
if 3.9999999999999998e-36 < y Initial program 100.0%
Taylor expanded in x around 0 78.7%
mul-1-neg78.7%
distribute-neg-frac78.7%
Simplified78.7%
expm1-log1p-u78.4%
expm1-udef71.2%
add-sqr-sqrt0.0%
sqrt-unprod4.8%
sqr-neg4.8%
sqrt-unprod13.4%
add-sqr-sqrt16.4%
frac-2neg16.4%
add-sqr-sqrt0.0%
sqrt-unprod32.6%
sqr-neg32.6%
sqrt-unprod71.0%
add-sqr-sqrt71.2%
sub-neg71.2%
distribute-neg-in71.2%
metadata-eval71.2%
remove-double-neg71.2%
Applied egg-rr71.2%
expm1-def78.4%
expm1-log1p78.7%
+-commutative78.7%
Simplified78.7%
Final simplification77.0%
(FPCore (x y) :precision binary64 (if (<= y -1.1e+64) (+ 1.0 (/ (+ 2.0 (* x -2.0)) y)) (if (<= y 8.8e-39) (/ x (- 2.0 x)) (/ y (+ y -2.0)))))
double code(double x, double y) {
double tmp;
if (y <= -1.1e+64) {
tmp = 1.0 + ((2.0 + (x * -2.0)) / y);
} else if (y <= 8.8e-39) {
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.1d+64)) then
tmp = 1.0d0 + ((2.0d0 + (x * (-2.0d0))) / y)
else if (y <= 8.8d-39) 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.1e+64) {
tmp = 1.0 + ((2.0 + (x * -2.0)) / y);
} else if (y <= 8.8e-39) {
tmp = x / (2.0 - x);
} else {
tmp = y / (y + -2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.1e+64: tmp = 1.0 + ((2.0 + (x * -2.0)) / y) elif y <= 8.8e-39: tmp = x / (2.0 - x) else: tmp = y / (y + -2.0) return tmp
function code(x, y) tmp = 0.0 if (y <= -1.1e+64) tmp = Float64(1.0 + Float64(Float64(2.0 + Float64(x * -2.0)) / y)); elseif (y <= 8.8e-39) 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.1e+64) tmp = 1.0 + ((2.0 + (x * -2.0)) / y); elseif (y <= 8.8e-39) tmp = x / (2.0 - x); else tmp = y / (y + -2.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.1e+64], N[(1.0 + N[(N[(2.0 + N[(x * -2.0), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8.8e-39], 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.1 \cdot 10^{+64}:\\
\;\;\;\;1 + \frac{2 + x \cdot -2}{y}\\
\mathbf{elif}\;y \leq 8.8 \cdot 10^{-39}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y + -2}\\
\end{array}
\end{array}
if y < -1.10000000000000001e64Initial program 100.0%
flip--28.6%
associate-/r/28.6%
metadata-eval28.6%
pow228.6%
Applied egg-rr28.6%
associate-*l/26.4%
associate-+r+26.4%
+-commutative26.4%
Simplified26.4%
Taylor expanded in y around -inf 82.2%
Simplified82.2%
if -1.10000000000000001e64 < y < 8.80000000000000003e-39Initial program 100.0%
Taylor expanded in y around 0 74.1%
if 8.80000000000000003e-39 < y Initial program 100.0%
Taylor expanded in x around 0 78.7%
mul-1-neg78.7%
distribute-neg-frac78.7%
Simplified78.7%
expm1-log1p-u78.4%
expm1-udef71.2%
add-sqr-sqrt0.0%
sqrt-unprod4.8%
sqr-neg4.8%
sqrt-unprod13.4%
add-sqr-sqrt16.4%
frac-2neg16.4%
add-sqr-sqrt0.0%
sqrt-unprod32.6%
sqr-neg32.6%
sqrt-unprod71.0%
add-sqr-sqrt71.2%
sub-neg71.2%
distribute-neg-in71.2%
metadata-eval71.2%
remove-double-neg71.2%
Applied egg-rr71.2%
expm1-def78.4%
expm1-log1p78.7%
+-commutative78.7%
Simplified78.7%
Final simplification77.1%
(FPCore (x y) :precision binary64 (if (<= y -1.15e+64) 1.0 (if (<= y 330.0) -1.0 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -1.15e+64) {
tmp = 1.0;
} else if (y <= 330.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 (y <= (-1.15d+64)) then
tmp = 1.0d0
else if (y <= 330.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 (y <= -1.15e+64) {
tmp = 1.0;
} else if (y <= 330.0) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.15e+64: tmp = 1.0 elif y <= 330.0: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -1.15e+64) tmp = 1.0; elseif (y <= 330.0) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.15e+64) tmp = 1.0; elseif (y <= 330.0) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.15e+64], 1.0, If[LessEqual[y, 330.0], -1.0, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.15 \cdot 10^{+64}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 330:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.15e64 or 330 < y Initial program 100.0%
Taylor expanded in y around inf 80.8%
if -1.15e64 < y < 330Initial program 100.0%
Taylor expanded in x around inf 49.4%
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%
Taylor expanded in x around inf 35.6%
Final simplification35.6%
(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 2024027
(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))))