Average Error: 28.0 → 5.7
Time: 8.6s
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}\;x \leq -2.5212314714250252 \cdot 10^{-247} \lor \neg \left(x \leq 8.638771279925528 \cdot 10^{-239}\right):\\ \;\;\;\;\frac{1}{x \cdot \left(x \cdot {\left(c \cdot s\right)}^{\left(0.5 \cdot 2\right)}\right)} \cdot \frac{\cos \left(x \cdot 2\right)}{{\left(c \cdot s\right)}^{\left(0.5 \cdot 2\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\cos \left(x \cdot 2\right)}{x}}{\left(x \cdot {\left(c \cdot s\right)}^{\left(0.5 \cdot 2\right)}\right) \cdot {\left(c \cdot s\right)}^{\left(\frac{2}{2}\right)}}\\ \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}\;x \leq -2.5212314714250252 \cdot 10^{-247} \lor \neg \left(x \leq 8.638771279925528 \cdot 10^{-239}\right):\\
\;\;\;\;\frac{1}{x \cdot \left(x \cdot {\left(c \cdot s\right)}^{\left(0.5 \cdot 2\right)}\right)} \cdot \frac{\cos \left(x \cdot 2\right)}{{\left(c \cdot s\right)}^{\left(0.5 \cdot 2\right)}}\\

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

\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 (or (<= x -2.5212314714250252e-247) (not (<= x 8.638771279925528e-239)))
   (*
    (/ 1.0 (* x (* x (pow (* c s) (* 0.5 2.0)))))
    (/ (cos (* x 2.0)) (pow (* c s) (* 0.5 2.0))))
   (/
    (/ (cos (* x 2.0)) x)
    (* (* x (pow (* c s) (* 0.5 2.0))) (pow (* c s) (/ 2.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 (((x <= -2.5212314714250252e-247) || !(x <= 8.638771279925528e-239))) {
		tmp = ((double) ((1.0 / ((double) (x * ((double) (x * ((double) pow(((double) (c * s)), ((double) (0.5 * 2.0))))))))) * (((double) cos(((double) (x * 2.0)))) / ((double) pow(((double) (c * s)), ((double) (0.5 * 2.0)))))));
	} else {
		tmp = ((((double) cos(((double) (x * 2.0)))) / x) / ((double) (((double) (x * ((double) pow(((double) (c * s)), ((double) (0.5 * 2.0)))))) * ((double) pow(((double) (c * s)), (2.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 x < -2.5212314714250252e-247 or 8.6387712799255281e-239 < x

    1. Initial program Error: 27.0 bits

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}\]
    2. SimplifiedError: 27.0 bits

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{x \cdot \left(x \cdot \left({c}^{2} \cdot {s}^{2}\right)\right)}}\]
    3. Using strategy rm
    4. Applied pow-prod-downError: 11.9 bits

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

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

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

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

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(x \cdot \left(x \cdot {\left(c \cdot s\right)}^{\left(0.5 \cdot 2\right)}\right)\right) \cdot {\left(c \cdot s\right)}^{\left(\frac{2}{2}\right)}}}\]
    11. Using strategy rm
    12. Applied *-un-lft-identityError: 5.1 bits

      \[\leadsto \frac{\color{blue}{1 \cdot \cos \left(2 \cdot x\right)}}{\left(x \cdot \left(x \cdot {\left(c \cdot s\right)}^{\left(0.5 \cdot 2\right)}\right)\right) \cdot {\left(c \cdot s\right)}^{\left(\frac{2}{2}\right)}}\]
    13. Applied times-fracError: 5.2 bits

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

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

    if -2.5212314714250252e-247 < x < 8.6387712799255281e-239

    1. Initial program Error: 49.5 bits

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}\]
    2. SimplifiedError: 49.3 bits

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{x \cdot \left(x \cdot \left({c}^{2} \cdot {s}^{2}\right)\right)}}\]
    3. Using strategy rm
    4. Applied pow-prod-downError: 44.6 bits

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.5212314714250252 \cdot 10^{-247} \lor \neg \left(x \leq 8.638771279925528 \cdot 10^{-239}\right):\\ \;\;\;\;\frac{1}{x \cdot \left(x \cdot {\left(c \cdot s\right)}^{\left(0.5 \cdot 2\right)}\right)} \cdot \frac{\cos \left(x \cdot 2\right)}{{\left(c \cdot s\right)}^{\left(0.5 \cdot 2\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\cos \left(x \cdot 2\right)}{x}}{\left(x \cdot {\left(c \cdot s\right)}^{\left(0.5 \cdot 2\right)}\right) \cdot {\left(c \cdot s\right)}^{\left(\frac{2}{2}\right)}}\\ \end{array}\]

Reproduce

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