Average Error: 1.4 → 0.6
Time: 13.4s
Precision: 64
$\sqrt{1 + \cos x} - \sqrt{1 - \sin x}$
$\log \left(e^{\frac{\left(\cos x + 1\right) - \left(1 - \sin x\right)}{\sqrt{1 + \cos x} + \sqrt{1 - \sin x}}}\right)$
\sqrt{1 + \cos x} - \sqrt{1 - \sin x}
\log \left(e^{\frac{\left(\cos x + 1\right) - \left(1 - \sin x\right)}{\sqrt{1 + \cos x} + \sqrt{1 - \sin x}}}\right)
double f(double x) {
double r1054880 = 1.0;
double r1054881 = x;
double r1054882 = cos(r1054881);
double r1054883 = r1054880 + r1054882;
double r1054884 = sqrt(r1054883);
double r1054885 = sin(r1054881);
double r1054886 = r1054880 - r1054885;
double r1054887 = sqrt(r1054886);
double r1054888 = r1054884 - r1054887;
return r1054888;
}


double f(double x) {
double r1054889 = x;
double r1054890 = cos(r1054889);
double r1054891 = 1.0;
double r1054892 = r1054890 + r1054891;
double r1054893 = sin(r1054889);
double r1054894 = r1054891 - r1054893;
double r1054895 = r1054892 - r1054894;
double r1054896 = r1054891 + r1054890;
double r1054897 = sqrt(r1054896);
double r1054898 = sqrt(r1054894);
double r1054899 = r1054897 + r1054898;
double r1054900 = r1054895 / r1054899;
double r1054901 = exp(r1054900);
double r1054902 = log(r1054901);
return r1054902;
}



# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Initial program 1.4

$\sqrt{1 + \cos x} - \sqrt{1 - \sin x}$
2. Using strategy rm
3. Applied flip--1.8

$\leadsto \color{blue}{\frac{\sqrt{1 + \cos x} \cdot \sqrt{1 + \cos x} - \sqrt{1 - \sin x} \cdot \sqrt{1 - \sin x}}{\sqrt{1 + \cos x} + \sqrt{1 - \sin x}}}$
4. Simplified1.0

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

$\leadsto \color{blue}{\log \left(e^{\frac{\left(\cos x + 1\right) - \left(1 - \sin x\right)}{\sqrt{1 + \cos x} + \sqrt{1 - \sin x}}}\right)}$
7. Final simplification0.6

$\leadsto \log \left(e^{\frac{\left(\cos x + 1\right) - \left(1 - \sin x\right)}{\sqrt{1 + \cos x} + \sqrt{1 - \sin x}}}\right)$

# Reproduce

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