Average Error: 28.3 → 1.9
Time: 9.9s
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} t_0 := c \cdot \left(s \cdot \sqrt{x}\right)\\ t_1 := \frac{\cos \left(x + x\right)}{x}\\ \mathbf{if}\;x \leq 3.413023980714311 \cdot 10^{-307}:\\ \;\;\;\;\frac{\frac{\frac{t_1}{c}}{s}}{s \cdot \left(x \cdot c\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{t_1}{t_0}}{t_0}\\ \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}
t_0 := c \cdot \left(s \cdot \sqrt{x}\right)\\
t_1 := \frac{\cos \left(x + x\right)}{x}\\
\mathbf{if}\;x \leq 3.413023980714311 \cdot 10^{-307}:\\
\;\;\;\;\frac{\frac{\frac{t_1}{c}}{s}}{s \cdot \left(x \cdot c\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{t_1}{t_0}}{t_0}\\


\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
 (let* ((t_0 (* c (* s (sqrt x)))) (t_1 (/ (cos (+ x x)) x)))
   (if (<= x 3.413023980714311e-307)
     (/ (/ (/ t_1 c) s) (* s (* x c)))
     (/ (/ t_1 t_0) t_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 t_0 = c * (s * sqrt(x));
	double t_1 = cos((x + x)) / x;
	double tmp;
	if (x <= 3.413023980714311e-307) {
		tmp = ((t_1 / c) / s) / (s * (x * c));
	} else {
		tmp = (t_1 / t_0) / t_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 < 3.41302398071431097e-307

    1. Initial program 28.4

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Applied egg-rr26.5

      \[\leadsto \color{blue}{\frac{1}{\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)} \cdot \frac{\cos \left(x + x\right)}{x}} \]
    3. Applied egg-rr18.2

      \[\leadsto \color{blue}{\frac{\frac{\frac{\cos \left(x + x\right)}{x}}{c}}{c \cdot \left(x \cdot \left(s \cdot s\right)\right)}} \]
    4. Applied egg-rr15.3

      \[\leadsto \color{blue}{\frac{1}{c \cdot x} \cdot \frac{\frac{\frac{\cos \left(x + x\right)}{x}}{c}}{s \cdot s}} \]
    5. Applied egg-rr2.9

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

    if 3.41302398071431097e-307 < x

    1. Initial program 28.2

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Applied egg-rr26.8

      \[\leadsto \color{blue}{\frac{1}{\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)} \cdot \frac{\cos \left(x + x\right)}{x}} \]
    3. Applied egg-rr0.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 3.413023980714311 \cdot 10^{-307}:\\ \;\;\;\;\frac{\frac{\frac{\frac{\cos \left(x + x\right)}{x}}{c}}{s}}{s \cdot \left(x \cdot c\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{\cos \left(x + x\right)}{x}}{c \cdot \left(s \cdot \sqrt{x}\right)}}{c \cdot \left(s \cdot \sqrt{x}\right)}\\ \end{array} \]

Reproduce

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