
(FPCore (x) :precision binary64 :pre TRUE (/ 1.0 (* x x)))
double code(double x) {
return 1.0 / (x * x);
}
real(8) function code(x)
use fmin_fmax_functions
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]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = (1) / (x * x) END code
\frac{1}{x \cdot x}
Herbie found 3 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 :pre TRUE (/ 1.0 (* x x)))
double code(double x) {
return 1.0 / (x * x);
}
real(8) function code(x)
use fmin_fmax_functions
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]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = (1) / (x * x) END code
\frac{1}{x \cdot x}
(FPCore (x) :precision binary64 :pre TRUE (pow x -2.0))
double code(double x) {
return pow(x, -2.0);
}
real(8) function code(x)
use fmin_fmax_functions
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]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = x ^ (-2) END code
{x}^{-2}
Initial program 99.2%
Applied rewrites100.0%
(FPCore (x) :precision binary64 :pre TRUE (/ (/ 1.0 x) x))
double code(double x) {
return (1.0 / x) / x;
}
real(8) function code(x)
use fmin_fmax_functions
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]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = ((1) / x) / x END code
\frac{\frac{1}{x}}{x}
Initial program 99.2%
Applied rewrites99.8%
herbie shell --seed 2026092
(FPCore (x)
:name "Numeric.SpecFunctions:$slogFactorial from math-functions-0.1.5.2, A"
:precision binary64
(/ 1.0 (* x x)))