Average Error: 11.1 → 2.3
Time: 19.5s
Precision: 64
$\frac{1}{{pR}^{2}} \cdot \left(\cos \left(p0 + pR \cdot t\right) - \cos p0\right)$
$\begin{array}{l} \mathbf{if}\;\frac{1}{{pR}^{2}} \cdot \left(\cos \left(p0 + pR \cdot t\right) - \cos p0\right) \le 0.0:\\ \;\;\;\;\frac{1}{{pR}^{2}} \cdot \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)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}$
\frac{1}{{pR}^{2}} \cdot \left(\cos \left(p0 + pR \cdot t\right) - \cos p0\right)
\begin{array}{l}
\mathbf{if}\;\frac{1}{{pR}^{2}} \cdot \left(\cos \left(p0 + pR \cdot t\right) - \cos p0\right) \le 0.0:\\
\;\;\;\;\frac{1}{{pR}^{2}} \cdot \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)\\

\mathbf{else}:\\
\;\;\;\;0\\

\end{array}
double f(double pR, double p0, double t) {
double r3171485 = 1.0;
double r3171486 = pR;
double r3171487 = 2.0;
double r3171488 = pow(r3171486, r3171487);
double r3171489 = r3171485 / r3171488;
double r3171490 = p0;
double r3171491 = t;
double r3171492 = r3171486 * r3171491;
double r3171493 = r3171490 + r3171492;
double r3171494 = cos(r3171493);
double r3171495 = cos(r3171490);
double r3171496 = r3171494 - r3171495;
double r3171497 = r3171489 * r3171496;
return r3171497;
}


double f(double pR, double p0, double t) {
double r3171498 = 1.0;
double r3171499 = pR;
double r3171500 = 2.0;
double r3171501 = pow(r3171499, r3171500);
double r3171502 = r3171498 / r3171501;
double r3171503 = p0;
double r3171504 = t;
double r3171505 = r3171499 * r3171504;
double r3171506 = r3171503 + r3171505;
double r3171507 = cos(r3171506);
double r3171508 = cos(r3171503);
double r3171509 = r3171507 - r3171508;
double r3171510 = r3171502 * r3171509;
double r3171511 = 0.0;
bool r3171512 = r3171510 <= r3171511;
double r3171513 = -2.0;
double r3171514 = r3171506 + r3171503;
double r3171515 = 2.0;
double r3171516 = r3171514 / r3171515;
double r3171517 = sin(r3171516);
double r3171518 = r3171504 * r3171499;
double r3171519 = r3171518 / r3171515;
double r3171520 = sin(r3171519);
double r3171521 = r3171517 * r3171520;
double r3171522 = r3171513 * r3171521;
double r3171523 = r3171502 * r3171522;
double r3171524 = 0.0;
double r3171525 = r3171512 ? r3171523 : r3171524;
return r3171525;
}



# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Split input into 2 regimes
2. ## if (* (/ 1.0f0 (pow pR 2.0f0)) (- (cos (+ p0 (* pR t))) (cos p0))) < 0.0

1. Initial program 3.7

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

$\leadsto \frac{1}{{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. Simplified1.7

$\leadsto \frac{1}{{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{t \cdot pR + 0}{2}\right)\right)}\right)$

## if 0.0 < (* (/ 1.0f0 (pow pR 2.0f0)) (- (cos (+ p0 (* pR t))) (cos p0)))

1. Initial program 21.1

$\frac{1}{{pR}^{2}} \cdot \left(\cos \left(p0 + pR \cdot t\right) - \cos p0\right)$
2. Taylor expanded around 0 3.2

$\leadsto \color{blue}{0}$
3. Recombined 2 regimes into one program.
4. Final simplification2.3

$\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{{pR}^{2}} \cdot \left(\cos \left(p0 + pR \cdot t\right) - \cos p0\right) \le 0.0:\\ \;\;\;\;\frac{1}{{pR}^{2}} \cdot \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)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}$

# Reproduce

herbie shell --seed 1
(FPCore (pR p0 t)
:name "1/pR^2*(cos(p0 + pR*t) - cos(p0))"
:precision binary32
(* (/ 1 (pow pR 2)) (- (cos (+ p0 (* pR t))) (cos p0))))