Average Error: 28.0 → 8.1
Time: 13.3s
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 := \cos \left(x + x\right)\\ \mathbf{if}\;x \leq 2.549378178247403 \cdot 10^{-309}:\\ \;\;\;\;\frac{\frac{\frac{1}{x} \cdot t_1}{c}}{{s}^{2} \cdot \left(x \cdot c\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{t_1}{x}}{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 := \cos \left(x + x\right)\\
\mathbf{if}\;x \leq 2.549378178247403 \cdot 10^{-309}:\\
\;\;\;\;\frac{\frac{\frac{1}{x} \cdot t_1}{c}}{{s}^{2} \cdot \left(x \cdot c\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{t_1}{x}}{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))))
   (if (<= x 2.549378178247403e-309)
     (/ (/ (* (/ 1.0 x) t_1) c) (* (pow s 2.0) (* x c)))
     (/ (/ (/ t_1 x) 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));
	double tmp;
	if (x <= 2.549378178247403e-309) {
		tmp = (((1.0 / x) * t_1) / c) / (pow(s, 2.0) * (x * c));
	} else {
		tmp = ((t_1 / x) / 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 < 2.5493781782474033e-309

    1. Initial program 27.4

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

      \[\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.3

      \[\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. Taylor expanded in c around 0 15.2

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

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

    if 2.5493781782474033e-309 < x

    1. Initial program 28.5

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

      \[\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.8

      \[\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 simplification8.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 2.549378178247403 \cdot 10^{-309}:\\ \;\;\;\;\frac{\frac{\frac{1}{x} \cdot \cos \left(x + x\right)}{c}}{{s}^{2} \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 2022130 
(FPCore (x c s)
  :name "mixedcos"
  :precision binary64
  (/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))