
(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-exp33.1%
exp-prod31.3%
flip-+13.1%
div-inv13.1%
+-inverses13.1%
+-inverses13.1%
pow-unpow14.3%
+-inverses14.3%
metadata-eval14.3%
metadata-eval14.3%
+-inverses14.3%
pow-unpow0.0%
+-inverses0.0%
+-inverses0.0%
div-inv0.0%
flip-+20.6%
exp-prod20.6%
*-un-lft-identity20.6%
add-cube-cbrt20.6%
Applied egg-rr4.0%
(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-exp33.1%
exp-prod31.3%
flip-+13.1%
div-inv13.1%
+-inverses13.1%
+-inverses13.1%
pow-unpow14.3%
+-inverses14.3%
metadata-eval14.3%
metadata-eval14.3%
+-inverses14.3%
pow-unpow0.0%
+-inverses0.0%
+-inverses0.0%
div-inv0.0%
flip-+20.6%
exp-prod20.6%
*-un-lft-identity20.6%
*-un-lft-identity20.6%
log-prod20.6%
metadata-eval20.6%
Applied egg-rr0.0%
Simplified3.3%
herbie shell --seed 2024131
(FPCore (x y)
:name "Numeric.Integration.TanhSinh:simpson from integration-0.2.1"
:precision binary64
(* x (+ y y)))