
(FPCore (x) :precision binary64 (/ 1.0 (* x x)))
double code(double x) {
return 1.0 / (x * x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 / (x * x)
end function
public static double code(double x) {
return 1.0 / (x * x);
}
def code(x): return 1.0 / (x * x)
function code(x) return Float64(1.0 / Float64(x * x)) end
function tmp = code(x) tmp = 1.0 / (x * x); end
code[x_] := N[(1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x \cdot x}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 4 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (/ 1.0 (* x x)))
double code(double x) {
return 1.0 / (x * x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 / (x * x)
end function
public static double code(double x) {
return 1.0 / (x * x);
}
def code(x): return 1.0 / (x * x)
function code(x) return Float64(1.0 / Float64(x * x)) end
function tmp = code(x) tmp = 1.0 / (x * x); end
code[x_] := N[(1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x \cdot x}
\end{array}
(FPCore (x) :precision binary64 (pow x -2.0))
double code(double x) {
return pow(x, -2.0);
}
real(8) function code(x)
real(8), intent (in) :: x
code = x ** (-2.0d0)
end function
public static double code(double x) {
return Math.pow(x, -2.0);
}
def code(x): return math.pow(x, -2.0)
function code(x) return x ^ -2.0 end
function tmp = code(x) tmp = x ^ -2.0; end
code[x_] := N[Power[x, -2.0], $MachinePrecision]
\begin{array}{l}
\\
{x}^{-2}
\end{array}
Initial program 98.6%
Taylor expanded in x around 0 98.6%
exp-to-pow53.4%
*-commutative53.4%
rec-exp54.4%
distribute-lft-neg-in54.4%
metadata-eval54.4%
*-commutative54.4%
exp-to-pow100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x) :precision binary64 (/ 1.0 (* x x)))
double code(double x) {
return 1.0 / (x * x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 / (x * x)
end function
public static double code(double x) {
return 1.0 / (x * x);
}
def code(x): return 1.0 / (x * x)
function code(x) return Float64(1.0 / Float64(x * x)) end
function tmp = code(x) tmp = 1.0 / (x * x); end
code[x_] := N[(1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x \cdot x}
\end{array}
Initial program 98.6%
Final simplification98.6%
(FPCore (x) :precision binary64 (/ 1.0 x))
double code(double x) {
return 1.0 / x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 / x
end function
public static double code(double x) {
return 1.0 / x;
}
def code(x): return 1.0 / x
function code(x) return Float64(1.0 / x) end
function tmp = code(x) tmp = 1.0 / x; end
code[x_] := N[(1.0 / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x}
\end{array}
Initial program 98.6%
inv-pow98.6%
/-rgt-identity98.6%
/-rgt-identity98.6%
add-sqr-sqrt98.6%
sqrt-unprod81.8%
associate-*l*81.8%
associate-*l*81.8%
sqrt-prod49.2%
sqrt-prod55.5%
sqrt-prod55.3%
unpow-prod-down56.3%
Applied egg-rr20.9%
Simplified5.1%
Final simplification5.1%
(FPCore (x) :precision binary64 1.0)
double code(double x) {
return 1.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0
end function
public static double code(double x) {
return 1.0;
}
def code(x): return 1.0
function code(x) return 1.0 end
function tmp = code(x) tmp = 1.0; end
code[x_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 98.6%
Applied egg-rr4.4%
/-rgt-identity4.4%
*-commutative4.4%
associate-*r/4.4%
unpow24.4%
rem-3cbrt-rft4.4%
*-inverses4.4%
Simplified4.4%
Final simplification4.4%
(FPCore (x) :precision binary64 (/ (/ 1.0 x) x))
double code(double x) {
return (1.0 / x) / x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 / x) / x
end function
public static double code(double x) {
return (1.0 / x) / x;
}
def code(x): return (1.0 / x) / x
function code(x) return Float64(Float64(1.0 / x) / x) end
function tmp = code(x) tmp = (1.0 / x) / x; end
code[x_] := N[(N[(1.0 / x), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x}}{x}
\end{array}
herbie shell --seed 2023320
(FPCore (x)
:name "Numeric.SpecFunctions:$slogFactorial from math-functions-0.1.5.2, A"
:precision binary64
:herbie-target
(/ (/ 1.0 x) x)
(/ 1.0 (* x x)))