Average Error: 4.6 → 2.5
Time: 21.3s
Precision: 64
$9.999999960041972002500187954865396022797 \cdot 10^{-12} \le \left|pR\right| \le 10^{4}$
$\frac{a}{{pR}^{2}} \cdot \left(\cos \left(p0 - pR \cdot t\right) - \cos p0\right)$
$\frac{\left(\sin \left(\frac{\left(p0 - pR \cdot t\right) + p0}{2}\right) \cdot \sin \left(\frac{-pR \cdot t}{2}\right)\right) \cdot \left(a \cdot -2\right)}{{pR}^{2}}$
\frac{a}{{pR}^{2}} \cdot \left(\cos \left(p0 - pR \cdot t\right) - \cos p0\right)
\frac{\left(\sin \left(\frac{\left(p0 - pR \cdot t\right) + p0}{2}\right) \cdot \sin \left(\frac{-pR \cdot t}{2}\right)\right) \cdot \left(a \cdot -2\right)}{{pR}^{2}}
double f(double a, double pR, double p0, double t) {
double r516305 = a;
double r516306 = pR;
double r516307 = 2.0;
double r516308 = pow(r516306, r516307);
double r516309 = r516305 / r516308;
double r516310 = p0;
double r516311 = t;
double r516312 = r516306 * r516311;
double r516313 = r516310 - r516312;
double r516314 = cos(r516313);
double r516315 = cos(r516310);
double r516316 = r516314 - r516315;
double r516317 = r516309 * r516316;
return r516317;
}


double f(double a, double pR, double p0, double t) {
double r516318 = p0;
double r516319 = pR;
double r516320 = t;
double r516321 = r516319 * r516320;
double r516322 = r516318 - r516321;
double r516323 = r516322 + r516318;
double r516324 = 2.0;
double r516325 = r516323 / r516324;
double r516326 = sin(r516325);
double r516327 = -r516321;
double r516328 = r516327 / r516324;
double r516329 = sin(r516328);
double r516330 = r516326 * r516329;
double r516331 = a;
double r516332 = -2.0;
double r516333 = r516331 * r516332;
double r516334 = r516330 * r516333;
double r516335 = 2.0;
double r516336 = pow(r516319, r516335);
double r516337 = r516334 / r516336;
return r516337;
}



# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Initial program 4.6

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

$\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. Using strategy rm
5. Applied associate-*l/4.2

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

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

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

# Reproduce

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