Average Error: 27.7 → 2.9
Time: 17.7s
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 -6.43178686487588 \cdot 10^{+34}:\\ \;\;\;\;\frac{1}{\frac{\left(\left(sin \cdot cos\right) \cdot x\right) \cdot \left(\left(sin \cdot cos\right) \cdot x\right)}{\cos \left(x \cdot 2\right)}}\\ \mathbf{elif}\;cos \le 5.117094630849011 \cdot 10^{-162}:\\ \;\;\;\;\frac{\cos \left(x \cdot 2\right)}{\left(\left(x \cdot cos\right) \cdot sin\right) \cdot \left(\left(x \cdot cos\right) \cdot sin\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{\left(\left(sin \cdot cos\right) \cdot x\right) \cdot \left(\left(sin \cdot cos\right) \cdot x\right)}{\cos \left(x \cdot 2\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 -6.43178686487588 \cdot 10^{+34}:\\
\;\;\;\;\frac{1}{\frac{\left(\left(sin \cdot cos\right) \cdot x\right) \cdot \left(\left(sin \cdot cos\right) \cdot x\right)}{\cos \left(x \cdot 2\right)}}\\

\mathbf{elif}\;cos \le 5.117094630849011 \cdot 10^{-162}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{\left(\left(x \cdot cos\right) \cdot sin\right) \cdot \left(\left(x \cdot cos\right) \cdot sin\right)}\\

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

\end{array}
double f(double x, double cos, double sin) {
        double r693561 = 2.0;
        double r693562 = x;
        double r693563 = r693561 * r693562;
        double r693564 = cos(r693563);
        double r693565 = cos;
        double r693566 = pow(r693565, r693561);
        double r693567 = sin;
        double r693568 = pow(r693567, r693561);
        double r693569 = r693562 * r693568;
        double r693570 = r693569 * r693562;
        double r693571 = r693566 * r693570;
        double r693572 = r693564 / r693571;
        return r693572;
}

double f(double x, double cos, double sin) {
        double r693573 = cos;
        double r693574 = -6.43178686487588e+34;
        bool r693575 = r693573 <= r693574;
        double r693576 = 1.0;
        double r693577 = sin;
        double r693578 = r693577 * r693573;
        double r693579 = x;
        double r693580 = r693578 * r693579;
        double r693581 = r693580 * r693580;
        double r693582 = 2.0;
        double r693583 = r693579 * r693582;
        double r693584 = cos(r693583);
        double r693585 = r693581 / r693584;
        double r693586 = r693576 / r693585;
        double r693587 = 5.117094630849011e-162;
        bool r693588 = r693573 <= r693587;
        double r693589 = r693579 * r693573;
        double r693590 = r693589 * r693577;
        double r693591 = r693590 * r693590;
        double r693592 = r693584 / r693591;
        double r693593 = r693588 ? r693592 : r693586;
        double r693594 = r693575 ? r693586 : r693593;
        return r693594;
}

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 < -6.43178686487588e+34 or 5.117094630849011e-162 < cos

    1. Initial program 22.5

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

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

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

    if -6.43178686487588e+34 < cos < 5.117094630849011e-162

    1. Initial program 40.9

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

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

      \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{x \cdot \left(sin \cdot cos\right)}}{x \cdot \left(sin \cdot cos\right)}}\]
    5. Using strategy rm
    6. Applied associate-/r*3.1

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;cos \le -6.43178686487588 \cdot 10^{+34}:\\ \;\;\;\;\frac{1}{\frac{\left(\left(sin \cdot cos\right) \cdot x\right) \cdot \left(\left(sin \cdot cos\right) \cdot x\right)}{\cos \left(x \cdot 2\right)}}\\ \mathbf{elif}\;cos \le 5.117094630849011 \cdot 10^{-162}:\\ \;\;\;\;\frac{\cos \left(x \cdot 2\right)}{\left(\left(x \cdot cos\right) \cdot sin\right) \cdot \left(\left(x \cdot cos\right) \cdot sin\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{\left(\left(sin \cdot cos\right) \cdot x\right) \cdot \left(\left(sin \cdot cos\right) \cdot x\right)}{\cos \left(x \cdot 2\right)}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019154 +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))))