
(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}
(FPCore (x y) :precision binary64 (let* ((t_0 (+ (+ (* x x) (* y (* x 2.0))) (* y y)))) (if (<= t_0 2e+306) t_0 (* y (+ y (* x (+ 2.0 (/ x y))))))))
double code(double x, double y) {
double t_0 = ((x * x) + (y * (x * 2.0))) + (y * y);
double tmp;
if (t_0 <= 2e+306) {
tmp = t_0;
} else {
tmp = y * (y + (x * (2.0 + (x / y))));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = ((x * x) + (y * (x * 2.0d0))) + (y * y)
if (t_0 <= 2d+306) then
tmp = t_0
else
tmp = y * (y + (x * (2.0d0 + (x / y))))
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = ((x * x) + (y * (x * 2.0))) + (y * y);
double tmp;
if (t_0 <= 2e+306) {
tmp = t_0;
} else {
tmp = y * (y + (x * (2.0 + (x / y))));
}
return tmp;
}
def code(x, y): t_0 = ((x * x) + (y * (x * 2.0))) + (y * y) tmp = 0 if t_0 <= 2e+306: tmp = t_0 else: tmp = y * (y + (x * (2.0 + (x / y)))) return tmp
function code(x, y) t_0 = Float64(Float64(Float64(x * x) + Float64(y * Float64(x * 2.0))) + Float64(y * y)) tmp = 0.0 if (t_0 <= 2e+306) tmp = t_0; else tmp = Float64(y * Float64(y + Float64(x * Float64(2.0 + Float64(x / y))))); end return tmp end
function tmp_2 = code(x, y) t_0 = ((x * x) + (y * (x * 2.0))) + (y * y); tmp = 0.0; if (t_0 <= 2e+306) tmp = t_0; else tmp = y * (y + (x * (2.0 + (x / y)))); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(N[(x * x), $MachinePrecision] + N[(y * N[(x * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 2e+306], t$95$0, N[(y * N[(y + N[(x * N[(2.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x \cdot x + y \cdot \left(x \cdot 2\right)\right) + y \cdot y\\
\mathbf{if}\;t\_0 \leq 2 \cdot 10^{+306}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(y + x \cdot \left(2 + \frac{x}{y}\right)\right)\\
\end{array}
\end{array}
if (+.f64 (+.f64 (*.f64 x x) (*.f64 (*.f64 x #s(literal 2 binary64)) y)) (*.f64 y y)) < 2.00000000000000003e306Initial program 100.0%
if 2.00000000000000003e306 < (+.f64 (+.f64 (*.f64 x x) (*.f64 (*.f64 x #s(literal 2 binary64)) y)) (*.f64 y y)) Initial program 92.9%
flip-+N/A
fmm-defN/A
div-subN/A
--lowering--.f64N/A
Applied egg-rr5.1%
Taylor expanded in y around inf
Simplified96.9%
distribute-lft-outN/A
*-commutativeN/A
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
associate-/l*N/A
distribute-lft-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y) :precision binary64 (fma y y (* x (+ x (* y 2.0)))))
double code(double x, double y) {
return fma(y, y, (x * (x + (y * 2.0))));
}
function code(x, y) return fma(y, y, Float64(x * Float64(x + Float64(y * 2.0)))) end
code[x_, y_] := N[(y * y + N[(x * N[(x + N[(y * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y, y, x \cdot \left(x + y \cdot 2\right)\right)
\end{array}
Initial program 97.2%
associate-+l+N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f6499.2%
Simplified99.2%
distribute-rgt-inN/A
associate-+l+N/A
+-commutativeN/A
fma-defineN/A
fma-lowering-fma.f64N/A
associate-*l*N/A
distribute-lft-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f6498.0%
Applied egg-rr98.0%
(FPCore (x y) :precision binary64 (if (<= y 8500.0) (+ (* x x) (* y (+ y (* x 2.0)))) (* y (+ y (* x (+ 2.0 (/ x y)))))))
double code(double x, double y) {
double tmp;
if (y <= 8500.0) {
tmp = (x * x) + (y * (y + (x * 2.0)));
} else {
tmp = y * (y + (x * (2.0 + (x / y))));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 8500.0d0) then
tmp = (x * x) + (y * (y + (x * 2.0d0)))
else
tmp = y * (y + (x * (2.0d0 + (x / y))))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 8500.0) {
tmp = (x * x) + (y * (y + (x * 2.0)));
} else {
tmp = y * (y + (x * (2.0 + (x / y))));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 8500.0: tmp = (x * x) + (y * (y + (x * 2.0))) else: tmp = y * (y + (x * (2.0 + (x / y)))) return tmp
function code(x, y) tmp = 0.0 if (y <= 8500.0) tmp = Float64(Float64(x * x) + Float64(y * Float64(y + Float64(x * 2.0)))); else tmp = Float64(y * Float64(y + Float64(x * Float64(2.0 + Float64(x / y))))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 8500.0) tmp = (x * x) + (y * (y + (x * 2.0))); else tmp = y * (y + (x * (2.0 + (x / y)))); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 8500.0], N[(N[(x * x), $MachinePrecision] + N[(y * N[(y + N[(x * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(y + N[(x * N[(2.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8500:\\
\;\;\;\;x \cdot x + y \cdot \left(y + x \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(y + x \cdot \left(2 + \frac{x}{y}\right)\right)\\
\end{array}
\end{array}
if y < 8500Initial program 98.4%
associate-+l+N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64100.0%
Simplified100.0%
if 8500 < y Initial program 93.6%
flip-+N/A
fmm-defN/A
div-subN/A
--lowering--.f64N/A
Applied egg-rr26.1%
Taylor expanded in y around inf
Simplified98.4%
distribute-lft-outN/A
*-commutativeN/A
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
associate-/l*N/A
distribute-lft-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y) :precision binary64 (if (<= y 5e-173) (* x (+ x (* y 2.0))) (* y (+ y (* x (+ 2.0 (/ x y)))))))
double code(double x, double y) {
double tmp;
if (y <= 5e-173) {
tmp = x * (x + (y * 2.0));
} else {
tmp = y * (y + (x * (2.0 + (x / y))));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 5d-173) then
tmp = x * (x + (y * 2.0d0))
else
tmp = y * (y + (x * (2.0d0 + (x / y))))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 5e-173) {
tmp = x * (x + (y * 2.0));
} else {
tmp = y * (y + (x * (2.0 + (x / y))));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 5e-173: tmp = x * (x + (y * 2.0)) else: tmp = y * (y + (x * (2.0 + (x / y)))) return tmp
function code(x, y) tmp = 0.0 if (y <= 5e-173) tmp = Float64(x * Float64(x + Float64(y * 2.0))); else tmp = Float64(y * Float64(y + Float64(x * Float64(2.0 + Float64(x / y))))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 5e-173) tmp = x * (x + (y * 2.0)); else tmp = y * (y + (x * (2.0 + (x / y)))); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 5e-173], N[(x * N[(x + N[(y * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(y + N[(x * N[(2.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5 \cdot 10^{-173}:\\
\;\;\;\;x \cdot \left(x + y \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(y + x \cdot \left(2 + \frac{x}{y}\right)\right)\\
\end{array}
\end{array}
if y < 5.0000000000000002e-173Initial program 98.1%
associate-+l+N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64100.0%
Simplified100.0%
Taylor expanded in x around inf
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
associate-*r/N/A
associate-*l/N/A
associate-/l*N/A
*-inversesN/A
*-rgt-identityN/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f6464.0%
Simplified64.0%
if 5.0000000000000002e-173 < y Initial program 96.0%
flip-+N/A
fmm-defN/A
div-subN/A
--lowering--.f64N/A
Applied egg-rr32.0%
Taylor expanded in y around inf
Simplified96.3%
distribute-lft-outN/A
*-commutativeN/A
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
associate-/l*N/A
distribute-lft-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f6497.2%
Applied egg-rr97.2%
Final simplification77.0%
(FPCore (x y) :precision binary64 (if (<= x -1.45e-145) (* x x) (* y (* y (+ 1.0 (/ (* x 2.0) y))))))
double code(double x, double y) {
double tmp;
if (x <= -1.45e-145) {
tmp = x * x;
} else {
tmp = y * (y * (1.0 + ((x * 2.0) / y)));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-1.45d-145)) then
tmp = x * x
else
tmp = y * (y * (1.0d0 + ((x * 2.0d0) / y)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.45e-145) {
tmp = x * x;
} else {
tmp = y * (y * (1.0 + ((x * 2.0) / y)));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.45e-145: tmp = x * x else: tmp = y * (y * (1.0 + ((x * 2.0) / y))) return tmp
function code(x, y) tmp = 0.0 if (x <= -1.45e-145) tmp = Float64(x * x); else tmp = Float64(y * Float64(y * Float64(1.0 + Float64(Float64(x * 2.0) / y)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.45e-145) tmp = x * x; else tmp = y * (y * (1.0 + ((x * 2.0) / y))); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.45e-145], N[(x * x), $MachinePrecision], N[(y * N[(y * N[(1.0 + N[(N[(x * 2.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.45 \cdot 10^{-145}:\\
\;\;\;\;x \cdot x\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(y \cdot \left(1 + \frac{x \cdot 2}{y}\right)\right)\\
\end{array}
\end{array}
if x < -1.44999999999999992e-145Initial program 95.7%
associate-+l+N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f6497.8%
Simplified97.8%
Taylor expanded in x around inf
unpow2N/A
*-lowering-*.f6473.0%
Simplified73.0%
if -1.44999999999999992e-145 < x Initial program 98.1%
associate-+l+N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64100.0%
Simplified100.0%
distribute-rgt-inN/A
associate-+l+N/A
+-commutativeN/A
fma-defineN/A
fma-lowering-fma.f64N/A
associate-*l*N/A
distribute-lft-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f6498.1%
Applied egg-rr98.1%
Taylor expanded in y around inf
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
associate-*r/N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6471.0%
Simplified71.0%
(FPCore (x y) :precision binary64 (if (<= x -1.45e-145) (* x x) (* y (+ y (* x 2.0)))))
double code(double x, double y) {
double tmp;
if (x <= -1.45e-145) {
tmp = x * x;
} else {
tmp = y * (y + (x * 2.0));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-1.45d-145)) then
tmp = x * x
else
tmp = y * (y + (x * 2.0d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.45e-145) {
tmp = x * x;
} else {
tmp = y * (y + (x * 2.0));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.45e-145: tmp = x * x else: tmp = y * (y + (x * 2.0)) return tmp
function code(x, y) tmp = 0.0 if (x <= -1.45e-145) tmp = Float64(x * x); else tmp = Float64(y * Float64(y + Float64(x * 2.0))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.45e-145) tmp = x * x; else tmp = y * (y + (x * 2.0)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.45e-145], N[(x * x), $MachinePrecision], N[(y * N[(y + N[(x * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.45 \cdot 10^{-145}:\\
\;\;\;\;x \cdot x\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(y + x \cdot 2\right)\\
\end{array}
\end{array}
if x < -1.44999999999999992e-145Initial program 95.7%
associate-+l+N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f6497.8%
Simplified97.8%
Taylor expanded in x around inf
unpow2N/A
*-lowering-*.f6473.0%
Simplified73.0%
if -1.44999999999999992e-145 < x Initial program 98.1%
associate-+l+N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64100.0%
Simplified100.0%
Taylor expanded in x around 0
fma-defineN/A
*-rgt-identityN/A
*-inversesN/A
associate-/l*N/A
associate-*l/N/A
associate-*r*N/A
unpow2N/A
*-commutativeN/A
*-commutativeN/A
fma-defineN/A
associate-*l*N/A
*-lft-identityN/A
distribute-rgt-inN/A
unpow2N/A
+-commutativeN/A
associate-*l*N/A
*-lowering-*.f64N/A
distribute-lft-inN/A
*-rgt-identityN/A
associate-*r/N/A
associate-*r/N/A
associate-*l/N/A
*-inversesN/A
*-lft-identityN/A
Simplified68.1%
Final simplification69.8%
(FPCore (x y) :precision binary64 (if (<= x -1.45e-145) (* x x) (* y y)))
double code(double x, double y) {
double tmp;
if (x <= -1.45e-145) {
tmp = x * x;
} else {
tmp = y * y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-1.45d-145)) then
tmp = x * x
else
tmp = y * y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.45e-145) {
tmp = x * x;
} else {
tmp = y * y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.45e-145: tmp = x * x else: tmp = y * y return tmp
function code(x, y) tmp = 0.0 if (x <= -1.45e-145) tmp = Float64(x * x); else tmp = Float64(y * y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.45e-145) tmp = x * x; else tmp = y * y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.45e-145], N[(x * x), $MachinePrecision], N[(y * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.45 \cdot 10^{-145}:\\
\;\;\;\;x \cdot x\\
\mathbf{else}:\\
\;\;\;\;y \cdot y\\
\end{array}
\end{array}
if x < -1.44999999999999992e-145Initial program 95.7%
associate-+l+N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f6497.8%
Simplified97.8%
Taylor expanded in x around inf
unpow2N/A
*-lowering-*.f6473.0%
Simplified73.0%
if -1.44999999999999992e-145 < x Initial program 98.1%
associate-+l+N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64100.0%
Simplified100.0%
Taylor expanded in x around 0
unpow2N/A
*-lowering-*.f6466.8%
Simplified66.8%
(FPCore (x y) :precision binary64 (* x x))
double code(double x, double y) {
return x * x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * x
end function
public static double code(double x, double y) {
return x * x;
}
def code(x, y): return x * x
function code(x, y) return Float64(x * x) end
function tmp = code(x, y) tmp = x * x; end
code[x_, y_] := N[(x * x), $MachinePrecision]
\begin{array}{l}
\\
x \cdot x
\end{array}
Initial program 97.2%
associate-+l+N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f6499.2%
Simplified99.2%
Taylor expanded in x around inf
unpow2N/A
*-lowering-*.f6455.1%
Simplified55.1%
(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 2024160
(FPCore (x y)
:name "Examples.Basics.ProofTests:f4 from sbv-4.4"
:precision binary64
:alt
(! :herbie-platform default (+ (* x x) (+ (* y y) (* (* x y) 2))))
(+ (+ (* x x) (* (* x 2.0) y)) (* y y)))