
(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 (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 (<= y -1.0) (* y x) (if (<= y 6.6e-162) (- x) (if (<= y 1.15) 0.918938533204673 (* y x)))))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = y * x;
} else if (y <= 6.6e-162) {
tmp = -x;
} else if (y <= 1.15) {
tmp = 0.918938533204673;
} 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 <= (-1.0d0)) then
tmp = y * x
else if (y <= 6.6d-162) then
tmp = -x
else if (y <= 1.15d0) then
tmp = 0.918938533204673d0
else
tmp = y * x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = y * x;
} else if (y <= 6.6e-162) {
tmp = -x;
} else if (y <= 1.15) {
tmp = 0.918938533204673;
} else {
tmp = y * x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = y * x elif y <= 6.6e-162: tmp = -x elif y <= 1.15: tmp = 0.918938533204673 else: tmp = y * x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = Float64(y * x); elseif (y <= 6.6e-162) tmp = Float64(-x); elseif (y <= 1.15) tmp = 0.918938533204673; else tmp = Float64(y * x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.0) tmp = y * x; elseif (y <= 6.6e-162) tmp = -x; elseif (y <= 1.15) tmp = 0.918938533204673; else tmp = y * x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], N[(y * x), $MachinePrecision], If[LessEqual[y, 6.6e-162], (-x), If[LessEqual[y, 1.15], 0.918938533204673, N[(y * x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;y \leq 6.6 \cdot 10^{-162}:\\
\;\;\;\;-x\\
\mathbf{elif}\;y \leq 1.15:\\
\;\;\;\;0.918938533204673\\
\mathbf{else}:\\
\;\;\;\;y \cdot x\\
\end{array}
\end{array}
if y < -1 or 1.1499999999999999 < y 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 x around inf 48.4%
sub-neg48.4%
distribute-rgt-in48.4%
*-commutative48.4%
metadata-eval48.4%
neg-mul-148.4%
Applied egg-rr48.4%
Taylor expanded in y around inf 47.6%
if -1 < y < 6.60000000000000026e-162Initial 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 x around inf 98.7%
Taylor expanded in x around inf 62.6%
Taylor expanded in y around 0 62.3%
neg-mul-162.3%
Simplified62.3%
if 6.60000000000000026e-162 < y < 1.1499999999999999Initial program 99.9%
associate-+l-99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around 0 100.0%
Taylor expanded in x around inf 99.9%
Taylor expanded in x around 0 58.5%
Final simplification54.6%
(FPCore (x y) :precision binary64 (if (or (<= y -0.115) (not (<= y 1.36e-17))) (* x (+ y -1.0)) (- 0.918938533204673 x)))
double code(double x, double y) {
double tmp;
if ((y <= -0.115) || !(y <= 1.36e-17)) {
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.115d0)) .or. (.not. (y <= 1.36d-17))) 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.115) || !(y <= 1.36e-17)) {
tmp = x * (y + -1.0);
} else {
tmp = 0.918938533204673 - x;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -0.115) or not (y <= 1.36e-17): tmp = x * (y + -1.0) else: tmp = 0.918938533204673 - x return tmp
function code(x, y) tmp = 0.0 if ((y <= -0.115) || !(y <= 1.36e-17)) 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.115) || ~((y <= 1.36e-17))) tmp = x * (y + -1.0); else tmp = 0.918938533204673 - x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -0.115], N[Not[LessEqual[y, 1.36e-17]], $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.115 \lor \neg \left(y \leq 1.36 \cdot 10^{-17}\right):\\
\;\;\;\;x \cdot \left(y + -1\right)\\
\mathbf{else}:\\
\;\;\;\;0.918938533204673 - x\\
\end{array}
\end{array}
if y < -0.115000000000000005 or 1.36e-17 < y 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 x around inf 49.6%
Taylor expanded in x around inf 49.5%
if -0.115000000000000005 < y < 1.36e-17Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 98.7%
neg-mul-198.7%
unsub-neg98.7%
Simplified98.7%
Final simplification73.5%
(FPCore (x y) :precision binary64 (if (or (<= y -1.45) (not (<= y 1.0))) (* y (- x 0.5)) (- 0.918938533204673 x)))
double code(double x, double y) {
double tmp;
if ((y <= -1.45) || !(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.45d0)) .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.45) || !(y <= 1.0)) {
tmp = y * (x - 0.5);
} else {
tmp = 0.918938533204673 - x;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.45) 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.45) || !(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.45) || ~((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.45], 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.45 \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.44999999999999996 or 1 < y Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 98.2%
if -1.44999999999999996 < y < 1Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 98.1%
neg-mul-198.1%
unsub-neg98.1%
Simplified98.1%
Final simplification98.2%
(FPCore (x y) :precision binary64 (if (<= x -0.7) (- (* y x) x) (if (<= x 0.62) (- 0.918938533204673 (* y 0.5)) (* x (+ y -1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -0.7) {
tmp = (y * x) - x;
} else if (x <= 0.62) {
tmp = 0.918938533204673 - (y * 0.5);
} else {
tmp = x * (y + -1.0);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-0.7d0)) then
tmp = (y * x) - x
else if (x <= 0.62d0) then
tmp = 0.918938533204673d0 - (y * 0.5d0)
else
tmp = x * (y + (-1.0d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -0.7) {
tmp = (y * x) - x;
} else if (x <= 0.62) {
tmp = 0.918938533204673 - (y * 0.5);
} else {
tmp = x * (y + -1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -0.7: tmp = (y * x) - x elif x <= 0.62: tmp = 0.918938533204673 - (y * 0.5) else: tmp = x * (y + -1.0) return tmp
function code(x, y) tmp = 0.0 if (x <= -0.7) tmp = Float64(Float64(y * x) - x); elseif (x <= 0.62) tmp = Float64(0.918938533204673 - Float64(y * 0.5)); else tmp = Float64(x * Float64(y + -1.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -0.7) tmp = (y * x) - x; elseif (x <= 0.62) tmp = 0.918938533204673 - (y * 0.5); else tmp = x * (y + -1.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -0.7], N[(N[(y * x), $MachinePrecision] - x), $MachinePrecision], If[LessEqual[x, 0.62], N[(0.918938533204673 - N[(y * 0.5), $MachinePrecision]), $MachinePrecision], N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.7:\\
\;\;\;\;y \cdot x - x\\
\mathbf{elif}\;x \leq 0.62:\\
\;\;\;\;0.918938533204673 - y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(y + -1\right)\\
\end{array}
\end{array}
if x < -0.69999999999999996Initial 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 x around inf 99.4%
Taylor expanded in x around inf 96.8%
sub-neg99.4%
distribute-rgt-in99.4%
*-commutative99.4%
metadata-eval99.4%
neg-mul-199.4%
Applied egg-rr96.8%
if -0.69999999999999996 < x < 0.619999999999999996Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 98.1%
if 0.619999999999999996 < 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 x around inf 99.5%
Taylor expanded in x around inf 99.5%
Final simplification98.2%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* x (+ y -1.0))))
(if (<= x -3.2e-6)
(+ 0.918938533204673 t_0)
(if (<= x 0.62) (- 0.918938533204673 (* y 0.5)) t_0))))
double code(double x, double y) {
double t_0 = x * (y + -1.0);
double tmp;
if (x <= -3.2e-6) {
tmp = 0.918938533204673 + t_0;
} else if (x <= 0.62) {
tmp = 0.918938533204673 - (y * 0.5);
} 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 <= (-3.2d-6)) then
tmp = 0.918938533204673d0 + t_0
else if (x <= 0.62d0) then
tmp = 0.918938533204673d0 - (y * 0.5d0)
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 <= -3.2e-6) {
tmp = 0.918938533204673 + t_0;
} else if (x <= 0.62) {
tmp = 0.918938533204673 - (y * 0.5);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = x * (y + -1.0) tmp = 0 if x <= -3.2e-6: tmp = 0.918938533204673 + t_0 elif x <= 0.62: tmp = 0.918938533204673 - (y * 0.5) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(x * Float64(y + -1.0)) tmp = 0.0 if (x <= -3.2e-6) tmp = Float64(0.918938533204673 + t_0); elseif (x <= 0.62) tmp = Float64(0.918938533204673 - Float64(y * 0.5)); 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 <= -3.2e-6) tmp = 0.918938533204673 + t_0; elseif (x <= 0.62) tmp = 0.918938533204673 - (y * 0.5); 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, -3.2e-6], N[(0.918938533204673 + t$95$0), $MachinePrecision], If[LessEqual[x, 0.62], N[(0.918938533204673 - N[(y * 0.5), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(y + -1\right)\\
\mathbf{if}\;x \leq -3.2 \cdot 10^{-6}:\\
\;\;\;\;0.918938533204673 + t\_0\\
\mathbf{elif}\;x \leq 0.62:\\
\;\;\;\;0.918938533204673 - y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -3.1999999999999999e-6Initial 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 x around inf 99.4%
if -3.1999999999999999e-6 < x < 0.619999999999999996Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 98.6%
if 0.619999999999999996 < 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 x around inf 99.5%
Taylor expanded in x around inf 99.5%
Final simplification99.1%
(FPCore (x y) :precision binary64 (if (<= x -3.1e-7) (+ 0.918938533204673 (- (* y x) x)) (if (<= x 0.55) (- 0.918938533204673 (* y 0.5)) (* x (+ y -1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -3.1e-7) {
tmp = 0.918938533204673 + ((y * x) - x);
} else if (x <= 0.55) {
tmp = 0.918938533204673 - (y * 0.5);
} else {
tmp = x * (y + -1.0);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-3.1d-7)) then
tmp = 0.918938533204673d0 + ((y * x) - x)
else if (x <= 0.55d0) then
tmp = 0.918938533204673d0 - (y * 0.5d0)
else
tmp = x * (y + (-1.0d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -3.1e-7) {
tmp = 0.918938533204673 + ((y * x) - x);
} else if (x <= 0.55) {
tmp = 0.918938533204673 - (y * 0.5);
} else {
tmp = x * (y + -1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -3.1e-7: tmp = 0.918938533204673 + ((y * x) - x) elif x <= 0.55: tmp = 0.918938533204673 - (y * 0.5) else: tmp = x * (y + -1.0) return tmp
function code(x, y) tmp = 0.0 if (x <= -3.1e-7) tmp = Float64(0.918938533204673 + Float64(Float64(y * x) - x)); elseif (x <= 0.55) tmp = Float64(0.918938533204673 - Float64(y * 0.5)); else tmp = Float64(x * Float64(y + -1.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -3.1e-7) tmp = 0.918938533204673 + ((y * x) - x); elseif (x <= 0.55) tmp = 0.918938533204673 - (y * 0.5); else tmp = x * (y + -1.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -3.1e-7], N[(0.918938533204673 + N[(N[(y * x), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.55], N[(0.918938533204673 - N[(y * 0.5), $MachinePrecision]), $MachinePrecision], N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.1 \cdot 10^{-7}:\\
\;\;\;\;0.918938533204673 + \left(y \cdot x - x\right)\\
\mathbf{elif}\;x \leq 0.55:\\
\;\;\;\;0.918938533204673 - y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(y + -1\right)\\
\end{array}
\end{array}
if x < -3.1e-7Initial 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 x around inf 99.4%
sub-neg99.4%
distribute-rgt-in99.4%
*-commutative99.4%
metadata-eval99.4%
neg-mul-199.4%
Applied egg-rr99.4%
if -3.1e-7 < x < 0.55000000000000004Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 98.6%
if 0.55000000000000004 < 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 x around inf 99.5%
Taylor expanded in x around inf 99.5%
Final simplification99.1%
(FPCore (x y) :precision binary64 (if (or (<= y -23.0) (not (<= y 1.0))) (* y x) (- 0.918938533204673 x)))
double code(double x, double y) {
double tmp;
if ((y <= -23.0) || !(y <= 1.0)) {
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 <= (-23.0d0)) .or. (.not. (y <= 1.0d0))) 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 <= -23.0) || !(y <= 1.0)) {
tmp = y * x;
} else {
tmp = 0.918938533204673 - x;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -23.0) or not (y <= 1.0): tmp = y * x else: tmp = 0.918938533204673 - x return tmp
function code(x, y) tmp = 0.0 if ((y <= -23.0) || !(y <= 1.0)) 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 <= -23.0) || ~((y <= 1.0))) tmp = y * x; else tmp = 0.918938533204673 - x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -23.0], N[Not[LessEqual[y, 1.0]], $MachinePrecision]], N[(y * x), $MachinePrecision], N[(0.918938533204673 - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -23 \lor \neg \left(y \leq 1\right):\\
\;\;\;\;y \cdot x\\
\mathbf{else}:\\
\;\;\;\;0.918938533204673 - x\\
\end{array}
\end{array}
if y < -23 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 100.0%
Taylor expanded in x around inf 48.4%
sub-neg48.4%
distribute-rgt-in48.4%
*-commutative48.4%
metadata-eval48.4%
neg-mul-148.4%
Applied egg-rr48.4%
Taylor expanded in y around inf 47.6%
if -23 < y < 1Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 98.1%
neg-mul-198.1%
unsub-neg98.1%
Simplified98.1%
Final simplification72.8%
(FPCore (x y) :precision binary64 (if (or (<= x -0.92) (not (<= x 850000000.0))) (- x) 0.918938533204673))
double code(double x, double y) {
double tmp;
if ((x <= -0.92) || !(x <= 850000000.0)) {
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 <= 850000000.0d0))) 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 <= 850000000.0)) {
tmp = -x;
} else {
tmp = 0.918938533204673;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -0.92) or not (x <= 850000000.0): tmp = -x else: tmp = 0.918938533204673 return tmp
function code(x, y) tmp = 0.0 if ((x <= -0.92) || !(x <= 850000000.0)) 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 <= 850000000.0))) tmp = -x; else tmp = 0.918938533204673; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -0.92], N[Not[LessEqual[x, 850000000.0]], $MachinePrecision]], (-x), 0.918938533204673]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.92 \lor \neg \left(x \leq 850000000\right):\\
\;\;\;\;-x\\
\mathbf{else}:\\
\;\;\;\;0.918938533204673\\
\end{array}
\end{array}
if x < -0.92000000000000004 or 8.5e8 < 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 x around inf 99.7%
Taylor expanded in x around inf 98.4%
Taylor expanded in y around 0 55.7%
neg-mul-155.7%
Simplified55.7%
if -0.92000000000000004 < x < 8.5e8Initial 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 x around inf 45.1%
Taylor expanded in x around 0 43.7%
Final simplification50.0%
(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(0.918938533204673 + Float64(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[(0.918938533204673 + N[(N[(y * N[(x + -0.5), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.918938533204673 + \left(y \cdot \left(x + -0.5\right) - x\right)
\end{array}
Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
+-commutative100.0%
mul-1-neg100.0%
unsub-neg100.0%
sub-neg100.0%
metadata-eval100.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 0 100.0%
Taylor expanded in x around inf 73.7%
Taylor expanded in x around 0 22.3%
Final simplification22.3%
herbie shell --seed 2024082
(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))