
(FPCore (x y) :precision binary64 (+ (+ (* x x) (* (* x 2.0) y)) (* y y)))
double code(double x, double y) {
return ((x * x) + ((x * 2.0) * y)) + (y * y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x * x) + ((x * 2.0d0) * y)) + (y * y)
end function
public static double code(double x, double y) {
return ((x * x) + ((x * 2.0) * y)) + (y * y);
}
def code(x, y): return ((x * x) + ((x * 2.0) * y)) + (y * y)
function code(x, y) return Float64(Float64(Float64(x * x) + Float64(Float64(x * 2.0) * y)) + Float64(y * y)) end
function tmp = code(x, y) tmp = ((x * x) + ((x * 2.0) * y)) + (y * y); end
code[x_, y_] := N[(N[(N[(x * x), $MachinePrecision] + N[(N[(x * 2.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (+ (+ (* x x) (* (* x 2.0) y)) (* y y)))
double code(double x, double y) {
return ((x * x) + ((x * 2.0) * y)) + (y * y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x * x) + ((x * 2.0d0) * y)) + (y * y)
end function
public static double code(double x, double y) {
return ((x * x) + ((x * 2.0) * y)) + (y * y);
}
def code(x, y): return ((x * x) + ((x * 2.0) * y)) + (y * y)
function code(x, y) return Float64(Float64(Float64(x * x) + Float64(Float64(x * 2.0) * y)) + Float64(y * y)) end
function tmp = code(x, y) tmp = ((x * x) + ((x * 2.0) * y)) + (y * y); end
code[x_, y_] := N[(N[(N[(x * x), $MachinePrecision] + N[(N[(x * 2.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y
\end{array}
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= (+ (+ (* x x) (* (* x 2.0) y)) (* y y)) 5e+306) (+ (* x x) (fma y y (* x (* 2.0 y)))) (+ (* x x) (pow y 2.0))))
assert(x < y);
double code(double x, double y) {
double tmp;
if ((((x * x) + ((x * 2.0) * y)) + (y * y)) <= 5e+306) {
tmp = (x * x) + fma(y, y, (x * (2.0 * y)));
} else {
tmp = (x * x) + pow(y, 2.0);
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (Float64(Float64(Float64(x * x) + Float64(Float64(x * 2.0) * y)) + Float64(y * y)) <= 5e+306) tmp = Float64(Float64(x * x) + fma(y, y, Float64(x * Float64(2.0 * y)))); else tmp = Float64(Float64(x * x) + (y ^ 2.0)); end return tmp end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[N[(N[(N[(x * x), $MachinePrecision] + N[(N[(x * 2.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision], 5e+306], N[(N[(x * x), $MachinePrecision] + N[(y * y + N[(x * N[(2.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] + N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y \leq 5 \cdot 10^{+306}:\\
\;\;\;\;x \cdot x + \mathsf{fma}\left(y, y, x \cdot \left(2 \cdot y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x + {y}^{2}\\
\end{array}
\end{array}
if (+.f64 (+.f64 (*.f64 x x) (*.f64 (*.f64 x 2) y)) (*.f64 y y)) < 4.99999999999999993e306Initial program 100.0%
associate-+l+100.0%
*-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
+-commutative100.0%
fma-def100.0%
*-commutative100.0%
*-commutative100.0%
Simplified100.0%
if 4.99999999999999993e306 < (+.f64 (+.f64 (*.f64 x x) (*.f64 (*.f64 x 2) y)) (*.f64 y y)) Initial program 80.6%
associate-+l+80.6%
*-commutative80.6%
*-commutative80.6%
associate-*l*80.6%
+-commutative80.6%
fma-def80.6%
*-commutative80.6%
*-commutative80.6%
Simplified80.6%
Taylor expanded in y around inf 100.0%
Final simplification100.0%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= (+ (+ (* x x) (* (* x 2.0) y)) (* y y)) 5e+306) (fma x x (* y (+ (* x 2.0) y))) (+ (* x x) (pow y 2.0))))
assert(x < y);
double code(double x, double y) {
double tmp;
if ((((x * x) + ((x * 2.0) * y)) + (y * y)) <= 5e+306) {
tmp = fma(x, x, (y * ((x * 2.0) + y)));
} else {
tmp = (x * x) + pow(y, 2.0);
}
return tmp;
}
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (Float64(Float64(Float64(x * x) + Float64(Float64(x * 2.0) * y)) + Float64(y * y)) <= 5e+306) tmp = fma(x, x, Float64(y * Float64(Float64(x * 2.0) + y))); else tmp = Float64(Float64(x * x) + (y ^ 2.0)); end return tmp end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[N[(N[(N[(x * x), $MachinePrecision] + N[(N[(x * 2.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision], 5e+306], N[(x * x + N[(y * N[(N[(x * 2.0), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] + N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y \leq 5 \cdot 10^{+306}:\\
\;\;\;\;\mathsf{fma}\left(x, x, y \cdot \left(x \cdot 2 + y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x + {y}^{2}\\
\end{array}
\end{array}
if (+.f64 (+.f64 (*.f64 x x) (*.f64 (*.f64 x 2) y)) (*.f64 y y)) < 4.99999999999999993e306Initial program 100.0%
associate-+l+100.0%
*-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
+-commutative100.0%
fma-def100.0%
associate-*l*100.0%
*-commutative100.0%
distribute-lft-out100.0%
Simplified100.0%
if 4.99999999999999993e306 < (+.f64 (+.f64 (*.f64 x x) (*.f64 (*.f64 x 2) y)) (*.f64 y y)) Initial program 80.6%
associate-+l+80.6%
*-commutative80.6%
*-commutative80.6%
associate-*l*80.6%
+-commutative80.6%
fma-def80.6%
*-commutative80.6%
*-commutative80.6%
Simplified80.6%
Taylor expanded in y around inf 100.0%
Final simplification100.0%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= (+ (+ (* x x) (* (* x 2.0) y)) (* y y)) 5e+306) (+ (* y y) (* x (+ x (* 2.0 y)))) (+ (* x x) (pow y 2.0))))
assert(x < y);
double code(double x, double y) {
double tmp;
if ((((x * x) + ((x * 2.0) * y)) + (y * y)) <= 5e+306) {
tmp = (y * y) + (x * (x + (2.0 * y)));
} else {
tmp = (x * x) + pow(y, 2.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) :: tmp
if ((((x * x) + ((x * 2.0d0) * y)) + (y * y)) <= 5d+306) then
tmp = (y * y) + (x * (x + (2.0d0 * y)))
else
tmp = (x * x) + (y ** 2.0d0)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if ((((x * x) + ((x * 2.0) * y)) + (y * y)) <= 5e+306) {
tmp = (y * y) + (x * (x + (2.0 * y)));
} else {
tmp = (x * x) + Math.pow(y, 2.0);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if (((x * x) + ((x * 2.0) * y)) + (y * y)) <= 5e+306: tmp = (y * y) + (x * (x + (2.0 * y))) else: tmp = (x * x) + math.pow(y, 2.0) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (Float64(Float64(Float64(x * x) + Float64(Float64(x * 2.0) * y)) + Float64(y * y)) <= 5e+306) tmp = Float64(Float64(y * y) + Float64(x * Float64(x + Float64(2.0 * y)))); else tmp = Float64(Float64(x * x) + (y ^ 2.0)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if ((((x * x) + ((x * 2.0) * y)) + (y * y)) <= 5e+306)
tmp = (y * y) + (x * (x + (2.0 * y)));
else
tmp = (x * x) + (y ^ 2.0);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[N[(N[(N[(x * x), $MachinePrecision] + N[(N[(x * 2.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision], 5e+306], N[(N[(y * y), $MachinePrecision] + N[(x * N[(x + N[(2.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] + N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y \leq 5 \cdot 10^{+306}:\\
\;\;\;\;y \cdot y + x \cdot \left(x + 2 \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x + {y}^{2}\\
\end{array}
\end{array}
if (+.f64 (+.f64 (*.f64 x x) (*.f64 (*.f64 x 2) y)) (*.f64 y y)) < 4.99999999999999993e306Initial program 100.0%
associate-*r*100.0%
distribute-lft-out100.0%
*-commutative100.0%
Applied egg-rr100.0%
if 4.99999999999999993e306 < (+.f64 (+.f64 (*.f64 x x) (*.f64 (*.f64 x 2) y)) (*.f64 y y)) Initial program 80.6%
associate-+l+80.6%
*-commutative80.6%
*-commutative80.6%
associate-*l*80.6%
+-commutative80.6%
fma-def80.6%
*-commutative80.6%
*-commutative80.6%
Simplified80.6%
Taylor expanded in y around inf 100.0%
Final simplification100.0%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 5.1e+141) (+ (* y y) (* x (+ x (* 2.0 y)))) (* y (+ (* x 2.0) y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 5.1e+141) {
tmp = (y * y) + (x * (x + (2.0 * y)));
} else {
tmp = y * ((x * 2.0) + 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 <= 5.1d+141) then
tmp = (y * y) + (x * (x + (2.0d0 * y)))
else
tmp = y * ((x * 2.0d0) + y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 5.1e+141) {
tmp = (y * y) + (x * (x + (2.0 * y)));
} else {
tmp = y * ((x * 2.0) + y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 5.1e+141: tmp = (y * y) + (x * (x + (2.0 * y))) else: tmp = y * ((x * 2.0) + y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 5.1e+141) tmp = Float64(Float64(y * y) + Float64(x * Float64(x + Float64(2.0 * y)))); else tmp = Float64(y * Float64(Float64(x * 2.0) + y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 5.1e+141)
tmp = (y * y) + (x * (x + (2.0 * y)));
else
tmp = y * ((x * 2.0) + 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, 5.1e+141], N[(N[(y * y), $MachinePrecision] + N[(x * N[(x + N[(2.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(N[(x * 2.0), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.1 \cdot 10^{+141}:\\
\;\;\;\;y \cdot y + x \cdot \left(x + 2 \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(x \cdot 2 + y\right)\\
\end{array}
\end{array}
if y < 5.0999999999999997e141Initial program 93.2%
associate-*r*93.2%
distribute-lft-out97.7%
*-commutative97.7%
Applied egg-rr97.7%
if 5.0999999999999997e141 < y Initial program 83.3%
associate-*r*83.3%
distribute-lft-out86.1%
*-commutative86.1%
Applied egg-rr86.1%
Taylor expanded in x around 0 83.3%
+-commutative83.3%
unpow283.3%
associate-*r*83.3%
*-commutative83.3%
distribute-rgt-out97.2%
*-commutative97.2%
Simplified97.2%
Final simplification97.6%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -1.15e-144) (* x x) (* x (+ x (* 2.0 y)))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -1.15e-144) {
tmp = x * x;
} else {
tmp = x * (x + (2.0 * 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 <= (-1.15d-144)) then
tmp = x * x
else
tmp = x * (x + (2.0d0 * y))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -1.15e-144) {
tmp = x * x;
} else {
tmp = x * (x + (2.0 * y));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -1.15e-144: tmp = x * x else: tmp = x * (x + (2.0 * y)) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -1.15e-144) tmp = Float64(x * x); else tmp = Float64(x * Float64(x + Float64(2.0 * y))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -1.15e-144)
tmp = x * x;
else
tmp = x * (x + (2.0 * 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[x, -1.15e-144], N[(x * x), $MachinePrecision], N[(x * N[(x + N[(2.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.15 \cdot 10^{-144}:\\
\;\;\;\;x \cdot x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(x + 2 \cdot y\right)\\
\end{array}
\end{array}
if x < -1.15e-144Initial program 90.3%
associate-+l+90.3%
*-commutative90.3%
*-commutative90.3%
associate-*l*90.3%
+-commutative90.3%
fma-def90.3%
*-commutative90.3%
*-commutative90.3%
Simplified90.3%
Taylor expanded in x around inf 69.0%
unpow269.0%
Applied egg-rr69.0%
if -1.15e-144 < x Initial program 92.6%
associate-+l+92.6%
*-commutative92.6%
*-commutative92.6%
associate-*l*92.6%
+-commutative92.6%
fma-def92.6%
*-commutative92.6%
*-commutative92.6%
Simplified92.6%
Taylor expanded in x around inf 52.0%
+-commutative52.0%
unpow252.0%
*-commutative52.0%
associate-*r*52.0%
*-commutative52.0%
distribute-rgt-in56.3%
*-commutative56.3%
Simplified56.3%
Final simplification60.9%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -3.5e-110) (* x x) (* y (+ (* x 2.0) y))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -3.5e-110) {
tmp = x * x;
} else {
tmp = y * ((x * 2.0) + 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 <= (-3.5d-110)) then
tmp = x * x
else
tmp = y * ((x * 2.0d0) + y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -3.5e-110) {
tmp = x * x;
} else {
tmp = y * ((x * 2.0) + y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -3.5e-110: tmp = x * x else: tmp = y * ((x * 2.0) + y) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -3.5e-110) tmp = Float64(x * x); else tmp = Float64(y * Float64(Float64(x * 2.0) + y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -3.5e-110)
tmp = x * x;
else
tmp = y * ((x * 2.0) + 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[x, -3.5e-110], N[(x * x), $MachinePrecision], N[(y * N[(N[(x * 2.0), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.5 \cdot 10^{-110}:\\
\;\;\;\;x \cdot x\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(x \cdot 2 + y\right)\\
\end{array}
\end{array}
if x < -3.49999999999999974e-110Initial program 89.5%
associate-+l+89.5%
*-commutative89.5%
*-commutative89.5%
associate-*l*89.5%
+-commutative89.5%
fma-def89.5%
*-commutative89.5%
*-commutative89.5%
Simplified89.5%
Taylor expanded in x around inf 74.4%
unpow274.4%
Applied egg-rr74.4%
if -3.49999999999999974e-110 < x Initial program 92.9%
associate-*r*92.9%
distribute-lft-out97.0%
*-commutative97.0%
Applied egg-rr97.0%
Taylor expanded in x around 0 59.7%
+-commutative59.7%
unpow259.7%
associate-*r*59.7%
*-commutative59.7%
distribute-rgt-out62.7%
*-commutative62.7%
Simplified62.7%
Final simplification66.6%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -5.5e-291) (* x x) (* (* x 2.0) y)))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -5.5e-291) {
tmp = x * x;
} else {
tmp = (x * 2.0) * 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 <= (-5.5d-291)) then
tmp = x * x
else
tmp = (x * 2.0d0) * y
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -5.5e-291) {
tmp = x * x;
} else {
tmp = (x * 2.0) * y;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -5.5e-291: tmp = x * x else: tmp = (x * 2.0) * y return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -5.5e-291) tmp = Float64(x * x); else tmp = Float64(Float64(x * 2.0) * y); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -5.5e-291)
tmp = x * x;
else
tmp = (x * 2.0) * 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[x, -5.5e-291], N[(x * x), $MachinePrecision], N[(N[(x * 2.0), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.5 \cdot 10^{-291}:\\
\;\;\;\;x \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot 2\right) \cdot y\\
\end{array}
\end{array}
if x < -5.5000000000000002e-291Initial program 92.5%
associate-+l+92.5%
*-commutative92.5%
*-commutative92.5%
associate-*l*92.5%
+-commutative92.5%
fma-def92.5%
*-commutative92.5%
*-commutative92.5%
Simplified92.5%
Taylor expanded in x around inf 59.8%
unpow259.8%
Applied egg-rr59.8%
if -5.5000000000000002e-291 < x Initial program 91.1%
associate-+l+91.1%
*-commutative91.1%
*-commutative91.1%
associate-*l*91.1%
+-commutative91.1%
fma-def91.2%
*-commutative91.2%
*-commutative91.2%
Simplified91.2%
Taylor expanded in x around inf 56.8%
+-commutative56.8%
unpow256.8%
*-commutative56.8%
associate-*r*56.8%
*-commutative56.8%
distribute-rgt-in61.9%
*-commutative61.9%
Simplified61.9%
Taylor expanded in x around 0 17.3%
associate-*r*17.3%
*-commutative17.3%
*-commutative17.3%
*-commutative17.3%
Simplified17.3%
Final simplification37.2%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (* x x))
assert(x < y);
double code(double x, double y) {
return x * 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 * x
end function
assert x < y;
public static double code(double x, double y) {
return x * x;
}
[x, y] = sort([x, y]) def code(x, y): return x * x
x, y = sort([x, y]) function code(x, y) return Float64(x * x) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = x * x;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(x * x), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
x \cdot x
\end{array}
Initial program 91.8%
associate-+l+91.8%
*-commutative91.8%
*-commutative91.8%
associate-*l*91.8%
+-commutative91.8%
fma-def91.8%
*-commutative91.8%
*-commutative91.8%
Simplified91.8%
Taylor expanded in x around inf 61.4%
unpow261.4%
Applied egg-rr61.4%
Final simplification61.4%
(FPCore (x y) :precision binary64 (+ (* x x) (+ (* y y) (* (* x y) 2.0))))
double code(double x, double y) {
return (x * x) + ((y * y) + ((x * y) * 2.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * x) + ((y * y) + ((x * y) * 2.0d0))
end function
public static double code(double x, double y) {
return (x * x) + ((y * y) + ((x * y) * 2.0));
}
def code(x, y): return (x * x) + ((y * y) + ((x * y) * 2.0))
function code(x, y) return Float64(Float64(x * x) + Float64(Float64(y * y) + Float64(Float64(x * y) * 2.0))) end
function tmp = code(x, y) tmp = (x * x) + ((y * y) + ((x * y) * 2.0)); end
code[x_, y_] := N[(N[(x * x), $MachinePrecision] + N[(N[(y * y), $MachinePrecision] + N[(N[(x * y), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot x + \left(y \cdot y + \left(x \cdot y\right) \cdot 2\right)
\end{array}
herbie shell --seed 2023336
(FPCore (x y)
:name "Examples.Basics.ProofTests:f4 from sbv-4.4"
:precision binary64
:herbie-target
(+ (* x x) (+ (* y y) (* (* x y) 2.0)))
(+ (+ (* x x) (* (* x 2.0) y)) (* y y)))