
(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 (- 0.918938533204673 (fma y (- 0.5 x) x)))
double code(double x, double y) {
return 0.918938533204673 - fma(y, (0.5 - x), x);
}
function code(x, y) return Float64(0.918938533204673 - fma(y, Float64(0.5 - x), x)) end
code[x_, y_] := N[(0.918938533204673 - N[(y * N[(0.5 - x), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, x\right)
\end{array}
Initial program 100.0%
+-commutative100.0%
cancel-sign-sub-inv100.0%
+-commutative100.0%
associate-+r+100.0%
cancel-sign-sub-inv100.0%
associate-+l-100.0%
sub-neg100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
associate--r+100.0%
distribute-lft-out--100.0%
unsub-neg100.0%
fma-neg100.0%
unsub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(if (<= x -2.75e+218)
(* y x)
(if (<= x -13500000000.0)
(- x)
(if (<= x -4.5e-146)
(* y -0.5)
(if (<= x -3.5e-202)
0.918938533204673
(if (<= x 5e-302)
(* y -0.5)
(if (<= x 0.92)
0.918938533204673
(if (or (<= x 4.5e+79)
(and (not (<= x 4.2e+231)) (<= x 6.6e+285)))
(- x)
(* y x)))))))))
double code(double x, double y) {
double tmp;
if (x <= -2.75e+218) {
tmp = y * x;
} else if (x <= -13500000000.0) {
tmp = -x;
} else if (x <= -4.5e-146) {
tmp = y * -0.5;
} else if (x <= -3.5e-202) {
tmp = 0.918938533204673;
} else if (x <= 5e-302) {
tmp = y * -0.5;
} else if (x <= 0.92) {
tmp = 0.918938533204673;
} else if ((x <= 4.5e+79) || (!(x <= 4.2e+231) && (x <= 6.6e+285))) {
tmp = -x;
} else {
tmp = y * x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-2.75d+218)) then
tmp = y * x
else if (x <= (-13500000000.0d0)) then
tmp = -x
else if (x <= (-4.5d-146)) then
tmp = y * (-0.5d0)
else if (x <= (-3.5d-202)) then
tmp = 0.918938533204673d0
else if (x <= 5d-302) then
tmp = y * (-0.5d0)
else if (x <= 0.92d0) then
tmp = 0.918938533204673d0
else if ((x <= 4.5d+79) .or. (.not. (x <= 4.2d+231)) .and. (x <= 6.6d+285)) then
tmp = -x
else
tmp = y * x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -2.75e+218) {
tmp = y * x;
} else if (x <= -13500000000.0) {
tmp = -x;
} else if (x <= -4.5e-146) {
tmp = y * -0.5;
} else if (x <= -3.5e-202) {
tmp = 0.918938533204673;
} else if (x <= 5e-302) {
tmp = y * -0.5;
} else if (x <= 0.92) {
tmp = 0.918938533204673;
} else if ((x <= 4.5e+79) || (!(x <= 4.2e+231) && (x <= 6.6e+285))) {
tmp = -x;
} else {
tmp = y * x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2.75e+218: tmp = y * x elif x <= -13500000000.0: tmp = -x elif x <= -4.5e-146: tmp = y * -0.5 elif x <= -3.5e-202: tmp = 0.918938533204673 elif x <= 5e-302: tmp = y * -0.5 elif x <= 0.92: tmp = 0.918938533204673 elif (x <= 4.5e+79) or (not (x <= 4.2e+231) and (x <= 6.6e+285)): tmp = -x else: tmp = y * x return tmp
function code(x, y) tmp = 0.0 if (x <= -2.75e+218) tmp = Float64(y * x); elseif (x <= -13500000000.0) tmp = Float64(-x); elseif (x <= -4.5e-146) tmp = Float64(y * -0.5); elseif (x <= -3.5e-202) tmp = 0.918938533204673; elseif (x <= 5e-302) tmp = Float64(y * -0.5); elseif (x <= 0.92) tmp = 0.918938533204673; elseif ((x <= 4.5e+79) || (!(x <= 4.2e+231) && (x <= 6.6e+285))) tmp = Float64(-x); else tmp = Float64(y * x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2.75e+218) tmp = y * x; elseif (x <= -13500000000.0) tmp = -x; elseif (x <= -4.5e-146) tmp = y * -0.5; elseif (x <= -3.5e-202) tmp = 0.918938533204673; elseif (x <= 5e-302) tmp = y * -0.5; elseif (x <= 0.92) tmp = 0.918938533204673; elseif ((x <= 4.5e+79) || (~((x <= 4.2e+231)) && (x <= 6.6e+285))) tmp = -x; else tmp = y * x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2.75e+218], N[(y * x), $MachinePrecision], If[LessEqual[x, -13500000000.0], (-x), If[LessEqual[x, -4.5e-146], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, -3.5e-202], 0.918938533204673, If[LessEqual[x, 5e-302], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 0.92], 0.918938533204673, If[Or[LessEqual[x, 4.5e+79], And[N[Not[LessEqual[x, 4.2e+231]], $MachinePrecision], LessEqual[x, 6.6e+285]]], (-x), N[(y * x), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.75 \cdot 10^{+218}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;x \leq -13500000000:\\
\;\;\;\;-x\\
\mathbf{elif}\;x \leq -4.5 \cdot 10^{-146}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq -3.5 \cdot 10^{-202}:\\
\;\;\;\;0.918938533204673\\
\mathbf{elif}\;x \leq 5 \cdot 10^{-302}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 0.92:\\
\;\;\;\;0.918938533204673\\
\mathbf{elif}\;x \leq 4.5 \cdot 10^{+79} \lor \neg \left(x \leq 4.2 \cdot 10^{+231}\right) \land x \leq 6.6 \cdot 10^{+285}:\\
\;\;\;\;-x\\
\mathbf{else}:\\
\;\;\;\;y \cdot x\\
\end{array}
\end{array}
if x < -2.7500000000000002e218 or 4.49999999999999994e79 < x < 4.19999999999999969e231 or 6.5999999999999995e285 < 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 70.4%
if -2.7500000000000002e218 < x < -1.35e10 or 0.92000000000000004 < x < 4.49999999999999994e79 or 4.19999999999999969e231 < x < 6.5999999999999995e285Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 96.9%
Taylor expanded in y around 0 65.7%
neg-mul-165.7%
Simplified65.7%
if -1.35e10 < x < -4.5000000000000001e-146 or -3.4999999999999999e-202 < x < 5.00000000000000033e-302Initial program 99.9%
+-commutative99.9%
cancel-sign-sub-inv99.9%
+-commutative99.9%
associate-+r+99.9%
cancel-sign-sub-inv99.9%
associate-+l-99.9%
sub-neg99.9%
distribute-rgt-in99.9%
metadata-eval99.9%
neg-mul-199.9%
associate--r+99.9%
distribute-lft-out--100.0%
unsub-neg100.0%
fma-neg100.0%
unsub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 68.8%
Taylor expanded in x around 0 65.0%
*-commutative65.0%
Simplified65.0%
if -4.5000000000000001e-146 < x < -3.4999999999999999e-202 or 5.00000000000000033e-302 < x < 0.92000000000000004Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 63.7%
Taylor expanded in x around 0 62.0%
Final simplification65.7%
(FPCore (x y)
:precision binary64
(if (<= x -1.5e+219)
(* y x)
(if (<= x -230000000.0)
(- x)
(if (<= x 0.92)
0.918938533204673
(if (or (<= x 1.9e+79) (and (not (<= x 3e+243)) (<= x 4e+283)))
(- x)
(* y x))))))
double code(double x, double y) {
double tmp;
if (x <= -1.5e+219) {
tmp = y * x;
} else if (x <= -230000000.0) {
tmp = -x;
} else if (x <= 0.92) {
tmp = 0.918938533204673;
} else if ((x <= 1.9e+79) || (!(x <= 3e+243) && (x <= 4e+283))) {
tmp = -x;
} else {
tmp = y * 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.5d+219)) then
tmp = y * x
else if (x <= (-230000000.0d0)) then
tmp = -x
else if (x <= 0.92d0) then
tmp = 0.918938533204673d0
else if ((x <= 1.9d+79) .or. (.not. (x <= 3d+243)) .and. (x <= 4d+283)) then
tmp = -x
else
tmp = y * x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.5e+219) {
tmp = y * x;
} else if (x <= -230000000.0) {
tmp = -x;
} else if (x <= 0.92) {
tmp = 0.918938533204673;
} else if ((x <= 1.9e+79) || (!(x <= 3e+243) && (x <= 4e+283))) {
tmp = -x;
} else {
tmp = y * x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.5e+219: tmp = y * x elif x <= -230000000.0: tmp = -x elif x <= 0.92: tmp = 0.918938533204673 elif (x <= 1.9e+79) or (not (x <= 3e+243) and (x <= 4e+283)): tmp = -x else: tmp = y * x return tmp
function code(x, y) tmp = 0.0 if (x <= -1.5e+219) tmp = Float64(y * x); elseif (x <= -230000000.0) tmp = Float64(-x); elseif (x <= 0.92) tmp = 0.918938533204673; elseif ((x <= 1.9e+79) || (!(x <= 3e+243) && (x <= 4e+283))) tmp = Float64(-x); else tmp = Float64(y * x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.5e+219) tmp = y * x; elseif (x <= -230000000.0) tmp = -x; elseif (x <= 0.92) tmp = 0.918938533204673; elseif ((x <= 1.9e+79) || (~((x <= 3e+243)) && (x <= 4e+283))) tmp = -x; else tmp = y * x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.5e+219], N[(y * x), $MachinePrecision], If[LessEqual[x, -230000000.0], (-x), If[LessEqual[x, 0.92], 0.918938533204673, If[Or[LessEqual[x, 1.9e+79], And[N[Not[LessEqual[x, 3e+243]], $MachinePrecision], LessEqual[x, 4e+283]]], (-x), N[(y * x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.5 \cdot 10^{+219}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;x \leq -230000000:\\
\;\;\;\;-x\\
\mathbf{elif}\;x \leq 0.92:\\
\;\;\;\;0.918938533204673\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{+79} \lor \neg \left(x \leq 3 \cdot 10^{+243}\right) \land x \leq 4 \cdot 10^{+283}:\\
\;\;\;\;-x\\
\mathbf{else}:\\
\;\;\;\;y \cdot x\\
\end{array}
\end{array}
if x < -1.4999999999999999e219 or 1.9000000000000001e79 < x < 2.99999999999999984e243 or 3.99999999999999982e283 < 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 70.4%
if -1.4999999999999999e219 < x < -2.3e8 or 0.92000000000000004 < x < 1.9000000000000001e79 or 2.99999999999999984e243 < x < 3.99999999999999982e283Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 96.6%
Taylor expanded in y around 0 64.9%
neg-mul-164.9%
Simplified64.9%
if -2.3e8 < x < 0.92000000000000004Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 51.2%
Taylor expanded in x around 0 48.7%
Final simplification58.5%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* x (+ y -1.0))))
(if (<= x -1.15e-10)
t_0
(if (<= x -3.05e-148)
(* y -0.5)
(if (<= x -3e-202)
0.918938533204673
(if (<= x 7.8e-306)
(* y -0.5)
(if (<= x 140000.0) (- 0.918938533204673 x) t_0)))))))
double code(double x, double y) {
double t_0 = x * (y + -1.0);
double tmp;
if (x <= -1.15e-10) {
tmp = t_0;
} else if (x <= -3.05e-148) {
tmp = y * -0.5;
} else if (x <= -3e-202) {
tmp = 0.918938533204673;
} else if (x <= 7.8e-306) {
tmp = y * -0.5;
} else if (x <= 140000.0) {
tmp = 0.918938533204673 - x;
} 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 + (-1.0d0))
if (x <= (-1.15d-10)) then
tmp = t_0
else if (x <= (-3.05d-148)) then
tmp = y * (-0.5d0)
else if (x <= (-3d-202)) then
tmp = 0.918938533204673d0
else if (x <= 7.8d-306) then
tmp = y * (-0.5d0)
else if (x <= 140000.0d0) then
tmp = 0.918938533204673d0 - x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x * (y + -1.0);
double tmp;
if (x <= -1.15e-10) {
tmp = t_0;
} else if (x <= -3.05e-148) {
tmp = y * -0.5;
} else if (x <= -3e-202) {
tmp = 0.918938533204673;
} else if (x <= 7.8e-306) {
tmp = y * -0.5;
} else if (x <= 140000.0) {
tmp = 0.918938533204673 - x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = x * (y + -1.0) tmp = 0 if x <= -1.15e-10: tmp = t_0 elif x <= -3.05e-148: tmp = y * -0.5 elif x <= -3e-202: tmp = 0.918938533204673 elif x <= 7.8e-306: tmp = y * -0.5 elif x <= 140000.0: tmp = 0.918938533204673 - x else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(x * Float64(y + -1.0)) tmp = 0.0 if (x <= -1.15e-10) tmp = t_0; elseif (x <= -3.05e-148) tmp = Float64(y * -0.5); elseif (x <= -3e-202) tmp = 0.918938533204673; elseif (x <= 7.8e-306) tmp = Float64(y * -0.5); elseif (x <= 140000.0) tmp = Float64(0.918938533204673 - x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = x * (y + -1.0); tmp = 0.0; if (x <= -1.15e-10) tmp = t_0; elseif (x <= -3.05e-148) tmp = y * -0.5; elseif (x <= -3e-202) tmp = 0.918938533204673; elseif (x <= 7.8e-306) tmp = y * -0.5; elseif (x <= 140000.0) tmp = 0.918938533204673 - x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.15e-10], t$95$0, If[LessEqual[x, -3.05e-148], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, -3e-202], 0.918938533204673, If[LessEqual[x, 7.8e-306], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 140000.0], N[(0.918938533204673 - x), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(y + -1\right)\\
\mathbf{if}\;x \leq -1.15 \cdot 10^{-10}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -3.05 \cdot 10^{-148}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq -3 \cdot 10^{-202}:\\
\;\;\;\;0.918938533204673\\
\mathbf{elif}\;x \leq 7.8 \cdot 10^{-306}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 140000:\\
\;\;\;\;0.918938533204673 - x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.15000000000000004e-10 or 1.4e5 < x Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 97.5%
if -1.15000000000000004e-10 < x < -3.04999999999999988e-148 or -3.00000000000000011e-202 < x < 7.799999999999999e-306Initial program 100.0%
+-commutative100.0%
cancel-sign-sub-inv100.0%
+-commutative100.0%
associate-+r+100.0%
cancel-sign-sub-inv100.0%
associate-+l-100.0%
sub-neg100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
associate--r+100.0%
distribute-lft-out--100.0%
unsub-neg100.0%
fma-neg100.0%
unsub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 70.1%
Taylor expanded in x around 0 69.5%
*-commutative69.5%
Simplified69.5%
if -3.04999999999999988e-148 < x < -3.00000000000000011e-202Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 89.7%
Taylor expanded in x around 0 89.7%
if 7.799999999999999e-306 < x < 1.4e5Initial program 100.0%
+-commutative100.0%
cancel-sign-sub-inv100.0%
+-commutative100.0%
associate-+r+100.0%
cancel-sign-sub-inv100.0%
associate-+l-100.0%
sub-neg100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
associate--r+100.0%
distribute-lft-out--100.0%
unsub-neg100.0%
fma-neg100.0%
unsub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 59.8%
Final simplification82.8%
(FPCore (x y)
:precision binary64
(if (<= y -7.4e+270)
(* y -0.5)
(if (<= y -1.9e+86)
(* y x)
(if (<= y -380.0)
(* y -0.5)
(if (<= y 1.1) (- 0.918938533204673 x) (* y x))))))
double code(double x, double y) {
double tmp;
if (y <= -7.4e+270) {
tmp = y * -0.5;
} else if (y <= -1.9e+86) {
tmp = y * x;
} else if (y <= -380.0) {
tmp = y * -0.5;
} else if (y <= 1.1) {
tmp = 0.918938533204673 - x;
} else {
tmp = y * x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-7.4d+270)) then
tmp = y * (-0.5d0)
else if (y <= (-1.9d+86)) then
tmp = y * x
else if (y <= (-380.0d0)) then
tmp = y * (-0.5d0)
else if (y <= 1.1d0) then
tmp = 0.918938533204673d0 - x
else
tmp = y * x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -7.4e+270) {
tmp = y * -0.5;
} else if (y <= -1.9e+86) {
tmp = y * x;
} else if (y <= -380.0) {
tmp = y * -0.5;
} else if (y <= 1.1) {
tmp = 0.918938533204673 - x;
} else {
tmp = y * x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -7.4e+270: tmp = y * -0.5 elif y <= -1.9e+86: tmp = y * x elif y <= -380.0: tmp = y * -0.5 elif y <= 1.1: tmp = 0.918938533204673 - x else: tmp = y * x return tmp
function code(x, y) tmp = 0.0 if (y <= -7.4e+270) tmp = Float64(y * -0.5); elseif (y <= -1.9e+86) tmp = Float64(y * x); elseif (y <= -380.0) tmp = Float64(y * -0.5); elseif (y <= 1.1) tmp = Float64(0.918938533204673 - x); else tmp = Float64(y * x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -7.4e+270) tmp = y * -0.5; elseif (y <= -1.9e+86) tmp = y * x; elseif (y <= -380.0) tmp = y * -0.5; elseif (y <= 1.1) tmp = 0.918938533204673 - x; else tmp = y * x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -7.4e+270], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, -1.9e+86], N[(y * x), $MachinePrecision], If[LessEqual[y, -380.0], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 1.1], N[(0.918938533204673 - x), $MachinePrecision], N[(y * x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.4 \cdot 10^{+270}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq -1.9 \cdot 10^{+86}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;y \leq -380:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 1.1:\\
\;\;\;\;0.918938533204673 - x\\
\mathbf{else}:\\
\;\;\;\;y \cdot x\\
\end{array}
\end{array}
if y < -7.39999999999999988e270 or -1.89999999999999989e86 < y < -380Initial program 100.0%
+-commutative100.0%
cancel-sign-sub-inv100.0%
+-commutative100.0%
associate-+r+100.0%
cancel-sign-sub-inv100.0%
associate-+l-100.0%
sub-neg100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
associate--r+100.0%
distribute-lft-out--100.0%
unsub-neg100.0%
fma-neg100.0%
unsub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 100.0%
Taylor expanded in x around 0 73.9%
*-commutative73.9%
Simplified73.9%
if -7.39999999999999988e270 < y < -1.89999999999999989e86 or 1.1000000000000001 < y Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 59.1%
Taylor expanded in y around inf 58.6%
if -380 < y < 1.1000000000000001Initial program 100.0%
+-commutative100.0%
cancel-sign-sub-inv100.0%
+-commutative100.0%
associate-+r+100.0%
cancel-sign-sub-inv100.0%
associate-+l-100.0%
sub-neg100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
associate--r+100.0%
distribute-lft-out--100.0%
unsub-neg100.0%
fma-neg100.0%
unsub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 95.8%
Final simplification79.0%
(FPCore (x y) :precision binary64 (if (or (<= y -56000000.0) (not (<= y 1.38e+14))) (* y (- x 0.5)) (- (* x (+ y -1.0)) -0.918938533204673)))
double code(double x, double y) {
double tmp;
if ((y <= -56000000.0) || !(y <= 1.38e+14)) {
tmp = y * (x - 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 <= (-56000000.0d0)) .or. (.not. (y <= 1.38d+14))) then
tmp = y * (x - 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 <= -56000000.0) || !(y <= 1.38e+14)) {
tmp = y * (x - 0.5);
} else {
tmp = (x * (y + -1.0)) - -0.918938533204673;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -56000000.0) or not (y <= 1.38e+14): tmp = y * (x - 0.5) else: tmp = (x * (y + -1.0)) - -0.918938533204673 return tmp
function code(x, y) tmp = 0.0 if ((y <= -56000000.0) || !(y <= 1.38e+14)) tmp = Float64(y * Float64(x - 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 <= -56000000.0) || ~((y <= 1.38e+14))) tmp = y * (x - 0.5); else tmp = (x * (y + -1.0)) - -0.918938533204673; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -56000000.0], N[Not[LessEqual[y, 1.38e+14]], $MachinePrecision]], N[(y * N[(x - 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 -56000000 \lor \neg \left(y \leq 1.38 \cdot 10^{+14}\right):\\
\;\;\;\;y \cdot \left(x - 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(y + -1\right) - -0.918938533204673\\
\end{array}
\end{array}
if y < -5.6e7 or 1.38e14 < y Initial program 100.0%
+-commutative100.0%
cancel-sign-sub-inv100.0%
+-commutative100.0%
associate-+r+100.0%
cancel-sign-sub-inv100.0%
associate-+l-100.0%
sub-neg100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
associate--r+100.0%
distribute-lft-out--100.0%
unsub-neg100.0%
fma-neg100.0%
unsub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 100.0%
if -5.6e7 < y < 1.38e14Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 97.8%
Final simplification98.9%
(FPCore (x y) :precision binary64 (if (or (<= y -1.4) (not (<= y 1.0))) (* y (- x 0.5)) (- 0.918938533204673 x)))
double code(double x, double y) {
double tmp;
if ((y <= -1.4) || !(y <= 1.0)) {
tmp = y * (x - 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.4d0)) .or. (.not. (y <= 1.0d0))) then
tmp = y * (x - 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.4) || !(y <= 1.0)) {
tmp = y * (x - 0.5);
} else {
tmp = 0.918938533204673 - x;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.4) or not (y <= 1.0): tmp = y * (x - 0.5) else: tmp = 0.918938533204673 - x return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.4) || !(y <= 1.0)) tmp = Float64(y * Float64(x - 0.5)); else tmp = Float64(0.918938533204673 - x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -1.4) || ~((y <= 1.0))) tmp = y * (x - 0.5); else tmp = 0.918938533204673 - x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1.4], N[Not[LessEqual[y, 1.0]], $MachinePrecision]], N[(y * N[(x - 0.5), $MachinePrecision]), $MachinePrecision], N[(0.918938533204673 - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.4 \lor \neg \left(y \leq 1\right):\\
\;\;\;\;y \cdot \left(x - 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;0.918938533204673 - x\\
\end{array}
\end{array}
if y < -1.3999999999999999 or 1 < y Initial program 100.0%
+-commutative100.0%
cancel-sign-sub-inv100.0%
+-commutative100.0%
associate-+r+100.0%
cancel-sign-sub-inv100.0%
associate-+l-100.0%
sub-neg100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
associate--r+100.0%
distribute-lft-out--100.0%
unsub-neg100.0%
fma-neg100.0%
unsub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 98.9%
if -1.3999999999999999 < y < 1Initial program 100.0%
+-commutative100.0%
cancel-sign-sub-inv100.0%
+-commutative100.0%
associate-+r+100.0%
cancel-sign-sub-inv100.0%
associate-+l-100.0%
sub-neg100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
associate--r+100.0%
distribute-lft-out--100.0%
unsub-neg100.0%
fma-neg100.0%
unsub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 96.4%
Final simplification97.6%
(FPCore (x y) :precision binary64 (if (or (<= x -0.74) (not (<= x 0.62))) (* x (+ y -1.0)) (- 0.918938533204673 (* y 0.5))))
double code(double x, double y) {
double tmp;
if ((x <= -0.74) || !(x <= 0.62)) {
tmp = x * (y + -1.0);
} else {
tmp = 0.918938533204673 - (y * 0.5);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-0.74d0)) .or. (.not. (x <= 0.62d0))) then
tmp = x * (y + (-1.0d0))
else
tmp = 0.918938533204673d0 - (y * 0.5d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -0.74) || !(x <= 0.62)) {
tmp = x * (y + -1.0);
} else {
tmp = 0.918938533204673 - (y * 0.5);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -0.74) or not (x <= 0.62): tmp = x * (y + -1.0) else: tmp = 0.918938533204673 - (y * 0.5) return tmp
function code(x, y) tmp = 0.0 if ((x <= -0.74) || !(x <= 0.62)) tmp = Float64(x * Float64(y + -1.0)); else tmp = Float64(0.918938533204673 - Float64(y * 0.5)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -0.74) || ~((x <= 0.62))) tmp = x * (y + -1.0); else tmp = 0.918938533204673 - (y * 0.5); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -0.74], N[Not[LessEqual[x, 0.62]], $MachinePrecision]], N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision], N[(0.918938533204673 - N[(y * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.74 \lor \neg \left(x \leq 0.62\right):\\
\;\;\;\;x \cdot \left(y + -1\right)\\
\mathbf{else}:\\
\;\;\;\;0.918938533204673 - y \cdot 0.5\\
\end{array}
\end{array}
if x < -0.73999999999999999 or 0.619999999999999996 < x Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 97.8%
if -0.73999999999999999 < x < 0.619999999999999996Initial program 100.0%
+-commutative100.0%
cancel-sign-sub-inv100.0%
+-commutative100.0%
associate-+r+100.0%
cancel-sign-sub-inv100.0%
associate-+l-100.0%
sub-neg100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
associate--r+100.0%
distribute-lft-out--100.0%
unsub-neg100.0%
fma-neg100.0%
unsub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 97.5%
*-commutative97.5%
Simplified97.5%
Final simplification97.6%
(FPCore (x y) :precision binary64 (if (or (<= x -230000000.0) (not (<= x 0.92))) (- x) 0.918938533204673))
double code(double x, double y) {
double tmp;
if ((x <= -230000000.0) || !(x <= 0.92)) {
tmp = -x;
} 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 <= (-230000000.0d0)) .or. (.not. (x <= 0.92d0))) then
tmp = -x
else
tmp = 0.918938533204673d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -230000000.0) || !(x <= 0.92)) {
tmp = -x;
} else {
tmp = 0.918938533204673;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -230000000.0) or not (x <= 0.92): tmp = -x else: tmp = 0.918938533204673 return tmp
function code(x, y) tmp = 0.0 if ((x <= -230000000.0) || !(x <= 0.92)) tmp = Float64(-x); else tmp = 0.918938533204673; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -230000000.0) || ~((x <= 0.92))) tmp = -x; else tmp = 0.918938533204673; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -230000000.0], N[Not[LessEqual[x, 0.92]], $MachinePrecision]], (-x), 0.918938533204673]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -230000000 \lor \neg \left(x \leq 0.92\right):\\
\;\;\;\;-x\\
\mathbf{else}:\\
\;\;\;\;0.918938533204673\\
\end{array}
\end{array}
if x < -2.3e8 or 0.92000000000000004 < x Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 98.1%
Taylor expanded in y around 0 49.9%
neg-mul-149.9%
Simplified49.9%
if -2.3e8 < x < 0.92000000000000004Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 51.2%
Taylor expanded in x around 0 48.7%
Final simplification49.3%
(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.3%
Taylor expanded in x around 0 24.4%
Final simplification24.4%
herbie shell --seed 2024036
(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))