Average Error: 27.4 → 2.8
Time: 7.9s
Precision: 64
\[\frac{\cos \left(2 \cdot x\right)}{{cos}^{2} \cdot \left(\left(x \cdot {sin}^{2}\right) \cdot x\right)}\]
\[\frac{\frac{\mathsf{log1p}\left(\mathsf{expm1}\left(\cos \left(2 \cdot x\right)\right)\right)}{\left|{cos}^{\left(\frac{2}{2}\right)} \cdot \left(x \cdot {sin}^{\left(\frac{2}{2}\right)}\right)\right|}}{\left|{cos}^{\left(\frac{2}{2}\right)} \cdot \left(x \cdot {sin}^{\left(\frac{2}{2}\right)}\right)\right|}\]
\frac{\cos \left(2 \cdot x\right)}{{cos}^{2} \cdot \left(\left(x \cdot {sin}^{2}\right) \cdot x\right)}
\frac{\frac{\mathsf{log1p}\left(\mathsf{expm1}\left(\cos \left(2 \cdot x\right)\right)\right)}{\left|{cos}^{\left(\frac{2}{2}\right)} \cdot \left(x \cdot {sin}^{\left(\frac{2}{2}\right)}\right)\right|}}{\left|{cos}^{\left(\frac{2}{2}\right)} \cdot \left(x \cdot {sin}^{\left(\frac{2}{2}\right)}\right)\right|}
double code(double x, double cos, double sin) {
	return (cos((2.0 * x)) / (pow(cos, 2.0) * ((x * pow(sin, 2.0)) * x)));
}
double code(double x, double cos, double sin) {
	return ((log1p(expm1(cos((2.0 * x)))) / fabs((pow(cos, (2.0 / 2.0)) * (x * pow(sin, (2.0 / 2.0)))))) / fabs((pow(cos, (2.0 / 2.0)) * (x * pow(sin, (2.0 / 2.0))))));
}

Error

Bits error versus x

Bits error versus cos

Bits error versus sin

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 27.4

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

    \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{cos}^{2} \cdot \left(\left(x \cdot \color{blue}{\left({sin}^{\left(\frac{2}{2}\right)} \cdot {sin}^{\left(\frac{2}{2}\right)}\right)}\right) \cdot x\right)}\]
  4. Applied associate-*r*21.3

    \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{cos}^{2} \cdot \left(\color{blue}{\left(\left(x \cdot {sin}^{\left(\frac{2}{2}\right)}\right) \cdot {sin}^{\left(\frac{2}{2}\right)}\right)} \cdot x\right)}\]
  5. Using strategy rm
  6. Applied add-sqr-sqrt21.4

    \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\sqrt{{cos}^{2} \cdot \left(\left(\left(x \cdot {sin}^{\left(\frac{2}{2}\right)}\right) \cdot {sin}^{\left(\frac{2}{2}\right)}\right) \cdot x\right)} \cdot \sqrt{{cos}^{2} \cdot \left(\left(\left(x \cdot {sin}^{\left(\frac{2}{2}\right)}\right) \cdot {sin}^{\left(\frac{2}{2}\right)}\right) \cdot x\right)}}}\]
  7. Simplified21.3

    \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left|{cos}^{\left(\frac{2}{2}\right)} \cdot \left(x \cdot {sin}^{\left(\frac{2}{2}\right)}\right)\right|} \cdot \sqrt{{cos}^{2} \cdot \left(\left(\left(x \cdot {sin}^{\left(\frac{2}{2}\right)}\right) \cdot {sin}^{\left(\frac{2}{2}\right)}\right) \cdot x\right)}}\]
  8. Simplified3.0

    \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left|{cos}^{\left(\frac{2}{2}\right)} \cdot \left(x \cdot {sin}^{\left(\frac{2}{2}\right)}\right)\right| \cdot \color{blue}{\left|{cos}^{\left(\frac{2}{2}\right)} \cdot \left(x \cdot {sin}^{\left(\frac{2}{2}\right)}\right)\right|}}\]
  9. Using strategy rm
  10. Applied associate-/r*2.8

    \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{\left|{cos}^{\left(\frac{2}{2}\right)} \cdot \left(x \cdot {sin}^{\left(\frac{2}{2}\right)}\right)\right|}}{\left|{cos}^{\left(\frac{2}{2}\right)} \cdot \left(x \cdot {sin}^{\left(\frac{2}{2}\right)}\right)\right|}}\]
  11. Using strategy rm
  12. Applied log1p-expm1-u2.8

    \[\leadsto \frac{\frac{\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\cos \left(2 \cdot x\right)\right)\right)}}{\left|{cos}^{\left(\frac{2}{2}\right)} \cdot \left(x \cdot {sin}^{\left(\frac{2}{2}\right)}\right)\right|}}{\left|{cos}^{\left(\frac{2}{2}\right)} \cdot \left(x \cdot {sin}^{\left(\frac{2}{2}\right)}\right)\right|}\]
  13. Final simplification2.8

    \[\leadsto \frac{\frac{\mathsf{log1p}\left(\mathsf{expm1}\left(\cos \left(2 \cdot x\right)\right)\right)}{\left|{cos}^{\left(\frac{2}{2}\right)} \cdot \left(x \cdot {sin}^{\left(\frac{2}{2}\right)}\right)\right|}}{\left|{cos}^{\left(\frac{2}{2}\right)} \cdot \left(x \cdot {sin}^{\left(\frac{2}{2}\right)}\right)\right|}\]

Reproduce

herbie shell --seed 2020106 +o rules:numerics
(FPCore (x cos sin)
  :name "cos(2*x)/(cos^2(x)*sin^2(x))"
  :precision binary64
  (/ (cos (* 2 x)) (* (pow cos 2) (* (* x (pow sin 2)) x))))