| Alternative 1 | |
|---|---|
| Error | 0.0 |
| Cost | 6976 |
\[x \cdot \left(x \cdot \mathsf{fma}\left(x, x \cdot -0.041666666666666664, 0.5\right)\right)
\]
(FPCore (x) :precision binary64 (- 1.0 (cos x)))
(FPCore (x) :precision binary64 (+ (* (* x x) 0.5) (* (pow x 4.0) (+ (* (* x x) 0.001388888888888889) -0.041666666666666664))))
double code(double x) {
return 1.0 - cos(x);
}
double code(double x) {
return ((x * x) * 0.5) + (pow(x, 4.0) * (((x * x) * 0.001388888888888889) + -0.041666666666666664));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 - cos(x)
end function
real(8) function code(x)
real(8), intent (in) :: x
code = ((x * x) * 0.5d0) + ((x ** 4.0d0) * (((x * x) * 0.001388888888888889d0) + (-0.041666666666666664d0)))
end function
public static double code(double x) {
return 1.0 - Math.cos(x);
}
public static double code(double x) {
return ((x * x) * 0.5) + (Math.pow(x, 4.0) * (((x * x) * 0.001388888888888889) + -0.041666666666666664));
}
def code(x): return 1.0 - math.cos(x)
def code(x): return ((x * x) * 0.5) + (math.pow(x, 4.0) * (((x * x) * 0.001388888888888889) + -0.041666666666666664))
function code(x) return Float64(1.0 - cos(x)) end
function code(x) return Float64(Float64(Float64(x * x) * 0.5) + Float64((x ^ 4.0) * Float64(Float64(Float64(x * x) * 0.001388888888888889) + -0.041666666666666664))) end
function tmp = code(x) tmp = 1.0 - cos(x); end
function tmp = code(x) tmp = ((x * x) * 0.5) + ((x ^ 4.0) * (((x * x) * 0.001388888888888889) + -0.041666666666666664)); end
code[x_] := N[(1.0 - N[Cos[x], $MachinePrecision]), $MachinePrecision]
code[x_] := N[(N[(N[(x * x), $MachinePrecision] * 0.5), $MachinePrecision] + N[(N[Power[x, 4.0], $MachinePrecision] * N[(N[(N[(x * x), $MachinePrecision] * 0.001388888888888889), $MachinePrecision] + -0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
1 - \cos x
\left(x \cdot x\right) \cdot 0.5 + {x}^{4} \cdot \left(\left(x \cdot x\right) \cdot 0.001388888888888889 + -0.041666666666666664\right)
Results
| Original | 30.1 |
|---|---|
| Target | 0.0 |
| Herbie | 0.0 |
Initial program 30.1
Taylor expanded in x around 0 0.0
Applied egg-rr30.3
Simplified0.0
Applied egg-rr0.0
Final simplification0.0
| Alternative 1 | |
|---|---|
| Error | 0.0 |
| Cost | 6976 |
| Alternative 2 | |
|---|---|
| Error | 0.1 |
| Cost | 960 |
| Alternative 3 | |
|---|---|
| Error | 0.1 |
| Cost | 704 |
| Alternative 4 | |
|---|---|
| Error | 0.3 |
| Cost | 320 |
| Alternative 5 | |
|---|---|
| Error | 0.3 |
| Cost | 320 |
herbie shell --seed 2022343
(FPCore (x)
:name "ENA, Section 1.4, Mentioned, A"
:precision binary64
:pre (and (<= -0.01 x) (<= x 0.01))
:herbie-target
(/ (* (sin x) (sin x)) (+ 1.0 (cos x)))
(- 1.0 (cos x)))