
(FPCore (x y) :precision binary64 (* x (+ 1.0 (* y y))))
double code(double x, double y) {
return x * (1.0 + (y * y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (1.0d0 + (y * y))
end function
public static double code(double x, double y) {
return x * (1.0 + (y * y));
}
def code(x, y): return x * (1.0 + (y * y))
function code(x, y) return Float64(x * Float64(1.0 + Float64(y * y))) end
function tmp = code(x, y) tmp = x * (1.0 + (y * y)); end
code[x_, y_] := N[(x * N[(1.0 + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 + y \cdot y\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 4 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (* x (+ 1.0 (* y y))))
double code(double x, double y) {
return x * (1.0 + (y * y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (1.0d0 + (y * y))
end function
public static double code(double x, double y) {
return x * (1.0 + (y * y));
}
def code(x, y): return x * (1.0 + (y * y))
function code(x, y) return Float64(x * Float64(1.0 + Float64(y * y))) end
function tmp = code(x, y) tmp = x * (1.0 + (y * y)); end
code[x_, y_] := N[(x * N[(1.0 + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 + y \cdot y\right)
\end{array}
(FPCore (x y) :precision binary64 (+ x (* y (* y x))))
double code(double x, double y) {
return x + (y * (y * x));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x + (y * (y * x))
end function
public static double code(double x, double y) {
return x + (y * (y * x));
}
def code(x, y): return x + (y * (y * x))
function code(x, y) return Float64(x + Float64(y * Float64(y * x))) end
function tmp = code(x, y) tmp = x + (y * (y * x)); end
code[x_, y_] := N[(x + N[(y * N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + y \cdot \left(y \cdot x\right)
\end{array}
Initial program 90.8%
+-commutative90.8%
distribute-lft-in90.8%
pow290.8%
*-rgt-identity90.8%
Applied egg-rr90.8%
add-sqr-sqrt64.7%
pow264.7%
*-commutative64.7%
sqrt-prod49.8%
sqrt-pow154.1%
metadata-eval54.1%
pow154.1%
Applied egg-rr54.1%
unpow254.1%
*-commutative54.1%
associate-*r*54.1%
associate-*r*54.1%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (+ x (* x (* y y))))
double code(double x, double y) {
return x + (x * (y * y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x + (x * (y * y))
end function
public static double code(double x, double y) {
return x + (x * (y * y));
}
def code(x, y): return x + (x * (y * y))
function code(x, y) return Float64(x + Float64(x * Float64(y * y))) end
function tmp = code(x, y) tmp = x + (x * (y * y)); end
code[x_, y_] := N[(x + N[(x * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + x \cdot \left(y \cdot y\right)
\end{array}
Initial program 90.8%
+-commutative90.8%
distribute-lft-in90.8%
pow290.8%
*-rgt-identity90.8%
Applied egg-rr90.8%
unpow290.8%
Applied egg-rr90.8%
Final simplification90.8%
(FPCore (x y) :precision binary64 (* x (+ (* y y) 1.0)))
double code(double x, double y) {
return x * ((y * y) + 1.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * ((y * y) + 1.0d0)
end function
public static double code(double x, double y) {
return x * ((y * y) + 1.0);
}
def code(x, y): return x * ((y * y) + 1.0)
function code(x, y) return Float64(x * Float64(Float64(y * y) + 1.0)) end
function tmp = code(x, y) tmp = x * ((y * y) + 1.0); end
code[x_, y_] := N[(x * N[(N[(y * y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(y \cdot y + 1\right)
\end{array}
Initial program 90.8%
Final simplification90.8%
(FPCore (x y) :precision binary64 x)
double code(double x, double y) {
return x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x
end function
public static double code(double x, double y) {
return x;
}
def code(x, y): return x
function code(x, y) return x end
function tmp = code(x, y) tmp = x; end
code[x_, y_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 90.8%
Taylor expanded in y around 0 50.5%
(FPCore (x y) :precision binary64 (+ x (* (* x y) y)))
double code(double x, double y) {
return x + ((x * y) * y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x + ((x * y) * y)
end function
public static double code(double x, double y) {
return x + ((x * y) * y);
}
def code(x, y): return x + ((x * y) * y)
function code(x, y) return Float64(x + Float64(Float64(x * y) * y)) end
function tmp = code(x, y) tmp = x + ((x * y) * y); end
code[x_, y_] := N[(x + N[(N[(x * y), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(x \cdot y\right) \cdot y
\end{array}
herbie shell --seed 2024135
(FPCore (x y)
:name "Numeric.Integration.TanhSinh:everywhere from integration-0.2.1"
:precision binary64
:alt
(! :herbie-platform default (+ x (* (* x y) y)))
(* x (+ 1.0 (* y y))))