Numeric.SpecFunctions:$slogFactorial from math-functions-0.1.5.2, A

Percentage Accurate: 99.2% → 100.0%
Time: 981.0ms
Alternatives: 3
Speedup: 1.0×

Specification

?
\[\frac{1}{x \cdot x} \]
(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}

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 3 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 99.2% accurate, 1.0× speedup?

\[\frac{1}{x \cdot x} \]
(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}

Alternative 1: 100.0% accurate, 0.4× speedup?

\[{x}^{-2} \]
(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}
Derivation
  1. Initial program 99.2%

    \[\frac{1}{x \cdot x} \]
  2. Step-by-step derivation
    1. Applied rewrites100.0%

      \[\leadsto {x}^{-2} \]
    2. Add Preprocessing

    Alternative 2: 99.8% accurate, 0.9× speedup?

    \[\frac{\frac{1}{x}}{x} \]
    (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}
    
    Derivation
    1. Initial program 99.2%

      \[\frac{1}{x \cdot x} \]
    2. Step-by-step derivation
      1. Applied rewrites99.8%

        \[\leadsto \frac{\frac{1}{x}}{x} \]
      2. Add Preprocessing

      Reproduce

      ?
      herbie shell --seed 2026092 
      (FPCore (x)
        :name "Numeric.SpecFunctions:$slogFactorial from math-functions-0.1.5.2, A"
        :precision binary64
        (/ 1.0 (* x x)))