| Alternative 1 | |
|---|---|
| Error | 0.6 |
| Cost | 320 |
\[\frac{1}{x \cdot x}
\]
(FPCore (x) :precision binary64 (/ 1.0 (* x x)))
(FPCore (x) :precision binary64 (pow x -2.0))
double code(double x) {
return 1.0 / (x * x);
}
double code(double x) {
return pow(x, -2.0);
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 / (x * x)
end function
real(8) function code(x)
real(8), intent (in) :: x
code = x ** (-2.0d0)
end function
public static double code(double x) {
return 1.0 / (x * x);
}
public static double code(double x) {
return Math.pow(x, -2.0);
}
def code(x): return 1.0 / (x * x)
def code(x): return math.pow(x, -2.0)
function code(x) return Float64(1.0 / Float64(x * x)) end
function code(x) return x ^ -2.0 end
function tmp = code(x) tmp = 1.0 / (x * x); end
function tmp = code(x) tmp = x ^ -2.0; end
code[x_] := N[(1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision]
code[x_] := N[Power[x, -2.0], $MachinePrecision]
\frac{1}{x \cdot x}
{x}^{-2}
Results
| Original | 0.6 |
|---|---|
| Target | 0.2 |
| Herbie | 0.0 |
Initial program 0.6
Taylor expanded in x around 0 0.6
Simplified0.0
[Start]0.6 | \[ \frac{1}{{x}^{2}}
\] |
|---|---|
unpow2 [=>]0.6 | \[ \frac{1}{\color{blue}{x \cdot x}}
\] |
associate-/r* [=>]0.2 | \[ \color{blue}{\frac{\frac{1}{x}}{x}}
\] |
/-rgt-identity [<=]0.2 | \[ \frac{\frac{1}{x}}{\color{blue}{\frac{x}{1}}}
\] |
associate-/l* [<=]0.2 | \[ \color{blue}{\frac{\frac{1}{x} \cdot 1}{x}}
\] |
associate-*r/ [<=]0.3 | \[ \color{blue}{\frac{1}{x} \cdot \frac{1}{x}}
\] |
unpow-1 [<=]0.3 | \[ \color{blue}{{x}^{-1}} \cdot \frac{1}{x}
\] |
unpow-1 [<=]0.3 | \[ {x}^{-1} \cdot \color{blue}{{x}^{-1}}
\] |
pow-sqr [=>]0.0 | \[ \color{blue}{{x}^{\left(2 \cdot -1\right)}}
\] |
metadata-eval [=>]0.0 | \[ {x}^{\color{blue}{-2}}
\] |
Final simplification0.0
| Alternative 1 | |
|---|---|
| Error | 0.6 |
| Cost | 320 |
| Alternative 2 | |
|---|---|
| Error | 0.2 |
| Cost | 320 |
herbie shell --seed 2023039
(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)))