
(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 10 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 -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}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(if (<= y -18000000.0)
(+ 0.918938533204673 (* y (- x 0.5)))
(if (<= y 1.0)
(- (- 0.918938533204673 (* y 0.5)) x)
(- (* x y) (- (* y 0.5) 0.918938533204673)))))
double code(double x, double y) {
double tmp;
if (y <= -18000000.0) {
tmp = 0.918938533204673 + (y * (x - 0.5));
} else if (y <= 1.0) {
tmp = (0.918938533204673 - (y * 0.5)) - x;
} else {
tmp = (x * y) - ((y * 0.5) - 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 <= (-18000000.0d0)) then
tmp = 0.918938533204673d0 + (y * (x - 0.5d0))
else if (y <= 1.0d0) then
tmp = (0.918938533204673d0 - (y * 0.5d0)) - x
else
tmp = (x * y) - ((y * 0.5d0) - 0.918938533204673d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -18000000.0) {
tmp = 0.918938533204673 + (y * (x - 0.5));
} else if (y <= 1.0) {
tmp = (0.918938533204673 - (y * 0.5)) - x;
} else {
tmp = (x * y) - ((y * 0.5) - 0.918938533204673);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -18000000.0: tmp = 0.918938533204673 + (y * (x - 0.5)) elif y <= 1.0: tmp = (0.918938533204673 - (y * 0.5)) - x else: tmp = (x * y) - ((y * 0.5) - 0.918938533204673) return tmp
function code(x, y) tmp = 0.0 if (y <= -18000000.0) tmp = Float64(0.918938533204673 + Float64(y * Float64(x - 0.5))); elseif (y <= 1.0) tmp = Float64(Float64(0.918938533204673 - Float64(y * 0.5)) - x); else tmp = Float64(Float64(x * y) - Float64(Float64(y * 0.5) - 0.918938533204673)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -18000000.0) tmp = 0.918938533204673 + (y * (x - 0.5)); elseif (y <= 1.0) tmp = (0.918938533204673 - (y * 0.5)) - x; else tmp = (x * y) - ((y * 0.5) - 0.918938533204673); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -18000000.0], N[(0.918938533204673 + N[(y * N[(x - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.0], N[(N[(0.918938533204673 - N[(y * 0.5), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], N[(N[(x * y), $MachinePrecision] - N[(N[(y * 0.5), $MachinePrecision] - 0.918938533204673), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -18000000:\\
\;\;\;\;0.918938533204673 + y \cdot \left(x - 0.5\right)\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;\left(0.918938533204673 - y \cdot 0.5\right) - x\\
\mathbf{else}:\\
\;\;\;\;x \cdot y - \left(y \cdot 0.5 - 0.918938533204673\right)\\
\end{array}
\end{array}
if y < -1.8e7Initial program 100.0%
associate-+l-100.0%
fma-neg100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
fma-neg100.0%
sub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 99.4%
associate--r-99.4%
distribute-lft-out--99.4%
Applied egg-rr99.4%
if -1.8e7 < y < 1Initial program 100.0%
associate-+l-100.0%
fma-neg100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
fma-neg100.0%
sub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 99.4%
neg-mul-199.4%
Simplified99.4%
if 1 < y Initial program 100.0%
associate-+l-100.0%
fma-neg100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
fma-neg100.0%
sub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 96.2%
Final simplification98.8%
(FPCore (x y)
:precision binary64
(if (<= y -6.2e+265)
(* x y)
(if (<= y -1.85)
(* y -0.5)
(if (<= y 0.032)
0.918938533204673
(if (<= y 3.4e+110) (* y -0.5) (* x y))))))
double code(double x, double y) {
double tmp;
if (y <= -6.2e+265) {
tmp = x * y;
} else if (y <= -1.85) {
tmp = y * -0.5;
} else if (y <= 0.032) {
tmp = 0.918938533204673;
} else if (y <= 3.4e+110) {
tmp = y * -0.5;
} 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 <= (-6.2d+265)) then
tmp = x * y
else if (y <= (-1.85d0)) then
tmp = y * (-0.5d0)
else if (y <= 0.032d0) then
tmp = 0.918938533204673d0
else if (y <= 3.4d+110) then
tmp = y * (-0.5d0)
else
tmp = x * y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -6.2e+265) {
tmp = x * y;
} else if (y <= -1.85) {
tmp = y * -0.5;
} else if (y <= 0.032) {
tmp = 0.918938533204673;
} else if (y <= 3.4e+110) {
tmp = y * -0.5;
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -6.2e+265: tmp = x * y elif y <= -1.85: tmp = y * -0.5 elif y <= 0.032: tmp = 0.918938533204673 elif y <= 3.4e+110: tmp = y * -0.5 else: tmp = x * y return tmp
function code(x, y) tmp = 0.0 if (y <= -6.2e+265) tmp = Float64(x * y); elseif (y <= -1.85) tmp = Float64(y * -0.5); elseif (y <= 0.032) tmp = 0.918938533204673; elseif (y <= 3.4e+110) tmp = Float64(y * -0.5); else tmp = Float64(x * y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -6.2e+265) tmp = x * y; elseif (y <= -1.85) tmp = y * -0.5; elseif (y <= 0.032) tmp = 0.918938533204673; elseif (y <= 3.4e+110) tmp = y * -0.5; else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -6.2e+265], N[(x * y), $MachinePrecision], If[LessEqual[y, -1.85], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 0.032], 0.918938533204673, If[LessEqual[y, 3.4e+110], N[(y * -0.5), $MachinePrecision], N[(x * y), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.2 \cdot 10^{+265}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;y \leq -1.85:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 0.032:\\
\;\;\;\;0.918938533204673\\
\mathbf{elif}\;y \leq 3.4 \cdot 10^{+110}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if y < -6.20000000000000016e265 or 3.4000000000000001e110 < y Initial program 100.0%
associate-+l-100.0%
fma-neg100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
fma-neg100.0%
sub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 100.0%
Taylor expanded in x around inf 67.1%
if -6.20000000000000016e265 < y < -1.8500000000000001 or 0.032000000000000001 < y < 3.4000000000000001e110Initial program 100.0%
associate-+l-100.0%
fma-neg100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
fma-neg100.0%
sub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 95.4%
Taylor expanded in y around inf 93.1%
Taylor expanded in x around 0 61.1%
if -1.8500000000000001 < y < 0.032000000000000001Initial program 100.0%
associate-+l-100.0%
fma-neg100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
fma-neg100.0%
sub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 59.2%
Taylor expanded in y around 0 57.0%
Final simplification59.8%
(FPCore (x y) :precision binary64 (if (or (<= y -18000000.0) (not (<= y 1.0))) (+ 0.918938533204673 (* y (- x 0.5))) (- (- 0.918938533204673 (* y 0.5)) x)))
double code(double x, double y) {
double tmp;
if ((y <= -18000000.0) || !(y <= 1.0)) {
tmp = 0.918938533204673 + (y * (x - 0.5));
} 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 ((y <= (-18000000.0d0)) .or. (.not. (y <= 1.0d0))) then
tmp = 0.918938533204673d0 + (y * (x - 0.5d0))
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 ((y <= -18000000.0) || !(y <= 1.0)) {
tmp = 0.918938533204673 + (y * (x - 0.5));
} else {
tmp = (0.918938533204673 - (y * 0.5)) - x;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -18000000.0) or not (y <= 1.0): tmp = 0.918938533204673 + (y * (x - 0.5)) else: tmp = (0.918938533204673 - (y * 0.5)) - x return tmp
function code(x, y) tmp = 0.0 if ((y <= -18000000.0) || !(y <= 1.0)) tmp = Float64(0.918938533204673 + Float64(y * Float64(x - 0.5))); 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 ((y <= -18000000.0) || ~((y <= 1.0))) tmp = 0.918938533204673 + (y * (x - 0.5)); else tmp = (0.918938533204673 - (y * 0.5)) - x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -18000000.0], N[Not[LessEqual[y, 1.0]], $MachinePrecision]], N[(0.918938533204673 + N[(y * N[(x - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.918938533204673 - N[(y * 0.5), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -18000000 \lor \neg \left(y \leq 1\right):\\
\;\;\;\;0.918938533204673 + y \cdot \left(x - 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.918938533204673 - y \cdot 0.5\right) - x\\
\end{array}
\end{array}
if y < -1.8e7 or 1 < y Initial program 100.0%
associate-+l-100.0%
fma-neg100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
fma-neg100.0%
sub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 97.9%
associate--r-97.9%
distribute-lft-out--97.9%
Applied egg-rr97.9%
if -1.8e7 < y < 1Initial program 100.0%
associate-+l-100.0%
fma-neg100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
fma-neg100.0%
sub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 99.4%
neg-mul-199.4%
Simplified99.4%
Final simplification98.7%
(FPCore (x y) :precision binary64 (if (or (<= y -0.013) (not (<= y 1.75))) (* y (- x 0.5)) 0.918938533204673))
double code(double x, double y) {
double tmp;
if ((y <= -0.013) || !(y <= 1.75)) {
tmp = y * (x - 0.5);
} 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 ((y <= (-0.013d0)) .or. (.not. (y <= 1.75d0))) then
tmp = y * (x - 0.5d0)
else
tmp = 0.918938533204673d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -0.013) || !(y <= 1.75)) {
tmp = y * (x - 0.5);
} else {
tmp = 0.918938533204673;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -0.013) or not (y <= 1.75): tmp = y * (x - 0.5) else: tmp = 0.918938533204673 return tmp
function code(x, y) tmp = 0.0 if ((y <= -0.013) || !(y <= 1.75)) tmp = Float64(y * Float64(x - 0.5)); else tmp = 0.918938533204673; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -0.013) || ~((y <= 1.75))) tmp = y * (x - 0.5); else tmp = 0.918938533204673; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -0.013], N[Not[LessEqual[y, 1.75]], $MachinePrecision]], N[(y * N[(x - 0.5), $MachinePrecision]), $MachinePrecision], 0.918938533204673]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.013 \lor \neg \left(y \leq 1.75\right):\\
\;\;\;\;y \cdot \left(x - 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;0.918938533204673\\
\end{array}
\end{array}
if y < -0.0129999999999999994 or 1.75 < y Initial program 100.0%
associate-+l-100.0%
fma-neg100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
fma-neg100.0%
sub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 97.9%
Taylor expanded in y around inf 96.4%
if -0.0129999999999999994 < y < 1.75Initial program 100.0%
associate-+l-100.0%
fma-neg100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
fma-neg100.0%
sub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 58.7%
Taylor expanded in y around 0 56.6%
Final simplification74.3%
(FPCore (x y) :precision binary64 (if (or (<= y -1.85) (not (<= y 2.5))) (* y (- x 0.5)) (+ 0.918938533204673 (* x y))))
double code(double x, double y) {
double tmp;
if ((y <= -1.85) || !(y <= 2.5)) {
tmp = y * (x - 0.5);
} else {
tmp = 0.918938533204673 + (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.85d0)) .or. (.not. (y <= 2.5d0))) then
tmp = y * (x - 0.5d0)
else
tmp = 0.918938533204673d0 + (x * y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -1.85) || !(y <= 2.5)) {
tmp = y * (x - 0.5);
} else {
tmp = 0.918938533204673 + (x * y);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.85) or not (y <= 2.5): tmp = y * (x - 0.5) else: tmp = 0.918938533204673 + (x * y) return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.85) || !(y <= 2.5)) tmp = Float64(y * Float64(x - 0.5)); else tmp = Float64(0.918938533204673 + Float64(x * y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -1.85) || ~((y <= 2.5))) tmp = y * (x - 0.5); else tmp = 0.918938533204673 + (x * y); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1.85], N[Not[LessEqual[y, 2.5]], $MachinePrecision]], N[(y * N[(x - 0.5), $MachinePrecision]), $MachinePrecision], N[(0.918938533204673 + N[(x * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.85 \lor \neg \left(y \leq 2.5\right):\\
\;\;\;\;y \cdot \left(x - 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;0.918938533204673 + x \cdot y\\
\end{array}
\end{array}
if y < -1.8500000000000001 or 2.5 < y Initial program 100.0%
associate-+l-100.0%
fma-neg100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
fma-neg100.0%
sub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 98.6%
Taylor expanded in y around inf 97.1%
if -1.8500000000000001 < y < 2.5Initial program 100.0%
associate-+l-100.0%
fma-neg100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
fma-neg100.0%
sub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 58.5%
associate--r-58.5%
distribute-lft-out--58.5%
Applied egg-rr58.5%
Taylor expanded in x around inf 56.9%
Final simplification74.6%
(FPCore (x y) :precision binary64 (if (<= x -0.5) (+ 0.918938533204673 (* x y)) (if (<= x 0.000112) (- 0.918938533204673 (* y 0.5)) (* y (- x 0.5)))))
double code(double x, double y) {
double tmp;
if (x <= -0.5) {
tmp = 0.918938533204673 + (x * y);
} else if (x <= 0.000112) {
tmp = 0.918938533204673 - (y * 0.5);
} else {
tmp = y * (x - 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.5d0)) then
tmp = 0.918938533204673d0 + (x * y)
else if (x <= 0.000112d0) then
tmp = 0.918938533204673d0 - (y * 0.5d0)
else
tmp = y * (x - 0.5d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -0.5) {
tmp = 0.918938533204673 + (x * y);
} else if (x <= 0.000112) {
tmp = 0.918938533204673 - (y * 0.5);
} else {
tmp = y * (x - 0.5);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -0.5: tmp = 0.918938533204673 + (x * y) elif x <= 0.000112: tmp = 0.918938533204673 - (y * 0.5) else: tmp = y * (x - 0.5) return tmp
function code(x, y) tmp = 0.0 if (x <= -0.5) tmp = Float64(0.918938533204673 + Float64(x * y)); elseif (x <= 0.000112) tmp = Float64(0.918938533204673 - Float64(y * 0.5)); else tmp = Float64(y * Float64(x - 0.5)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -0.5) tmp = 0.918938533204673 + (x * y); elseif (x <= 0.000112) tmp = 0.918938533204673 - (y * 0.5); else tmp = y * (x - 0.5); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -0.5], N[(0.918938533204673 + N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.000112], N[(0.918938533204673 - N[(y * 0.5), $MachinePrecision]), $MachinePrecision], N[(y * N[(x - 0.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.5:\\
\;\;\;\;0.918938533204673 + x \cdot y\\
\mathbf{elif}\;x \leq 0.000112:\\
\;\;\;\;0.918938533204673 - y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(x - 0.5\right)\\
\end{array}
\end{array}
if x < -0.5Initial program 100.0%
associate-+l-100.0%
fma-neg100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
fma-neg100.0%
sub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 53.0%
associate--r-53.0%
distribute-lft-out--53.0%
Applied egg-rr53.0%
Taylor expanded in x around inf 53.0%
if -0.5 < x < 1.11999999999999998e-4Initial program 100.0%
associate-+l-100.0%
fma-neg100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
fma-neg100.0%
sub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 98.6%
Taylor expanded in x around 0 98.4%
if 1.11999999999999998e-4 < x Initial program 100.0%
associate-+l-100.0%
fma-neg100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
fma-neg100.0%
sub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 42.4%
Taylor expanded in y around inf 42.7%
Final simplification76.2%
(FPCore (x y) :precision binary64 (if (<= y -1.85) (* y -0.5) (if (<= y 0.032) 0.918938533204673 (* y -0.5))))
double code(double x, double y) {
double tmp;
if (y <= -1.85) {
tmp = y * -0.5;
} else if (y <= 0.032) {
tmp = 0.918938533204673;
} else {
tmp = 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 (y <= (-1.85d0)) then
tmp = y * (-0.5d0)
else if (y <= 0.032d0) then
tmp = 0.918938533204673d0
else
tmp = y * (-0.5d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.85) {
tmp = y * -0.5;
} else if (y <= 0.032) {
tmp = 0.918938533204673;
} else {
tmp = y * -0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.85: tmp = y * -0.5 elif y <= 0.032: tmp = 0.918938533204673 else: tmp = y * -0.5 return tmp
function code(x, y) tmp = 0.0 if (y <= -1.85) tmp = Float64(y * -0.5); elseif (y <= 0.032) tmp = 0.918938533204673; else tmp = Float64(y * -0.5); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.85) tmp = y * -0.5; elseif (y <= 0.032) tmp = 0.918938533204673; else tmp = y * -0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.85], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 0.032], 0.918938533204673, N[(y * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.85:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 0.032:\\
\;\;\;\;0.918938533204673\\
\mathbf{else}:\\
\;\;\;\;y \cdot -0.5\\
\end{array}
\end{array}
if y < -1.8500000000000001 or 0.032000000000000001 < y Initial program 100.0%
associate-+l-100.0%
fma-neg100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
fma-neg100.0%
sub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 97.1%
Taylor expanded in y around inf 95.6%
Taylor expanded in x around 0 52.3%
if -1.8500000000000001 < y < 0.032000000000000001Initial program 100.0%
associate-+l-100.0%
fma-neg100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
fma-neg100.0%
sub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 59.2%
Taylor expanded in y around 0 57.0%
Final simplification54.9%
(FPCore (x y) :precision binary64 (+ 0.918938533204673 (* y (- x 0.5))))
double code(double x, double y) {
return 0.918938533204673 + (y * (x - 0.5));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 0.918938533204673d0 + (y * (x - 0.5d0))
end function
public static double code(double x, double y) {
return 0.918938533204673 + (y * (x - 0.5));
}
def code(x, y): return 0.918938533204673 + (y * (x - 0.5))
function code(x, y) return Float64(0.918938533204673 + Float64(y * Float64(x - 0.5))) end
function tmp = code(x, y) tmp = 0.918938533204673 + (y * (x - 0.5)); end
code[x_, y_] := N[(0.918938533204673 + N[(y * N[(x - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.918938533204673 + y \cdot \left(x - 0.5\right)
\end{array}
Initial program 100.0%
associate-+l-100.0%
fma-neg100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
fma-neg100.0%
sub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 76.2%
associate--r-76.2%
distribute-lft-out--76.2%
Applied egg-rr76.2%
Final simplification76.2%
(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%
fma-neg100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
fma-neg100.0%
sub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 76.2%
Taylor expanded in y around 0 32.8%
Final simplification32.8%
herbie shell --seed 2023199
(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))