
(FPCore (x y) :precision binary64 (* x (+ y y)))
double code(double x, double y) {
return x * (y + y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (y + y)
end function
public static double code(double x, double y) {
return x * (y + y);
}
def code(x, y): return x * (y + y)
function code(x, y) return Float64(x * Float64(y + y)) end
function tmp = code(x, y) tmp = x * (y + y); end
code[x_, y_] := N[(x * N[(y + y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(y + y\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 3 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (* x (+ y y)))
double code(double x, double y) {
return x * (y + y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (y + y)
end function
public static double code(double x, double y) {
return x * (y + y);
}
def code(x, y): return x * (y + y)
function code(x, y) return Float64(x * Float64(y + y)) end
function tmp = code(x, y) tmp = x * (y + y); end
code[x_, y_] := N[(x * N[(y + y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(y + y\right)
\end{array}
(FPCore (x y) :precision binary64 (* x (+ y y)))
double code(double x, double y) {
return x * (y + y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (y + y)
end function
public static double code(double x, double y) {
return x * (y + y);
}
def code(x, y): return x * (y + y)
function code(x, y) return Float64(x * Float64(y + y)) end
function tmp = code(x, y) tmp = x * (y + y); end
code[x_, y_] := N[(x * N[(y + y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(y + y\right)
\end{array}
Initial program 100.0%
(FPCore (x y) :precision binary64 (+ y y))
double code(double x, double y) {
return y + y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = y + y
end function
public static double code(double x, double y) {
return y + y;
}
def code(x, y): return y + y
function code(x, y) return Float64(y + y) end
function tmp = code(x, y) tmp = y + y; end
code[x_, y_] := N[(y + y), $MachinePrecision]
\begin{array}{l}
\\
y + y
\end{array}
Initial program 100.0%
add-log-exp31.2%
exp-prod29.4%
flip-+15.7%
div-inv15.7%
+-inverses15.7%
+-inverses15.7%
pow-unpow17.3%
+-inverses17.3%
metadata-eval17.3%
metadata-eval17.3%
+-inverses17.3%
pow-unpow0.0%
+-inverses0.0%
+-inverses0.0%
div-inv0.0%
flip-+22.3%
exp-prod22.3%
*-un-lft-identity22.3%
add-cube-cbrt22.3%
Applied egg-rr4.1%
(FPCore (x y) :precision binary64 -2.0)
double code(double x, double y) {
return -2.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = -2.0d0
end function
public static double code(double x, double y) {
return -2.0;
}
def code(x, y): return -2.0
function code(x, y) return -2.0 end
function tmp = code(x, y) tmp = -2.0; end
code[x_, y_] := -2.0
\begin{array}{l}
\\
-2
\end{array}
Initial program 100.0%
add-log-exp31.2%
exp-prod29.4%
flip-+15.7%
div-inv15.7%
+-inverses15.7%
+-inverses15.7%
pow-unpow17.3%
+-inverses17.3%
metadata-eval17.3%
metadata-eval17.3%
+-inverses17.3%
pow-unpow0.0%
+-inverses0.0%
+-inverses0.0%
div-inv0.0%
flip-+22.3%
exp-prod22.3%
*-un-lft-identity22.3%
*-un-lft-identity22.3%
log-prod22.3%
metadata-eval22.3%
Applied egg-rr0.0%
Simplified3.4%
herbie shell --seed 2024116
(FPCore (x y)
:name "Numeric.Integration.TanhSinh:simpson from integration-0.2.1"
:precision binary64
(* x (+ y y)))