
(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 9 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%
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%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(if (<= x -2.4e+287)
(- x)
(if (<= x -7.2e+46)
(* y x)
(if (<= x -0.92)
(- x)
(if (<= x 1.32e-295)
0.918938533204673
(if (<= x 3.5e-264)
(* y -0.5)
(if (<= x 0.92) 0.918938533204673 (- x))))))))
double code(double x, double y) {
double tmp;
if (x <= -2.4e+287) {
tmp = -x;
} else if (x <= -7.2e+46) {
tmp = y * x;
} else if (x <= -0.92) {
tmp = -x;
} else if (x <= 1.32e-295) {
tmp = 0.918938533204673;
} else if (x <= 3.5e-264) {
tmp = y * -0.5;
} else if (x <= 0.92) {
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 <= (-2.4d+287)) then
tmp = -x
else if (x <= (-7.2d+46)) then
tmp = y * x
else if (x <= (-0.92d0)) then
tmp = -x
else if (x <= 1.32d-295) then
tmp = 0.918938533204673d0
else if (x <= 3.5d-264) then
tmp = y * (-0.5d0)
else if (x <= 0.92d0) 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 <= -2.4e+287) {
tmp = -x;
} else if (x <= -7.2e+46) {
tmp = y * x;
} else if (x <= -0.92) {
tmp = -x;
} else if (x <= 1.32e-295) {
tmp = 0.918938533204673;
} else if (x <= 3.5e-264) {
tmp = y * -0.5;
} else if (x <= 0.92) {
tmp = 0.918938533204673;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2.4e+287: tmp = -x elif x <= -7.2e+46: tmp = y * x elif x <= -0.92: tmp = -x elif x <= 1.32e-295: tmp = 0.918938533204673 elif x <= 3.5e-264: tmp = y * -0.5 elif x <= 0.92: tmp = 0.918938533204673 else: tmp = -x return tmp
function code(x, y) tmp = 0.0 if (x <= -2.4e+287) tmp = Float64(-x); elseif (x <= -7.2e+46) tmp = Float64(y * x); elseif (x <= -0.92) tmp = Float64(-x); elseif (x <= 1.32e-295) tmp = 0.918938533204673; elseif (x <= 3.5e-264) tmp = Float64(y * -0.5); elseif (x <= 0.92) tmp = 0.918938533204673; else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2.4e+287) tmp = -x; elseif (x <= -7.2e+46) tmp = y * x; elseif (x <= -0.92) tmp = -x; elseif (x <= 1.32e-295) tmp = 0.918938533204673; elseif (x <= 3.5e-264) tmp = y * -0.5; elseif (x <= 0.92) tmp = 0.918938533204673; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2.4e+287], (-x), If[LessEqual[x, -7.2e+46], N[(y * x), $MachinePrecision], If[LessEqual[x, -0.92], (-x), If[LessEqual[x, 1.32e-295], 0.918938533204673, If[LessEqual[x, 3.5e-264], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 0.92], 0.918938533204673, (-x)]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.4 \cdot 10^{+287}:\\
\;\;\;\;-x\\
\mathbf{elif}\;x \leq -7.2 \cdot 10^{+46}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;x \leq -0.92:\\
\;\;\;\;-x\\
\mathbf{elif}\;x \leq 1.32 \cdot 10^{-295}:\\
\;\;\;\;0.918938533204673\\
\mathbf{elif}\;x \leq 3.5 \cdot 10^{-264}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 0.92:\\
\;\;\;\;0.918938533204673\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if x < -2.3999999999999999e287 or -7.1999999999999997e46 < x < -0.92000000000000004 or 0.92000000000000004 < x Initial program 99.9%
associate-+l-99.9%
fma-neg100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
fma-neg99.9%
sub-neg99.9%
remove-double-neg99.9%
+-commutative99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around inf 93.0%
sub-neg93.0%
metadata-eval93.0%
*-commutative93.0%
distribute-rgt-in93.0%
fma-def93.0%
neg-mul-193.0%
fma-neg93.0%
Simplified93.0%
Taylor expanded in y around 0 60.8%
neg-mul-160.8%
Simplified60.8%
if -2.3999999999999999e287 < x < -7.1999999999999997e46Initial 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 68.0%
Taylor expanded in x around inf 67.5%
if -0.92000000000000004 < x < 1.32e-295 or 3.5e-264 < x < 0.92000000000000004Initial 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.9%
Taylor expanded in y around 0 62.3%
if 1.32e-295 < x < 3.5e-264Initial 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 86.0%
Taylor expanded in x around 0 86.0%
*-commutative86.0%
Simplified86.0%
Final simplification63.7%
(FPCore (x y) :precision binary64 (if (or (<= y -6.2e-7) (not (<= y 7.5e-7))) (+ (* y x) (- 0.918938533204673 (* y 0.5))) (- 0.918938533204673 x)))
double code(double x, double y) {
double tmp;
if ((y <= -6.2e-7) || !(y <= 7.5e-7)) {
tmp = (y * x) + (0.918938533204673 - (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 <= (-6.2d-7)) .or. (.not. (y <= 7.5d-7))) then
tmp = (y * x) + (0.918938533204673d0 - (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 <= -6.2e-7) || !(y <= 7.5e-7)) {
tmp = (y * x) + (0.918938533204673 - (y * 0.5));
} else {
tmp = 0.918938533204673 - x;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -6.2e-7) or not (y <= 7.5e-7): tmp = (y * x) + (0.918938533204673 - (y * 0.5)) else: tmp = 0.918938533204673 - x return tmp
function code(x, y) tmp = 0.0 if ((y <= -6.2e-7) || !(y <= 7.5e-7)) tmp = Float64(Float64(y * x) + Float64(0.918938533204673 - 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 <= -6.2e-7) || ~((y <= 7.5e-7))) tmp = (y * x) + (0.918938533204673 - (y * 0.5)); else tmp = 0.918938533204673 - x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -6.2e-7], N[Not[LessEqual[y, 7.5e-7]], $MachinePrecision]], N[(N[(y * x), $MachinePrecision] + N[(0.918938533204673 - N[(y * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.918938533204673 - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.2 \cdot 10^{-7} \lor \neg \left(y \leq 7.5 \cdot 10^{-7}\right):\\
\;\;\;\;y \cdot x + \left(0.918938533204673 - y \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;0.918938533204673 - x\\
\end{array}
\end{array}
if y < -6.1999999999999999e-7 or 7.5000000000000002e-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 100.0%
if -6.1999999999999999e-7 < y < 7.5000000000000002e-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 98.6%
neg-mul-198.6%
sub-neg98.6%
Simplified98.6%
Final simplification99.2%
(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
(if (<= x -0.92)
(- x)
(if (<= x 1.7e-303)
0.918938533204673
(if (<= x 2.9e-266)
(* y -0.5)
(if (<= x 0.92) 0.918938533204673 (- x))))))
double code(double x, double y) {
double tmp;
if (x <= -0.92) {
tmp = -x;
} else if (x <= 1.7e-303) {
tmp = 0.918938533204673;
} else if (x <= 2.9e-266) {
tmp = y * -0.5;
} else if (x <= 0.92) {
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 <= 1.7d-303) then
tmp = 0.918938533204673d0
else if (x <= 2.9d-266) then
tmp = y * (-0.5d0)
else if (x <= 0.92d0) 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 <= 1.7e-303) {
tmp = 0.918938533204673;
} else if (x <= 2.9e-266) {
tmp = y * -0.5;
} else if (x <= 0.92) {
tmp = 0.918938533204673;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -0.92: tmp = -x elif x <= 1.7e-303: tmp = 0.918938533204673 elif x <= 2.9e-266: tmp = y * -0.5 elif x <= 0.92: tmp = 0.918938533204673 else: tmp = -x return tmp
function code(x, y) tmp = 0.0 if (x <= -0.92) tmp = Float64(-x); elseif (x <= 1.7e-303) tmp = 0.918938533204673; elseif (x <= 2.9e-266) tmp = Float64(y * -0.5); elseif (x <= 0.92) 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 <= 1.7e-303) tmp = 0.918938533204673; elseif (x <= 2.9e-266) tmp = y * -0.5; elseif (x <= 0.92) tmp = 0.918938533204673; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -0.92], (-x), If[LessEqual[x, 1.7e-303], 0.918938533204673, If[LessEqual[x, 2.9e-266], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 0.92], 0.918938533204673, (-x)]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.92:\\
\;\;\;\;-x\\
\mathbf{elif}\;x \leq 1.7 \cdot 10^{-303}:\\
\;\;\;\;0.918938533204673\\
\mathbf{elif}\;x \leq 2.9 \cdot 10^{-266}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 0.92:\\
\;\;\;\;0.918938533204673\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if x < -0.92000000000000004 or 0.92000000000000004 < 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 x around inf 96.1%
sub-neg96.1%
metadata-eval96.1%
*-commutative96.1%
distribute-rgt-in96.1%
fma-def96.1%
neg-mul-196.1%
fma-neg96.1%
Simplified96.1%
Taylor expanded in y around 0 49.5%
neg-mul-149.5%
Simplified49.5%
if -0.92000000000000004 < x < 1.7e-303 or 2.89999999999999996e-266 < x < 0.92000000000000004Initial 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.9%
Taylor expanded in y around 0 62.3%
if 1.7e-303 < x < 2.89999999999999996e-266Initial 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 86.0%
Taylor expanded in x around 0 86.0%
*-commutative86.0%
Simplified86.0%
Final simplification56.2%
(FPCore (x y)
:precision binary64
(if (<= y -880000000000.0)
(* y x)
(if (<= y 1.82)
(- 0.918938533204673 x)
(if (<= y 6.6e+179) (* y -0.5) (* y x)))))
double code(double x, double y) {
double tmp;
if (y <= -880000000000.0) {
tmp = y * x;
} else if (y <= 1.82) {
tmp = 0.918938533204673 - x;
} else if (y <= 6.6e+179) {
tmp = y * -0.5;
} 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 <= (-880000000000.0d0)) then
tmp = y * x
else if (y <= 1.82d0) then
tmp = 0.918938533204673d0 - x
else if (y <= 6.6d+179) then
tmp = y * (-0.5d0)
else
tmp = y * x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -880000000000.0) {
tmp = y * x;
} else if (y <= 1.82) {
tmp = 0.918938533204673 - x;
} else if (y <= 6.6e+179) {
tmp = y * -0.5;
} else {
tmp = y * x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -880000000000.0: tmp = y * x elif y <= 1.82: tmp = 0.918938533204673 - x elif y <= 6.6e+179: tmp = y * -0.5 else: tmp = y * x return tmp
function code(x, y) tmp = 0.0 if (y <= -880000000000.0) tmp = Float64(y * x); elseif (y <= 1.82) tmp = Float64(0.918938533204673 - x); elseif (y <= 6.6e+179) tmp = Float64(y * -0.5); else tmp = Float64(y * x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -880000000000.0) tmp = y * x; elseif (y <= 1.82) tmp = 0.918938533204673 - x; elseif (y <= 6.6e+179) tmp = y * -0.5; else tmp = y * x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -880000000000.0], N[(y * x), $MachinePrecision], If[LessEqual[y, 1.82], N[(0.918938533204673 - x), $MachinePrecision], If[LessEqual[y, 6.6e+179], N[(y * -0.5), $MachinePrecision], N[(y * x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -880000000000:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;y \leq 1.82:\\
\;\;\;\;0.918938533204673 - x\\
\mathbf{elif}\;y \leq 6.6 \cdot 10^{+179}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;y \cdot x\\
\end{array}
\end{array}
if y < -8.8e11 or 6.59999999999999955e179 < y Initial program 99.9%
associate-+l-99.9%
fma-neg100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
fma-neg99.9%
sub-neg99.9%
remove-double-neg99.9%
+-commutative99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around inf 99.9%
Taylor expanded in x around inf 65.4%
if -8.8e11 < y < 1.82000000000000006Initial 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 96.5%
neg-mul-196.5%
sub-neg96.5%
Simplified96.5%
if 1.82000000000000006 < y < 6.59999999999999955e179Initial 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.9%
Taylor expanded in x around 0 73.4%
*-commutative73.4%
Simplified73.4%
Final simplification83.5%
(FPCore (x y) :precision binary64 (if (or (<= y -1.45) (not (<= y 1.7))) (* y (- x 0.5)) (- 0.918938533204673 x)))
double code(double x, double y) {
double tmp;
if ((y <= -1.45) || !(y <= 1.7)) {
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.7d0))) 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.7)) {
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.7): 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.7)) 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.7))) 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.7]], $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.7\right):\\
\;\;\;\;y \cdot \left(x - 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;0.918938533204673 - x\\
\end{array}
\end{array}
if y < -1.44999999999999996 or 1.69999999999999996 < 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.7%
if -1.44999999999999996 < y < 1.69999999999999996Initial 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.7%
neg-mul-197.7%
sub-neg97.7%
Simplified97.7%
Final simplification98.2%
(FPCore (x y) :precision binary64 (if (<= x -0.92) (- x) (if (<= x 0.92) 0.918938533204673 (- x))))
double code(double x, double y) {
double tmp;
if (x <= -0.92) {
tmp = -x;
} else if (x <= 0.92) {
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 <= 0.92d0) 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 <= 0.92) {
tmp = 0.918938533204673;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -0.92: tmp = -x elif x <= 0.92: tmp = 0.918938533204673 else: tmp = -x return tmp
function code(x, y) tmp = 0.0 if (x <= -0.92) tmp = Float64(-x); elseif (x <= 0.92) 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 <= 0.92) tmp = 0.918938533204673; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -0.92], (-x), If[LessEqual[x, 0.92], 0.918938533204673, (-x)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.92:\\
\;\;\;\;-x\\
\mathbf{elif}\;x \leq 0.92:\\
\;\;\;\;0.918938533204673\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if x < -0.92000000000000004 or 0.92000000000000004 < 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 x around inf 96.1%
sub-neg96.1%
metadata-eval96.1%
*-commutative96.1%
distribute-rgt-in96.1%
fma-def96.1%
neg-mul-196.1%
fma-neg96.1%
Simplified96.1%
Taylor expanded in y around 0 49.5%
neg-mul-149.5%
Simplified49.5%
if -0.92000000000000004 < x < 0.92000000000000004Initial 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.9%
Taylor expanded in y around 0 59.6%
Final simplification54.3%
(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 73.7%
Taylor expanded in y around 0 29.4%
Final simplification29.4%
herbie shell --seed 2023238
(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))