Average Error: 55.1 → 25.8
Time: 22.5s
Precision: 64
$\cos x - \cos \left(x + \frac{1}{x}\right)$
$-2 \cdot \left(\sqrt[3]{{\left(\sin \left(\frac{x + \left(x + \frac{1}{x}\right)}{2}\right)\right)}^{3}} \cdot \sin \left(-\frac{\frac{1}{x}}{2}\right)\right)$
\cos x - \cos \left(x + \frac{1}{x}\right)
-2 \cdot \left(\sqrt[3]{{\left(\sin \left(\frac{x + \left(x + \frac{1}{x}\right)}{2}\right)\right)}^{3}} \cdot \sin \left(-\frac{\frac{1}{x}}{2}\right)\right)
double f(double x) {
double r1716749 = x;
double r1716750 = cos(r1716749);
double r1716751 = 1.0;
double r1716752 = r1716751 / r1716749;
double r1716753 = r1716749 + r1716752;
double r1716754 = cos(r1716753);
double r1716755 = r1716750 - r1716754;
return r1716755;
}


double f(double x) {
double r1716756 = -2.0;
double r1716757 = x;
double r1716758 = 1.0;
double r1716759 = r1716758 / r1716757;
double r1716760 = r1716757 + r1716759;
double r1716761 = r1716757 + r1716760;
double r1716762 = 2.0;
double r1716763 = r1716761 / r1716762;
double r1716764 = sin(r1716763);
double r1716765 = 3.0;
double r1716766 = pow(r1716764, r1716765);
double r1716767 = cbrt(r1716766);
double r1716768 = r1716759 / r1716762;
double r1716769 = -r1716768;
double r1716770 = sin(r1716769);
double r1716771 = r1716767 * r1716770;
double r1716772 = r1716756 * r1716771;
return r1716772;
}



# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Initial program 55.1

$\cos x - \cos \left(x + \frac{1}{x}\right)$
2. Using strategy rm
3. Applied diff-cos55.1

$\leadsto \color{blue}{-2 \cdot \left(\sin \left(\frac{x - \left(x + \frac{1}{x}\right)}{2}\right) \cdot \sin \left(\frac{x + \left(x + \frac{1}{x}\right)}{2}\right)\right)}$
4. Simplified25.6

$\leadsto -2 \cdot \color{blue}{\left(\sin \left(\frac{x + \left(x + \frac{1}{x}\right)}{2}\right) \cdot \sin \left(-\frac{\frac{1}{x}}{2}\right)\right)}$
5. Using strategy rm

$\leadsto -2 \cdot \left(\color{blue}{\sqrt[3]{\left(\sin \left(\frac{x + \left(x + \frac{1}{x}\right)}{2}\right) \cdot \sin \left(\frac{x + \left(x + \frac{1}{x}\right)}{2}\right)\right) \cdot \sin \left(\frac{x + \left(x + \frac{1}{x}\right)}{2}\right)}} \cdot \sin \left(-\frac{\frac{1}{x}}{2}\right)\right)$
7. Simplified25.8

$\leadsto -2 \cdot \left(\sqrt[3]{\color{blue}{{\left(\sin \left(\frac{x + \left(x + \frac{1}{x}\right)}{2}\right)\right)}^{3}}} \cdot \sin \left(-\frac{\frac{1}{x}}{2}\right)\right)$
8. Final simplification25.8

$\leadsto -2 \cdot \left(\sqrt[3]{{\left(\sin \left(\frac{x + \left(x + \frac{1}{x}\right)}{2}\right)\right)}^{3}} \cdot \sin \left(-\frac{\frac{1}{x}}{2}\right)\right)$

# Reproduce

herbie shell --seed 1
(FPCore (x)
:name "cos(x)-cos(x+1/x)"
:precision binary64
(- (cos x) (cos (+ x (/ 1 x)))))