| Alternative 1 | |
|---|---|
| Error | 0.6 |
| Cost | 320 |
\[\frac{1}{x \cdot x}
\]
(FPCore (x) :precision binary64 (/ 1.0 (* x x)))
(FPCore (x) :precision binary64 (- (/ (/ (/ 3.0 x) x) 4.0) (/ (/ (/ -1.0 x) x) 4.0)))
double code(double x) {
return 1.0 / (x * x);
}
double code(double x) {
return (((3.0 / x) / x) / 4.0) - (((-1.0 / x) / x) / 4.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 = (((3.0d0 / x) / x) / 4.0d0) - ((((-1.0d0) / x) / x) / 4.0d0)
end function
public static double code(double x) {
return 1.0 / (x * x);
}
public static double code(double x) {
return (((3.0 / x) / x) / 4.0) - (((-1.0 / x) / x) / 4.0);
}
def code(x): return 1.0 / (x * x)
def code(x): return (((3.0 / x) / x) / 4.0) - (((-1.0 / x) / x) / 4.0)
function code(x) return Float64(1.0 / Float64(x * x)) end
function code(x) return Float64(Float64(Float64(Float64(3.0 / x) / x) / 4.0) - Float64(Float64(Float64(-1.0 / x) / x) / 4.0)) end
function tmp = code(x) tmp = 1.0 / (x * x); end
function tmp = code(x) tmp = (((3.0 / x) / x) / 4.0) - (((-1.0 / x) / x) / 4.0); end
code[x_] := N[(1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision]
code[x_] := N[(N[(N[(N[(3.0 / x), $MachinePrecision] / x), $MachinePrecision] / 4.0), $MachinePrecision] - N[(N[(N[(-1.0 / x), $MachinePrecision] / x), $MachinePrecision] / 4.0), $MachinePrecision]), $MachinePrecision]
\frac{1}{x \cdot x}
\frac{\frac{\frac{3}{x}}{x}}{4} - \frac{\frac{\frac{-1}{x}}{x}}{4}
Results
| Original | 0.6 |
|---|---|
| Target | 0.2 |
| Herbie | 0.2 |
Initial program 0.6
Applied egg-rr0.2
Final simplification0.2
| Alternative 1 | |
|---|---|
| Error | 0.6 |
| Cost | 320 |
| Alternative 2 | |
|---|---|
| Error | 0.2 |
| Cost | 320 |
herbie shell --seed 2023100
(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)))