Average Error: 28.4 → 2.2
Time: 18.0s
Precision: binary64
\[[c, s]=\mathsf{sort}([c, s])\]
\[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}\]
\[\begin{array}{l} \mathbf{if}\;c \leq -5.631581554822726 \cdot 10^{+259}:\\ \;\;\;\;\frac{\cos \left(2 \cdot x\right)}{{\left(\left|s \cdot \left(c \cdot x\right)\right|\right)}^{1.5} \cdot \sqrt{\left|s \cdot \left(c \cdot x\right)\right|}}\\ \mathbf{elif}\;c \leq -8.463457387048583 \cdot 10^{-225}:\\ \;\;\;\;\cos \left(2 \cdot x\right) \cdot {\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\ \mathbf{else}:\\ \;\;\;\;\cos \left(2 \cdot x\right) \cdot \frac{1}{{\left(s \cdot \left(c \cdot x\right)\right)}^{2}}\\ \end{array}\]
\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}
\begin{array}{l}
\mathbf{if}\;c \leq -5.631581554822726 \cdot 10^{+259}:\\
\;\;\;\;\frac{\cos \left(2 \cdot x\right)}{{\left(\left|s \cdot \left(c \cdot x\right)\right|\right)}^{1.5} \cdot \sqrt{\left|s \cdot \left(c \cdot x\right)\right|}}\\

\mathbf{elif}\;c \leq -8.463457387048583 \cdot 10^{-225}:\\
\;\;\;\;\cos \left(2 \cdot x\right) \cdot {\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\

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

\end{array}
(FPCore (x c s)
 :precision binary64
 (/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))
(FPCore (x c s)
 :precision binary64
 (if (<= c -5.631581554822726e+259)
   (/
    (cos (* 2.0 x))
    (* (pow (fabs (* s (* c x))) 1.5) (sqrt (fabs (* s (* c x))))))
   (if (<= c -8.463457387048583e-225)
     (* (cos (* 2.0 x)) (pow (* c (* x s)) -2.0))
     (* (cos (* 2.0 x)) (/ 1.0 (pow (* s (* c x)) 2.0))))))
double code(double x, double c, double s) {
	return cos(2.0 * x) / (pow(c, 2.0) * ((x * pow(s, 2.0)) * x));
}
double code(double x, double c, double s) {
	double tmp;
	if (c <= -5.631581554822726e+259) {
		tmp = cos(2.0 * x) / (pow(fabs(s * (c * x)), 1.5) * sqrt(fabs(s * (c * x))));
	} else if (c <= -8.463457387048583e-225) {
		tmp = cos(2.0 * x) * pow((c * (x * s)), -2.0);
	} else {
		tmp = cos(2.0 * x) * (1.0 / pow((s * (c * x)), 2.0));
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus c

Bits error versus s

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if c < -5.6315815548227259e259

    1. Initial program 23.4

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt_binary64_44123.4

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \cdot \sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}}}\]
    4. Simplified23.4

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left|s \cdot \left(x \cdot c\right)\right|} \cdot \sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}}\]
    5. Simplified1.9

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left|s \cdot \left(x \cdot c\right)\right| \cdot \color{blue}{\left|s \cdot \left(x \cdot c\right)\right|}}\]
    6. Using strategy rm
    7. Applied add-sqr-sqrt_binary64_4412.0

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left|s \cdot \left(x \cdot c\right)\right| \cdot \color{blue}{\left(\sqrt{\left|s \cdot \left(x \cdot c\right)\right|} \cdot \sqrt{\left|s \cdot \left(x \cdot c\right)\right|}\right)}}\]
    8. Applied associate-*r*_binary64_3592.0

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(\left|s \cdot \left(x \cdot c\right)\right| \cdot \sqrt{\left|s \cdot \left(x \cdot c\right)\right|}\right) \cdot \sqrt{\left|s \cdot \left(x \cdot c\right)\right|}}}\]
    9. Simplified2.0

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left|s \cdot \left(x \cdot c\right)\right|\right)}^{1.5}} \cdot \sqrt{\left|s \cdot \left(x \cdot c\right)\right|}}\]

    if -5.6315815548227259e259 < c < -8.4634573870485826e-225

    1. Initial program 27.3

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt_binary64_44127.4

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \cdot \sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}}}\]
    4. Simplified27.3

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left|s \cdot \left(x \cdot c\right)\right|} \cdot \sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}}\]
    5. Simplified2.9

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left|s \cdot \left(x \cdot c\right)\right| \cdot \color{blue}{\left|s \cdot \left(x \cdot c\right)\right|}}\]
    6. Using strategy rm
    7. Applied div-inv_binary64_4162.9

      \[\leadsto \color{blue}{\cos \left(2 \cdot x\right) \cdot \frac{1}{\left|s \cdot \left(x \cdot c\right)\right| \cdot \left|s \cdot \left(x \cdot c\right)\right|}}\]
    8. Simplified2.9

      \[\leadsto \cos \left(2 \cdot x\right) \cdot \color{blue}{\frac{1}{{\left(s \cdot \left(x \cdot c\right)\right)}^{2}}}\]
    9. Using strategy rm
    10. Applied pow-flip_binary64_4932.6

      \[\leadsto \cos \left(2 \cdot x\right) \cdot \color{blue}{{\left(s \cdot \left(x \cdot c\right)\right)}^{\left(-2\right)}}\]
    11. Simplified2.6

      \[\leadsto \cos \left(2 \cdot x\right) \cdot {\left(s \cdot \left(x \cdot c\right)\right)}^{\color{blue}{-2}}\]
    12. Using strategy rm
    13. Applied associate-*r*_binary64_3591.7

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

    if -8.4634573870485826e-225 < c

    1. Initial program 32.5

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt_binary64_44132.5

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \cdot \sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}}}\]
    4. Simplified32.5

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left|s \cdot \left(x \cdot c\right)\right|} \cdot \sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}}\]
    5. Simplified3.4

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left|s \cdot \left(x \cdot c\right)\right| \cdot \color{blue}{\left|s \cdot \left(x \cdot c\right)\right|}}\]
    6. Using strategy rm
    7. Applied div-inv_binary64_4163.5

      \[\leadsto \color{blue}{\cos \left(2 \cdot x\right) \cdot \frac{1}{\left|s \cdot \left(x \cdot c\right)\right| \cdot \left|s \cdot \left(x \cdot c\right)\right|}}\]
    8. Simplified3.5

      \[\leadsto \cos \left(2 \cdot x\right) \cdot \color{blue}{\frac{1}{{\left(s \cdot \left(x \cdot c\right)\right)}^{2}}}\]
    9. Using strategy rm
    10. Applied *-un-lft-identity_binary64_4193.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -5.631581554822726 \cdot 10^{+259}:\\ \;\;\;\;\frac{\cos \left(2 \cdot x\right)}{{\left(\left|s \cdot \left(c \cdot x\right)\right|\right)}^{1.5} \cdot \sqrt{\left|s \cdot \left(c \cdot x\right)\right|}}\\ \mathbf{elif}\;c \leq -8.463457387048583 \cdot 10^{-225}:\\ \;\;\;\;\cos \left(2 \cdot x\right) \cdot {\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\ \mathbf{else}:\\ \;\;\;\;\cos \left(2 \cdot x\right) \cdot \frac{1}{{\left(s \cdot \left(c \cdot x\right)\right)}^{2}}\\ \end{array}\]

Reproduce

herbie shell --seed 2021075 
(FPCore (x c s)
  :name "mixedcos"
  :precision binary64
  (/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))