
(FPCore (x y) :precision binary64 (+ (- (* x (- y 1.0)) (* y 0.5)) 0.918938533204673))
double code(double x, double y) {
return ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x * (y - 1.0d0)) - (y * 0.5d0)) + 0.918938533204673d0
end function
public static double code(double x, double y) {
return ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673;
}
def code(x, y): return ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673
function code(x, y) return Float64(Float64(Float64(x * Float64(y - 1.0)) - Float64(y * 0.5)) + 0.918938533204673) end
function tmp = code(x, y) tmp = ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673; end
code[x_, y_] := N[(N[(N[(x * N[(y - 1.0), $MachinePrecision]), $MachinePrecision] - N[(y * 0.5), $MachinePrecision]), $MachinePrecision] + 0.918938533204673), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (+ (- (* x (- y 1.0)) (* y 0.5)) 0.918938533204673))
double code(double x, double y) {
return ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x * (y - 1.0d0)) - (y * 0.5d0)) + 0.918938533204673d0
end function
public static double code(double x, double y) {
return ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673;
}
def code(x, y): return ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673
function code(x, y) return Float64(Float64(Float64(x * Float64(y - 1.0)) - Float64(y * 0.5)) + 0.918938533204673) end
function tmp = code(x, y) tmp = ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673; end
code[x_, y_] := N[(N[(N[(x * N[(y - 1.0), $MachinePrecision]), $MachinePrecision] - N[(y * 0.5), $MachinePrecision]), $MachinePrecision] + 0.918938533204673), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673
\end{array}
(FPCore (x y) :precision binary64 (+ (- (* x y) x) (- 0.918938533204673 (* y 0.5))))
double code(double x, double y) {
return ((x * y) - x) + (0.918938533204673 - (y * 0.5));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x * y) - x) + (0.918938533204673d0 - (y * 0.5d0))
end function
public static double code(double x, double y) {
return ((x * y) - x) + (0.918938533204673 - (y * 0.5));
}
def code(x, y): return ((x * y) - x) + (0.918938533204673 - (y * 0.5))
function code(x, y) return Float64(Float64(Float64(x * y) - x) + Float64(0.918938533204673 - Float64(y * 0.5))) end
function tmp = code(x, y) tmp = ((x * y) - x) + (0.918938533204673 - (y * 0.5)); end
code[x_, y_] := N[(N[(N[(x * y), $MachinePrecision] - x), $MachinePrecision] + N[(0.918938533204673 - N[(y * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot y - x\right) + \left(0.918938533204673 - y \cdot 0.5\right)
\end{array}
Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
distribute-rgt-in100.0%
*-commutative100.0%
mul-1-neg100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- (- x) (* y 0.5))))
(if (<= y -1.3e+203)
(* x y)
(if (<= y -1.85)
t_0
(if (<= y 1.8)
(- (- -0.918938533204673) x)
(if (or (<= y 2.3e+190) (not (<= y 5.6e+274))) t_0 (* x y)))))))
double code(double x, double y) {
double t_0 = -x - (y * 0.5);
double tmp;
if (y <= -1.3e+203) {
tmp = x * y;
} else if (y <= -1.85) {
tmp = t_0;
} else if (y <= 1.8) {
tmp = -(-0.918938533204673) - x;
} else if ((y <= 2.3e+190) || !(y <= 5.6e+274)) {
tmp = t_0;
} else {
tmp = x * y;
}
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 (y <= (-1.3d+203)) then
tmp = x * y
else if (y <= (-1.85d0)) then
tmp = t_0
else if (y <= 1.8d0) then
tmp = -(-0.918938533204673d0) - x
else if ((y <= 2.3d+190) .or. (.not. (y <= 5.6d+274))) then
tmp = t_0
else
tmp = x * y
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = -x - (y * 0.5);
double tmp;
if (y <= -1.3e+203) {
tmp = x * y;
} else if (y <= -1.85) {
tmp = t_0;
} else if (y <= 1.8) {
tmp = -(-0.918938533204673) - x;
} else if ((y <= 2.3e+190) || !(y <= 5.6e+274)) {
tmp = t_0;
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y): t_0 = -x - (y * 0.5) tmp = 0 if y <= -1.3e+203: tmp = x * y elif y <= -1.85: tmp = t_0 elif y <= 1.8: tmp = -(-0.918938533204673) - x elif (y <= 2.3e+190) or not (y <= 5.6e+274): tmp = t_0 else: tmp = x * y return tmp
function code(x, y) t_0 = Float64(Float64(-x) - Float64(y * 0.5)) tmp = 0.0 if (y <= -1.3e+203) tmp = Float64(x * y); elseif (y <= -1.85) tmp = t_0; elseif (y <= 1.8) tmp = Float64(Float64(-(-0.918938533204673)) - x); elseif ((y <= 2.3e+190) || !(y <= 5.6e+274)) tmp = t_0; else tmp = Float64(x * y); end return tmp end
function tmp_2 = code(x, y) t_0 = -x - (y * 0.5); tmp = 0.0; if (y <= -1.3e+203) tmp = x * y; elseif (y <= -1.85) tmp = t_0; elseif (y <= 1.8) tmp = -(-0.918938533204673) - x; elseif ((y <= 2.3e+190) || ~((y <= 5.6e+274))) tmp = t_0; else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[((-x) - N[(y * 0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.3e+203], N[(x * y), $MachinePrecision], If[LessEqual[y, -1.85], t$95$0, If[LessEqual[y, 1.8], N[((--0.918938533204673) - x), $MachinePrecision], If[Or[LessEqual[y, 2.3e+190], N[Not[LessEqual[y, 5.6e+274]], $MachinePrecision]], t$95$0, N[(x * y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-x\right) - y \cdot 0.5\\
\mathbf{if}\;y \leq -1.3 \cdot 10^{+203}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;y \leq -1.85:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.8:\\
\;\;\;\;\left(--0.918938533204673\right) - x\\
\mathbf{elif}\;y \leq 2.3 \cdot 10^{+190} \lor \neg \left(y \leq 5.6 \cdot 10^{+274}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if y < -1.2999999999999999e203 or 2.3e190 < y < 5.60000000000000017e274Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 70.0%
Taylor expanded in y around inf 70.0%
Taylor expanded in x around inf 70.0%
if -1.2999999999999999e203 < y < -1.8500000000000001 or 1.80000000000000004 < y < 2.3e190 or 5.60000000000000017e274 < y Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 57.7%
neg-mul-157.7%
Simplified57.7%
Taylor expanded in y around inf 56.7%
*-commutative56.7%
Simplified56.7%
if -1.8500000000000001 < y < 1.80000000000000004Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 99.2%
neg-mul-199.2%
Simplified99.2%
Taylor expanded in y around 0 97.3%
Final simplification79.8%
(FPCore (x y) :precision binary64 (if (or (<= y -1.65) (not (<= y 1.8))) (- (* x y) (* y 0.5)) (- (- -0.918938533204673) x)))
double code(double x, double y) {
double tmp;
if ((y <= -1.65) || !(y <= 1.8)) {
tmp = (x * y) - (y * 0.5);
} else {
tmp = -(-0.918938533204673) - 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.65d0)) .or. (.not. (y <= 1.8d0))) then
tmp = (x * y) - (y * 0.5d0)
else
tmp = -(-0.918938533204673d0) - x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -1.65) || !(y <= 1.8)) {
tmp = (x * y) - (y * 0.5);
} else {
tmp = -(-0.918938533204673) - x;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.65) or not (y <= 1.8): tmp = (x * y) - (y * 0.5) else: tmp = -(-0.918938533204673) - x return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.65) || !(y <= 1.8)) tmp = Float64(Float64(x * y) - Float64(y * 0.5)); else tmp = Float64(Float64(-(-0.918938533204673)) - x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -1.65) || ~((y <= 1.8))) tmp = (x * y) - (y * 0.5); else tmp = -(-0.918938533204673) - x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1.65], N[Not[LessEqual[y, 1.8]], $MachinePrecision]], N[(N[(x * y), $MachinePrecision] - N[(y * 0.5), $MachinePrecision]), $MachinePrecision], N[((--0.918938533204673) - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.65 \lor \neg \left(y \leq 1.8\right):\\
\;\;\;\;x \cdot y - y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\left(--0.918938533204673\right) - x\\
\end{array}
\end{array}
if y < -1.6499999999999999 or 1.80000000000000004 < y Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 99.2%
*-commutative51.1%
Simplified99.2%
Taylor expanded in y around inf 96.8%
if -1.6499999999999999 < y < 1.80000000000000004Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 99.2%
neg-mul-199.2%
Simplified99.2%
Taylor expanded in y around 0 97.3%
Final simplification97.0%
(FPCore (x y) :precision binary64 (if (or (<= y -850000000000.0) (not (<= y 4000000.0))) (- (* x y) (* y 0.5)) (- (* x (+ y -1.0)) -0.918938533204673)))
double code(double x, double y) {
double tmp;
if ((y <= -850000000000.0) || !(y <= 4000000.0)) {
tmp = (x * y) - (y * 0.5);
} else {
tmp = (x * (y + -1.0)) - -0.918938533204673;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= (-850000000000.0d0)) .or. (.not. (y <= 4000000.0d0))) then
tmp = (x * y) - (y * 0.5d0)
else
tmp = (x * (y + (-1.0d0))) - (-0.918938533204673d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -850000000000.0) || !(y <= 4000000.0)) {
tmp = (x * y) - (y * 0.5);
} else {
tmp = (x * (y + -1.0)) - -0.918938533204673;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -850000000000.0) or not (y <= 4000000.0): tmp = (x * y) - (y * 0.5) else: tmp = (x * (y + -1.0)) - -0.918938533204673 return tmp
function code(x, y) tmp = 0.0 if ((y <= -850000000000.0) || !(y <= 4000000.0)) tmp = Float64(Float64(x * y) - Float64(y * 0.5)); else tmp = Float64(Float64(x * Float64(y + -1.0)) - -0.918938533204673); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -850000000000.0) || ~((y <= 4000000.0))) tmp = (x * y) - (y * 0.5); else tmp = (x * (y + -1.0)) - -0.918938533204673; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -850000000000.0], N[Not[LessEqual[y, 4000000.0]], $MachinePrecision]], N[(N[(x * y), $MachinePrecision] - N[(y * 0.5), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision] - -0.918938533204673), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -850000000000 \lor \neg \left(y \leq 4000000\right):\\
\;\;\;\;x \cdot y - y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(y + -1\right) - -0.918938533204673\\
\end{array}
\end{array}
if y < -8.5e11 or 4e6 < y Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 99.8%
*-commutative53.0%
Simplified99.8%
Taylor expanded in y around inf 99.8%
if -8.5e11 < y < 4e6Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 97.4%
Final simplification98.5%
(FPCore (x y) :precision binary64 (if (or (<= x -1.08e+18) (not (<= x 8e-41))) (- (* x (+ y -1.0)) -0.918938533204673) (- (- 0.918938533204673 (* y 0.5)) x)))
double code(double x, double y) {
double tmp;
if ((x <= -1.08e+18) || !(x <= 8e-41)) {
tmp = (x * (y + -1.0)) - -0.918938533204673;
} else {
tmp = (0.918938533204673 - (y * 0.5)) - x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-1.08d+18)) .or. (.not. (x <= 8d-41))) then
tmp = (x * (y + (-1.0d0))) - (-0.918938533204673d0)
else
tmp = (0.918938533204673d0 - (y * 0.5d0)) - x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -1.08e+18) || !(x <= 8e-41)) {
tmp = (x * (y + -1.0)) - -0.918938533204673;
} else {
tmp = (0.918938533204673 - (y * 0.5)) - x;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.08e+18) or not (x <= 8e-41): tmp = (x * (y + -1.0)) - -0.918938533204673 else: tmp = (0.918938533204673 - (y * 0.5)) - x return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.08e+18) || !(x <= 8e-41)) tmp = Float64(Float64(x * Float64(y + -1.0)) - -0.918938533204673); else tmp = Float64(Float64(0.918938533204673 - Float64(y * 0.5)) - x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1.08e+18) || ~((x <= 8e-41))) tmp = (x * (y + -1.0)) - -0.918938533204673; else tmp = (0.918938533204673 - (y * 0.5)) - x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.08e+18], N[Not[LessEqual[x, 8e-41]], $MachinePrecision]], N[(N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision] - -0.918938533204673), $MachinePrecision], N[(N[(0.918938533204673 - N[(y * 0.5), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.08 \cdot 10^{+18} \lor \neg \left(x \leq 8 \cdot 10^{-41}\right):\\
\;\;\;\;x \cdot \left(y + -1\right) - -0.918938533204673\\
\mathbf{else}:\\
\;\;\;\;\left(0.918938533204673 - y \cdot 0.5\right) - x\\
\end{array}
\end{array}
if x < -1.08e18 or 8.00000000000000005e-41 < x Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
if -1.08e18 < x < 8.00000000000000005e-41Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 99.5%
neg-mul-199.5%
Simplified99.5%
Final simplification99.7%
(FPCore (x y) :precision binary64 (if (or (<= x -1.08e+18) (not (<= x 8e-41))) (- (- (* x y) x) -0.918938533204673) (- (- 0.918938533204673 (* y 0.5)) x)))
double code(double x, double y) {
double tmp;
if ((x <= -1.08e+18) || !(x <= 8e-41)) {
tmp = ((x * y) - x) - -0.918938533204673;
} else {
tmp = (0.918938533204673 - (y * 0.5)) - x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-1.08d+18)) .or. (.not. (x <= 8d-41))) then
tmp = ((x * y) - x) - (-0.918938533204673d0)
else
tmp = (0.918938533204673d0 - (y * 0.5d0)) - x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -1.08e+18) || !(x <= 8e-41)) {
tmp = ((x * y) - x) - -0.918938533204673;
} else {
tmp = (0.918938533204673 - (y * 0.5)) - x;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.08e+18) or not (x <= 8e-41): tmp = ((x * y) - x) - -0.918938533204673 else: tmp = (0.918938533204673 - (y * 0.5)) - x return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.08e+18) || !(x <= 8e-41)) tmp = Float64(Float64(Float64(x * y) - x) - -0.918938533204673); else tmp = Float64(Float64(0.918938533204673 - Float64(y * 0.5)) - x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1.08e+18) || ~((x <= 8e-41))) tmp = ((x * y) - x) - -0.918938533204673; else tmp = (0.918938533204673 - (y * 0.5)) - x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.08e+18], N[Not[LessEqual[x, 8e-41]], $MachinePrecision]], N[(N[(N[(x * y), $MachinePrecision] - x), $MachinePrecision] - -0.918938533204673), $MachinePrecision], N[(N[(0.918938533204673 - N[(y * 0.5), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.08 \cdot 10^{+18} \lor \neg \left(x \leq 8 \cdot 10^{-41}\right):\\
\;\;\;\;\left(x \cdot y - x\right) - -0.918938533204673\\
\mathbf{else}:\\
\;\;\;\;\left(0.918938533204673 - y \cdot 0.5\right) - x\\
\end{array}
\end{array}
if x < -1.08e18 or 8.00000000000000005e-41 < x Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
distribute-rgt-in100.0%
*-commutative100.0%
mul-1-neg100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 100.0%
if -1.08e18 < x < 8.00000000000000005e-41Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 99.5%
neg-mul-199.5%
Simplified99.5%
Final simplification99.7%
(FPCore (x y) :precision binary64 (if (or (<= y -1.92) (not (<= y 1.0))) (* x y) (- (- -0.918938533204673) x)))
double code(double x, double y) {
double tmp;
if ((y <= -1.92) || !(y <= 1.0)) {
tmp = x * y;
} else {
tmp = -(-0.918938533204673) - 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.92d0)) .or. (.not. (y <= 1.0d0))) then
tmp = x * y
else
tmp = -(-0.918938533204673d0) - x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -1.92) || !(y <= 1.0)) {
tmp = x * y;
} else {
tmp = -(-0.918938533204673) - x;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.92) or not (y <= 1.0): tmp = x * y else: tmp = -(-0.918938533204673) - x return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.92) || !(y <= 1.0)) tmp = Float64(x * y); else tmp = Float64(Float64(-(-0.918938533204673)) - x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -1.92) || ~((y <= 1.0))) tmp = x * y; else tmp = -(-0.918938533204673) - x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1.92], N[Not[LessEqual[y, 1.0]], $MachinePrecision]], N[(x * y), $MachinePrecision], N[((--0.918938533204673) - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.92 \lor \neg \left(y \leq 1\right):\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;\left(--0.918938533204673\right) - x\\
\end{array}
\end{array}
if y < -1.9199999999999999 or 1 < y Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 51.8%
Taylor expanded in y around inf 49.4%
Taylor expanded in x around inf 49.1%
if -1.9199999999999999 < y < 1Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 99.2%
neg-mul-199.2%
Simplified99.2%
Taylor expanded in y around 0 97.3%
Final simplification74.7%
(FPCore (x y) :precision binary64 (if (<= y -1.65) (- (* x y) -0.918938533204673) (if (<= y 1.6) (- (- -0.918938533204673) x) (* x y))))
double code(double x, double y) {
double tmp;
if (y <= -1.65) {
tmp = (x * y) - -0.918938533204673;
} else if (y <= 1.6) {
tmp = -(-0.918938533204673) - x;
} else {
tmp = 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 <= (-1.65d0)) then
tmp = (x * y) - (-0.918938533204673d0)
else if (y <= 1.6d0) then
tmp = -(-0.918938533204673d0) - x
else
tmp = x * y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.65) {
tmp = (x * y) - -0.918938533204673;
} else if (y <= 1.6) {
tmp = -(-0.918938533204673) - x;
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.65: tmp = (x * y) - -0.918938533204673 elif y <= 1.6: tmp = -(-0.918938533204673) - x else: tmp = x * y return tmp
function code(x, y) tmp = 0.0 if (y <= -1.65) tmp = Float64(Float64(x * y) - -0.918938533204673); elseif (y <= 1.6) tmp = Float64(Float64(-(-0.918938533204673)) - x); else tmp = Float64(x * y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.65) tmp = (x * y) - -0.918938533204673; elseif (y <= 1.6) tmp = -(-0.918938533204673) - x; else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.65], N[(N[(x * y), $MachinePrecision] - -0.918938533204673), $MachinePrecision], If[LessEqual[y, 1.6], N[((--0.918938533204673) - x), $MachinePrecision], N[(x * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.65:\\
\;\;\;\;x \cdot y - -0.918938533204673\\
\mathbf{elif}\;y \leq 1.6:\\
\;\;\;\;\left(--0.918938533204673\right) - x\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if y < -1.6499999999999999Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 55.3%
Taylor expanded in y around inf 52.1%
if -1.6499999999999999 < y < 1.6000000000000001Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 99.2%
neg-mul-199.2%
Simplified99.2%
Taylor expanded in y around 0 97.3%
if 1.6000000000000001 < y Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 48.5%
Taylor expanded in y around inf 46.7%
Taylor expanded in x around inf 47.1%
Final simplification74.9%
(FPCore (x y) :precision binary64 (if (or (<= x -1.08e+18) (not (<= x 0.92))) (* x y) 0.918938533204673))
double code(double x, double y) {
double tmp;
if ((x <= -1.08e+18) || !(x <= 0.92)) {
tmp = x * y;
} else {
tmp = 0.918938533204673;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-1.08d+18)) .or. (.not. (x <= 0.92d0))) then
tmp = x * y
else
tmp = 0.918938533204673d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -1.08e+18) || !(x <= 0.92)) {
tmp = x * y;
} else {
tmp = 0.918938533204673;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.08e+18) or not (x <= 0.92): tmp = x * y else: tmp = 0.918938533204673 return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.08e+18) || !(x <= 0.92)) tmp = Float64(x * y); else tmp = 0.918938533204673; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1.08e+18) || ~((x <= 0.92))) tmp = x * y; else tmp = 0.918938533204673; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.08e+18], N[Not[LessEqual[x, 0.92]], $MachinePrecision]], N[(x * y), $MachinePrecision], 0.918938533204673]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.08 \cdot 10^{+18} \lor \neg \left(x \leq 0.92\right):\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;0.918938533204673\\
\end{array}
\end{array}
if x < -1.08e18 or 0.92000000000000004 < x Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
Taylor expanded in y around inf 48.8%
Taylor expanded in x around inf 48.9%
if -1.08e18 < x < 0.92000000000000004Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 55.3%
Taylor expanded in y around inf 51.2%
Taylor expanded in x around 0 50.9%
Final simplification50.0%
(FPCore (x y) :precision binary64 (+ 0.918938533204673 (- (* x (+ y -1.0)) (* y 0.5))))
double code(double x, double y) {
return 0.918938533204673 + ((x * (y + -1.0)) - (y * 0.5));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 0.918938533204673d0 + ((x * (y + (-1.0d0))) - (y * 0.5d0))
end function
public static double code(double x, double y) {
return 0.918938533204673 + ((x * (y + -1.0)) - (y * 0.5));
}
def code(x, y): return 0.918938533204673 + ((x * (y + -1.0)) - (y * 0.5))
function code(x, y) return Float64(0.918938533204673 + Float64(Float64(x * Float64(y + -1.0)) - Float64(y * 0.5))) end
function tmp = code(x, y) tmp = 0.918938533204673 + ((x * (y + -1.0)) - (y * 0.5)); end
code[x_, y_] := N[(0.918938533204673 + N[(N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision] - N[(y * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.918938533204673 + \left(x \cdot \left(y + -1\right) - y \cdot 0.5\right)
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y) :precision binary64 0.918938533204673)
double code(double x, double y) {
return 0.918938533204673;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 0.918938533204673d0
end function
public static double code(double x, double y) {
return 0.918938533204673;
}
def code(x, y): return 0.918938533204673
function code(x, y) return 0.918938533204673 end
function tmp = code(x, y) tmp = 0.918938533204673; end
code[x_, y_] := 0.918938533204673
\begin{array}{l}
\\
0.918938533204673
\end{array}
Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 76.4%
Taylor expanded in y around inf 50.1%
Taylor expanded in x around 0 28.0%
Final simplification28.0%
herbie shell --seed 2024039
(FPCore (x y)
:name "Numeric.SpecFunctions:logGamma from math-functions-0.1.5.2, A"
:precision binary64
(+ (- (* x (- y 1.0)) (* y 0.5)) 0.918938533204673))