Average Error: 30.1 → 0.0
Time: 8.1s
Precision: binary64
Cost: 7424
\[-0.01 \leq x \land x \leq 0.01\]
\[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) \]
(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)

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original30.1
Target0.0
Herbie0.0
\[\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.0

    \[\leadsto \color{blue}{0.5 \cdot {x}^{2} + \left(-0.041666666666666664 \cdot {x}^{4} + 0.001388888888888889 \cdot {x}^{6}\right)} \]
  3. Applied egg-rr30.3

    \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(0.5 \cdot \left(x \cdot x\right)\right)} - 1\right)} + \left(-0.041666666666666664 \cdot {x}^{4} + 0.001388888888888889 \cdot {x}^{6}\right) \]
  4. Simplified0.0

    \[\leadsto \color{blue}{\left(x \cdot x\right) \cdot 0.5} + \left(-0.041666666666666664 \cdot {x}^{4} + 0.001388888888888889 \cdot {x}^{6}\right) \]
    Proof
    (+.f64 (*.f64 (*.f64 x x) 1/2) (+.f64 (*.f64 -1/24 (pow.f64 x 4)) (*.f64 1/720 (pow.f64 x 6)))): 0 points increase in error, 0 points decrease in error
    (+.f64 (Rewrite<= *-commutative_binary64 (*.f64 1/2 (*.f64 x x))) (+.f64 (*.f64 -1/24 (pow.f64 x 4)) (*.f64 1/720 (pow.f64 x 6)))): 0 points increase in error, 1 points decrease in error
    (+.f64 (Rewrite<= expm1-log1p_binary64 (expm1.f64 (log1p.f64 (*.f64 1/2 (*.f64 x x))))) (+.f64 (*.f64 -1/24 (pow.f64 x 4)) (*.f64 1/720 (pow.f64 x 6)))): 0 points increase in error, 1 points decrease in error
    (+.f64 (Rewrite<= expm1-def_binary64 (-.f64 (exp.f64 (log1p.f64 (*.f64 1/2 (*.f64 x x)))) 1)) (+.f64 (*.f64 -1/24 (pow.f64 x 4)) (*.f64 1/720 (pow.f64 x 6)))): 1 points increase in error, 0 points decrease in error
  5. Applied egg-rr0.0

    \[\leadsto \left(x \cdot x\right) \cdot 0.5 + \color{blue}{{x}^{4} \cdot \left(\left(x \cdot x\right) \cdot 0.001388888888888889 + -0.041666666666666664\right)} \]
  6. Final simplification0.0

    \[\leadsto \left(x \cdot x\right) \cdot 0.5 + {x}^{4} \cdot \left(\left(x \cdot x\right) \cdot 0.001388888888888889 + -0.041666666666666664\right) \]

Alternatives

Alternative 1
Error0.0
Cost6976
\[x \cdot \left(x \cdot \mathsf{fma}\left(x, x \cdot -0.041666666666666664, 0.5\right)\right) \]
Alternative 2
Error0.1
Cost960
\[\left(x \cdot x\right) \cdot 0.5 + \left(x \cdot x\right) \cdot \left(x \cdot \left(x \cdot -0.041666666666666664\right)\right) \]
Alternative 3
Error0.1
Cost704
\[\left(x \cdot x\right) \cdot \left(0.5 + \left(x \cdot x\right) \cdot -0.041666666666666664\right) \]
Alternative 4
Error0.3
Cost320
\[\left(x \cdot x\right) \cdot 0.5 \]
Alternative 5
Error0.3
Cost320
\[x \cdot \left(x \cdot 0.5\right) \]

Error

Reproduce

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)))