
(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 8 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
(let* ((t_0 (+ 0.918938533204673 (* x y))))
(if (<= x -7.4e+264)
(- 0.918938533204673 x)
(if (<= x -2.6e+20)
t_0
(if (<= x -1e-13)
(- 0.918938533204673 x)
(if (<= x 0.5) (- 0.918938533204673 (* y 0.5)) t_0))))))
double code(double x, double y) {
double t_0 = 0.918938533204673 + (x * y);
double tmp;
if (x <= -7.4e+264) {
tmp = 0.918938533204673 - x;
} else if (x <= -2.6e+20) {
tmp = t_0;
} else if (x <= -1e-13) {
tmp = 0.918938533204673 - x;
} else if (x <= 0.5) {
tmp = 0.918938533204673 - (y * 0.5);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = 0.918938533204673d0 + (x * y)
if (x <= (-7.4d+264)) then
tmp = 0.918938533204673d0 - x
else if (x <= (-2.6d+20)) then
tmp = t_0
else if (x <= (-1d-13)) then
tmp = 0.918938533204673d0 - x
else if (x <= 0.5d0) then
tmp = 0.918938533204673d0 - (y * 0.5d0)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 0.918938533204673 + (x * y);
double tmp;
if (x <= -7.4e+264) {
tmp = 0.918938533204673 - x;
} else if (x <= -2.6e+20) {
tmp = t_0;
} else if (x <= -1e-13) {
tmp = 0.918938533204673 - x;
} else if (x <= 0.5) {
tmp = 0.918938533204673 - (y * 0.5);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 0.918938533204673 + (x * y) tmp = 0 if x <= -7.4e+264: tmp = 0.918938533204673 - x elif x <= -2.6e+20: tmp = t_0 elif x <= -1e-13: tmp = 0.918938533204673 - x elif x <= 0.5: tmp = 0.918938533204673 - (y * 0.5) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(0.918938533204673 + Float64(x * y)) tmp = 0.0 if (x <= -7.4e+264) tmp = Float64(0.918938533204673 - x); elseif (x <= -2.6e+20) tmp = t_0; elseif (x <= -1e-13) tmp = Float64(0.918938533204673 - x); elseif (x <= 0.5) tmp = Float64(0.918938533204673 - Float64(y * 0.5)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 0.918938533204673 + (x * y); tmp = 0.0; if (x <= -7.4e+264) tmp = 0.918938533204673 - x; elseif (x <= -2.6e+20) tmp = t_0; elseif (x <= -1e-13) tmp = 0.918938533204673 - x; elseif (x <= 0.5) tmp = 0.918938533204673 - (y * 0.5); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(0.918938533204673 + N[(x * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -7.4e+264], N[(0.918938533204673 - x), $MachinePrecision], If[LessEqual[x, -2.6e+20], t$95$0, If[LessEqual[x, -1e-13], N[(0.918938533204673 - x), $MachinePrecision], If[LessEqual[x, 0.5], N[(0.918938533204673 - N[(y * 0.5), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.918938533204673 + x \cdot y\\
\mathbf{if}\;x \leq -7.4 \cdot 10^{+264}:\\
\;\;\;\;0.918938533204673 - x\\
\mathbf{elif}\;x \leq -2.6 \cdot 10^{+20}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -1 \cdot 10^{-13}:\\
\;\;\;\;0.918938533204673 - x\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;0.918938533204673 - y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -7.3999999999999998e264 or -2.6e20 < x < -1e-13Initial program 100.0%
+-commutative100.0%
cancel-sign-sub-inv100.0%
+-commutative100.0%
associate-+r+100.0%
cancel-sign-sub-inv100.0%
associate-+l-100.0%
sub-neg100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
associate--r+100.0%
distribute-lft-out--100.0%
unsub-neg100.0%
fma-neg100.0%
unsub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 89.0%
if -7.3999999999999998e264 < x < -2.6e20 or 0.5 < x Initial program 100.0%
+-commutative100.0%
cancel-sign-sub-inv100.0%
+-commutative100.0%
associate-+r+100.0%
cancel-sign-sub-inv100.0%
associate-+l-100.0%
sub-neg100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
associate--r+100.0%
distribute-lft-out--100.0%
unsub-neg100.0%
fma-neg100.0%
unsub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 60.7%
Taylor expanded in x around inf 60.6%
mul-1-neg60.6%
distribute-lft-neg-out60.6%
*-commutative60.6%
Simplified60.6%
if -1e-13 < x < 0.5Initial program 100.0%
+-commutative100.0%
cancel-sign-sub-inv100.0%
+-commutative100.0%
associate-+r+100.0%
cancel-sign-sub-inv100.0%
associate-+l-100.0%
sub-neg100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
associate--r+100.0%
distribute-lft-out--100.0%
unsub-neg100.0%
fma-neg100.0%
unsub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 98.7%
*-commutative98.7%
Simplified98.7%
Final simplification82.2%
(FPCore (x y) :precision binary64 (if (or (<= x -1e-13) (not (<= x 0.00025))) (+ 0.918938533204673 (* x (+ y -1.0))) (- 0.918938533204673 (* y 0.5))))
double code(double x, double y) {
double tmp;
if ((x <= -1e-13) || !(x <= 0.00025)) {
tmp = 0.918938533204673 + (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 <= (-1d-13)) .or. (.not. (x <= 0.00025d0))) then
tmp = 0.918938533204673d0 + (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 <= -1e-13) || !(x <= 0.00025)) {
tmp = 0.918938533204673 + (x * (y + -1.0));
} else {
tmp = 0.918938533204673 - (y * 0.5);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1e-13) or not (x <= 0.00025): tmp = 0.918938533204673 + (x * (y + -1.0)) else: tmp = 0.918938533204673 - (y * 0.5) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1e-13) || !(x <= 0.00025)) tmp = Float64(0.918938533204673 + 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 <= -1e-13) || ~((x <= 0.00025))) tmp = 0.918938533204673 + (x * (y + -1.0)); else tmp = 0.918938533204673 - (y * 0.5); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1e-13], N[Not[LessEqual[x, 0.00025]], $MachinePrecision]], N[(0.918938533204673 + N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.918938533204673 - N[(y * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-13} \lor \neg \left(x \leq 0.00025\right):\\
\;\;\;\;0.918938533204673 + x \cdot \left(y + -1\right)\\
\mathbf{else}:\\
\;\;\;\;0.918938533204673 - y \cdot 0.5\\
\end{array}
\end{array}
if x < -1e-13 or 2.5000000000000001e-4 < x Initial program 100.0%
+-commutative100.0%
cancel-sign-sub-inv100.0%
+-commutative100.0%
associate-+r+100.0%
cancel-sign-sub-inv100.0%
associate-+l-100.0%
sub-neg100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
associate--r+100.0%
distribute-lft-out--100.0%
unsub-neg100.0%
fma-neg100.0%
unsub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in x around inf 99.9%
mul-1-neg99.9%
unsub-neg99.9%
Simplified99.9%
if -1e-13 < x < 2.5000000000000001e-4Initial program 100.0%
+-commutative100.0%
cancel-sign-sub-inv100.0%
+-commutative100.0%
associate-+r+100.0%
cancel-sign-sub-inv100.0%
associate-+l-100.0%
sub-neg100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
associate--r+100.0%
distribute-lft-out--100.0%
unsub-neg100.0%
fma-neg100.0%
unsub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 98.7%
*-commutative98.7%
Simplified98.7%
Final simplification99.3%
(FPCore (x y) :precision binary64 (if (or (<= x -1e-13) (not (<= x 1.25))) (+ 0.918938533204673 (* x (+ y -1.0))) (+ 0.918938533204673 (* y (- x 0.5)))))
double code(double x, double y) {
double tmp;
if ((x <= -1e-13) || !(x <= 1.25)) {
tmp = 0.918938533204673 + (x * (y + -1.0));
} else {
tmp = 0.918938533204673 + (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 <= (-1d-13)) .or. (.not. (x <= 1.25d0))) then
tmp = 0.918938533204673d0 + (x * (y + (-1.0d0)))
else
tmp = 0.918938533204673d0 + (y * (x - 0.5d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -1e-13) || !(x <= 1.25)) {
tmp = 0.918938533204673 + (x * (y + -1.0));
} else {
tmp = 0.918938533204673 + (y * (x - 0.5));
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1e-13) or not (x <= 1.25): tmp = 0.918938533204673 + (x * (y + -1.0)) else: tmp = 0.918938533204673 + (y * (x - 0.5)) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1e-13) || !(x <= 1.25)) tmp = Float64(0.918938533204673 + Float64(x * Float64(y + -1.0))); else tmp = Float64(0.918938533204673 + Float64(y * Float64(x - 0.5))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1e-13) || ~((x <= 1.25))) tmp = 0.918938533204673 + (x * (y + -1.0)); else tmp = 0.918938533204673 + (y * (x - 0.5)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1e-13], N[Not[LessEqual[x, 1.25]], $MachinePrecision]], N[(0.918938533204673 + N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.918938533204673 + N[(y * N[(x - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-13} \lor \neg \left(x \leq 1.25\right):\\
\;\;\;\;0.918938533204673 + x \cdot \left(y + -1\right)\\
\mathbf{else}:\\
\;\;\;\;0.918938533204673 + y \cdot \left(x - 0.5\right)\\
\end{array}
\end{array}
if x < -1e-13 or 1.25 < x Initial program 100.0%
+-commutative100.0%
cancel-sign-sub-inv100.0%
+-commutative100.0%
associate-+r+100.0%
cancel-sign-sub-inv100.0%
associate-+l-100.0%
sub-neg100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
associate--r+100.0%
distribute-lft-out--100.0%
unsub-neg100.0%
fma-neg100.0%
unsub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in x around inf 99.9%
mul-1-neg99.9%
unsub-neg99.9%
Simplified99.9%
if -1e-13 < x < 1.25Initial program 100.0%
+-commutative100.0%
cancel-sign-sub-inv100.0%
+-commutative100.0%
associate-+r+100.0%
cancel-sign-sub-inv100.0%
associate-+l-100.0%
sub-neg100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
associate--r+100.0%
distribute-lft-out--100.0%
unsub-neg100.0%
fma-neg100.0%
unsub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 100.0%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(if (<= x -1e-13)
(+ 0.918938533204673 (* x (+ y -1.0)))
(if (<= x 1.4)
(+ 0.918938533204673 (* y (- x 0.5)))
(+ 0.918938533204673 (- (* x y) x)))))
double code(double x, double y) {
double tmp;
if (x <= -1e-13) {
tmp = 0.918938533204673 + (x * (y + -1.0));
} else if (x <= 1.4) {
tmp = 0.918938533204673 + (y * (x - 0.5));
} else {
tmp = 0.918938533204673 + ((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 <= (-1d-13)) then
tmp = 0.918938533204673d0 + (x * (y + (-1.0d0)))
else if (x <= 1.4d0) then
tmp = 0.918938533204673d0 + (y * (x - 0.5d0))
else
tmp = 0.918938533204673d0 + ((x * y) - x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1e-13) {
tmp = 0.918938533204673 + (x * (y + -1.0));
} else if (x <= 1.4) {
tmp = 0.918938533204673 + (y * (x - 0.5));
} else {
tmp = 0.918938533204673 + ((x * y) - x);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1e-13: tmp = 0.918938533204673 + (x * (y + -1.0)) elif x <= 1.4: tmp = 0.918938533204673 + (y * (x - 0.5)) else: tmp = 0.918938533204673 + ((x * y) - x) return tmp
function code(x, y) tmp = 0.0 if (x <= -1e-13) tmp = Float64(0.918938533204673 + Float64(x * Float64(y + -1.0))); elseif (x <= 1.4) tmp = Float64(0.918938533204673 + Float64(y * Float64(x - 0.5))); else tmp = Float64(0.918938533204673 + Float64(Float64(x * y) - x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1e-13) tmp = 0.918938533204673 + (x * (y + -1.0)); elseif (x <= 1.4) tmp = 0.918938533204673 + (y * (x - 0.5)); else tmp = 0.918938533204673 + ((x * y) - x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1e-13], N[(0.918938533204673 + N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.4], N[(0.918938533204673 + N[(y * N[(x - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.918938533204673 + N[(N[(x * y), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-13}:\\
\;\;\;\;0.918938533204673 + x \cdot \left(y + -1\right)\\
\mathbf{elif}\;x \leq 1.4:\\
\;\;\;\;0.918938533204673 + y \cdot \left(x - 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;0.918938533204673 + \left(x \cdot y - x\right)\\
\end{array}
\end{array}
if x < -1e-13Initial program 100.0%
+-commutative100.0%
cancel-sign-sub-inv100.0%
+-commutative100.0%
associate-+r+100.0%
cancel-sign-sub-inv100.0%
associate-+l-100.0%
sub-neg100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
associate--r+100.0%
distribute-lft-out--100.0%
unsub-neg100.0%
fma-neg100.0%
unsub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
mul-1-neg100.0%
unsub-neg100.0%
Simplified100.0%
if -1e-13 < x < 1.3999999999999999Initial program 100.0%
+-commutative100.0%
cancel-sign-sub-inv100.0%
+-commutative100.0%
associate-+r+100.0%
cancel-sign-sub-inv100.0%
associate-+l-100.0%
sub-neg100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
associate--r+100.0%
distribute-lft-out--100.0%
unsub-neg100.0%
fma-neg100.0%
unsub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 100.0%
if 1.3999999999999999 < x Initial program 100.0%
+-commutative100.0%
cancel-sign-sub-inv100.0%
+-commutative100.0%
associate-+r+100.0%
cancel-sign-sub-inv100.0%
associate-+l-100.0%
sub-neg100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
associate--r+100.0%
distribute-lft-out--100.0%
unsub-neg100.0%
fma-neg100.0%
unsub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
fma-udef100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 99.8%
mul-1-neg60.0%
distribute-lft-neg-out60.0%
*-commutative60.0%
Simplified99.8%
+-commutative99.8%
distribute-rgt-neg-out99.8%
unsub-neg99.8%
Applied egg-rr99.8%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (or (<= x -1e-13) (not (<= x 6.8e-5))) (- 0.918938533204673 x) (- 0.918938533204673 (* y 0.5))))
double code(double x, double y) {
double tmp;
if ((x <= -1e-13) || !(x <= 6.8e-5)) {
tmp = 0.918938533204673 - 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 <= (-1d-13)) .or. (.not. (x <= 6.8d-5))) then
tmp = 0.918938533204673d0 - 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 <= -1e-13) || !(x <= 6.8e-5)) {
tmp = 0.918938533204673 - x;
} else {
tmp = 0.918938533204673 - (y * 0.5);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1e-13) or not (x <= 6.8e-5): tmp = 0.918938533204673 - x else: tmp = 0.918938533204673 - (y * 0.5) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1e-13) || !(x <= 6.8e-5)) tmp = Float64(0.918938533204673 - 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 <= -1e-13) || ~((x <= 6.8e-5))) tmp = 0.918938533204673 - x; else tmp = 0.918938533204673 - (y * 0.5); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1e-13], N[Not[LessEqual[x, 6.8e-5]], $MachinePrecision]], N[(0.918938533204673 - x), $MachinePrecision], N[(0.918938533204673 - N[(y * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-13} \lor \neg \left(x \leq 6.8 \cdot 10^{-5}\right):\\
\;\;\;\;0.918938533204673 - x\\
\mathbf{else}:\\
\;\;\;\;0.918938533204673 - y \cdot 0.5\\
\end{array}
\end{array}
if x < -1e-13 or 6.7999999999999999e-5 < x Initial program 100.0%
+-commutative100.0%
cancel-sign-sub-inv100.0%
+-commutative100.0%
associate-+r+100.0%
cancel-sign-sub-inv100.0%
associate-+l-100.0%
sub-neg100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
associate--r+100.0%
distribute-lft-out--100.0%
unsub-neg100.0%
fma-neg100.0%
unsub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 47.6%
if -1e-13 < x < 6.7999999999999999e-5Initial program 100.0%
+-commutative100.0%
cancel-sign-sub-inv100.0%
+-commutative100.0%
associate-+r+100.0%
cancel-sign-sub-inv100.0%
associate-+l-100.0%
sub-neg100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
associate--r+100.0%
distribute-lft-out--100.0%
unsub-neg100.0%
fma-neg100.0%
unsub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 98.7%
*-commutative98.7%
Simplified98.7%
Final simplification74.0%
(FPCore (x y) :precision binary64 (+ 0.918938533204673 (- (* y (- x 0.5)) x)))
double code(double x, double y) {
return 0.918938533204673 + ((y * (x - 0.5)) - x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 0.918938533204673d0 + ((y * (x - 0.5d0)) - x)
end function
public static double code(double x, double y) {
return 0.918938533204673 + ((y * (x - 0.5)) - x);
}
def code(x, y): return 0.918938533204673 + ((y * (x - 0.5)) - x)
function code(x, y) return Float64(0.918938533204673 + Float64(Float64(y * Float64(x - 0.5)) - x)) end
function tmp = code(x, y) tmp = 0.918938533204673 + ((y * (x - 0.5)) - x); end
code[x_, y_] := N[(0.918938533204673 + N[(N[(y * N[(x - 0.5), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.918938533204673 + \left(y \cdot \left(x - 0.5\right) - x\right)
\end{array}
Initial program 100.0%
+-commutative100.0%
cancel-sign-sub-inv100.0%
+-commutative100.0%
associate-+r+100.0%
cancel-sign-sub-inv100.0%
associate-+l-100.0%
sub-neg100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
associate--r+100.0%
distribute-lft-out--100.0%
unsub-neg100.0%
fma-neg100.0%
unsub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
fma-udef100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y) :precision binary64 (- 0.918938533204673 x))
double code(double x, double y) {
return 0.918938533204673 - x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 0.918938533204673d0 - x
end function
public static double code(double x, double y) {
return 0.918938533204673 - x;
}
def code(x, y): return 0.918938533204673 - x
function code(x, y) return Float64(0.918938533204673 - x) end
function tmp = code(x, y) tmp = 0.918938533204673 - x; end
code[x_, y_] := N[(0.918938533204673 - x), $MachinePrecision]
\begin{array}{l}
\\
0.918938533204673 - x
\end{array}
Initial program 100.0%
+-commutative100.0%
cancel-sign-sub-inv100.0%
+-commutative100.0%
associate-+r+100.0%
cancel-sign-sub-inv100.0%
associate-+l-100.0%
sub-neg100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
associate--r+100.0%
distribute-lft-out--100.0%
unsub-neg100.0%
fma-neg100.0%
unsub-neg100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 48.6%
Final simplification48.6%
herbie shell --seed 2023308
(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))