
(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 12 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 (fma y (+ x -0.5) (- 0.918938533204673 x)))
double code(double x, double y) {
return fma(y, (x + -0.5), (0.918938533204673 - x));
}
function code(x, y) return fma(y, Float64(x + -0.5), Float64(0.918938533204673 - x)) end
code[x_, y_] := N[(y * N[(x + -0.5), $MachinePrecision] + N[(0.918938533204673 - x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y, x + -0.5, 0.918938533204673 - x\right)
\end{array}
Initial program 100.0%
cancel-sign-sub-inv100.0%
+-commutative100.0%
sub-neg100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
associate-+r+100.0%
unsub-neg100.0%
associate-+l-100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
distribute-lft-out100.0%
fma-neg100.0%
+-commutative100.0%
metadata-eval100.0%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
+-commutative100.0%
unsub-neg100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(if (<= x -1.45e+204)
(- x)
(if (<= x -0.95)
(* y x)
(if (<= x 16.5)
0.918938533204673
(if (or (<= x 9e+38) (not (<= x 5.5e+141))) (- x) (* y x))))))
double code(double x, double y) {
double tmp;
if (x <= -1.45e+204) {
tmp = -x;
} else if (x <= -0.95) {
tmp = y * x;
} else if (x <= 16.5) {
tmp = 0.918938533204673;
} else if ((x <= 9e+38) || !(x <= 5.5e+141)) {
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.45d+204)) then
tmp = -x
else if (x <= (-0.95d0)) then
tmp = y * x
else if (x <= 16.5d0) then
tmp = 0.918938533204673d0
else if ((x <= 9d+38) .or. (.not. (x <= 5.5d+141))) 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.45e+204) {
tmp = -x;
} else if (x <= -0.95) {
tmp = y * x;
} else if (x <= 16.5) {
tmp = 0.918938533204673;
} else if ((x <= 9e+38) || !(x <= 5.5e+141)) {
tmp = -x;
} else {
tmp = y * x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.45e+204: tmp = -x elif x <= -0.95: tmp = y * x elif x <= 16.5: tmp = 0.918938533204673 elif (x <= 9e+38) or not (x <= 5.5e+141): tmp = -x else: tmp = y * x return tmp
function code(x, y) tmp = 0.0 if (x <= -1.45e+204) tmp = Float64(-x); elseif (x <= -0.95) tmp = Float64(y * x); elseif (x <= 16.5) tmp = 0.918938533204673; elseif ((x <= 9e+38) || !(x <= 5.5e+141)) tmp = Float64(-x); else tmp = Float64(y * x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.45e+204) tmp = -x; elseif (x <= -0.95) tmp = y * x; elseif (x <= 16.5) tmp = 0.918938533204673; elseif ((x <= 9e+38) || ~((x <= 5.5e+141))) tmp = -x; else tmp = y * x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.45e+204], (-x), If[LessEqual[x, -0.95], N[(y * x), $MachinePrecision], If[LessEqual[x, 16.5], 0.918938533204673, If[Or[LessEqual[x, 9e+38], N[Not[LessEqual[x, 5.5e+141]], $MachinePrecision]], (-x), N[(y * x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.45 \cdot 10^{+204}:\\
\;\;\;\;-x\\
\mathbf{elif}\;x \leq -0.95:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;x \leq 16.5:\\
\;\;\;\;0.918938533204673\\
\mathbf{elif}\;x \leq 9 \cdot 10^{+38} \lor \neg \left(x \leq 5.5 \cdot 10^{+141}\right):\\
\;\;\;\;-x\\
\mathbf{else}:\\
\;\;\;\;y \cdot x\\
\end{array}
\end{array}
if x < -1.45000000000000002e204 or 16.5 < x < 8.99999999999999961e38 or 5.49999999999999967e141 < x Initial program 99.9%
cancel-sign-sub-inv99.9%
+-commutative99.9%
sub-neg99.9%
distribute-rgt-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
associate-+r+100.0%
unsub-neg100.0%
associate-+l-100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
distribute-lft-out100.0%
fma-neg100.0%
+-commutative100.0%
metadata-eval100.0%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
+-commutative100.0%
unsub-neg100.0%
Simplified100.0%
fma-undefine100.0%
associate-+r-100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 97.6%
Taylor expanded in y around 0 67.8%
neg-mul-167.8%
Simplified67.8%
if -1.45000000000000002e204 < x < -0.94999999999999996 or 8.99999999999999961e38 < x < 5.49999999999999967e141Initial program 100.0%
cancel-sign-sub-inv100.0%
+-commutative100.0%
sub-neg100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
associate-+r+100.0%
unsub-neg100.0%
associate-+l-100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
distribute-lft-out100.0%
fma-neg100.0%
+-commutative100.0%
metadata-eval100.0%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
+-commutative100.0%
unsub-neg100.0%
Simplified100.0%
fma-undefine100.0%
associate-+r-100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 99.3%
Taylor expanded in y around inf 63.6%
if -0.94999999999999996 < x < 16.5Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 98.4%
Taylor expanded in y around 0 53.1%
Final simplification59.3%
(FPCore (x y) :precision binary64 (if (or (<= y -1.85e-13) (not (<= y 0.00325))) (+ (* y x) (- 0.918938533204673 (* y 0.5))) (- (+ 0.918938533204673 (* y x)) x)))
double code(double x, double y) {
double tmp;
if ((y <= -1.85e-13) || !(y <= 0.00325)) {
tmp = (y * x) + (0.918938533204673 - (y * 0.5));
} else {
tmp = (0.918938533204673 + (y * x)) - 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.85d-13)) .or. (.not. (y <= 0.00325d0))) then
tmp = (y * x) + (0.918938533204673d0 - (y * 0.5d0))
else
tmp = (0.918938533204673d0 + (y * x)) - x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -1.85e-13) || !(y <= 0.00325)) {
tmp = (y * x) + (0.918938533204673 - (y * 0.5));
} else {
tmp = (0.918938533204673 + (y * x)) - x;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.85e-13) or not (y <= 0.00325): tmp = (y * x) + (0.918938533204673 - (y * 0.5)) else: tmp = (0.918938533204673 + (y * x)) - x return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.85e-13) || !(y <= 0.00325)) tmp = Float64(Float64(y * x) + Float64(0.918938533204673 - Float64(y * 0.5))); else tmp = Float64(Float64(0.918938533204673 + Float64(y * x)) - x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -1.85e-13) || ~((y <= 0.00325))) tmp = (y * x) + (0.918938533204673 - (y * 0.5)); else tmp = (0.918938533204673 + (y * x)) - x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1.85e-13], N[Not[LessEqual[y, 0.00325]], $MachinePrecision]], N[(N[(y * x), $MachinePrecision] + N[(0.918938533204673 - N[(y * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.918938533204673 + N[(y * x), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.85 \cdot 10^{-13} \lor \neg \left(y \leq 0.00325\right):\\
\;\;\;\;y \cdot x + \left(0.918938533204673 - y \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.918938533204673 + y \cdot x\right) - x\\
\end{array}
\end{array}
if y < -1.84999999999999994e-13 or 0.00324999999999999985 < y Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 99.0%
if -1.84999999999999994e-13 < y < 0.00324999999999999985Initial program 100.0%
cancel-sign-sub-inv100.0%
+-commutative100.0%
sub-neg100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
associate-+r+100.0%
unsub-neg100.0%
associate-+l-100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
distribute-lft-out100.0%
fma-neg100.0%
+-commutative100.0%
metadata-eval100.0%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
+-commutative100.0%
unsub-neg100.0%
Simplified100.0%
fma-undefine100.0%
associate-+r-100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 99.7%
*-commutative99.7%
Simplified99.7%
Final simplification99.4%
(FPCore (x y) :precision binary64 (if (or (<= x -2.9e-9) (not (<= x 1.9e-8))) (- (+ 0.918938533204673 (* y x)) x) (- 0.918938533204673 (* y 0.5))))
double code(double x, double y) {
double tmp;
if ((x <= -2.9e-9) || !(x <= 1.9e-8)) {
tmp = (0.918938533204673 + (y * x)) - x;
} 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 <= (-2.9d-9)) .or. (.not. (x <= 1.9d-8))) then
tmp = (0.918938533204673d0 + (y * x)) - x
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 <= -2.9e-9) || !(x <= 1.9e-8)) {
tmp = (0.918938533204673 + (y * x)) - x;
} else {
tmp = 0.918938533204673 - (y * 0.5);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -2.9e-9) or not (x <= 1.9e-8): tmp = (0.918938533204673 + (y * x)) - x else: tmp = 0.918938533204673 - (y * 0.5) return tmp
function code(x, y) tmp = 0.0 if ((x <= -2.9e-9) || !(x <= 1.9e-8)) tmp = Float64(Float64(0.918938533204673 + Float64(y * x)) - x); else tmp = Float64(0.918938533204673 - Float64(y * 0.5)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -2.9e-9) || ~((x <= 1.9e-8))) tmp = (0.918938533204673 + (y * x)) - x; else tmp = 0.918938533204673 - (y * 0.5); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -2.9e-9], N[Not[LessEqual[x, 1.9e-8]], $MachinePrecision]], N[(N[(0.918938533204673 + N[(y * x), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], N[(0.918938533204673 - N[(y * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.9 \cdot 10^{-9} \lor \neg \left(x \leq 1.9 \cdot 10^{-8}\right):\\
\;\;\;\;\left(0.918938533204673 + y \cdot x\right) - x\\
\mathbf{else}:\\
\;\;\;\;0.918938533204673 - y \cdot 0.5\\
\end{array}
\end{array}
if x < -2.89999999999999991e-9 or 1.90000000000000014e-8 < x Initial program 100.0%
cancel-sign-sub-inv100.0%
+-commutative100.0%
sub-neg100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
associate-+r+100.0%
unsub-neg100.0%
associate-+l-100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
distribute-lft-out100.0%
fma-neg100.0%
+-commutative100.0%
metadata-eval100.0%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
+-commutative100.0%
unsub-neg100.0%
Simplified100.0%
fma-undefine100.0%
associate-+r-100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 97.9%
*-commutative97.9%
Simplified97.9%
if -2.89999999999999991e-9 < x < 1.90000000000000014e-8Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 99.5%
Final simplification98.6%
(FPCore (x y) :precision binary64 (if (or (<= y -0.000102) (not (<= y 3.25e-9))) (* x (+ y -1.0)) (- 0.918938533204673 x)))
double code(double x, double y) {
double tmp;
if ((y <= -0.000102) || !(y <= 3.25e-9)) {
tmp = x * (y + -1.0);
} 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 <= (-0.000102d0)) .or. (.not. (y <= 3.25d-9))) then
tmp = x * (y + (-1.0d0))
else
tmp = 0.918938533204673d0 - x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -0.000102) || !(y <= 3.25e-9)) {
tmp = x * (y + -1.0);
} else {
tmp = 0.918938533204673 - x;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -0.000102) or not (y <= 3.25e-9): tmp = x * (y + -1.0) else: tmp = 0.918938533204673 - x return tmp
function code(x, y) tmp = 0.0 if ((y <= -0.000102) || !(y <= 3.25e-9)) tmp = Float64(x * Float64(y + -1.0)); else tmp = Float64(0.918938533204673 - x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -0.000102) || ~((y <= 3.25e-9))) tmp = x * (y + -1.0); else tmp = 0.918938533204673 - x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -0.000102], N[Not[LessEqual[y, 3.25e-9]], $MachinePrecision]], N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision], N[(0.918938533204673 - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.000102 \lor \neg \left(y \leq 3.25 \cdot 10^{-9}\right):\\
\;\;\;\;x \cdot \left(y + -1\right)\\
\mathbf{else}:\\
\;\;\;\;0.918938533204673 - x\\
\end{array}
\end{array}
if y < -1.01999999999999999e-4 or 3.2500000000000002e-9 < y Initial program 100.0%
cancel-sign-sub-inv100.0%
+-commutative100.0%
sub-neg100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
associate-+r+100.0%
unsub-neg100.0%
associate-+l-100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
distribute-lft-out100.0%
fma-neg100.0%
+-commutative100.0%
metadata-eval100.0%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
+-commutative100.0%
unsub-neg100.0%
Simplified100.0%
fma-undefine100.0%
associate-+r-100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 52.8%
if -1.01999999999999999e-4 < y < 3.2500000000000002e-9Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 98.5%
neg-mul-198.5%
sub-neg98.5%
Simplified98.5%
Final simplification76.5%
(FPCore (x y) :precision binary64 (if (or (<= y -1.42) (not (<= y 1.05))) (* y (- x 0.5)) (- 0.918938533204673 x)))
double code(double x, double y) {
double tmp;
if ((y <= -1.42) || !(y <= 1.05)) {
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.42d0)) .or. (.not. (y <= 1.05d0))) 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.42) || !(y <= 1.05)) {
tmp = y * (x - 0.5);
} else {
tmp = 0.918938533204673 - x;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.42) or not (y <= 1.05): tmp = y * (x - 0.5) else: tmp = 0.918938533204673 - x return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.42) || !(y <= 1.05)) 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.42) || ~((y <= 1.05))) tmp = y * (x - 0.5); else tmp = 0.918938533204673 - x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1.42], N[Not[LessEqual[y, 1.05]], $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.42 \lor \neg \left(y \leq 1.05\right):\\
\;\;\;\;y \cdot \left(x - 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;0.918938533204673 - x\\
\end{array}
\end{array}
if y < -1.4199999999999999 or 1.05000000000000004 < y Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 98.3%
if -1.4199999999999999 < y < 1.05000000000000004Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 96.7%
neg-mul-196.7%
sub-neg96.7%
Simplified96.7%
Final simplification97.5%
(FPCore (x y) :precision binary64 (if (or (<= x -0.62) (not (<= x 0.92))) (* x (+ y -1.0)) (- 0.918938533204673 (* y 0.5))))
double code(double x, double y) {
double tmp;
if ((x <= -0.62) || !(x <= 0.92)) {
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.62d0)) .or. (.not. (x <= 0.92d0))) 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.62) || !(x <= 0.92)) {
tmp = x * (y + -1.0);
} else {
tmp = 0.918938533204673 - (y * 0.5);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -0.62) or not (x <= 0.92): tmp = x * (y + -1.0) else: tmp = 0.918938533204673 - (y * 0.5) return tmp
function code(x, y) tmp = 0.0 if ((x <= -0.62) || !(x <= 0.92)) 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.62) || ~((x <= 0.92))) 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.62], N[Not[LessEqual[x, 0.92]], $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.62 \lor \neg \left(x \leq 0.92\right):\\
\;\;\;\;x \cdot \left(y + -1\right)\\
\mathbf{else}:\\
\;\;\;\;0.918938533204673 - y \cdot 0.5\\
\end{array}
\end{array}
if x < -0.619999999999999996 or 0.92000000000000004 < x Initial program 100.0%
cancel-sign-sub-inv100.0%
+-commutative100.0%
sub-neg100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
associate-+r+100.0%
unsub-neg100.0%
associate-+l-100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
distribute-lft-out100.0%
fma-neg100.0%
+-commutative100.0%
metadata-eval100.0%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
+-commutative100.0%
unsub-neg100.0%
Simplified100.0%
fma-undefine100.0%
associate-+r-100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 98.0%
if -0.619999999999999996 < x < 0.92000000000000004Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 97.7%
Final simplification97.8%
(FPCore (x y) :precision binary64 (if (<= x -0.68) (* x (+ y -1.0)) (if (<= x 0.5) (- 0.918938533204673 (* y 0.5)) (- (* y x) x))))
double code(double x, double y) {
double tmp;
if (x <= -0.68) {
tmp = x * (y + -1.0);
} else if (x <= 0.5) {
tmp = 0.918938533204673 - (y * 0.5);
} else {
tmp = (y * x) - x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-0.68d0)) then
tmp = x * (y + (-1.0d0))
else if (x <= 0.5d0) then
tmp = 0.918938533204673d0 - (y * 0.5d0)
else
tmp = (y * x) - x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -0.68) {
tmp = x * (y + -1.0);
} else if (x <= 0.5) {
tmp = 0.918938533204673 - (y * 0.5);
} else {
tmp = (y * x) - x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -0.68: tmp = x * (y + -1.0) elif x <= 0.5: tmp = 0.918938533204673 - (y * 0.5) else: tmp = (y * x) - x return tmp
function code(x, y) tmp = 0.0 if (x <= -0.68) tmp = Float64(x * Float64(y + -1.0)); elseif (x <= 0.5) tmp = Float64(0.918938533204673 - Float64(y * 0.5)); else tmp = Float64(Float64(y * x) - x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -0.68) tmp = x * (y + -1.0); elseif (x <= 0.5) tmp = 0.918938533204673 - (y * 0.5); else tmp = (y * x) - x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -0.68], N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.5], N[(0.918938533204673 - N[(y * 0.5), $MachinePrecision]), $MachinePrecision], N[(N[(y * x), $MachinePrecision] - x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.68:\\
\;\;\;\;x \cdot \left(y + -1\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;0.918938533204673 - y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;y \cdot x - x\\
\end{array}
\end{array}
if x < -0.680000000000000049Initial program 100.0%
cancel-sign-sub-inv100.0%
+-commutative100.0%
sub-neg100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
associate-+r+100.0%
unsub-neg100.0%
associate-+l-100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
distribute-lft-out100.0%
fma-neg100.0%
+-commutative100.0%
metadata-eval100.0%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
+-commutative100.0%
unsub-neg100.0%
Simplified100.0%
fma-undefine100.0%
associate-+r-100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 99.2%
if -0.680000000000000049 < x < 0.5Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 97.7%
if 0.5 < x Initial program 99.9%
cancel-sign-sub-inv99.9%
+-commutative99.9%
sub-neg99.9%
distribute-rgt-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
associate-+r+100.0%
unsub-neg100.0%
associate-+l-100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
distribute-lft-out100.0%
fma-neg100.0%
+-commutative100.0%
metadata-eval100.0%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
+-commutative100.0%
unsub-neg100.0%
Simplified100.0%
fma-undefine100.0%
associate-+r-100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 96.8%
sub-neg96.8%
distribute-rgt-in96.9%
*-commutative96.9%
metadata-eval96.9%
neg-mul-196.9%
Applied egg-rr96.9%
unsub-neg96.9%
*-commutative96.9%
Applied egg-rr96.9%
Final simplification97.8%
(FPCore (x y) :precision binary64 (if (or (<= y -5500000000.0) (not (<= y 1.5))) (* y x) (- 0.918938533204673 x)))
double code(double x, double y) {
double tmp;
if ((y <= -5500000000.0) || !(y <= 1.5)) {
tmp = y * x;
} 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 <= (-5500000000.0d0)) .or. (.not. (y <= 1.5d0))) then
tmp = y * x
else
tmp = 0.918938533204673d0 - x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -5500000000.0) || !(y <= 1.5)) {
tmp = y * x;
} else {
tmp = 0.918938533204673 - x;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -5500000000.0) or not (y <= 1.5): tmp = y * x else: tmp = 0.918938533204673 - x return tmp
function code(x, y) tmp = 0.0 if ((y <= -5500000000.0) || !(y <= 1.5)) tmp = Float64(y * x); else tmp = Float64(0.918938533204673 - x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -5500000000.0) || ~((y <= 1.5))) tmp = y * x; else tmp = 0.918938533204673 - x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -5500000000.0], N[Not[LessEqual[y, 1.5]], $MachinePrecision]], N[(y * x), $MachinePrecision], N[(0.918938533204673 - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5500000000 \lor \neg \left(y \leq 1.5\right):\\
\;\;\;\;y \cdot x\\
\mathbf{else}:\\
\;\;\;\;0.918938533204673 - x\\
\end{array}
\end{array}
if y < -5.5e9 or 1.5 < y Initial program 100.0%
cancel-sign-sub-inv100.0%
+-commutative100.0%
sub-neg100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
associate-+r+100.0%
unsub-neg100.0%
associate-+l-100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
distribute-lft-out100.0%
fma-neg100.0%
+-commutative100.0%
metadata-eval100.0%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
+-commutative100.0%
unsub-neg100.0%
Simplified100.0%
fma-undefine100.0%
associate-+r-100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 52.9%
Taylor expanded in y around inf 52.6%
if -5.5e9 < y < 1.5Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 95.5%
neg-mul-195.5%
sub-neg95.5%
Simplified95.5%
Final simplification75.9%
(FPCore (x y) :precision binary64 (if (or (<= x -0.92) (not (<= x 16.5))) (- x) 0.918938533204673))
double code(double x, double y) {
double tmp;
if ((x <= -0.92) || !(x <= 16.5)) {
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 <= (-0.92d0)) .or. (.not. (x <= 16.5d0))) 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 <= -0.92) || !(x <= 16.5)) {
tmp = -x;
} else {
tmp = 0.918938533204673;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -0.92) or not (x <= 16.5): tmp = -x else: tmp = 0.918938533204673 return tmp
function code(x, y) tmp = 0.0 if ((x <= -0.92) || !(x <= 16.5)) tmp = Float64(-x); else tmp = 0.918938533204673; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -0.92) || ~((x <= 16.5))) tmp = -x; else tmp = 0.918938533204673; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -0.92], N[Not[LessEqual[x, 16.5]], $MachinePrecision]], (-x), 0.918938533204673]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.92 \lor \neg \left(x \leq 16.5\right):\\
\;\;\;\;-x\\
\mathbf{else}:\\
\;\;\;\;0.918938533204673\\
\end{array}
\end{array}
if x < -0.92000000000000004 or 16.5 < x Initial program 100.0%
cancel-sign-sub-inv100.0%
+-commutative100.0%
sub-neg100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
associate-+r+100.0%
unsub-neg100.0%
associate-+l-100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
distribute-lft-out100.0%
fma-neg100.0%
+-commutative100.0%
metadata-eval100.0%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
+-commutative100.0%
unsub-neg100.0%
Simplified100.0%
fma-undefine100.0%
associate-+r-100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 98.6%
Taylor expanded in y around 0 51.0%
neg-mul-151.0%
Simplified51.0%
if -0.92000000000000004 < x < 16.5Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 98.4%
Taylor expanded in y around 0 53.1%
Final simplification52.1%
(FPCore (x y) :precision binary64 (- (+ 0.918938533204673 (* y (+ x -0.5))) x))
double code(double x, double y) {
return (0.918938533204673 + (y * (x + -0.5))) - x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (0.918938533204673d0 + (y * (x + (-0.5d0)))) - x
end function
public static double code(double x, double y) {
return (0.918938533204673 + (y * (x + -0.5))) - x;
}
def code(x, y): return (0.918938533204673 + (y * (x + -0.5))) - x
function code(x, y) return Float64(Float64(0.918938533204673 + Float64(y * Float64(x + -0.5))) - x) end
function tmp = code(x, y) tmp = (0.918938533204673 + (y * (x + -0.5))) - x; end
code[x_, y_] := N[(N[(0.918938533204673 + N[(y * N[(x + -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]
\begin{array}{l}
\\
\left(0.918938533204673 + y \cdot \left(x + -0.5\right)\right) - x
\end{array}
Initial program 100.0%
cancel-sign-sub-inv100.0%
+-commutative100.0%
sub-neg100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
associate-+r+100.0%
unsub-neg100.0%
associate-+l-100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
distribute-lft-out100.0%
fma-neg100.0%
+-commutative100.0%
metadata-eval100.0%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
+-commutative100.0%
unsub-neg100.0%
Simplified100.0%
fma-undefine100.0%
associate-+r-100.0%
Applied egg-rr100.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 inf 74.2%
Taylor expanded in y around 0 28.1%
Final simplification28.1%
herbie shell --seed 2024053
(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))