Average Error: 28.4 → 2.4
Time: 9.0s
Precision: binary64
\[\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}^{2} \leq 1.9855534058125402 \cdot 10^{+265}:\\ \;\;\;\;\frac{\frac{\cos \left(2 \cdot x\right)}{\left|{c}^{\left(\frac{2}{2}\right)} \cdot \left(x \cdot {s}^{\left(\frac{2}{2}\right)}\right)\right|}}{\left|{c}^{\left(\frac{2}{2}\right)} \cdot \left(x \cdot {s}^{\left(\frac{2}{2}\right)}\right)\right|}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(2 \cdot x\right)}{{\left(\left|x \cdot {\left({s}^{1} \cdot {c}^{1}\right)}^{1}\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}^{2} \leq 1.9855534058125402 \cdot 10^{+265}:\\
\;\;\;\;\frac{\frac{\cos \left(2 \cdot x\right)}{\left|{c}^{\left(\frac{2}{2}\right)} \cdot \left(x \cdot {s}^{\left(\frac{2}{2}\right)}\right)\right|}}{\left|{c}^{\left(\frac{2}{2}\right)} \cdot \left(x \cdot {s}^{\left(\frac{2}{2}\right)}\right)\right|}\\

\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(2 \cdot x\right)}{{\left(\left|x \cdot {\left({s}^{1} \cdot {c}^{1}\right)}^{1}\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 (<= (pow c 2.0) 1.9855534058125402e+265)
   (/
    (/
     (cos (* 2.0 x))
     (fabs (* (pow c (/ 2.0 2.0)) (* x (pow s (/ 2.0 2.0))))))
    (fabs (* (pow c (/ 2.0 2.0)) (* x (pow s (/ 2.0 2.0))))))
   (/
    (cos (* 2.0 x))
    (pow (fabs (* x (pow (* (pow s 1.0) (pow c 1.0)) 1.0))) 2.0))))
double code(double x, double c, double s) {
	return (((double) cos(((double) (2.0 * x)))) / ((double) (((double) pow(c, 2.0)) * ((double) (((double) (x * ((double) pow(s, 2.0)))) * x)))));
}
double code(double x, double c, double s) {
	double tmp;
	if ((((double) pow(c, 2.0)) <= 1.9855534058125402e+265)) {
		tmp = ((((double) cos(((double) (2.0 * x)))) / ((double) fabs(((double) (((double) pow(c, (2.0 / 2.0))) * ((double) (x * ((double) pow(s, (2.0 / 2.0)))))))))) / ((double) fabs(((double) (((double) pow(c, (2.0 / 2.0))) * ((double) (x * ((double) pow(s, (2.0 / 2.0))))))))));
	} else {
		tmp = (((double) cos(((double) (2.0 * x)))) / ((double) pow(((double) fabs(((double) (x * ((double) pow(((double) (((double) pow(s, 1.0)) * ((double) pow(c, 1.0)))), 1.0)))))), 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 2 regimes
  2. if (pow c 2.0) < 1.9855534058125402e265

    1. Initial program Error: 30.8 bits

      \[\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 sqr-powError: 30.8 bits

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot \color{blue}{\left({s}^{\left(\frac{2}{2}\right)} \cdot {s}^{\left(\frac{2}{2}\right)}\right)}\right) \cdot x\right)}\]
    4. Applied associate-*r*Error: 23.2 bits

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left(\left(x \cdot {s}^{\left(\frac{2}{2}\right)}\right) \cdot {s}^{\left(\frac{2}{2}\right)}\right)} \cdot x\right)}\]
    5. Using strategy rm
    6. Applied add-sqr-sqrtError: 23.2 bits

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\sqrt{{c}^{2} \cdot \left(\left(\left(x \cdot {s}^{\left(\frac{2}{2}\right)}\right) \cdot {s}^{\left(\frac{2}{2}\right)}\right) \cdot x\right)} \cdot \sqrt{{c}^{2} \cdot \left(\left(\left(x \cdot {s}^{\left(\frac{2}{2}\right)}\right) \cdot {s}^{\left(\frac{2}{2}\right)}\right) \cdot x\right)}}}\]
    7. SimplifiedError: 23.2 bits

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left|\left(x \cdot {s}^{\left(\frac{2}{2}\right)}\right) \cdot {c}^{\left(\frac{2}{2}\right)}\right|} \cdot \sqrt{{c}^{2} \cdot \left(\left(\left(x \cdot {s}^{\left(\frac{2}{2}\right)}\right) \cdot {s}^{\left(\frac{2}{2}\right)}\right) \cdot x\right)}}\]
    8. SimplifiedError: 2.6 bits

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left|\left(x \cdot {s}^{\left(\frac{2}{2}\right)}\right) \cdot {c}^{\left(\frac{2}{2}\right)}\right| \cdot \color{blue}{\left|\left(x \cdot {s}^{\left(\frac{2}{2}\right)}\right) \cdot {c}^{\left(\frac{2}{2}\right)}\right|}}\]
    9. Using strategy rm
    10. Applied associate-/r*Error: 2.3 bits

      \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{\left|\left(x \cdot {s}^{\left(\frac{2}{2}\right)}\right) \cdot {c}^{\left(\frac{2}{2}\right)}\right|}}{\left|\left(x \cdot {s}^{\left(\frac{2}{2}\right)}\right) \cdot {c}^{\left(\frac{2}{2}\right)}\right|}}\]
    11. SimplifiedError: 2.3 bits

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

    if 1.9855534058125402e265 < (pow c 2.0)

    1. Initial program Error: 24.6 bits

      \[\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 sqr-powError: 24.6 bits

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot \color{blue}{\left({s}^{\left(\frac{2}{2}\right)} \cdot {s}^{\left(\frac{2}{2}\right)}\right)}\right) \cdot x\right)}\]
    4. Applied associate-*r*Error: 20.8 bits

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left(\left(x \cdot {s}^{\left(\frac{2}{2}\right)}\right) \cdot {s}^{\left(\frac{2}{2}\right)}\right)} \cdot x\right)}\]
    5. Using strategy rm
    6. Applied add-sqr-sqrtError: 20.8 bits

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\sqrt{{c}^{2} \cdot \left(\left(\left(x \cdot {s}^{\left(\frac{2}{2}\right)}\right) \cdot {s}^{\left(\frac{2}{2}\right)}\right) \cdot x\right)} \cdot \sqrt{{c}^{2} \cdot \left(\left(\left(x \cdot {s}^{\left(\frac{2}{2}\right)}\right) \cdot {s}^{\left(\frac{2}{2}\right)}\right) \cdot x\right)}}}\]
    7. SimplifiedError: 20.8 bits

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left|\left(x \cdot {s}^{\left(\frac{2}{2}\right)}\right) \cdot {c}^{\left(\frac{2}{2}\right)}\right|} \cdot \sqrt{{c}^{2} \cdot \left(\left(\left(x \cdot {s}^{\left(\frac{2}{2}\right)}\right) \cdot {s}^{\left(\frac{2}{2}\right)}\right) \cdot x\right)}}\]
    8. SimplifiedError: 3.3 bits

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left|\left(x \cdot {s}^{\left(\frac{2}{2}\right)}\right) \cdot {c}^{\left(\frac{2}{2}\right)}\right| \cdot \color{blue}{\left|\left(x \cdot {s}^{\left(\frac{2}{2}\right)}\right) \cdot {c}^{\left(\frac{2}{2}\right)}\right|}}\]
    9. Taylor expanded around inf Error: 2.5 bits

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{\left(\left|{\left({s}^{1} \cdot {c}^{1}\right)}^{1} \cdot x\right|\right)}^{2}}}\]
    10. SimplifiedError: 2.5 bits

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;{c}^{2} \leq 1.9855534058125402 \cdot 10^{+265}:\\ \;\;\;\;\frac{\frac{\cos \left(2 \cdot x\right)}{\left|{c}^{\left(\frac{2}{2}\right)} \cdot \left(x \cdot {s}^{\left(\frac{2}{2}\right)}\right)\right|}}{\left|{c}^{\left(\frac{2}{2}\right)} \cdot \left(x \cdot {s}^{\left(\frac{2}{2}\right)}\right)\right|}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(2 \cdot x\right)}{{\left(\left|x \cdot {\left({s}^{1} \cdot {c}^{1}\right)}^{1}\right|\right)}^{2}}\\ \end{array}\]

Reproduce

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