
(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 3 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 99.0%
lift-/.f64N/A
inv-powN/A
lift-*.f64N/A
pow2N/A
pow-powN/A
lower-pow.f64N/A
metadata-eval100.0
Applied rewrites100.0%
(FPCore (x) :precision binary64 (/ (pow x -1.0) x))
double code(double x) {
return pow(x, -1.0) / x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x ** (-1.0d0)) / x
end function
public static double code(double x) {
return Math.pow(x, -1.0) / x;
}
def code(x): return math.pow(x, -1.0) / x
function code(x) return Float64((x ^ -1.0) / x) end
function tmp = code(x) tmp = (x ^ -1.0) / x; end
code[x_] := N[(N[Power[x, -1.0], $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{{x}^{-1}}{x}
\end{array}
Initial program 99.0%
lift-/.f64N/A
metadata-evalN/A
lift-*.f64N/A
frac-timesN/A
metadata-evalN/A
distribute-neg-fracN/A
inv-powN/A
associate-*l/N/A
unpow1N/A
sqr-powN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f64N/A
lower-/.f64N/A
inv-powN/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6446.6
Applied rewrites46.6%
Taylor expanded in x around 0
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
Final simplification99.8%
(FPCore (x) :precision binary64 (pow (* x x) -1.0))
double code(double x) {
return pow((x * x), -1.0);
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x * x) ** (-1.0d0)
end function
public static double code(double x) {
return Math.pow((x * x), -1.0);
}
def code(x): return math.pow((x * x), -1.0)
function code(x) return Float64(x * x) ^ -1.0 end
function tmp = code(x) tmp = (x * x) ^ -1.0; end
code[x_] := N[Power[N[(x * x), $MachinePrecision], -1.0], $MachinePrecision]
\begin{array}{l}
\\
{\left(x \cdot x\right)}^{-1}
\end{array}
Initial program 99.0%
Final simplification99.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(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 2024313
(FPCore (x)
:name "Numeric.SpecFunctions:$slogFactorial from math-functions-0.1.5.2, A"
:precision binary64
:alt
(! :herbie-platform default (/ (/ 1 x) x))
(/ 1.0 (* x x)))