Average Error: 4.5 → 2.6
Time: 19.5s
Precision: 64
$1.000000013351431960018089739605784416199 \cdot 10^{-10} \le \left|pR\right| \le 10^{4}$
$\frac{a}{{pR}^{2}} \cdot \left(\cos \left(p0 + pR \cdot t\right) - \cos p0\right)$
$\frac{a}{{pR}^{2}} \cdot \left(-2 \cdot \left(\sin \left(\frac{\left(p0 + pR \cdot t\right) + p0}{2}\right) \cdot \sin \left(\frac{pR \cdot t}{2}\right)\right)\right)$
\frac{a}{{pR}^{2}} \cdot \left(\cos \left(p0 + pR \cdot t\right) - \cos p0\right)
\frac{a}{{pR}^{2}} \cdot \left(-2 \cdot \left(\sin \left(\frac{\left(p0 + pR \cdot t\right) + p0}{2}\right) \cdot \sin \left(\frac{pR \cdot t}{2}\right)\right)\right)
double f(double a, double pR, double p0, double t) {
double r3152372 = a;
double r3152373 = pR;
double r3152374 = 2.0;
double r3152375 = pow(r3152373, r3152374);
double r3152376 = r3152372 / r3152375;
double r3152377 = p0;
double r3152378 = t;
double r3152379 = r3152373 * r3152378;
double r3152380 = r3152377 + r3152379;
double r3152381 = cos(r3152380);
double r3152382 = cos(r3152377);
double r3152383 = r3152381 - r3152382;
double r3152384 = r3152376 * r3152383;
return r3152384;
}


double f(double a, double pR, double p0, double t) {
double r3152385 = a;
double r3152386 = pR;
double r3152387 = 2.0;
double r3152388 = pow(r3152386, r3152387);
double r3152389 = r3152385 / r3152388;
double r3152390 = -2.0;
double r3152391 = p0;
double r3152392 = t;
double r3152393 = r3152386 * r3152392;
double r3152394 = r3152391 + r3152393;
double r3152395 = r3152394 + r3152391;
double r3152396 = 2.0;
double r3152397 = r3152395 / r3152396;
double r3152398 = sin(r3152397);
double r3152399 = r3152393 / r3152396;
double r3152400 = sin(r3152399);
double r3152401 = r3152398 * r3152400;
double r3152402 = r3152390 * r3152401;
double r3152403 = r3152389 * r3152402;
return r3152403;
}



# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Initial program 4.5

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

$\leadsto \frac{a}{{pR}^{2}} \cdot \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)}$
4. Simplified2.6

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

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

# Reproduce

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