Average Error: 27.9 → 2.6
Time: 13.3s
Precision: 64
Internal Precision: 128
\[\frac{\cos \left(2 \cdot x\right)}{{cos}^{2} \cdot \left(\left(x \cdot {sin}^{2}\right) \cdot x\right)}\]
\[\begin{array}{l} \mathbf{if}\;sin \le -7.477021423829115 \cdot 10^{-308}:\\ \;\;\;\;\frac{\left(\cos x - \sin x\right) \cdot \left(\sin x + \cos x\right)}{\left(sin \cdot \left(x \cdot cos\right)\right) \cdot \left(sin \cdot \left(x \cdot cos\right)\right)}\\ \mathbf{elif}\;sin \le 9.850296288943132 \cdot 10^{-242}:\\ \;\;\;\;\frac{\cos \left(x \cdot 2\right)}{\left(\left(x \cdot sin\right) \cdot cos\right) \cdot \left(\left(x \cdot sin\right) \cdot cos\right)}\\ \mathbf{elif}\;sin \le 1.5137559334682638 \cdot 10^{+181}:\\ \;\;\;\;\frac{\frac{{\left(\cos x \cdot \cos x\right)}^{3} - \left(\sin x \cdot \left(\sin x \cdot \sin x\right)\right) \cdot \left(\sin x \cdot \left(\sin x \cdot \sin x\right)\right)}{\left(\left(\sin x \cdot \sin x\right) \cdot \left(\sin x \cdot \sin x\right) + \left(\sin x \cdot \sin x\right) \cdot \left(\cos x \cdot \cos x\right)\right) + \left(\cos x \cdot \cos x\right) \cdot \left(\cos x \cdot \cos x\right)}}{\left(sin \cdot \left(x \cdot cos\right)\right) \cdot \left(sin \cdot \left(x \cdot cos\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(x \cdot 2\right)}{\left(\left(x \cdot sin\right) \cdot cos\right) \cdot \left(\left(x \cdot sin\right) \cdot cos\right)}\\ \end{array}\]

Error

Bits error versus x

Bits error versus cos

Bits error versus sin

Derivation

  1. Split input into 3 regimes
  2. if sin < -7.477021423829115e-308

    1. Initial program 27.2

      \[\frac{\cos \left(2 \cdot x\right)}{{cos}^{2} \cdot \left(\left(x \cdot {sin}^{2}\right) \cdot x\right)}\]
    2. Simplified3.0

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{\left(sin \cdot \left(x \cdot cos\right)\right) \cdot \left(sin \cdot \left(x \cdot cos\right)\right)}}\]
    3. Using strategy rm
    4. Applied cos-23.0

      \[\leadsto \frac{\color{blue}{\cos x \cdot \cos x - \sin x \cdot \sin x}}{\left(sin \cdot \left(x \cdot cos\right)\right) \cdot \left(sin \cdot \left(x \cdot cos\right)\right)}\]
    5. Using strategy rm
    6. Applied difference-of-squares3.0

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

    if -7.477021423829115e-308 < sin < 9.850296288943132e-242 or 1.5137559334682638e+181 < sin

    1. Initial program 30.9

      \[\frac{\cos \left(2 \cdot x\right)}{{cos}^{2} \cdot \left(\left(x \cdot {sin}^{2}\right) \cdot x\right)}\]
    2. Simplified6.6

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{\left(sin \cdot \left(x \cdot cos\right)\right) \cdot \left(sin \cdot \left(x \cdot cos\right)\right)}}\]
    3. Taylor expanded around inf 34.2

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{x}^{2} \cdot \left({cos}^{2} \cdot {sin}^{2}\right)}}\]
    4. Simplified3.3

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

    if 9.850296288943132e-242 < sin < 1.5137559334682638e+181

    1. Initial program 27.4

      \[\frac{\cos \left(2 \cdot x\right)}{{cos}^{2} \cdot \left(\left(x \cdot {sin}^{2}\right) \cdot x\right)}\]
    2. Simplified1.5

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{\left(sin \cdot \left(x \cdot cos\right)\right) \cdot \left(sin \cdot \left(x \cdot cos\right)\right)}}\]
    3. Using strategy rm
    4. Applied cos-21.6

      \[\leadsto \frac{\color{blue}{\cos x \cdot \cos x - \sin x \cdot \sin x}}{\left(sin \cdot \left(x \cdot cos\right)\right) \cdot \left(sin \cdot \left(x \cdot cos\right)\right)}\]
    5. Using strategy rm
    6. Applied flip3--1.6

      \[\leadsto \frac{\color{blue}{\frac{{\left(\cos x \cdot \cos x\right)}^{3} - {\left(\sin x \cdot \sin x\right)}^{3}}{\left(\cos x \cdot \cos x\right) \cdot \left(\cos x \cdot \cos x\right) + \left(\left(\sin x \cdot \sin x\right) \cdot \left(\sin x \cdot \sin x\right) + \left(\cos x \cdot \cos x\right) \cdot \left(\sin x \cdot \sin x\right)\right)}}}{\left(sin \cdot \left(x \cdot cos\right)\right) \cdot \left(sin \cdot \left(x \cdot cos\right)\right)}\]
    7. Using strategy rm
    8. Applied add-cbrt-cube1.7

      \[\leadsto \frac{\frac{{\left(\cos x \cdot \cos x\right)}^{3} - {\left(\sin x \cdot \color{blue}{\sqrt[3]{\left(\sin x \cdot \sin x\right) \cdot \sin x}}\right)}^{3}}{\left(\cos x \cdot \cos x\right) \cdot \left(\cos x \cdot \cos x\right) + \left(\left(\sin x \cdot \sin x\right) \cdot \left(\sin x \cdot \sin x\right) + \left(\cos x \cdot \cos x\right) \cdot \left(\sin x \cdot \sin x\right)\right)}}{\left(sin \cdot \left(x \cdot cos\right)\right) \cdot \left(sin \cdot \left(x \cdot cos\right)\right)}\]
    9. Applied add-cbrt-cube1.8

      \[\leadsto \frac{\frac{{\left(\cos x \cdot \cos x\right)}^{3} - {\left(\color{blue}{\sqrt[3]{\left(\sin x \cdot \sin x\right) \cdot \sin x}} \cdot \sqrt[3]{\left(\sin x \cdot \sin x\right) \cdot \sin x}\right)}^{3}}{\left(\cos x \cdot \cos x\right) \cdot \left(\cos x \cdot \cos x\right) + \left(\left(\sin x \cdot \sin x\right) \cdot \left(\sin x \cdot \sin x\right) + \left(\cos x \cdot \cos x\right) \cdot \left(\sin x \cdot \sin x\right)\right)}}{\left(sin \cdot \left(x \cdot cos\right)\right) \cdot \left(sin \cdot \left(x \cdot cos\right)\right)}\]
    10. Applied cbrt-unprod1.7

      \[\leadsto \frac{\frac{{\left(\cos x \cdot \cos x\right)}^{3} - {\color{blue}{\left(\sqrt[3]{\left(\left(\sin x \cdot \sin x\right) \cdot \sin x\right) \cdot \left(\left(\sin x \cdot \sin x\right) \cdot \sin x\right)}\right)}}^{3}}{\left(\cos x \cdot \cos x\right) \cdot \left(\cos x \cdot \cos x\right) + \left(\left(\sin x \cdot \sin x\right) \cdot \left(\sin x \cdot \sin x\right) + \left(\cos x \cdot \cos x\right) \cdot \left(\sin x \cdot \sin x\right)\right)}}{\left(sin \cdot \left(x \cdot cos\right)\right) \cdot \left(sin \cdot \left(x \cdot cos\right)\right)}\]
    11. Applied rem-cube-cbrt1.6

      \[\leadsto \frac{\frac{{\left(\cos x \cdot \cos x\right)}^{3} - \color{blue}{\left(\left(\sin x \cdot \sin x\right) \cdot \sin x\right) \cdot \left(\left(\sin x \cdot \sin x\right) \cdot \sin x\right)}}{\left(\cos x \cdot \cos x\right) \cdot \left(\cos x \cdot \cos x\right) + \left(\left(\sin x \cdot \sin x\right) \cdot \left(\sin x \cdot \sin x\right) + \left(\cos x \cdot \cos x\right) \cdot \left(\sin x \cdot \sin x\right)\right)}}{\left(sin \cdot \left(x \cdot cos\right)\right) \cdot \left(sin \cdot \left(x \cdot cos\right)\right)}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification2.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;sin \le -7.477021423829115 \cdot 10^{-308}:\\ \;\;\;\;\frac{\left(\cos x - \sin x\right) \cdot \left(\sin x + \cos x\right)}{\left(sin \cdot \left(x \cdot cos\right)\right) \cdot \left(sin \cdot \left(x \cdot cos\right)\right)}\\ \mathbf{elif}\;sin \le 9.850296288943132 \cdot 10^{-242}:\\ \;\;\;\;\frac{\cos \left(x \cdot 2\right)}{\left(\left(x \cdot sin\right) \cdot cos\right) \cdot \left(\left(x \cdot sin\right) \cdot cos\right)}\\ \mathbf{elif}\;sin \le 1.5137559334682638 \cdot 10^{+181}:\\ \;\;\;\;\frac{\frac{{\left(\cos x \cdot \cos x\right)}^{3} - \left(\sin x \cdot \left(\sin x \cdot \sin x\right)\right) \cdot \left(\sin x \cdot \left(\sin x \cdot \sin x\right)\right)}{\left(\left(\sin x \cdot \sin x\right) \cdot \left(\sin x \cdot \sin x\right) + \left(\sin x \cdot \sin x\right) \cdot \left(\cos x \cdot \cos x\right)\right) + \left(\cos x \cdot \cos x\right) \cdot \left(\cos x \cdot \cos x\right)}}{\left(sin \cdot \left(x \cdot cos\right)\right) \cdot \left(sin \cdot \left(x \cdot cos\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(x \cdot 2\right)}{\left(\left(x \cdot sin\right) \cdot cos\right) \cdot \left(\left(x \cdot sin\right) \cdot cos\right)}\\ \end{array}\]

Reproduce

herbie shell --seed 2019053 
(FPCore (x cos sin)
  :name "cos(2*x)/(cos^2(x)*sin^2(x))"
  (/ (cos (* 2 x)) (* (pow cos 2) (* (* x (pow sin 2)) x))))