Average Error: 30.2 → 0.0
Time: 6.9s
Precision: binary64
Cost: 13120
\[-0.01 \leq x \land x \leq 0.01\]
\[1 - \cos x \]
\[\sin x \cdot \tan \left(\frac{x}{2}\right) \]
(FPCore (x) :precision binary64 (- 1.0 (cos x)))
(FPCore (x) :precision binary64 (* (sin x) (tan (/ x 2.0))))
double code(double x) {
	return 1.0 - cos(x);
}
double code(double x) {
	return sin(x) * tan((x / 2.0));
}
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 = sin(x) * tan((x / 2.0d0))
end function
public static double code(double x) {
	return 1.0 - Math.cos(x);
}
public static double code(double x) {
	return Math.sin(x) * Math.tan((x / 2.0));
}
def code(x):
	return 1.0 - math.cos(x)
def code(x):
	return math.sin(x) * math.tan((x / 2.0))
function code(x)
	return Float64(1.0 - cos(x))
end
function code(x)
	return Float64(sin(x) * tan(Float64(x / 2.0)))
end
function tmp = code(x)
	tmp = 1.0 - cos(x);
end
function tmp = code(x)
	tmp = sin(x) * tan((x / 2.0));
end
code[x_] := N[(1.0 - N[Cos[x], $MachinePrecision]), $MachinePrecision]
code[x_] := N[(N[Sin[x], $MachinePrecision] * N[Tan[N[(x / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
1 - \cos x
\sin x \cdot \tan \left(\frac{x}{2}\right)

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 30.2

    \[1 - \cos x \]
  2. Applied egg-rr0.0

    \[\leadsto \color{blue}{\frac{\sin x \cdot \sin x}{1 + \cos x}} \]
  3. Taylor expanded in x around inf 0.0

    \[\leadsto \color{blue}{\frac{{\sin x}^{2}}{1 + \cos x}} \]
  4. Simplified0.0

    \[\leadsto \color{blue}{\sin x \cdot \tan \left(\frac{x}{2}\right)} \]
    Proof
    (*.f64 (sin.f64 x) (tan.f64 (/.f64 x 2))): 0 points increase in error, 0 points decrease in error
    (*.f64 (sin.f64 x) (Rewrite<= hang-0p-tan_binary64 (/.f64 (sin.f64 x) (+.f64 1 (cos.f64 x))))): 1 points increase in error, 1 points decrease in error
    (Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 (sin.f64 x) (sin.f64 x)) (+.f64 1 (cos.f64 x)))): 2 points increase in error, 0 points decrease in error
    (/.f64 (Rewrite<= unpow2_binary64 (pow.f64 (sin.f64 x) 2)) (+.f64 1 (cos.f64 x))): 0 points increase in error, 0 points decrease in error
  5. Final simplification0.0

    \[\leadsto \sin x \cdot \tan \left(\frac{x}{2}\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.0
Cost832
\[x \cdot \left(x \cdot \left(x \cdot \left(x \cdot -0.041666666666666664\right)\right) + x \cdot 0.5\right) \]
Alternative 3
Error0.3
Cost320
\[x \cdot \left(x \cdot 0.5\right) \]

Error

Reproduce

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