
(FPCore (x y) :precision binary64 (- (+ x y) (* x y)))
double code(double x, double y) {
return (x + y) - (x * y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x + y) - (x * y)
end function
public static double code(double x, double y) {
return (x + y) - (x * y);
}
def code(x, y): return (x + y) - (x * y)
function code(x, y) return Float64(Float64(x + y) - Float64(x * y)) end
function tmp = code(x, y) tmp = (x + y) - (x * y); end
code[x_, y_] := N[(N[(x + y), $MachinePrecision] - N[(x * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + y\right) - x \cdot y
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (- (+ x y) (* x y)))
double code(double x, double y) {
return (x + y) - (x * y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x + y) - (x * y)
end function
public static double code(double x, double y) {
return (x + y) - (x * y);
}
def code(x, y): return (x + y) - (x * y)
function code(x, y) return Float64(Float64(x + y) - Float64(x * y)) end
function tmp = code(x, y) tmp = (x + y) - (x * y); end
code[x_, y_] := N[(N[(x + y), $MachinePrecision] - N[(x * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + y\right) - x \cdot y
\end{array}
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (fma x (- 1.0 y) y))
assert(x < y);
double code(double x, double y) {
return fma(x, (1.0 - y), y);
}
x, y = sort([x, y]) function code(x, y) return fma(x, Float64(1.0 - y), y) end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(x * N[(1.0 - y), $MachinePrecision] + y), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\mathsf{fma}\left(x, 1 - y, y\right)
\end{array}
Initial program 100.0%
+-commutative100.0%
*-commutative100.0%
associate--l+100.0%
+-commutative100.0%
*-lft-identity100.0%
metadata-eval100.0%
distribute-rgt-out--100.0%
fma-define100.0%
metadata-eval100.0%
Simplified100.0%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (* x (- y))))
(if (<= y -1.0)
t_0
(if (<= y 2.9e-174)
x
(if (<= y 8.5e-162)
y
(if (<= y 7.5e-48) x (if (<= y 5.6e+266) y t_0)))))))assert(x < y);
double code(double x, double y) {
double t_0 = x * -y;
double tmp;
if (y <= -1.0) {
tmp = t_0;
} else if (y <= 2.9e-174) {
tmp = x;
} else if (y <= 8.5e-162) {
tmp = y;
} else if (y <= 7.5e-48) {
tmp = x;
} else if (y <= 5.6e+266) {
tmp = y;
} else {
tmp = t_0;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
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
if (y <= (-1.0d0)) then
tmp = t_0
else if (y <= 2.9d-174) then
tmp = x
else if (y <= 8.5d-162) then
tmp = y
else if (y <= 7.5d-48) then
tmp = x
else if (y <= 5.6d+266) then
tmp = y
else
tmp = t_0
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = x * -y;
double tmp;
if (y <= -1.0) {
tmp = t_0;
} else if (y <= 2.9e-174) {
tmp = x;
} else if (y <= 8.5e-162) {
tmp = y;
} else if (y <= 7.5e-48) {
tmp = x;
} else if (y <= 5.6e+266) {
tmp = y;
} else {
tmp = t_0;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = x * -y tmp = 0 if y <= -1.0: tmp = t_0 elif y <= 2.9e-174: tmp = x elif y <= 8.5e-162: tmp = y elif y <= 7.5e-48: tmp = x elif y <= 5.6e+266: tmp = y else: tmp = t_0 return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(x * Float64(-y)) tmp = 0.0 if (y <= -1.0) tmp = t_0; elseif (y <= 2.9e-174) tmp = x; elseif (y <= 8.5e-162) tmp = y; elseif (y <= 7.5e-48) tmp = x; elseif (y <= 5.6e+266) tmp = y; else tmp = t_0; end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = x * -y;
tmp = 0.0;
if (y <= -1.0)
tmp = t_0;
elseif (y <= 2.9e-174)
tmp = x;
elseif (y <= 8.5e-162)
tmp = y;
elseif (y <= 7.5e-48)
tmp = x;
elseif (y <= 5.6e+266)
tmp = y;
else
tmp = t_0;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_] := Block[{t$95$0 = N[(x * (-y)), $MachinePrecision]}, If[LessEqual[y, -1.0], t$95$0, If[LessEqual[y, 2.9e-174], x, If[LessEqual[y, 8.5e-162], y, If[LessEqual[y, 7.5e-48], x, If[LessEqual[y, 5.6e+266], y, t$95$0]]]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := x \cdot \left(-y\right)\\
\mathbf{if}\;y \leq -1:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 2.9 \cdot 10^{-174}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 8.5 \cdot 10^{-162}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 7.5 \cdot 10^{-48}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 5.6 \cdot 10^{+266}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1 or 5.5999999999999999e266 < y Initial program 100.0%
associate--l+100.0%
+-commutative100.0%
remove-double-neg100.0%
unsub-neg100.0%
cancel-sign-sub-inv100.0%
associate--l+100.0%
neg-mul-1100.0%
cancel-sign-sub-inv100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-out100.0%
*-commutative100.0%
distribute-rgt-out100.0%
+-commutative100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 98.2%
mul-1-neg98.2%
unsub-neg98.2%
Simplified98.2%
Taylor expanded in x around inf 49.2%
mul-1-neg49.2%
distribute-lft-neg-out49.2%
*-commutative49.2%
Simplified49.2%
if -1 < y < 2.9000000000000001e-174 or 8.49999999999999955e-162 < y < 7.50000000000000042e-48Initial program 100.0%
associate--l+100.0%
+-commutative100.0%
remove-double-neg100.0%
unsub-neg100.0%
cancel-sign-sub-inv100.0%
associate--l+100.0%
neg-mul-1100.0%
cancel-sign-sub-inv100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-out100.0%
*-commutative100.0%
distribute-rgt-out100.0%
+-commutative100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 78.2%
if 2.9000000000000001e-174 < y < 8.49999999999999955e-162 or 7.50000000000000042e-48 < y < 5.5999999999999999e266Initial program 99.9%
associate--l+99.9%
+-commutative99.9%
remove-double-neg99.9%
unsub-neg99.9%
cancel-sign-sub-inv99.9%
associate--l+99.9%
neg-mul-199.9%
cancel-sign-sub-inv99.9%
distribute-lft-neg-out99.9%
distribute-rgt-neg-out99.9%
*-commutative99.9%
distribute-rgt-out99.9%
+-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around 0 50.3%
Final simplification61.8%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 2.9e-174) (* x (- 1.0 y)) (if (or (<= y 8.5e-162) (not (<= y 5.2e-47))) (- y (* x y)) x)))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 2.9e-174) {
tmp = x * (1.0 - y);
} else if ((y <= 8.5e-162) || !(y <= 5.2e-47)) {
tmp = y - (x * y);
} else {
tmp = x;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 2.9d-174) then
tmp = x * (1.0d0 - y)
else if ((y <= 8.5d-162) .or. (.not. (y <= 5.2d-47))) then
tmp = y - (x * y)
else
tmp = x
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 2.9e-174) {
tmp = x * (1.0 - y);
} else if ((y <= 8.5e-162) || !(y <= 5.2e-47)) {
tmp = y - (x * y);
} else {
tmp = x;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 2.9e-174: tmp = x * (1.0 - y) elif (y <= 8.5e-162) or not (y <= 5.2e-47): tmp = y - (x * y) else: tmp = x return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 2.9e-174) tmp = Float64(x * Float64(1.0 - y)); elseif ((y <= 8.5e-162) || !(y <= 5.2e-47)) tmp = Float64(y - Float64(x * y)); else tmp = x; end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 2.9e-174)
tmp = x * (1.0 - y);
elseif ((y <= 8.5e-162) || ~((y <= 5.2e-47)))
tmp = y - (x * y);
else
tmp = x;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 2.9e-174], N[(x * N[(1.0 - y), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 8.5e-162], N[Not[LessEqual[y, 5.2e-47]], $MachinePrecision]], N[(y - N[(x * y), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.9 \cdot 10^{-174}:\\
\;\;\;\;x \cdot \left(1 - y\right)\\
\mathbf{elif}\;y \leq 8.5 \cdot 10^{-162} \lor \neg \left(y \leq 5.2 \cdot 10^{-47}\right):\\
\;\;\;\;y - x \cdot y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < 2.9000000000000001e-174Initial program 100.0%
associate--l+100.0%
+-commutative100.0%
remove-double-neg100.0%
unsub-neg100.0%
cancel-sign-sub-inv100.0%
associate--l+100.0%
neg-mul-1100.0%
cancel-sign-sub-inv100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-out100.0%
*-commutative100.0%
distribute-rgt-out100.0%
+-commutative100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 66.4%
if 2.9000000000000001e-174 < y < 8.49999999999999955e-162 or 5.2e-47 < y Initial program 99.9%
associate--l+99.9%
+-commutative99.9%
remove-double-neg99.9%
unsub-neg99.9%
cancel-sign-sub-inv99.9%
associate--l+99.9%
neg-mul-199.9%
cancel-sign-sub-inv99.9%
distribute-lft-neg-out99.9%
distribute-rgt-neg-out99.9%
*-commutative99.9%
distribute-rgt-out99.9%
+-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around inf 90.2%
mul-1-neg90.2%
unsub-neg90.2%
Simplified90.2%
sub-neg90.2%
distribute-rgt-in90.3%
*-un-lft-identity90.3%
Applied egg-rr90.3%
if 8.49999999999999955e-162 < y < 5.2e-47Initial program 100.0%
associate--l+100.0%
+-commutative100.0%
remove-double-neg100.0%
unsub-neg100.0%
cancel-sign-sub-inv100.0%
associate--l+100.0%
neg-mul-1100.0%
cancel-sign-sub-inv100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-out100.0%
*-commutative100.0%
distribute-rgt-out100.0%
+-commutative100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 84.9%
Final simplification76.3%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 2.9e-174) (* x (- 1.0 y)) (if (or (<= y 8.5e-162) (not (<= y 2.9e-46))) (- y (* x y)) x)))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 2.9e-174) {
tmp = x * (1.0 - y);
} else if ((y <= 8.5e-162) || !(y <= 2.9e-46)) {
tmp = y - (x * y);
} else {
tmp = x;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 2.9d-174) then
tmp = x * (1.0d0 - y)
else if ((y <= 8.5d-162) .or. (.not. (y <= 2.9d-46))) then
tmp = y - (x * y)
else
tmp = x
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 2.9e-174) {
tmp = x * (1.0 - y);
} else if ((y <= 8.5e-162) || !(y <= 2.9e-46)) {
tmp = y - (x * y);
} else {
tmp = x;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 2.9e-174: tmp = x * (1.0 - y) elif (y <= 8.5e-162) or not (y <= 2.9e-46): tmp = y - (x * y) else: tmp = x return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 2.9e-174) tmp = Float64(x * Float64(1.0 - y)); elseif ((y <= 8.5e-162) || !(y <= 2.9e-46)) tmp = Float64(y - Float64(x * y)); else tmp = x; end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 2.9e-174)
tmp = x * (1.0 - y);
elseif ((y <= 8.5e-162) || ~((y <= 2.9e-46)))
tmp = y - (x * y);
else
tmp = x;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 2.9e-174], N[(x * N[(1.0 - y), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 8.5e-162], N[Not[LessEqual[y, 2.9e-46]], $MachinePrecision]], N[(y - N[(x * y), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.9 \cdot 10^{-174}:\\
\;\;\;\;x \cdot \left(1 - y\right)\\
\mathbf{elif}\;y \leq 8.5 \cdot 10^{-162} \lor \neg \left(y \leq 2.9 \cdot 10^{-46}\right):\\
\;\;\;\;y - x \cdot y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < 2.9000000000000001e-174Initial program 100.0%
associate--l+100.0%
+-commutative100.0%
remove-double-neg100.0%
unsub-neg100.0%
cancel-sign-sub-inv100.0%
associate--l+100.0%
neg-mul-1100.0%
cancel-sign-sub-inv100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-out100.0%
*-commutative100.0%
distribute-rgt-out100.0%
+-commutative100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 66.4%
if 2.9000000000000001e-174 < y < 8.49999999999999955e-162 or 2.90000000000000005e-46 < y Initial program 99.9%
associate--l+99.9%
+-commutative99.9%
remove-double-neg99.9%
unsub-neg99.9%
cancel-sign-sub-inv99.9%
associate--l+99.9%
neg-mul-199.9%
cancel-sign-sub-inv99.9%
distribute-lft-neg-out99.9%
distribute-rgt-neg-out99.9%
*-commutative99.9%
distribute-rgt-out99.9%
+-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around inf 90.3%
mul-1-neg90.3%
distribute-rgt-neg-out90.3%
Simplified90.3%
if 8.49999999999999955e-162 < y < 2.90000000000000005e-46Initial program 100.0%
associate--l+100.0%
+-commutative100.0%
remove-double-neg100.0%
unsub-neg100.0%
cancel-sign-sub-inv100.0%
associate--l+100.0%
neg-mul-1100.0%
cancel-sign-sub-inv100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-out100.0%
*-commutative100.0%
distribute-rgt-out100.0%
+-commutative100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 84.9%
Final simplification76.3%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 2.9e-174) (* x (- 1.0 y)) (if (or (<= y 8.5e-162) (not (<= y 2.95e-46))) (- y (* x y)) x)))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 2.9e-174) {
tmp = x * (1.0 - y);
} else if ((y <= 8.5e-162) || !(y <= 2.95e-46)) {
tmp = y - (x * y);
} else {
tmp = x;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 2.9d-174) then
tmp = x * (1.0d0 - y)
else if ((y <= 8.5d-162) .or. (.not. (y <= 2.95d-46))) then
tmp = y - (x * y)
else
tmp = x
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 2.9e-174) {
tmp = x * (1.0 - y);
} else if ((y <= 8.5e-162) || !(y <= 2.95e-46)) {
tmp = y - (x * y);
} else {
tmp = x;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 2.9e-174: tmp = x * (1.0 - y) elif (y <= 8.5e-162) or not (y <= 2.95e-46): tmp = y - (x * y) else: tmp = x return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 2.9e-174) tmp = Float64(x * Float64(1.0 - y)); elseif ((y <= 8.5e-162) || !(y <= 2.95e-46)) tmp = Float64(y - Float64(x * y)); else tmp = x; end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 2.9e-174)
tmp = x * (1.0 - y);
elseif ((y <= 8.5e-162) || ~((y <= 2.95e-46)))
tmp = y - (x * y);
else
tmp = x;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 2.9e-174], N[(x * N[(1.0 - y), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 8.5e-162], N[Not[LessEqual[y, 2.95e-46]], $MachinePrecision]], N[(y - N[(x * y), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.9 \cdot 10^{-174}:\\
\;\;\;\;x \cdot \left(1 - y\right)\\
\mathbf{elif}\;y \leq 8.5 \cdot 10^{-162} \lor \neg \left(y \leq 2.95 \cdot 10^{-46}\right):\\
\;\;\;\;y - x \cdot y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < 2.9000000000000001e-174Initial program 100.0%
associate--l+100.0%
+-commutative100.0%
remove-double-neg100.0%
unsub-neg100.0%
cancel-sign-sub-inv100.0%
associate--l+100.0%
neg-mul-1100.0%
cancel-sign-sub-inv100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-out100.0%
*-commutative100.0%
distribute-rgt-out100.0%
+-commutative100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 66.4%
if 2.9000000000000001e-174 < y < 8.49999999999999955e-162 or 2.95e-46 < y Initial program 99.9%
associate--l+99.9%
+-commutative99.9%
remove-double-neg99.9%
unsub-neg99.9%
cancel-sign-sub-inv99.9%
associate--l+99.9%
neg-mul-199.9%
cancel-sign-sub-inv99.9%
distribute-lft-neg-out99.9%
distribute-rgt-neg-out99.9%
*-commutative99.9%
distribute-rgt-out99.9%
+-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around inf 90.2%
mul-1-neg90.2%
unsub-neg90.2%
Simplified90.2%
sub-neg90.2%
distribute-rgt-in90.3%
*-un-lft-identity90.3%
Applied egg-rr90.3%
distribute-lft-neg-out90.3%
unsub-neg90.3%
*-commutative90.3%
Applied egg-rr90.3%
if 8.49999999999999955e-162 < y < 2.95e-46Initial program 100.0%
associate--l+100.0%
+-commutative100.0%
remove-double-neg100.0%
unsub-neg100.0%
cancel-sign-sub-inv100.0%
associate--l+100.0%
neg-mul-1100.0%
cancel-sign-sub-inv100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-out100.0%
*-commutative100.0%
distribute-rgt-out100.0%
+-commutative100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 84.9%
Final simplification76.3%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 2.9e-174) (* x (- 1.0 y)) (if (or (<= y 8.5e-162) (not (<= y 7.8e-47))) (* y (- 1.0 x)) x)))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 2.9e-174) {
tmp = x * (1.0 - y);
} else if ((y <= 8.5e-162) || !(y <= 7.8e-47)) {
tmp = y * (1.0 - x);
} else {
tmp = x;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 2.9d-174) then
tmp = x * (1.0d0 - y)
else if ((y <= 8.5d-162) .or. (.not. (y <= 7.8d-47))) then
tmp = y * (1.0d0 - x)
else
tmp = x
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 2.9e-174) {
tmp = x * (1.0 - y);
} else if ((y <= 8.5e-162) || !(y <= 7.8e-47)) {
tmp = y * (1.0 - x);
} else {
tmp = x;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 2.9e-174: tmp = x * (1.0 - y) elif (y <= 8.5e-162) or not (y <= 7.8e-47): tmp = y * (1.0 - x) else: tmp = x return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 2.9e-174) tmp = Float64(x * Float64(1.0 - y)); elseif ((y <= 8.5e-162) || !(y <= 7.8e-47)) tmp = Float64(y * Float64(1.0 - x)); else tmp = x; end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 2.9e-174)
tmp = x * (1.0 - y);
elseif ((y <= 8.5e-162) || ~((y <= 7.8e-47)))
tmp = y * (1.0 - x);
else
tmp = x;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 2.9e-174], N[(x * N[(1.0 - y), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 8.5e-162], N[Not[LessEqual[y, 7.8e-47]], $MachinePrecision]], N[(y * N[(1.0 - x), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.9 \cdot 10^{-174}:\\
\;\;\;\;x \cdot \left(1 - y\right)\\
\mathbf{elif}\;y \leq 8.5 \cdot 10^{-162} \lor \neg \left(y \leq 7.8 \cdot 10^{-47}\right):\\
\;\;\;\;y \cdot \left(1 - x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < 2.9000000000000001e-174Initial program 100.0%
associate--l+100.0%
+-commutative100.0%
remove-double-neg100.0%
unsub-neg100.0%
cancel-sign-sub-inv100.0%
associate--l+100.0%
neg-mul-1100.0%
cancel-sign-sub-inv100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-out100.0%
*-commutative100.0%
distribute-rgt-out100.0%
+-commutative100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 66.4%
if 2.9000000000000001e-174 < y < 8.49999999999999955e-162 or 7.79999999999999956e-47 < y Initial program 99.9%
associate--l+99.9%
+-commutative99.9%
remove-double-neg99.9%
unsub-neg99.9%
cancel-sign-sub-inv99.9%
associate--l+99.9%
neg-mul-199.9%
cancel-sign-sub-inv99.9%
distribute-lft-neg-out99.9%
distribute-rgt-neg-out99.9%
*-commutative99.9%
distribute-rgt-out99.9%
+-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around inf 90.2%
mul-1-neg90.2%
unsub-neg90.2%
Simplified90.2%
if 8.49999999999999955e-162 < y < 7.79999999999999956e-47Initial program 100.0%
associate--l+100.0%
+-commutative100.0%
remove-double-neg100.0%
unsub-neg100.0%
cancel-sign-sub-inv100.0%
associate--l+100.0%
neg-mul-1100.0%
cancel-sign-sub-inv100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-out100.0%
*-commutative100.0%
distribute-rgt-out100.0%
+-commutative100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 84.9%
Final simplification76.3%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 2.9e-174) x (if (<= y 8.5e-162) y (if (<= y 2.95e-46) x y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 2.9e-174) {
tmp = x;
} else if (y <= 8.5e-162) {
tmp = y;
} else if (y <= 2.95e-46) {
tmp = x;
} else {
tmp = y;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 2.9d-174) then
tmp = x
else if (y <= 8.5d-162) then
tmp = y
else if (y <= 2.95d-46) then
tmp = x
else
tmp = y
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 2.9e-174) {
tmp = x;
} else if (y <= 8.5e-162) {
tmp = y;
} else if (y <= 2.95e-46) {
tmp = x;
} else {
tmp = y;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 2.9e-174: tmp = x elif y <= 8.5e-162: tmp = y elif y <= 2.95e-46: tmp = x else: tmp = y return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 2.9e-174) tmp = x; elseif (y <= 8.5e-162) tmp = y; elseif (y <= 2.95e-46) tmp = x; else tmp = y; end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 2.9e-174)
tmp = x;
elseif (y <= 8.5e-162)
tmp = y;
elseif (y <= 2.95e-46)
tmp = x;
else
tmp = y;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 2.9e-174], x, If[LessEqual[y, 8.5e-162], y, If[LessEqual[y, 2.95e-46], x, y]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.9 \cdot 10^{-174}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 8.5 \cdot 10^{-162}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 2.95 \cdot 10^{-46}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if y < 2.9000000000000001e-174 or 8.49999999999999955e-162 < y < 2.95e-46Initial program 100.0%
associate--l+100.0%
+-commutative100.0%
remove-double-neg100.0%
unsub-neg100.0%
cancel-sign-sub-inv100.0%
associate--l+100.0%
neg-mul-1100.0%
cancel-sign-sub-inv100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-out100.0%
*-commutative100.0%
distribute-rgt-out100.0%
+-commutative100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 53.1%
if 2.9000000000000001e-174 < y < 8.49999999999999955e-162 or 2.95e-46 < y Initial program 99.9%
associate--l+99.9%
+-commutative99.9%
remove-double-neg99.9%
unsub-neg99.9%
cancel-sign-sub-inv99.9%
associate--l+99.9%
neg-mul-199.9%
cancel-sign-sub-inv99.9%
distribute-lft-neg-out99.9%
distribute-rgt-neg-out99.9%
*-commutative99.9%
distribute-rgt-out99.9%
+-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around 0 49.2%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (or (<= x -1e-19) (not (<= x 0.046))) (* x (- 1.0 y)) y))
assert(x < y);
double code(double x, double y) {
double tmp;
if ((x <= -1e-19) || !(x <= 0.046)) {
tmp = x * (1.0 - y);
} else {
tmp = y;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-1d-19)) .or. (.not. (x <= 0.046d0))) then
tmp = x * (1.0d0 - y)
else
tmp = y
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if ((x <= -1e-19) || !(x <= 0.046)) {
tmp = x * (1.0 - y);
} else {
tmp = y;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if (x <= -1e-19) or not (x <= 0.046): tmp = x * (1.0 - y) else: tmp = y return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if ((x <= -1e-19) || !(x <= 0.046)) tmp = Float64(x * Float64(1.0 - y)); else tmp = y; end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if ((x <= -1e-19) || ~((x <= 0.046)))
tmp = x * (1.0 - y);
else
tmp = y;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[Or[LessEqual[x, -1e-19], N[Not[LessEqual[x, 0.046]], $MachinePrecision]], N[(x * N[(1.0 - y), $MachinePrecision]), $MachinePrecision], y]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-19} \lor \neg \left(x \leq 0.046\right):\\
\;\;\;\;x \cdot \left(1 - y\right)\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if x < -9.9999999999999998e-20 or 0.045999999999999999 < x Initial program 100.0%
associate--l+100.0%
+-commutative100.0%
remove-double-neg100.0%
unsub-neg100.0%
cancel-sign-sub-inv100.0%
associate--l+100.0%
neg-mul-1100.0%
cancel-sign-sub-inv100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-out100.0%
*-commutative100.0%
distribute-rgt-out100.0%
+-commutative100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 94.8%
if -9.9999999999999998e-20 < x < 0.045999999999999999Initial program 100.0%
associate--l+100.0%
+-commutative100.0%
remove-double-neg100.0%
unsub-neg100.0%
cancel-sign-sub-inv100.0%
associate--l+100.0%
neg-mul-1100.0%
cancel-sign-sub-inv100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-out100.0%
*-commutative100.0%
distribute-rgt-out100.0%
+-commutative100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 75.9%
Final simplification85.7%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (+ y (* x (- 1.0 y))))
assert(x < y);
double code(double x, double y) {
return y + (x * (1.0 - y));
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = y + (x * (1.0d0 - y))
end function
assert x < y;
public static double code(double x, double y) {
return y + (x * (1.0 - y));
}
[x, y] = sort([x, y]) def code(x, y): return y + (x * (1.0 - y))
x, y = sort([x, y]) function code(x, y) return Float64(y + Float64(x * Float64(1.0 - y))) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = y + (x * (1.0 - y));
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(y + N[(x * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
y + x \cdot \left(1 - y\right)
\end{array}
Initial program 100.0%
associate--l+100.0%
+-commutative100.0%
remove-double-neg100.0%
unsub-neg100.0%
cancel-sign-sub-inv100.0%
associate--l+100.0%
neg-mul-1100.0%
cancel-sign-sub-inv100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-out100.0%
*-commutative100.0%
distribute-rgt-out100.0%
+-commutative100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 x)
assert(x < y);
double code(double x, double y) {
return x;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x
end function
assert x < y;
public static double code(double x, double y) {
return x;
}
[x, y] = sort([x, y]) def code(x, y): return x
x, y = sort([x, y]) function code(x, y) return x end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = x;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := x
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
x
\end{array}
Initial program 100.0%
associate--l+100.0%
+-commutative100.0%
remove-double-neg100.0%
unsub-neg100.0%
cancel-sign-sub-inv100.0%
associate--l+100.0%
neg-mul-1100.0%
cancel-sign-sub-inv100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-out100.0%
*-commutative100.0%
distribute-rgt-out100.0%
+-commutative100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 36.5%
herbie shell --seed 2024103
(FPCore (x y)
:name "Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, A"
:precision binary64
(- (+ x y) (* x y)))