Average Error: 39.8 → 0.7
Time: 15.3s
Precision: 64
Internal Precision: 2368
\[\cos \left(x + e\right) - \cos x\]
\[\begin{array}{l} \mathbf{if}\;e \le -0.00021352682501638267:\\ \;\;\;\;\cos x \cdot \cos e - \left(\cos x + \sin e \cdot \sin x\right)\\ \mathbf{elif}\;e \le 1.1702967621355792 \cdot 10^{-06}:\\ \;\;\;\;\left(\sin \left(\frac{e}{2}\right) \cdot \sin \left(\frac{\left(x + e\right) + x}{2}\right)\right) \cdot -2\\ \mathbf{else}:\\ \;\;\;\;\left(\cos x \cdot \cos e - \sin e \cdot \sin x\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 e < -0.00021352682501638267

    1. Initial program 29.9

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

      \[\leadsto \color{blue}{\left(\cos x \cdot \cos e - \sin x \cdot \sin e\right)} - \cos x\]
    4. Applied associate--l-0.9

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

    if -0.00021352682501638267 < e < 1.1702967621355792e-06

    1. Initial program 49.4

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

      \[\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. Simplified0.5

      \[\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 1.1702967621355792e-06 < e

    1. Initial program 30.4

      \[\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.
  4. Final simplification0.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;e \le -0.00021352682501638267:\\ \;\;\;\;\cos x \cdot \cos e - \left(\cos x + \sin e \cdot \sin x\right)\\ \mathbf{elif}\;e \le 1.1702967621355792 \cdot 10^{-06}:\\ \;\;\;\;\left(\sin \left(\frac{e}{2}\right) \cdot \sin \left(\frac{\left(x + e\right) + x}{2}\right)\right) \cdot -2\\ \mathbf{else}:\\ \;\;\;\;\left(\cos x \cdot \cos e - \sin e \cdot \sin x\right) - \cos x\\ \end{array}\]

Runtime

Time bar (total: 15.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)))