Average Error: 30.1 → 0.1
Time: 15.6s
Precision: binary64
Cost: 832
\[-0.01 \leq x \land x \leq 0.01\]
\[1 - \cos x \]
\[x \cdot \left(\left(-0.041666666666666664 \cdot \left(x \cdot x\right)\right) \cdot x + 0.5 \cdot x\right) \]
(FPCore (x) :precision binary64 (- 1.0 (cos x)))
(FPCore (x)
 :precision binary64
 (* x (+ (* (* -0.041666666666666664 (* x x)) x) (* 0.5 x))))
double code(double x) {
	return 1.0 - cos(x);
}
double code(double x) {
	return x * (((-0.041666666666666664 * (x * x)) * x) + (0.5 * x));
}
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 * ((((-0.041666666666666664d0) * (x * x)) * x) + (0.5d0 * x))
end function
public static double code(double x) {
	return 1.0 - Math.cos(x);
}
public static double code(double x) {
	return x * (((-0.041666666666666664 * (x * x)) * x) + (0.5 * x));
}
def code(x):
	return 1.0 - math.cos(x)
def code(x):
	return x * (((-0.041666666666666664 * (x * x)) * x) + (0.5 * x))
function code(x)
	return Float64(1.0 - cos(x))
end
function code(x)
	return Float64(x * Float64(Float64(Float64(-0.041666666666666664 * Float64(x * x)) * x) + Float64(0.5 * x)))
end
function tmp = code(x)
	tmp = 1.0 - cos(x);
end
function tmp = code(x)
	tmp = x * (((-0.041666666666666664 * (x * x)) * x) + (0.5 * x));
end
code[x_] := N[(1.0 - N[Cos[x], $MachinePrecision]), $MachinePrecision]
code[x_] := N[(x * N[(N[(N[(-0.041666666666666664 * N[(x * x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] + N[(0.5 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
1 - \cos x
x \cdot \left(\left(-0.041666666666666664 \cdot \left(x \cdot x\right)\right) \cdot x + 0.5 \cdot x\right)

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original30.1
Target0.0
Herbie0.1
\[\frac{\sin x \cdot \sin x}{1 + \cos x} \]

Derivation

  1. Initial program 30.1

    \[1 - \cos x \]
  2. Taylor expanded in x around 0 0.1

    \[\leadsto \color{blue}{0.5 \cdot {x}^{2} + -0.041666666666666664 \cdot {x}^{4}} \]
  3. Simplified0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(0.5, x \cdot x, -0.041666666666666664 \cdot {x}^{4}\right)} \]
    Proof
  4. Applied egg-rr0.1

    \[\leadsto \color{blue}{x \cdot \left(\left(-0.041666666666666664 \cdot \left(x \cdot x\right)\right) \cdot x + 0.5 \cdot x\right)} \]

Alternatives

Alternative 1
Error0.3
Cost320
\[0.5 \cdot \left(x \cdot x\right) \]
Alternative 2
Error0.3
Cost320
\[\left(0.5 \cdot x\right) \cdot x \]
Alternative 3
Error30.7
Cost192
\[x - x \]

Error

Reproduce

herbie shell --seed 2023010 
(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)))