Average Error: 27.8 → 2.9
Time: 23.8s
Precision: 64
\[\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}\;cos \le -9.175790255859891 \cdot 10^{-110}:\\ \;\;\;\;\left({\left(x \cdot \left(sin \cdot cos\right)\right)}^{-1} \cdot \cos \left(2 \cdot x\right)\right) \cdot {\left(x \cdot \left(sin \cdot cos\right)\right)}^{-1}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{\left(sin \cdot \left(x \cdot cos\right)\right) \cdot \left(sin \cdot \left(x \cdot cos\right)\right)}{\cos \left(2 \cdot x\right)}}\\ \end{array}\]
\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}\;cos \le -9.175790255859891 \cdot 10^{-110}:\\
\;\;\;\;\left({\left(x \cdot \left(sin \cdot cos\right)\right)}^{-1} \cdot \cos \left(2 \cdot x\right)\right) \cdot {\left(x \cdot \left(sin \cdot cos\right)\right)}^{-1}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\left(sin \cdot \left(x \cdot cos\right)\right) \cdot \left(sin \cdot \left(x \cdot cos\right)\right)}{\cos \left(2 \cdot x\right)}}\\

\end{array}
double f(double x, double cos, double sin) {
        double r2187128 = 2.0;
        double r2187129 = x;
        double r2187130 = r2187128 * r2187129;
        double r2187131 = cos(r2187130);
        double r2187132 = cos;
        double r2187133 = pow(r2187132, r2187128);
        double r2187134 = sin;
        double r2187135 = pow(r2187134, r2187128);
        double r2187136 = r2187129 * r2187135;
        double r2187137 = r2187136 * r2187129;
        double r2187138 = r2187133 * r2187137;
        double r2187139 = r2187131 / r2187138;
        return r2187139;
}

double f(double x, double cos, double sin) {
        double r2187140 = cos;
        double r2187141 = -9.175790255859891e-110;
        bool r2187142 = r2187140 <= r2187141;
        double r2187143 = x;
        double r2187144 = sin;
        double r2187145 = r2187144 * r2187140;
        double r2187146 = r2187143 * r2187145;
        double r2187147 = -1.0;
        double r2187148 = pow(r2187146, r2187147);
        double r2187149 = 2.0;
        double r2187150 = r2187149 * r2187143;
        double r2187151 = cos(r2187150);
        double r2187152 = r2187148 * r2187151;
        double r2187153 = r2187152 * r2187148;
        double r2187154 = 1.0;
        double r2187155 = r2187143 * r2187140;
        double r2187156 = r2187144 * r2187155;
        double r2187157 = r2187156 * r2187156;
        double r2187158 = r2187157 / r2187151;
        double r2187159 = r2187154 / r2187158;
        double r2187160 = r2187142 ? r2187153 : r2187159;
        return r2187160;
}

Error

Bits error versus x

Bits error versus cos

Bits error versus sin

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if cos < -9.175790255859891e-110

    1. Initial program 21.9

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

      \[\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 div-inv2.2

      \[\leadsto \color{blue}{\cos \left(2 \cdot x\right) \cdot \frac{1}{\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 pow12.2

      \[\leadsto \cos \left(2 \cdot x\right) \cdot \frac{1}{\left(sin \cdot \left(x \cdot cos\right)\right) \cdot \left(sin \cdot \left(x \cdot \color{blue}{{cos}^{1}}\right)\right)}\]
    7. Applied pow12.2

      \[\leadsto \cos \left(2 \cdot x\right) \cdot \frac{1}{\left(sin \cdot \left(x \cdot cos\right)\right) \cdot \left(sin \cdot \left(\color{blue}{{x}^{1}} \cdot {cos}^{1}\right)\right)}\]
    8. Applied pow-prod-down2.2

      \[\leadsto \cos \left(2 \cdot x\right) \cdot \frac{1}{\left(sin \cdot \left(x \cdot cos\right)\right) \cdot \left(sin \cdot \color{blue}{{\left(x \cdot cos\right)}^{1}}\right)}\]
    9. Applied pow12.2

      \[\leadsto \cos \left(2 \cdot x\right) \cdot \frac{1}{\left(sin \cdot \left(x \cdot cos\right)\right) \cdot \left(\color{blue}{{sin}^{1}} \cdot {\left(x \cdot cos\right)}^{1}\right)}\]
    10. Applied pow-prod-down2.2

      \[\leadsto \cos \left(2 \cdot x\right) \cdot \frac{1}{\left(sin \cdot \left(x \cdot cos\right)\right) \cdot \color{blue}{{\left(sin \cdot \left(x \cdot cos\right)\right)}^{1}}}\]
    11. Applied pow12.2

      \[\leadsto \cos \left(2 \cdot x\right) \cdot \frac{1}{\left(sin \cdot \left(x \cdot \color{blue}{{cos}^{1}}\right)\right) \cdot {\left(sin \cdot \left(x \cdot cos\right)\right)}^{1}}\]
    12. Applied pow12.2

      \[\leadsto \cos \left(2 \cdot x\right) \cdot \frac{1}{\left(sin \cdot \left(\color{blue}{{x}^{1}} \cdot {cos}^{1}\right)\right) \cdot {\left(sin \cdot \left(x \cdot cos\right)\right)}^{1}}\]
    13. Applied pow-prod-down2.2

      \[\leadsto \cos \left(2 \cdot x\right) \cdot \frac{1}{\left(sin \cdot \color{blue}{{\left(x \cdot cos\right)}^{1}}\right) \cdot {\left(sin \cdot \left(x \cdot cos\right)\right)}^{1}}\]
    14. Applied pow12.2

      \[\leadsto \cos \left(2 \cdot x\right) \cdot \frac{1}{\left(\color{blue}{{sin}^{1}} \cdot {\left(x \cdot cos\right)}^{1}\right) \cdot {\left(sin \cdot \left(x \cdot cos\right)\right)}^{1}}\]
    15. Applied pow-prod-down2.2

      \[\leadsto \cos \left(2 \cdot x\right) \cdot \frac{1}{\color{blue}{{\left(sin \cdot \left(x \cdot cos\right)\right)}^{1}} \cdot {\left(sin \cdot \left(x \cdot cos\right)\right)}^{1}}\]
    16. Applied pow-prod-up2.2

      \[\leadsto \cos \left(2 \cdot x\right) \cdot \frac{1}{\color{blue}{{\left(sin \cdot \left(x \cdot cos\right)\right)}^{\left(1 + 1\right)}}}\]
    17. Applied pow-flip2.0

      \[\leadsto \cos \left(2 \cdot x\right) \cdot \color{blue}{{\left(sin \cdot \left(x \cdot cos\right)\right)}^{\left(-\left(1 + 1\right)\right)}}\]
    18. Simplified2.0

      \[\leadsto \cos \left(2 \cdot x\right) \cdot {\left(sin \cdot \left(x \cdot cos\right)\right)}^{\color{blue}{-2}}\]
    19. Taylor expanded around inf 2.3

      \[\leadsto \cos \left(2 \cdot x\right) \cdot {\color{blue}{\left(x \cdot \left(cos \cdot sin\right)\right)}}^{-2}\]
    20. Using strategy rm
    21. Applied sqr-pow2.3

      \[\leadsto \cos \left(2 \cdot x\right) \cdot \color{blue}{\left({\left(x \cdot \left(cos \cdot sin\right)\right)}^{\left(\frac{-2}{2}\right)} \cdot {\left(x \cdot \left(cos \cdot sin\right)\right)}^{\left(\frac{-2}{2}\right)}\right)}\]
    22. Applied associate-*r*2.3

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

    if -9.175790255859891e-110 < cos

    1. Initial program 31.8

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

      \[\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 clear-num3.3

      \[\leadsto \color{blue}{\frac{1}{\frac{\left(sin \cdot \left(x \cdot cos\right)\right) \cdot \left(sin \cdot \left(x \cdot cos\right)\right)}{\cos \left(2 \cdot x\right)}}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification2.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;cos \le -9.175790255859891 \cdot 10^{-110}:\\ \;\;\;\;\left({\left(x \cdot \left(sin \cdot cos\right)\right)}^{-1} \cdot \cos \left(2 \cdot x\right)\right) \cdot {\left(x \cdot \left(sin \cdot cos\right)\right)}^{-1}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{\left(sin \cdot \left(x \cdot cos\right)\right) \cdot \left(sin \cdot \left(x \cdot cos\right)\right)}{\cos \left(2 \cdot x\right)}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019158 +o rules:numerics
(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))))