Average Error: 4.4 → 2.2
Time: 29.0s
Precision: 64
$9.999999960041972002500187954865396022797 \cdot 10^{-12} \le \left|pR\right| \le 10^{4}$
$\frac{\left(\cos \left(p0 - pR \cdot t\right) - \cos p0\right) \cdot a}{{pR}^{2}}$
$\frac{\left(-2 \cdot \left(\sin \left(\frac{\left(p0 - pR \cdot t\right) + p0}{2}\right) \cdot \sin \left(-\frac{t \cdot pR}{2}\right)\right)\right) \cdot a}{{pR}^{2}}$
\frac{\left(\cos \left(p0 - pR \cdot t\right) - \cos p0\right) \cdot a}{{pR}^{2}}
\frac{\left(-2 \cdot \left(\sin \left(\frac{\left(p0 - pR \cdot t\right) + p0}{2}\right) \cdot \sin \left(-\frac{t \cdot pR}{2}\right)\right)\right) \cdot a}{{pR}^{2}}
double f(double p0, double pR, double t, double a) {
double r507246 = p0;
double r507247 = pR;
double r507248 = t;
double r507249 = r507247 * r507248;
double r507250 = r507246 - r507249;
double r507251 = cos(r507250);
double r507252 = cos(r507246);
double r507253 = r507251 - r507252;
double r507254 = a;
double r507255 = r507253 * r507254;
double r507256 = 2.0;
double r507257 = pow(r507247, r507256);
double r507258 = r507255 / r507257;
return r507258;
}

double f(double p0, double pR, double t, double a) {
double r507259 = -2.0;
double r507260 = p0;
double r507261 = pR;
double r507262 = t;
double r507263 = r507261 * r507262;
double r507264 = r507260 - r507263;
double r507265 = r507264 + r507260;
double r507266 = 2.0;
double r507267 = r507265 / r507266;
double r507268 = sin(r507267);
double r507269 = r507262 * r507261;
double r507270 = r507269 / r507266;
double r507271 = -r507270;
double r507272 = sin(r507271);
double r507273 = r507268 * r507272;
double r507274 = r507259 * r507273;
double r507275 = a;
double r507276 = r507274 * r507275;
double r507277 = 2.0;
double r507278 = pow(r507261, r507277);
double r507279 = r507276 / r507278;
return r507279;
}

# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Initial program 4.4

$\frac{\left(\cos \left(p0 - pR \cdot t\right) - \cos p0\right) \cdot a}{{pR}^{2}}$
2. Using strategy rm
3. Applied diff-cos3.9

$\leadsto \frac{\color{blue}{\left(-2 \cdot \left(\sin \left(\frac{\left(p0 - pR \cdot t\right) - p0}{2}\right) \cdot \sin \left(\frac{\left(p0 - pR \cdot t\right) + p0}{2}\right)\right)\right)} \cdot a}{{pR}^{2}}$
4. Simplified2.2

$\leadsto \frac{\left(-2 \cdot \color{blue}{\left(\sin \left(\frac{\left(p0 - pR \cdot t\right) + p0}{2}\right) \cdot \sin \left(-\frac{t \cdot pR}{2}\right)\right)}\right) \cdot a}{{pR}^{2}}$
5. Final simplification2.2

$\leadsto \frac{\left(-2 \cdot \left(\sin \left(\frac{\left(p0 - pR \cdot t\right) + p0}{2}\right) \cdot \sin \left(-\frac{t \cdot pR}{2}\right)\right)\right) \cdot a}{{pR}^{2}}$

# Reproduce

herbie shell --seed 1
(FPCore (p0 pR t a)
:name "(cos(p0 - pR*t) - cos(p0)) * a / pR^2"
:precision binary32
:pre (<= 9.99999996e-12 (fabs pR) 1e4)
(/ (* (- (cos (- p0 (* pR t))) (cos p0)) a) (pow pR 2)))