| Alternative 1 | |
|---|---|
| Error | 0.4 |
| Cost | 12992 |
\[\left|x\right| \cdot \sqrt{2}
\]
(FPCore (x) :precision binary64 (sqrt (* 2.0 (pow x 2.0))))
(FPCore (x) :precision binary64 (* (* (fabs x) (sqrt 0.2222222222222222)) 3.0))
double code(double x) {
return sqrt((2.0 * pow(x, 2.0)));
}
double code(double x) {
return (fabs(x) * sqrt(0.2222222222222222)) * 3.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = sqrt((2.0d0 * (x ** 2.0d0)))
end function
real(8) function code(x)
real(8), intent (in) :: x
code = (abs(x) * sqrt(0.2222222222222222d0)) * 3.0d0
end function
public static double code(double x) {
return Math.sqrt((2.0 * Math.pow(x, 2.0)));
}
public static double code(double x) {
return (Math.abs(x) * Math.sqrt(0.2222222222222222)) * 3.0;
}
def code(x): return math.sqrt((2.0 * math.pow(x, 2.0)))
def code(x): return (math.fabs(x) * math.sqrt(0.2222222222222222)) * 3.0
function code(x) return sqrt(Float64(2.0 * (x ^ 2.0))) end
function code(x) return Float64(Float64(abs(x) * sqrt(0.2222222222222222)) * 3.0) end
function tmp = code(x) tmp = sqrt((2.0 * (x ^ 2.0))); end
function tmp = code(x) tmp = (abs(x) * sqrt(0.2222222222222222)) * 3.0; end
code[x_] := N[Sqrt[N[(2.0 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
code[x_] := N[(N[(N[Abs[x], $MachinePrecision] * N[Sqrt[0.2222222222222222], $MachinePrecision]), $MachinePrecision] * 3.0), $MachinePrecision]
\sqrt{2 \cdot {x}^{2}}
\left(\left|x\right| \cdot \sqrt{0.2222222222222222}\right) \cdot 3
Results
Initial program 30.2
Applied egg-rr0.5
Applied egg-rr0.3
Simplified0.3
| Alternative 1 | |
|---|---|
| Error | 0.4 |
| Cost | 12992 |
| Alternative 2 | |
|---|---|
| Error | 0.4 |
| Cost | 12992 |
| Alternative 3 | |
|---|---|
| Error | 0.4 |
| Cost | 6852 |
| Alternative 4 | |
|---|---|
| Error | 0.4 |
| Cost | 6788 |
| Alternative 5 | |
|---|---|
| Error | 31.1 |
| Cost | 6592 |
herbie shell --seed 2023010
(FPCore (x)
:name "sqrt D (should all be same)"
:precision binary64
(sqrt (* 2.0 (pow x 2.0))))