Average Error: 46.1 → 31.5
Time: 26.5s
Precision: 64
$\frac{{d}^{2} \cdot \left(theta - \sin theta\right)}{8 \cdot {\left(\sin \left(\frac{theta}{2}\right)\right)}^{2}}$
$\begin{array}{l} \mathbf{if}\;theta \le -0.06401716498651408016051789218181511387229:\\ \;\;\;\;\frac{{d}^{\left(\frac{2}{2}\right)} \cdot \left({d}^{\left(\frac{2}{2}\right)} \cdot \left(theta - \sin theta\right)\right)}{8 \cdot {\left(\sin \left(\frac{theta}{2}\right)\right)}^{2}}\\ \mathbf{elif}\;theta \le -1.194281810571421370783203556651507517227 \cdot 10^{-101}:\\ \;\;\;\;\frac{{d}^{2} \cdot \left(\left(\frac{1}{6} \cdot {theta}^{3} + \frac{1}{5040} \cdot {theta}^{7}\right) - \frac{1}{120} \cdot {theta}^{5}\right)}{8 \cdot {\left(\sin \left(\frac{theta}{2}\right)\right)}^{2}}\\ \mathbf{elif}\;theta \le 3.938076268831811983072802096426332320851 \cdot 10^{-115}:\\ \;\;\;\;0\\ \mathbf{elif}\;theta \le 0.04393657237915812169282148147431144025177:\\ \;\;\;\;\frac{{d}^{2} \cdot \left(\left(\frac{1}{6} \cdot {theta}^{3} + \frac{1}{5040} \cdot {theta}^{7}\right) - \frac{1}{120} \cdot {theta}^{5}\right)}{8 \cdot {\left(\sin \left(\frac{theta}{2}\right)\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{{d}^{\left(\frac{2}{2}\right)} \cdot \left({d}^{\left(\frac{2}{2}\right)} \cdot \left(theta - \sin theta\right)\right)}{8 \cdot {\left(\sin \left(\frac{theta}{2}\right)\right)}^{2}}\\ \end{array}$
\frac{{d}^{2} \cdot \left(theta - \sin theta\right)}{8 \cdot {\left(\sin \left(\frac{theta}{2}\right)\right)}^{2}}
\begin{array}{l}
\mathbf{if}\;theta \le -0.06401716498651408016051789218181511387229:\\
\;\;\;\;\frac{{d}^{\left(\frac{2}{2}\right)} \cdot \left({d}^{\left(\frac{2}{2}\right)} \cdot \left(theta - \sin theta\right)\right)}{8 \cdot {\left(\sin \left(\frac{theta}{2}\right)\right)}^{2}}\\

\mathbf{elif}\;theta \le -1.194281810571421370783203556651507517227 \cdot 10^{-101}:\\
\;\;\;\;\frac{{d}^{2} \cdot \left(\left(\frac{1}{6} \cdot {theta}^{3} + \frac{1}{5040} \cdot {theta}^{7}\right) - \frac{1}{120} \cdot {theta}^{5}\right)}{8 \cdot {\left(\sin \left(\frac{theta}{2}\right)\right)}^{2}}\\

\mathbf{elif}\;theta \le 3.938076268831811983072802096426332320851 \cdot 10^{-115}:\\
\;\;\;\;0\\

\mathbf{elif}\;theta \le 0.04393657237915812169282148147431144025177:\\
\;\;\;\;\frac{{d}^{2} \cdot \left(\left(\frac{1}{6} \cdot {theta}^{3} + \frac{1}{5040} \cdot {theta}^{7}\right) - \frac{1}{120} \cdot {theta}^{5}\right)}{8 \cdot {\left(\sin \left(\frac{theta}{2}\right)\right)}^{2}}\\

\mathbf{else}:\\
\;\;\;\;\frac{{d}^{\left(\frac{2}{2}\right)} \cdot \left({d}^{\left(\frac{2}{2}\right)} \cdot \left(theta - \sin theta\right)\right)}{8 \cdot {\left(\sin \left(\frac{theta}{2}\right)\right)}^{2}}\\

\end{array}
double f(double d, double theta) {
double r2528273 = d;
double r2528274 = 2.0;
double r2528275 = pow(r2528273, r2528274);
double r2528276 = theta;
double r2528277 = sin(r2528276);
double r2528278 = r2528276 - r2528277;
double r2528279 = r2528275 * r2528278;
double r2528280 = 8.0;
double r2528281 = r2528276 / r2528274;
double r2528282 = sin(r2528281);
double r2528283 = pow(r2528282, r2528274);
double r2528284 = r2528280 * r2528283;
double r2528285 = r2528279 / r2528284;
return r2528285;
}


double f(double d, double theta) {
double r2528286 = theta;
double r2528287 = -0.06401716498651408;
bool r2528288 = r2528286 <= r2528287;
double r2528289 = d;
double r2528290 = 2.0;
double r2528291 = 2.0;
double r2528292 = r2528290 / r2528291;
double r2528293 = pow(r2528289, r2528292);
double r2528294 = sin(r2528286);
double r2528295 = r2528286 - r2528294;
double r2528296 = r2528293 * r2528295;
double r2528297 = r2528293 * r2528296;
double r2528298 = 8.0;
double r2528299 = r2528286 / r2528290;
double r2528300 = sin(r2528299);
double r2528301 = pow(r2528300, r2528290);
double r2528302 = r2528298 * r2528301;
double r2528303 = r2528297 / r2528302;
double r2528304 = -1.1942818105714214e-101;
bool r2528305 = r2528286 <= r2528304;
double r2528306 = pow(r2528289, r2528290);
double r2528307 = 0.16666666666666666;
double r2528308 = 3.0;
double r2528309 = pow(r2528286, r2528308);
double r2528310 = r2528307 * r2528309;
double r2528311 = 0.0001984126984126984;
double r2528312 = 7.0;
double r2528313 = pow(r2528286, r2528312);
double r2528314 = r2528311 * r2528313;
double r2528315 = r2528310 + r2528314;
double r2528316 = 0.008333333333333333;
double r2528317 = 5.0;
double r2528318 = pow(r2528286, r2528317);
double r2528319 = r2528316 * r2528318;
double r2528320 = r2528315 - r2528319;
double r2528321 = r2528306 * r2528320;
double r2528322 = r2528321 / r2528302;
double r2528323 = 3.938076268831812e-115;
bool r2528324 = r2528286 <= r2528323;
double r2528325 = 0.0;
double r2528326 = 0.04393657237915812;
bool r2528327 = r2528286 <= r2528326;
double r2528328 = r2528327 ? r2528322 : r2528303;
double r2528329 = r2528324 ? r2528325 : r2528328;
double r2528330 = r2528305 ? r2528322 : r2528329;
double r2528331 = r2528288 ? r2528303 : r2528330;
return r2528331;
}



# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Split input into 3 regimes
2. ## if theta < -0.06401716498651408 or 0.04393657237915812 < theta

1. Initial program 39.3

$\frac{{d}^{2} \cdot \left(theta - \sin theta\right)}{8 \cdot {\left(\sin \left(\frac{theta}{2}\right)\right)}^{2}}$
2. Using strategy rm
3. Applied sqr-pow39.3

$\leadsto \frac{\color{blue}{\left({d}^{\left(\frac{2}{2}\right)} \cdot {d}^{\left(\frac{2}{2}\right)}\right)} \cdot \left(theta - \sin theta\right)}{8 \cdot {\left(\sin \left(\frac{theta}{2}\right)\right)}^{2}}$
4. Applied associate-*l*37.8

$\leadsto \frac{\color{blue}{{d}^{\left(\frac{2}{2}\right)} \cdot \left({d}^{\left(\frac{2}{2}\right)} \cdot \left(theta - \sin theta\right)\right)}}{8 \cdot {\left(\sin \left(\frac{theta}{2}\right)\right)}^{2}}$

## if -0.06401716498651408 < theta < -1.1942818105714214e-101 or 3.938076268831812e-115 < theta < 0.04393657237915812

1. Initial program 38.4

$\frac{{d}^{2} \cdot \left(theta - \sin theta\right)}{8 \cdot {\left(\sin \left(\frac{theta}{2}\right)\right)}^{2}}$
2. Taylor expanded around 0 10.8

$\leadsto \frac{{d}^{2} \cdot \color{blue}{\left(\left(\frac{1}{6} \cdot {theta}^{3} + \frac{1}{5040} \cdot {theta}^{7}\right) - \frac{1}{120} \cdot {theta}^{5}\right)}}{8 \cdot {\left(\sin \left(\frac{theta}{2}\right)\right)}^{2}}$

## if -1.1942818105714214e-101 < theta < 3.938076268831812e-115

1. Initial program 56.6

$\frac{{d}^{2} \cdot \left(theta - \sin theta\right)}{8 \cdot {\left(\sin \left(\frac{theta}{2}\right)\right)}^{2}}$
2. Taylor expanded around 0 34.4

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

$\leadsto \begin{array}{l} \mathbf{if}\;theta \le -0.06401716498651408016051789218181511387229:\\ \;\;\;\;\frac{{d}^{\left(\frac{2}{2}\right)} \cdot \left({d}^{\left(\frac{2}{2}\right)} \cdot \left(theta - \sin theta\right)\right)}{8 \cdot {\left(\sin \left(\frac{theta}{2}\right)\right)}^{2}}\\ \mathbf{elif}\;theta \le -1.194281810571421370783203556651507517227 \cdot 10^{-101}:\\ \;\;\;\;\frac{{d}^{2} \cdot \left(\left(\frac{1}{6} \cdot {theta}^{3} + \frac{1}{5040} \cdot {theta}^{7}\right) - \frac{1}{120} \cdot {theta}^{5}\right)}{8 \cdot {\left(\sin \left(\frac{theta}{2}\right)\right)}^{2}}\\ \mathbf{elif}\;theta \le 3.938076268831811983072802096426332320851 \cdot 10^{-115}:\\ \;\;\;\;0\\ \mathbf{elif}\;theta \le 0.04393657237915812169282148147431144025177:\\ \;\;\;\;\frac{{d}^{2} \cdot \left(\left(\frac{1}{6} \cdot {theta}^{3} + \frac{1}{5040} \cdot {theta}^{7}\right) - \frac{1}{120} \cdot {theta}^{5}\right)}{8 \cdot {\left(\sin \left(\frac{theta}{2}\right)\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{{d}^{\left(\frac{2}{2}\right)} \cdot \left({d}^{\left(\frac{2}{2}\right)} \cdot \left(theta - \sin theta\right)\right)}{8 \cdot {\left(\sin \left(\frac{theta}{2}\right)\right)}^{2}}\\ \end{array}$

# Reproduce

herbie shell --seed 1
(FPCore (d theta)
:name "pow(d,2) * (theta - sin(theta)) / (8 * pow(sin(theta/2),2))"
:precision binary64
(/ (* (pow d 2) (- theta (sin theta))) (* 8 (pow (sin (/ theta 2)) 2))))