
(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 (- (+ 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%
sub-neg100.0%
+-commutative100.0%
sub-neg100.0%
distribute-rgt-in100.0%
associate-+r+100.0%
associate-+l+100.0%
distribute-rgt-neg-in100.0%
distribute-lft-out100.0%
fma-def100.0%
+-commutative100.0%
metadata-eval100.0%
+-commutative100.0%
cancel-sign-sub-inv100.0%
*-lft-identity100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(if (<= y -1.9e+271)
(* y -0.5)
(if (<= y -7.5e+215)
(* y x)
(if (<= y -4.1e+183)
(* y -0.5)
(if (<= y -3e+20)
(* y x)
(if (<= y -1.25e-139)
0.918938533204673
(if (<= y -1.3e-190)
(- x)
(if (<= y 9e-298)
0.918938533204673
(if (<= y 8.5e-7)
(- x)
(if (<= y 2e+67) (* y x) (* y -0.5)))))))))))
double code(double x, double y) {
double tmp;
if (y <= -1.9e+271) {
tmp = y * -0.5;
} else if (y <= -7.5e+215) {
tmp = y * x;
} else if (y <= -4.1e+183) {
tmp = y * -0.5;
} else if (y <= -3e+20) {
tmp = y * x;
} else if (y <= -1.25e-139) {
tmp = 0.918938533204673;
} else if (y <= -1.3e-190) {
tmp = -x;
} else if (y <= 9e-298) {
tmp = 0.918938533204673;
} else if (y <= 8.5e-7) {
tmp = -x;
} else if (y <= 2e+67) {
tmp = y * x;
} 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.9d+271)) then
tmp = y * (-0.5d0)
else if (y <= (-7.5d+215)) then
tmp = y * x
else if (y <= (-4.1d+183)) then
tmp = y * (-0.5d0)
else if (y <= (-3d+20)) then
tmp = y * x
else if (y <= (-1.25d-139)) then
tmp = 0.918938533204673d0
else if (y <= (-1.3d-190)) then
tmp = -x
else if (y <= 9d-298) then
tmp = 0.918938533204673d0
else if (y <= 8.5d-7) then
tmp = -x
else if (y <= 2d+67) then
tmp = y * x
else
tmp = y * (-0.5d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.9e+271) {
tmp = y * -0.5;
} else if (y <= -7.5e+215) {
tmp = y * x;
} else if (y <= -4.1e+183) {
tmp = y * -0.5;
} else if (y <= -3e+20) {
tmp = y * x;
} else if (y <= -1.25e-139) {
tmp = 0.918938533204673;
} else if (y <= -1.3e-190) {
tmp = -x;
} else if (y <= 9e-298) {
tmp = 0.918938533204673;
} else if (y <= 8.5e-7) {
tmp = -x;
} else if (y <= 2e+67) {
tmp = y * x;
} else {
tmp = y * -0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.9e+271: tmp = y * -0.5 elif y <= -7.5e+215: tmp = y * x elif y <= -4.1e+183: tmp = y * -0.5 elif y <= -3e+20: tmp = y * x elif y <= -1.25e-139: tmp = 0.918938533204673 elif y <= -1.3e-190: tmp = -x elif y <= 9e-298: tmp = 0.918938533204673 elif y <= 8.5e-7: tmp = -x elif y <= 2e+67: tmp = y * x else: tmp = y * -0.5 return tmp
function code(x, y) tmp = 0.0 if (y <= -1.9e+271) tmp = Float64(y * -0.5); elseif (y <= -7.5e+215) tmp = Float64(y * x); elseif (y <= -4.1e+183) tmp = Float64(y * -0.5); elseif (y <= -3e+20) tmp = Float64(y * x); elseif (y <= -1.25e-139) tmp = 0.918938533204673; elseif (y <= -1.3e-190) tmp = Float64(-x); elseif (y <= 9e-298) tmp = 0.918938533204673; elseif (y <= 8.5e-7) tmp = Float64(-x); elseif (y <= 2e+67) tmp = Float64(y * x); else tmp = Float64(y * -0.5); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.9e+271) tmp = y * -0.5; elseif (y <= -7.5e+215) tmp = y * x; elseif (y <= -4.1e+183) tmp = y * -0.5; elseif (y <= -3e+20) tmp = y * x; elseif (y <= -1.25e-139) tmp = 0.918938533204673; elseif (y <= -1.3e-190) tmp = -x; elseif (y <= 9e-298) tmp = 0.918938533204673; elseif (y <= 8.5e-7) tmp = -x; elseif (y <= 2e+67) tmp = y * x; else tmp = y * -0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.9e+271], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, -7.5e+215], N[(y * x), $MachinePrecision], If[LessEqual[y, -4.1e+183], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, -3e+20], N[(y * x), $MachinePrecision], If[LessEqual[y, -1.25e-139], 0.918938533204673, If[LessEqual[y, -1.3e-190], (-x), If[LessEqual[y, 9e-298], 0.918938533204673, If[LessEqual[y, 8.5e-7], (-x), If[LessEqual[y, 2e+67], N[(y * x), $MachinePrecision], N[(y * -0.5), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.9 \cdot 10^{+271}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq -7.5 \cdot 10^{+215}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;y \leq -4.1 \cdot 10^{+183}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq -3 \cdot 10^{+20}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;y \leq -1.25 \cdot 10^{-139}:\\
\;\;\;\;0.918938533204673\\
\mathbf{elif}\;y \leq -1.3 \cdot 10^{-190}:\\
\;\;\;\;-x\\
\mathbf{elif}\;y \leq 9 \cdot 10^{-298}:\\
\;\;\;\;0.918938533204673\\
\mathbf{elif}\;y \leq 8.5 \cdot 10^{-7}:\\
\;\;\;\;-x\\
\mathbf{elif}\;y \leq 2 \cdot 10^{+67}:\\
\;\;\;\;y \cdot x\\
\mathbf{else}:\\
\;\;\;\;y \cdot -0.5\\
\end{array}
\end{array}
if y < -1.8999999999999999e271 or -7.4999999999999994e215 < y < -4.10000000000000015e183 or 1.99999999999999997e67 < 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 0 63.7%
*-commutative63.7%
Simplified63.7%
if -1.8999999999999999e271 < y < -7.4999999999999994e215 or -4.10000000000000015e183 < y < -3e20 or 8.50000000000000014e-7 < y < 1.99999999999999997e67Initial 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 94.5%
Taylor expanded in x around inf 66.5%
if -3e20 < y < -1.25000000000000008e-139 or -1.2999999999999999e-190 < y < 8.99999999999999985e-298Initial 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 93.3%
neg-mul-193.3%
sub-neg93.3%
Simplified93.3%
Taylor expanded in x around 0 55.9%
if -1.25000000000000008e-139 < y < -1.2999999999999999e-190 or 8.99999999999999985e-298 < y < 8.50000000000000014e-7Initial 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.3%
neg-mul-199.3%
Simplified99.3%
Taylor expanded in x around inf 72.5%
mul-1-neg72.5%
Simplified72.5%
Final simplification64.9%
(FPCore (x y)
:precision binary64
(if (<= y -4.1e+270)
(* y -0.5)
(if (<= y -8.6e+213)
(* y x)
(if (<= y -9e+182)
(* y -0.5)
(if (<= y -3e+20)
(* y x)
(if (<= y 1.25)
(- 0.918938533204673 x)
(if (<= y 9e+68) (* y x) (* y -0.5))))))))
double code(double x, double y) {
double tmp;
if (y <= -4.1e+270) {
tmp = y * -0.5;
} else if (y <= -8.6e+213) {
tmp = y * x;
} else if (y <= -9e+182) {
tmp = y * -0.5;
} else if (y <= -3e+20) {
tmp = y * x;
} else if (y <= 1.25) {
tmp = 0.918938533204673 - x;
} else if (y <= 9e+68) {
tmp = y * x;
} 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 <= (-4.1d+270)) then
tmp = y * (-0.5d0)
else if (y <= (-8.6d+213)) then
tmp = y * x
else if (y <= (-9d+182)) then
tmp = y * (-0.5d0)
else if (y <= (-3d+20)) then
tmp = y * x
else if (y <= 1.25d0) then
tmp = 0.918938533204673d0 - x
else if (y <= 9d+68) then
tmp = y * x
else
tmp = y * (-0.5d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -4.1e+270) {
tmp = y * -0.5;
} else if (y <= -8.6e+213) {
tmp = y * x;
} else if (y <= -9e+182) {
tmp = y * -0.5;
} else if (y <= -3e+20) {
tmp = y * x;
} else if (y <= 1.25) {
tmp = 0.918938533204673 - x;
} else if (y <= 9e+68) {
tmp = y * x;
} else {
tmp = y * -0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -4.1e+270: tmp = y * -0.5 elif y <= -8.6e+213: tmp = y * x elif y <= -9e+182: tmp = y * -0.5 elif y <= -3e+20: tmp = y * x elif y <= 1.25: tmp = 0.918938533204673 - x elif y <= 9e+68: tmp = y * x else: tmp = y * -0.5 return tmp
function code(x, y) tmp = 0.0 if (y <= -4.1e+270) tmp = Float64(y * -0.5); elseif (y <= -8.6e+213) tmp = Float64(y * x); elseif (y <= -9e+182) tmp = Float64(y * -0.5); elseif (y <= -3e+20) tmp = Float64(y * x); elseif (y <= 1.25) tmp = Float64(0.918938533204673 - x); elseif (y <= 9e+68) tmp = Float64(y * x); else tmp = Float64(y * -0.5); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -4.1e+270) tmp = y * -0.5; elseif (y <= -8.6e+213) tmp = y * x; elseif (y <= -9e+182) tmp = y * -0.5; elseif (y <= -3e+20) tmp = y * x; elseif (y <= 1.25) tmp = 0.918938533204673 - x; elseif (y <= 9e+68) tmp = y * x; else tmp = y * -0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -4.1e+270], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, -8.6e+213], N[(y * x), $MachinePrecision], If[LessEqual[y, -9e+182], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, -3e+20], N[(y * x), $MachinePrecision], If[LessEqual[y, 1.25], N[(0.918938533204673 - x), $MachinePrecision], If[LessEqual[y, 9e+68], N[(y * x), $MachinePrecision], N[(y * -0.5), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.1 \cdot 10^{+270}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq -8.6 \cdot 10^{+213}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;y \leq -9 \cdot 10^{+182}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq -3 \cdot 10^{+20}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;y \leq 1.25:\\
\;\;\;\;0.918938533204673 - x\\
\mathbf{elif}\;y \leq 9 \cdot 10^{+68}:\\
\;\;\;\;y \cdot x\\
\mathbf{else}:\\
\;\;\;\;y \cdot -0.5\\
\end{array}
\end{array}
if y < -4.09999999999999996e270 or -8.5999999999999999e213 < y < -9.00000000000000058e182 or 9.0000000000000007e68 < 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 0 63.7%
*-commutative63.7%
Simplified63.7%
if -4.09999999999999996e270 < y < -8.5999999999999999e213 or -9.00000000000000058e182 < y < -3e20 or 1.25 < y < 9.0000000000000007e68Initial 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.7%
Taylor expanded in x around inf 68.6%
if -3e20 < y < 1.25Initial 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 95.1%
neg-mul-195.1%
sub-neg95.1%
Simplified95.1%
Final simplification81.1%
(FPCore (x y) :precision binary64 (if (or (<= y -0.36) (not (<= y 1.7e-7))) (+ (* y x) (- 0.918938533204673 (* y 0.5))) (+ 0.918938533204673 (- (* y x) x))))
double code(double x, double y) {
double tmp;
if ((y <= -0.36) || !(y <= 1.7e-7)) {
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 <= (-0.36d0)) .or. (.not. (y <= 1.7d-7))) 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 <= -0.36) || !(y <= 1.7e-7)) {
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 <= -0.36) or not (y <= 1.7e-7): 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 <= -0.36) || !(y <= 1.7e-7)) tmp = Float64(Float64(y * x) + Float64(0.918938533204673 - Float64(y * 0.5))); else tmp = Float64(0.918938533204673 + Float64(Float64(y * x) - x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -0.36) || ~((y <= 1.7e-7))) 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, -0.36], N[Not[LessEqual[y, 1.7e-7]], $MachinePrecision]], N[(N[(y * x), $MachinePrecision] + N[(0.918938533204673 - N[(y * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.918938533204673 + N[(N[(y * x), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.36 \lor \neg \left(y \leq 1.7 \cdot 10^{-7}\right):\\
\;\;\;\;y \cdot x + \left(0.918938533204673 - y \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;0.918938533204673 + \left(y \cdot x - x\right)\\
\end{array}
\end{array}
if y < -0.35999999999999999 or 1.69999999999999987e-7 < 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 99.5%
if -0.35999999999999999 < y < 1.69999999999999987e-7Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
sub-neg100.0%
distribute-rgt-in100.0%
associate-+r+100.0%
associate-+l+100.0%
distribute-rgt-neg-in100.0%
distribute-lft-out100.0%
fma-def100.0%
+-commutative100.0%
metadata-eval100.0%
+-commutative100.0%
cancel-sign-sub-inv100.0%
*-lft-identity100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
Taylor expanded in x around inf 99.3%
associate--l+99.3%
*-commutative99.3%
+-commutative99.3%
*-commutative99.3%
Applied egg-rr99.3%
Final simplification99.4%
(FPCore (x y)
:precision binary64
(if (<= x -1.75e-30)
(- x)
(if (<= x 3.4e-240)
(* y -0.5)
(if (<= x 3.9e-182)
0.918938533204673
(if (<= x 2.2e-103)
(* y -0.5)
(if (<= x 680000000000.0) 0.918938533204673 (- x)))))))
double code(double x, double y) {
double tmp;
if (x <= -1.75e-30) {
tmp = -x;
} else if (x <= 3.4e-240) {
tmp = y * -0.5;
} else if (x <= 3.9e-182) {
tmp = 0.918938533204673;
} else if (x <= 2.2e-103) {
tmp = y * -0.5;
} else if (x <= 680000000000.0) {
tmp = 0.918938533204673;
} else {
tmp = -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.75d-30)) then
tmp = -x
else if (x <= 3.4d-240) then
tmp = y * (-0.5d0)
else if (x <= 3.9d-182) then
tmp = 0.918938533204673d0
else if (x <= 2.2d-103) then
tmp = y * (-0.5d0)
else if (x <= 680000000000.0d0) then
tmp = 0.918938533204673d0
else
tmp = -x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.75e-30) {
tmp = -x;
} else if (x <= 3.4e-240) {
tmp = y * -0.5;
} else if (x <= 3.9e-182) {
tmp = 0.918938533204673;
} else if (x <= 2.2e-103) {
tmp = y * -0.5;
} else if (x <= 680000000000.0) {
tmp = 0.918938533204673;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.75e-30: tmp = -x elif x <= 3.4e-240: tmp = y * -0.5 elif x <= 3.9e-182: tmp = 0.918938533204673 elif x <= 2.2e-103: tmp = y * -0.5 elif x <= 680000000000.0: tmp = 0.918938533204673 else: tmp = -x return tmp
function code(x, y) tmp = 0.0 if (x <= -1.75e-30) tmp = Float64(-x); elseif (x <= 3.4e-240) tmp = Float64(y * -0.5); elseif (x <= 3.9e-182) tmp = 0.918938533204673; elseif (x <= 2.2e-103) tmp = Float64(y * -0.5); elseif (x <= 680000000000.0) tmp = 0.918938533204673; else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.75e-30) tmp = -x; elseif (x <= 3.4e-240) tmp = y * -0.5; elseif (x <= 3.9e-182) tmp = 0.918938533204673; elseif (x <= 2.2e-103) tmp = y * -0.5; elseif (x <= 680000000000.0) tmp = 0.918938533204673; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.75e-30], (-x), If[LessEqual[x, 3.4e-240], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 3.9e-182], 0.918938533204673, If[LessEqual[x, 2.2e-103], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 680000000000.0], 0.918938533204673, (-x)]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.75 \cdot 10^{-30}:\\
\;\;\;\;-x\\
\mathbf{elif}\;x \leq 3.4 \cdot 10^{-240}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 3.9 \cdot 10^{-182}:\\
\;\;\;\;0.918938533204673\\
\mathbf{elif}\;x \leq 2.2 \cdot 10^{-103}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 680000000000:\\
\;\;\;\;0.918938533204673\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if x < -1.7500000000000001e-30 or 6.8e11 < 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 0 56.8%
neg-mul-156.8%
Simplified56.8%
Taylor expanded in x around inf 53.4%
mul-1-neg53.4%
Simplified53.4%
if -1.7500000000000001e-30 < x < 3.3999999999999999e-240 or 3.9e-182 < x < 2.1999999999999999e-103Initial 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 62.5%
Taylor expanded in x around 0 62.5%
*-commutative62.5%
Simplified62.5%
if 3.3999999999999999e-240 < x < 3.9e-182 or 2.1999999999999999e-103 < x < 6.8e11Initial 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 66.3%
neg-mul-166.3%
sub-neg66.3%
Simplified66.3%
Taylor expanded in x around 0 61.6%
Final simplification57.4%
(FPCore (x y) :precision binary64 (if (or (<= x -1.05e-8) (not (<= x 5.2e-10))) (+ 0.918938533204673 (- (* y x) x)) (- 0.918938533204673 (* y 0.5))))
double code(double x, double y) {
double tmp;
if ((x <= -1.05e-8) || !(x <= 5.2e-10)) {
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 <= (-1.05d-8)) .or. (.not. (x <= 5.2d-10))) 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 <= -1.05e-8) || !(x <= 5.2e-10)) {
tmp = 0.918938533204673 + ((y * x) - x);
} else {
tmp = 0.918938533204673 - (y * 0.5);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.05e-8) or not (x <= 5.2e-10): tmp = 0.918938533204673 + ((y * x) - x) else: tmp = 0.918938533204673 - (y * 0.5) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.05e-8) || !(x <= 5.2e-10)) tmp = Float64(0.918938533204673 + Float64(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 <= -1.05e-8) || ~((x <= 5.2e-10))) 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, -1.05e-8], N[Not[LessEqual[x, 5.2e-10]], $MachinePrecision]], N[(0.918938533204673 + N[(N[(y * x), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], N[(0.918938533204673 - N[(y * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.05 \cdot 10^{-8} \lor \neg \left(x \leq 5.2 \cdot 10^{-10}\right):\\
\;\;\;\;0.918938533204673 + \left(y \cdot x - x\right)\\
\mathbf{else}:\\
\;\;\;\;0.918938533204673 - y \cdot 0.5\\
\end{array}
\end{array}
if x < -1.04999999999999997e-8 or 5.19999999999999962e-10 < x Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
sub-neg100.0%
distribute-rgt-in100.0%
associate-+r+100.0%
associate-+l+100.0%
distribute-rgt-neg-in100.0%
distribute-lft-out100.0%
fma-def100.0%
+-commutative100.0%
metadata-eval100.0%
+-commutative100.0%
cancel-sign-sub-inv100.0%
*-lft-identity100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
Taylor expanded in x around inf 98.6%
associate--l+98.6%
*-commutative98.6%
+-commutative98.6%
*-commutative98.6%
Applied egg-rr98.6%
if -1.04999999999999997e-8 < x < 5.19999999999999962e-10Initial 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 x around 0 99.9%
Final simplification99.2%
(FPCore (x y) :precision binary64 (if (or (<= x -32.0) (not (<= x 0.000285))) (+ 0.918938533204673 (- (* y x) x)) (- (- 0.918938533204673 (* y 0.5)) x)))
double code(double x, double y) {
double tmp;
if ((x <= -32.0) || !(x <= 0.000285)) {
tmp = 0.918938533204673 + ((y * x) - x);
} else {
tmp = (0.918938533204673 - (y * 0.5)) - x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-32.0d0)) .or. (.not. (x <= 0.000285d0))) then
tmp = 0.918938533204673d0 + ((y * x) - x)
else
tmp = (0.918938533204673d0 - (y * 0.5d0)) - x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -32.0) || !(x <= 0.000285)) {
tmp = 0.918938533204673 + ((y * x) - x);
} else {
tmp = (0.918938533204673 - (y * 0.5)) - x;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -32.0) or not (x <= 0.000285): tmp = 0.918938533204673 + ((y * x) - x) else: tmp = (0.918938533204673 - (y * 0.5)) - x return tmp
function code(x, y) tmp = 0.0 if ((x <= -32.0) || !(x <= 0.000285)) tmp = Float64(0.918938533204673 + Float64(Float64(y * x) - x)); else tmp = Float64(Float64(0.918938533204673 - Float64(y * 0.5)) - x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -32.0) || ~((x <= 0.000285))) tmp = 0.918938533204673 + ((y * x) - x); else tmp = (0.918938533204673 - (y * 0.5)) - x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -32.0], N[Not[LessEqual[x, 0.000285]], $MachinePrecision]], N[(0.918938533204673 + N[(N[(y * x), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], N[(N[(0.918938533204673 - N[(y * 0.5), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -32 \lor \neg \left(x \leq 0.000285\right):\\
\;\;\;\;0.918938533204673 + \left(y \cdot x - x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.918938533204673 - y \cdot 0.5\right) - x\\
\end{array}
\end{array}
if x < -32 or 2.8499999999999999e-4 < x Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
sub-neg100.0%
distribute-rgt-in100.0%
associate-+r+100.0%
associate-+l+100.0%
distribute-rgt-neg-in100.0%
distribute-lft-out100.0%
fma-def100.0%
+-commutative100.0%
metadata-eval100.0%
+-commutative100.0%
cancel-sign-sub-inv100.0%
*-lft-identity100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
Taylor expanded in x around inf 99.2%
associate--l+99.2%
*-commutative99.2%
+-commutative99.2%
*-commutative99.2%
Applied egg-rr99.2%
if -32 < x < 2.8499999999999999e-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 0 99.2%
neg-mul-199.2%
Simplified99.2%
Final simplification99.2%
(FPCore (x y) :precision binary64 (if (or (<= y -1.32) (not (<= y 1.0))) (* y (- x 0.5)) (- 0.918938533204673 x)))
double code(double x, double y) {
double tmp;
if ((y <= -1.32) || !(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.32d0)) .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.32) || !(y <= 1.0)) {
tmp = y * (x - 0.5);
} else {
tmp = 0.918938533204673 - x;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.32) 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.32) || !(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.32) || ~((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.32], 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.32 \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.32000000000000006 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 98.3%
if -1.32000000000000006 < 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 97.1%
neg-mul-197.1%
sub-neg97.1%
Simplified97.1%
Final simplification97.7%
(FPCore (x y) :precision binary64 (if (<= x -0.92) (- x) (if (<= x 680000000000.0) 0.918938533204673 (- x))))
double code(double x, double y) {
double tmp;
if (x <= -0.92) {
tmp = -x;
} else if (x <= 680000000000.0) {
tmp = 0.918938533204673;
} else {
tmp = -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.92d0)) then
tmp = -x
else if (x <= 680000000000.0d0) then
tmp = 0.918938533204673d0
else
tmp = -x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -0.92) {
tmp = -x;
} else if (x <= 680000000000.0) {
tmp = 0.918938533204673;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -0.92: tmp = -x elif x <= 680000000000.0: tmp = 0.918938533204673 else: tmp = -x return tmp
function code(x, y) tmp = 0.0 if (x <= -0.92) tmp = Float64(-x); elseif (x <= 680000000000.0) tmp = 0.918938533204673; else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -0.92) tmp = -x; elseif (x <= 680000000000.0) tmp = 0.918938533204673; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -0.92], (-x), If[LessEqual[x, 680000000000.0], 0.918938533204673, (-x)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.92:\\
\;\;\;\;-x\\
\mathbf{elif}\;x \leq 680000000000:\\
\;\;\;\;0.918938533204673\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if x < -0.92000000000000004 or 6.8e11 < 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 0 56.1%
neg-mul-156.1%
Simplified56.1%
Taylor expanded in x around inf 54.7%
mul-1-neg54.7%
Simplified54.7%
if -0.92000000000000004 < x < 6.8e11Initial 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 45.7%
neg-mul-145.7%
sub-neg45.7%
Simplified45.7%
Taylor expanded in x around 0 43.5%
Final simplification49.4%
(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 0 51.0%
neg-mul-151.0%
sub-neg51.0%
Simplified51.0%
Taylor expanded in x around 0 21.7%
Final simplification21.7%
herbie shell --seed 2023230
(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))