Average Error: 39.8 → 0.9
Time: 35.3s
Precision: 64
Internal Precision: 2368
\[\cos \left(x + e\right) - \cos x\]
\[\begin{array}{l} \mathbf{if}\;\cos x \cdot \cos e - \left(\sin x \cdot \sin e + \cos x\right) \le -0.03320848810827198:\\ \;\;\;\;\left(\cos x \cdot \cos e - \sin x \cdot \sin e\right) - \cos x\\ \mathbf{if}\;\cos x \cdot \cos e - \left(\sin x \cdot \sin e + \cos x\right) \le 4.69573932950656 \cdot 10^{-07}:\\ \;\;\;\;-2 \cdot \left(\sin \left(\frac{x + \left(e + x\right)}{2}\right) \cdot \sin \left(\frac{e}{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\cos x \cdot \cos e - \sin x \cdot \sin e\right) - \cos x\\ \end{array}\]

Error

Bits error versus x

Bits error versus e

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if (- (* (cos x) (cos e)) (+ (* (sin x) (sin e)) (cos x))) < -0.03320848810827198

    1. Initial program 21.2

      \[\cos \left(x + e\right) - \cos x\]
    2. Using strategy rm
    3. Applied cos-sum0.5

      \[\leadsto \color{blue}{\left(\cos x \cdot \cos e - \sin x \cdot \sin e\right)} - \cos x\]

    if -0.03320848810827198 < (- (* (cos x) (cos e)) (+ (* (sin x) (sin e)) (cos x))) < 4.69573932950656e-07

    1. Initial program 47.7

      \[\cos \left(x + e\right) - \cos x\]
    2. Using strategy rm
    3. Applied diff-cos36.6

      \[\leadsto \color{blue}{-2 \cdot \left(\sin \left(\frac{\left(x + e\right) - x}{2}\right) \cdot \sin \left(\frac{\left(x + e\right) + x}{2}\right)\right)}\]
    4. Applied simplify1.2

      \[\leadsto -2 \cdot \color{blue}{\left(\sin \left(\frac{x + \left(e + x\right)}{2}\right) \cdot \sin \left(\frac{e}{2}\right)\right)}\]

    if 4.69573932950656e-07 < (- (* (cos x) (cos e)) (+ (* (sin x) (sin e)) (cos x)))

    1. Initial program 58.6

      \[\cos \left(x + e\right) - \cos x\]
    2. Using strategy rm
    3. Applied cos-sum1.0

      \[\leadsto \color{blue}{\left(\cos x \cdot \cos e - \sin x \cdot \sin e\right)} - \cos x\]
  3. Recombined 3 regimes into one program.

Runtime

Time bar (total: 35.3s)Debug log

herbie shell --seed '#(2775764126 3555076145 3898259844 1891440260 2599947619 1948460636)' 
(FPCore (x e)
  :name "cos(x+e) - cos(x)"
  (- (cos (+ x e)) (cos x)))