
(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 (+ 0.918938533204673 (- (* x (+ y -1.0)) (* y 0.5))))
double code(double x, double y) {
return 0.918938533204673 + ((x * (y + -1.0)) - (y * 0.5));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 0.918938533204673d0 + ((x * (y + (-1.0d0))) - (y * 0.5d0))
end function
public static double code(double x, double y) {
return 0.918938533204673 + ((x * (y + -1.0)) - (y * 0.5));
}
def code(x, y): return 0.918938533204673 + ((x * (y + -1.0)) - (y * 0.5))
function code(x, y) return Float64(0.918938533204673 + Float64(Float64(x * Float64(y + -1.0)) - Float64(y * 0.5))) end
function tmp = code(x, y) tmp = 0.918938533204673 + ((x * (y + -1.0)) - (y * 0.5)); end
code[x_, y_] := N[(0.918938533204673 + N[(N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision] - N[(y * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.918938533204673 + \left(x \cdot \left(y + -1\right) - y \cdot 0.5\right)
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* x (+ y -1.0))))
(if (<= x -0.025)
t_0
(if (<= x -1.2e-72)
(* y -0.5)
(if (<= x -5.2e-187)
(- 0.918938533204673 x)
(if (<= x 2.7e-275)
(* y -0.5)
(if (<= x 3.4e-105)
(- 0.918938533204673 x)
(if (<= x 0.5) (* y -0.5) t_0))))))))
double code(double x, double y) {
double t_0 = x * (y + -1.0);
double tmp;
if (x <= -0.025) {
tmp = t_0;
} else if (x <= -1.2e-72) {
tmp = y * -0.5;
} else if (x <= -5.2e-187) {
tmp = 0.918938533204673 - x;
} else if (x <= 2.7e-275) {
tmp = y * -0.5;
} else if (x <= 3.4e-105) {
tmp = 0.918938533204673 - x;
} else if (x <= 0.5) {
tmp = 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 <= (-0.025d0)) then
tmp = t_0
else if (x <= (-1.2d-72)) then
tmp = y * (-0.5d0)
else if (x <= (-5.2d-187)) then
tmp = 0.918938533204673d0 - x
else if (x <= 2.7d-275) then
tmp = y * (-0.5d0)
else if (x <= 3.4d-105) then
tmp = 0.918938533204673d0 - x
else if (x <= 0.5d0) then
tmp = 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 <= -0.025) {
tmp = t_0;
} else if (x <= -1.2e-72) {
tmp = y * -0.5;
} else if (x <= -5.2e-187) {
tmp = 0.918938533204673 - x;
} else if (x <= 2.7e-275) {
tmp = y * -0.5;
} else if (x <= 3.4e-105) {
tmp = 0.918938533204673 - x;
} else if (x <= 0.5) {
tmp = y * -0.5;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = x * (y + -1.0) tmp = 0 if x <= -0.025: tmp = t_0 elif x <= -1.2e-72: tmp = y * -0.5 elif x <= -5.2e-187: tmp = 0.918938533204673 - x elif x <= 2.7e-275: tmp = y * -0.5 elif x <= 3.4e-105: tmp = 0.918938533204673 - x elif x <= 0.5: tmp = 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 <= -0.025) tmp = t_0; elseif (x <= -1.2e-72) tmp = Float64(y * -0.5); elseif (x <= -5.2e-187) tmp = Float64(0.918938533204673 - x); elseif (x <= 2.7e-275) tmp = Float64(y * -0.5); elseif (x <= 3.4e-105) tmp = Float64(0.918938533204673 - x); elseif (x <= 0.5) tmp = 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 <= -0.025) tmp = t_0; elseif (x <= -1.2e-72) tmp = y * -0.5; elseif (x <= -5.2e-187) tmp = 0.918938533204673 - x; elseif (x <= 2.7e-275) tmp = y * -0.5; elseif (x <= 3.4e-105) tmp = 0.918938533204673 - x; elseif (x <= 0.5) tmp = 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, -0.025], t$95$0, If[LessEqual[x, -1.2e-72], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, -5.2e-187], N[(0.918938533204673 - x), $MachinePrecision], If[LessEqual[x, 2.7e-275], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 3.4e-105], N[(0.918938533204673 - x), $MachinePrecision], If[LessEqual[x, 0.5], N[(y * -0.5), $MachinePrecision], t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(y + -1\right)\\
\mathbf{if}\;x \leq -0.025:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -1.2 \cdot 10^{-72}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq -5.2 \cdot 10^{-187}:\\
\;\;\;\;0.918938533204673 - x\\
\mathbf{elif}\;x \leq 2.7 \cdot 10^{-275}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 3.4 \cdot 10^{-105}:\\
\;\;\;\;0.918938533204673 - x\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -0.025000000000000001 or 0.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 97.5%
if -0.025000000000000001 < x < -1.2e-72 or -5.1999999999999999e-187 < x < 2.69999999999999993e-275 or 3.39999999999999992e-105 < x < 0.5Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 71.6%
Taylor expanded in x around 0 67.8%
*-commutative67.8%
Simplified67.8%
if -1.2e-72 < x < -5.1999999999999999e-187 or 2.69999999999999993e-275 < x < 3.39999999999999992e-105Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 61.7%
neg-mul-161.7%
sub-neg61.7%
Simplified61.7%
Final simplification81.1%
(FPCore (x y) :precision binary64 (if (or (<= x -2.15e-20) (not (<= x 0.018))) (- (* x (+ y -1.0)) (* y 0.5)) (- 0.918938533204673 (* y 0.5))))
double code(double x, double y) {
double tmp;
if ((x <= -2.15e-20) || !(x <= 0.018)) {
tmp = (x * (y + -1.0)) - (y * 0.5);
} 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.15d-20)) .or. (.not. (x <= 0.018d0))) then
tmp = (x * (y + (-1.0d0))) - (y * 0.5d0)
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.15e-20) || !(x <= 0.018)) {
tmp = (x * (y + -1.0)) - (y * 0.5);
} else {
tmp = 0.918938533204673 - (y * 0.5);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -2.15e-20) or not (x <= 0.018): tmp = (x * (y + -1.0)) - (y * 0.5) else: tmp = 0.918938533204673 - (y * 0.5) return tmp
function code(x, y) tmp = 0.0 if ((x <= -2.15e-20) || !(x <= 0.018)) tmp = Float64(Float64(x * Float64(y + -1.0)) - Float64(y * 0.5)); 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.15e-20) || ~((x <= 0.018))) tmp = (x * (y + -1.0)) - (y * 0.5); else tmp = 0.918938533204673 - (y * 0.5); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -2.15e-20], N[Not[LessEqual[x, 0.018]], $MachinePrecision]], N[(N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision] - N[(y * 0.5), $MachinePrecision]), $MachinePrecision], N[(0.918938533204673 - N[(y * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.15 \cdot 10^{-20} \lor \neg \left(x \leq 0.018\right):\\
\;\;\;\;x \cdot \left(y + -1\right) - y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;0.918938533204673 - y \cdot 0.5\\
\end{array}
\end{array}
if x < -2.15000000000000006e-20 or 0.0179999999999999986 < x Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 99.2%
*-commutative99.2%
Simplified99.2%
if -2.15000000000000006e-20 < x < 0.0179999999999999986Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 99.0%
Final simplification99.1%
(FPCore (x y) :precision binary64 (if (or (<= x -2.15e-20) (not (<= x 0.018))) (- (* y (- x 0.5)) x) (- 0.918938533204673 (* y 0.5))))
double code(double x, double y) {
double tmp;
if ((x <= -2.15e-20) || !(x <= 0.018)) {
tmp = (y * (x - 0.5)) - 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.15d-20)) .or. (.not. (x <= 0.018d0))) then
tmp = (y * (x - 0.5d0)) - 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.15e-20) || !(x <= 0.018)) {
tmp = (y * (x - 0.5)) - x;
} else {
tmp = 0.918938533204673 - (y * 0.5);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -2.15e-20) or not (x <= 0.018): tmp = (y * (x - 0.5)) - x else: tmp = 0.918938533204673 - (y * 0.5) return tmp
function code(x, y) tmp = 0.0 if ((x <= -2.15e-20) || !(x <= 0.018)) tmp = Float64(Float64(y * Float64(x - 0.5)) - 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.15e-20) || ~((x <= 0.018))) tmp = (y * (x - 0.5)) - x; else tmp = 0.918938533204673 - (y * 0.5); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -2.15e-20], N[Not[LessEqual[x, 0.018]], $MachinePrecision]], N[(N[(y * N[(x - 0.5), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], N[(0.918938533204673 - N[(y * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.15 \cdot 10^{-20} \lor \neg \left(x \leq 0.018\right):\\
\;\;\;\;y \cdot \left(x - 0.5\right) - x\\
\mathbf{else}:\\
\;\;\;\;0.918938533204673 - y \cdot 0.5\\
\end{array}
\end{array}
if x < -2.15000000000000006e-20 or 0.0179999999999999986 < 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-out99.9%
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-undefine99.9%
associate-+r-99.9%
Applied egg-rr99.9%
Taylor expanded in y around inf 99.2%
if -2.15000000000000006e-20 < x < 0.0179999999999999986Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 99.0%
Final simplification99.1%
(FPCore (x y)
:precision binary64
(if (<= y -13500000.0)
(* y (- x 0.5))
(if (<= y 5500000.0)
(- (* x (+ y -1.0)) -0.918938533204673)
(- (* x y) (* y 0.5)))))
double code(double x, double y) {
double tmp;
if (y <= -13500000.0) {
tmp = y * (x - 0.5);
} else if (y <= 5500000.0) {
tmp = (x * (y + -1.0)) - -0.918938533204673;
} else {
tmp = (x * y) - (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 <= (-13500000.0d0)) then
tmp = y * (x - 0.5d0)
else if (y <= 5500000.0d0) then
tmp = (x * (y + (-1.0d0))) - (-0.918938533204673d0)
else
tmp = (x * y) - (y * 0.5d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -13500000.0) {
tmp = y * (x - 0.5);
} else if (y <= 5500000.0) {
tmp = (x * (y + -1.0)) - -0.918938533204673;
} else {
tmp = (x * y) - (y * 0.5);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -13500000.0: tmp = y * (x - 0.5) elif y <= 5500000.0: tmp = (x * (y + -1.0)) - -0.918938533204673 else: tmp = (x * y) - (y * 0.5) return tmp
function code(x, y) tmp = 0.0 if (y <= -13500000.0) tmp = Float64(y * Float64(x - 0.5)); elseif (y <= 5500000.0) tmp = Float64(Float64(x * Float64(y + -1.0)) - -0.918938533204673); else tmp = Float64(Float64(x * y) - Float64(y * 0.5)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -13500000.0) tmp = y * (x - 0.5); elseif (y <= 5500000.0) tmp = (x * (y + -1.0)) - -0.918938533204673; else tmp = (x * y) - (y * 0.5); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -13500000.0], N[(y * N[(x - 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5500000.0], N[(N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision] - -0.918938533204673), $MachinePrecision], N[(N[(x * y), $MachinePrecision] - N[(y * 0.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -13500000:\\
\;\;\;\;y \cdot \left(x - 0.5\right)\\
\mathbf{elif}\;y \leq 5500000:\\
\;\;\;\;x \cdot \left(y + -1\right) - -0.918938533204673\\
\mathbf{else}:\\
\;\;\;\;x \cdot y - y \cdot 0.5\\
\end{array}
\end{array}
if y < -1.35e7Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 99.9%
if -1.35e7 < y < 5.5e6Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 97.8%
if 5.5e6 < y Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 99.3%
*-commutative99.3%
Simplified99.3%
Taylor expanded in y around inf 99.3%
(FPCore (x y) :precision binary64 (if (or (<= x -0.68) (not (<= x 0.56))) (* x (+ y -1.0)) (- 0.918938533204673 (* y 0.5))))
double code(double x, double y) {
double tmp;
if ((x <= -0.68) || !(x <= 0.56)) {
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.68d0)) .or. (.not. (x <= 0.56d0))) 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.68) || !(x <= 0.56)) {
tmp = x * (y + -1.0);
} else {
tmp = 0.918938533204673 - (y * 0.5);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -0.68) or not (x <= 0.56): tmp = x * (y + -1.0) else: tmp = 0.918938533204673 - (y * 0.5) return tmp
function code(x, y) tmp = 0.0 if ((x <= -0.68) || !(x <= 0.56)) 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.68) || ~((x <= 0.56))) 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.68], N[Not[LessEqual[x, 0.56]], $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.68 \lor \neg \left(x \leq 0.56\right):\\
\;\;\;\;x \cdot \left(y + -1\right)\\
\mathbf{else}:\\
\;\;\;\;0.918938533204673 - y \cdot 0.5\\
\end{array}
\end{array}
if x < -0.680000000000000049 or 0.56000000000000005 < 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.5%
if -0.680000000000000049 < x < 0.56000000000000005Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 97.3%
Final simplification97.4%
(FPCore (x y) :precision binary64 (if (or (<= y -1.45) (not (<= y 1.45))) (* y (- x 0.5)) (- 0.918938533204673 x)))
double code(double x, double y) {
double tmp;
if ((y <= -1.45) || !(y <= 1.45)) {
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.45d0))) 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.45)) {
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.45): 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.45)) 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.45))) 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.45]], $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.45\right):\\
\;\;\;\;y \cdot \left(x - 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;0.918938533204673 - x\\
\end{array}
\end{array}
if y < -1.44999999999999996 or 1.44999999999999996 < y Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 96.8%
if -1.44999999999999996 < y < 1.44999999999999996Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 97.2%
neg-mul-197.2%
sub-neg97.2%
Simplified97.2%
Final simplification97.0%
(FPCore (x y) :precision binary64 (if (<= x -0.68) (* x (+ y -1.0)) (if (<= x 0.85) (- 0.918938533204673 (* y 0.5)) (- (* x y) x))))
double code(double x, double y) {
double tmp;
if (x <= -0.68) {
tmp = x * (y + -1.0);
} else if (x <= 0.85) {
tmp = 0.918938533204673 - (y * 0.5);
} else {
tmp = (x * 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 <= (-0.68d0)) then
tmp = x * (y + (-1.0d0))
else if (x <= 0.85d0) then
tmp = 0.918938533204673d0 - (y * 0.5d0)
else
tmp = (x * y) - 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.85) {
tmp = 0.918938533204673 - (y * 0.5);
} else {
tmp = (x * y) - x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -0.68: tmp = x * (y + -1.0) elif x <= 0.85: tmp = 0.918938533204673 - (y * 0.5) else: tmp = (x * y) - x return tmp
function code(x, y) tmp = 0.0 if (x <= -0.68) tmp = Float64(x * Float64(y + -1.0)); elseif (x <= 0.85) tmp = Float64(0.918938533204673 - Float64(y * 0.5)); else tmp = Float64(Float64(x * y) - 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.85) tmp = 0.918938533204673 - (y * 0.5); else tmp = (x * y) - 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.85], N[(0.918938533204673 - N[(y * 0.5), $MachinePrecision]), $MachinePrecision], N[(N[(x * y), $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.85:\\
\;\;\;\;0.918938533204673 - y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;x \cdot y - 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.8%
if -0.680000000000000049 < x < 0.849999999999999978Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 97.3%
if 0.849999999999999978 < x Initial program 99.9%
cancel-sign-sub-inv99.9%
+-commutative99.9%
sub-neg99.9%
distribute-rgt-in99.9%
metadata-eval99.9%
neg-mul-199.9%
associate-+r+99.9%
unsub-neg99.9%
associate-+l-99.9%
distribute-lft-neg-out99.9%
distribute-rgt-neg-in99.9%
distribute-lft-out99.9%
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-undefine99.9%
associate-+r-99.9%
Applied egg-rr99.9%
Taylor expanded in x around inf 94.8%
*-commutative94.8%
Simplified94.8%
Final simplification97.4%
(FPCore (x y) :precision binary64 (if (or (<= y -400000.0) (not (<= y 1.85))) (* y -0.5) (- 0.918938533204673 x)))
double code(double x, double y) {
double tmp;
if ((y <= -400000.0) || !(y <= 1.85)) {
tmp = y * -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 <= (-400000.0d0)) .or. (.not. (y <= 1.85d0))) then
tmp = y * (-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 <= -400000.0) || !(y <= 1.85)) {
tmp = y * -0.5;
} else {
tmp = 0.918938533204673 - x;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -400000.0) or not (y <= 1.85): tmp = y * -0.5 else: tmp = 0.918938533204673 - x return tmp
function code(x, y) tmp = 0.0 if ((y <= -400000.0) || !(y <= 1.85)) tmp = Float64(y * -0.5); else tmp = Float64(0.918938533204673 - x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -400000.0) || ~((y <= 1.85))) tmp = y * -0.5; else tmp = 0.918938533204673 - x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -400000.0], N[Not[LessEqual[y, 1.85]], $MachinePrecision]], N[(y * -0.5), $MachinePrecision], N[(0.918938533204673 - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -400000 \lor \neg \left(y \leq 1.85\right):\\
\;\;\;\;y \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;0.918938533204673 - x\\
\end{array}
\end{array}
if y < -4e5 or 1.8500000000000001 < y Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 98.1%
Taylor expanded in x around 0 51.0%
*-commutative51.0%
Simplified51.0%
if -4e5 < y < 1.8500000000000001Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 95.1%
neg-mul-195.1%
sub-neg95.1%
Simplified95.1%
Final simplification72.2%
(FPCore (x y) :precision binary64 (if (or (<= y -2e-18) (not (<= y 1.05))) (* y -0.5) (- x)))
double code(double x, double y) {
double tmp;
if ((y <= -2e-18) || !(y <= 1.05)) {
tmp = y * -0.5;
} 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 ((y <= (-2d-18)) .or. (.not. (y <= 1.05d0))) then
tmp = y * (-0.5d0)
else
tmp = -x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -2e-18) || !(y <= 1.05)) {
tmp = y * -0.5;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -2e-18) or not (y <= 1.05): tmp = y * -0.5 else: tmp = -x return tmp
function code(x, y) tmp = 0.0 if ((y <= -2e-18) || !(y <= 1.05)) tmp = Float64(y * -0.5); else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -2e-18) || ~((y <= 1.05))) tmp = y * -0.5; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -2e-18], N[Not[LessEqual[y, 1.05]], $MachinePrecision]], N[(y * -0.5), $MachinePrecision], (-x)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2 \cdot 10^{-18} \lor \neg \left(y \leq 1.05\right):\\
\;\;\;\;y \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if y < -2.0000000000000001e-18 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 93.7%
Taylor expanded in x around 0 48.7%
*-commutative48.7%
Simplified48.7%
if -2.0000000000000001e-18 < y < 1.05000000000000004Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 54.0%
*-commutative54.0%
Simplified54.0%
Taylor expanded in y around 0 52.3%
neg-mul-152.3%
Simplified52.3%
Final simplification50.3%
(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 (- x))
double code(double x, double y) {
return -x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = -x
end function
public static double code(double x, double y) {
return -x;
}
def code(x, y): return -x
function code(x, y) return Float64(-x) end
function tmp = code(x, y) tmp = -x; end
code[x_, y_] := (-x)
\begin{array}{l}
\\
-x
\end{array}
Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 77.1%
*-commutative77.1%
Simplified77.1%
Taylor expanded in y around 0 25.1%
neg-mul-125.1%
Simplified25.1%
herbie shell --seed 2024103
(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))