Beckmann Sample, normalization factor

Percentage Accurate: 97.8% → 98.5%
Time: 12.7s
Alternatives: 12
Speedup: 2.5×

Specification

?
\[\left(0 < cosTheta \land cosTheta < 0.9999\right) \land \left(-1 < c \land c < 1\right)\]
\[\begin{array}{l} \\ \frac{1}{\left(1 + c\right) + \left(\frac{1}{\sqrt{\pi}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\left(-cosTheta\right) \cdot cosTheta}} \end{array} \]
(FPCore (cosTheta c)
 :precision binary32
 (/
  1.0
  (+
   (+ 1.0 c)
   (*
    (* (/ 1.0 (sqrt PI)) (/ (sqrt (- (- 1.0 cosTheta) cosTheta)) cosTheta))
    (exp (* (- cosTheta) cosTheta))))))
float code(float cosTheta, float c) {
	return 1.0f / ((1.0f + c) + (((1.0f / sqrtf(((float) M_PI))) * (sqrtf(((1.0f - cosTheta) - cosTheta)) / cosTheta)) * expf((-cosTheta * cosTheta))));
}
function code(cosTheta, c)
	return Float32(Float32(1.0) / Float32(Float32(Float32(1.0) + c) + Float32(Float32(Float32(Float32(1.0) / sqrt(Float32(pi))) * Float32(sqrt(Float32(Float32(Float32(1.0) - cosTheta) - cosTheta)) / cosTheta)) * exp(Float32(Float32(-cosTheta) * cosTheta)))))
end
function tmp = code(cosTheta, c)
	tmp = single(1.0) / ((single(1.0) + c) + (((single(1.0) / sqrt(single(pi))) * (sqrt(((single(1.0) - cosTheta) - cosTheta)) / cosTheta)) * exp((-cosTheta * cosTheta))));
end
\begin{array}{l}

\\
\frac{1}{\left(1 + c\right) + \left(\frac{1}{\sqrt{\pi}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\left(-cosTheta\right) \cdot cosTheta}}
\end{array}

Sampling outcomes in binary32 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 12 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 97.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{1}{\left(1 + c\right) + \left(\frac{1}{\sqrt{\pi}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\left(-cosTheta\right) \cdot cosTheta}} \end{array} \]
(FPCore (cosTheta c)
 :precision binary32
 (/
  1.0
  (+
   (+ 1.0 c)
   (*
    (* (/ 1.0 (sqrt PI)) (/ (sqrt (- (- 1.0 cosTheta) cosTheta)) cosTheta))
    (exp (* (- cosTheta) cosTheta))))))
float code(float cosTheta, float c) {
	return 1.0f / ((1.0f + c) + (((1.0f / sqrtf(((float) M_PI))) * (sqrtf(((1.0f - cosTheta) - cosTheta)) / cosTheta)) * expf((-cosTheta * cosTheta))));
}
function code(cosTheta, c)
	return Float32(Float32(1.0) / Float32(Float32(Float32(1.0) + c) + Float32(Float32(Float32(Float32(1.0) / sqrt(Float32(pi))) * Float32(sqrt(Float32(Float32(Float32(1.0) - cosTheta) - cosTheta)) / cosTheta)) * exp(Float32(Float32(-cosTheta) * cosTheta)))))
end
function tmp = code(cosTheta, c)
	tmp = single(1.0) / ((single(1.0) + c) + (((single(1.0) / sqrt(single(pi))) * (sqrt(((single(1.0) - cosTheta) - cosTheta)) / cosTheta)) * exp((-cosTheta * cosTheta))));
end
\begin{array}{l}

\\
\frac{1}{\left(1 + c\right) + \left(\frac{1}{\sqrt{\pi}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\left(-cosTheta\right) \cdot cosTheta}}
\end{array}

Alternative 1: 98.5% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \frac{1}{\left(1 + c\right) + \frac{e^{cosTheta \cdot \left(-cosTheta\right)}}{cosTheta \cdot \sqrt{\frac{\pi}{\left(1 - cosTheta\right) - cosTheta}}}} \end{array} \]
(FPCore (cosTheta c)
 :precision binary32
 (/
  1.0
  (+
   (+ 1.0 c)
   (/
    (exp (* cosTheta (- cosTheta)))
    (* cosTheta (sqrt (/ PI (- (- 1.0 cosTheta) cosTheta))))))))
float code(float cosTheta, float c) {
	return 1.0f / ((1.0f + c) + (expf((cosTheta * -cosTheta)) / (cosTheta * sqrtf((((float) M_PI) / ((1.0f - cosTheta) - cosTheta))))));
}
function code(cosTheta, c)
	return Float32(Float32(1.0) / Float32(Float32(Float32(1.0) + c) + Float32(exp(Float32(cosTheta * Float32(-cosTheta))) / Float32(cosTheta * sqrt(Float32(Float32(pi) / Float32(Float32(Float32(1.0) - cosTheta) - cosTheta)))))))
end
function tmp = code(cosTheta, c)
	tmp = single(1.0) / ((single(1.0) + c) + (exp((cosTheta * -cosTheta)) / (cosTheta * sqrt((single(pi) / ((single(1.0) - cosTheta) - cosTheta))))));
end
\begin{array}{l}

\\
\frac{1}{\left(1 + c\right) + \frac{e^{cosTheta \cdot \left(-cosTheta\right)}}{cosTheta \cdot \sqrt{\frac{\pi}{\left(1 - cosTheta\right) - cosTheta}}}}
\end{array}
Derivation
  1. Initial program 97.6%

    \[\frac{1}{\left(1 + c\right) + \left(\frac{1}{\sqrt{\pi}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\left(-cosTheta\right) \cdot cosTheta}} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. frac-timesN/A

      \[\leadsto \frac{1}{\left(1 + c\right) + \color{blue}{\frac{1 \cdot \sqrt{\left(1 - cosTheta\right) - cosTheta}}{\sqrt{\mathsf{PI}\left(\right)} \cdot cosTheta}} \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}} \]
    2. *-lft-identityN/A

      \[\leadsto \frac{1}{\left(1 + c\right) + \frac{\color{blue}{\sqrt{\left(1 - cosTheta\right) - cosTheta}}}{\sqrt{\mathsf{PI}\left(\right)} \cdot cosTheta} \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}} \]
    3. /-lowering-/.f32N/A

      \[\leadsto \frac{1}{\left(1 + c\right) + \color{blue}{\frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{\sqrt{\mathsf{PI}\left(\right)} \cdot cosTheta}} \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}} \]
    4. sqrt-lowering-sqrt.f32N/A

      \[\leadsto \frac{1}{\left(1 + c\right) + \frac{\color{blue}{\sqrt{\left(1 - cosTheta\right) - cosTheta}}}{\sqrt{\mathsf{PI}\left(\right)} \cdot cosTheta} \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}} \]
    5. --lowering--.f32N/A

      \[\leadsto \frac{1}{\left(1 + c\right) + \frac{\sqrt{\color{blue}{\left(1 - cosTheta\right) - cosTheta}}}{\sqrt{\mathsf{PI}\left(\right)} \cdot cosTheta} \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}} \]
    6. --lowering--.f32N/A

      \[\leadsto \frac{1}{\left(1 + c\right) + \frac{\sqrt{\color{blue}{\left(1 - cosTheta\right)} - cosTheta}}{\sqrt{\mathsf{PI}\left(\right)} \cdot cosTheta} \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}} \]
    7. *-lowering-*.f32N/A

      \[\leadsto \frac{1}{\left(1 + c\right) + \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{\color{blue}{\sqrt{\mathsf{PI}\left(\right)} \cdot cosTheta}} \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}} \]
    8. sqrt-lowering-sqrt.f32N/A

      \[\leadsto \frac{1}{\left(1 + c\right) + \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{\color{blue}{\sqrt{\mathsf{PI}\left(\right)}} \cdot cosTheta} \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}} \]
    9. PI-lowering-PI.f3298.7

      \[\leadsto \frac{1}{\left(1 + c\right) + \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{\sqrt{\color{blue}{\pi}} \cdot cosTheta} \cdot e^{\left(-cosTheta\right) \cdot cosTheta}} \]
  4. Applied egg-rr98.7%

    \[\leadsto \frac{1}{\left(1 + c\right) + \color{blue}{\frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{\sqrt{\pi} \cdot cosTheta}} \cdot e^{\left(-cosTheta\right) \cdot cosTheta}} \]
  5. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \frac{1}{\left(1 + c\right) + \color{blue}{e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{\sqrt{\mathsf{PI}\left(\right)} \cdot cosTheta}}} \]
    2. *-commutativeN/A

      \[\leadsto \frac{1}{\left(1 + c\right) + e^{\color{blue}{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{\sqrt{\mathsf{PI}\left(\right)} \cdot cosTheta}} \]
    3. clear-numN/A

      \[\leadsto \frac{1}{\left(1 + c\right) + e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \color{blue}{\frac{1}{\frac{\sqrt{\mathsf{PI}\left(\right)} \cdot cosTheta}{\sqrt{\left(1 - cosTheta\right) - cosTheta}}}}} \]
    4. un-div-invN/A

      \[\leadsto \frac{1}{\left(1 + c\right) + \color{blue}{\frac{e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)}}{\frac{\sqrt{\mathsf{PI}\left(\right)} \cdot cosTheta}{\sqrt{\left(1 - cosTheta\right) - cosTheta}}}}} \]
    5. /-lowering-/.f32N/A

      \[\leadsto \frac{1}{\left(1 + c\right) + \color{blue}{\frac{e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)}}{\frac{\sqrt{\mathsf{PI}\left(\right)} \cdot cosTheta}{\sqrt{\left(1 - cosTheta\right) - cosTheta}}}}} \]
    6. exp-lowering-exp.f32N/A

      \[\leadsto \frac{1}{\left(1 + c\right) + \frac{\color{blue}{e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)}}}{\frac{\sqrt{\mathsf{PI}\left(\right)} \cdot cosTheta}{\sqrt{\left(1 - cosTheta\right) - cosTheta}}}} \]
    7. *-lowering-*.f32N/A

      \[\leadsto \frac{1}{\left(1 + c\right) + \frac{e^{\color{blue}{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)}}}{\frac{\sqrt{\mathsf{PI}\left(\right)} \cdot cosTheta}{\sqrt{\left(1 - cosTheta\right) - cosTheta}}}} \]
    8. neg-lowering-neg.f32N/A

      \[\leadsto \frac{1}{\left(1 + c\right) + \frac{e^{cosTheta \cdot \color{blue}{\left(\mathsf{neg}\left(cosTheta\right)\right)}}}{\frac{\sqrt{\mathsf{PI}\left(\right)} \cdot cosTheta}{\sqrt{\left(1 - cosTheta\right) - cosTheta}}}} \]
    9. *-commutativeN/A

      \[\leadsto \frac{1}{\left(1 + c\right) + \frac{e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)}}{\frac{\color{blue}{cosTheta \cdot \sqrt{\mathsf{PI}\left(\right)}}}{\sqrt{\left(1 - cosTheta\right) - cosTheta}}}} \]
    10. associate-/l*N/A

      \[\leadsto \frac{1}{\left(1 + c\right) + \frac{e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)}}{\color{blue}{cosTheta \cdot \frac{\sqrt{\mathsf{PI}\left(\right)}}{\sqrt{\left(1 - cosTheta\right) - cosTheta}}}}} \]
    11. sqrt-divN/A

      \[\leadsto \frac{1}{\left(1 + c\right) + \frac{e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)}}{cosTheta \cdot \color{blue}{\sqrt{\frac{\mathsf{PI}\left(\right)}{\left(1 - cosTheta\right) - cosTheta}}}}} \]
    12. *-lowering-*.f32N/A

      \[\leadsto \frac{1}{\left(1 + c\right) + \frac{e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)}}{\color{blue}{cosTheta \cdot \sqrt{\frac{\mathsf{PI}\left(\right)}{\left(1 - cosTheta\right) - cosTheta}}}}} \]
    13. sqrt-lowering-sqrt.f32N/A

      \[\leadsto \frac{1}{\left(1 + c\right) + \frac{e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)}}{cosTheta \cdot \color{blue}{\sqrt{\frac{\mathsf{PI}\left(\right)}{\left(1 - cosTheta\right) - cosTheta}}}}} \]
    14. /-lowering-/.f32N/A

      \[\leadsto \frac{1}{\left(1 + c\right) + \frac{e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)}}{cosTheta \cdot \sqrt{\color{blue}{\frac{\mathsf{PI}\left(\right)}{\left(1 - cosTheta\right) - cosTheta}}}}} \]
    15. PI-lowering-PI.f32N/A

      \[\leadsto \frac{1}{\left(1 + c\right) + \frac{e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)}}{cosTheta \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right)}}{\left(1 - cosTheta\right) - cosTheta}}}} \]
    16. --lowering--.f32N/A

      \[\leadsto \frac{1}{\left(1 + c\right) + \frac{e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)}}{cosTheta \cdot \sqrt{\frac{\mathsf{PI}\left(\right)}{\color{blue}{\left(1 - cosTheta\right) - cosTheta}}}}} \]
    17. --lowering--.f3298.7

      \[\leadsto \frac{1}{\left(1 + c\right) + \frac{e^{cosTheta \cdot \left(-cosTheta\right)}}{cosTheta \cdot \sqrt{\frac{\pi}{\color{blue}{\left(1 - cosTheta\right)} - cosTheta}}}} \]
  6. Applied egg-rr98.7%

    \[\leadsto \frac{1}{\left(1 + c\right) + \color{blue}{\frac{e^{cosTheta \cdot \left(-cosTheta\right)}}{cosTheta \cdot \sqrt{\frac{\pi}{\left(1 - cosTheta\right) - cosTheta}}}}} \]
  7. Add Preprocessing

Alternative 2: 98.3% accurate, 1.2× speedup?

\[\begin{array}{l} \\ cosTheta \cdot \frac{1}{\mathsf{fma}\left({e}^{\left(cosTheta \cdot \left(-cosTheta\right)\right)}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}, cosTheta\right)} \end{array} \]
(FPCore (cosTheta c)
 :precision binary32
 (*
  cosTheta
  (/
   1.0
   (fma
    (pow E (* cosTheta (- cosTheta)))
    (sqrt (/ (fma cosTheta -2.0 1.0) PI))
    cosTheta))))
float code(float cosTheta, float c) {
	return cosTheta * (1.0f / fmaf(powf(((float) M_E), (cosTheta * -cosTheta)), sqrtf((fmaf(cosTheta, -2.0f, 1.0f) / ((float) M_PI))), cosTheta));
}
function code(cosTheta, c)
	return Float32(cosTheta * Float32(Float32(1.0) / fma((Float32(exp(1)) ^ Float32(cosTheta * Float32(-cosTheta))), sqrt(Float32(fma(cosTheta, Float32(-2.0), Float32(1.0)) / Float32(pi))), cosTheta)))
end
\begin{array}{l}

\\
cosTheta \cdot \frac{1}{\mathsf{fma}\left({e}^{\left(cosTheta \cdot \left(-cosTheta\right)\right)}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}, cosTheta\right)}
\end{array}
Derivation
  1. Initial program 97.6%

    \[\frac{1}{\left(1 + c\right) + \left(\frac{1}{\sqrt{\pi}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\left(-cosTheta\right) \cdot cosTheta}} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \frac{1}{\color{blue}{\left(c + 1\right)} + \left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}} \]
    2. flip-+N/A

      \[\leadsto \frac{1}{\color{blue}{\frac{c \cdot c - 1 \cdot 1}{c - 1}} + \left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}} \]
    3. associate-*r/N/A

      \[\leadsto \frac{1}{\frac{c \cdot c - 1 \cdot 1}{c - 1} + \color{blue}{\frac{\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}} \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}} \]
    4. associate-*l/N/A

      \[\leadsto \frac{1}{\frac{c \cdot c - 1 \cdot 1}{c - 1} + \color{blue}{\frac{\left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \sqrt{\left(1 - cosTheta\right) - cosTheta}\right) \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}}{cosTheta}}} \]
    5. frac-addN/A

      \[\leadsto \frac{1}{\color{blue}{\frac{\left(c \cdot c - 1 \cdot 1\right) \cdot cosTheta + \left(c - 1\right) \cdot \left(\left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \sqrt{\left(1 - cosTheta\right) - cosTheta}\right) \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}\right)}{\left(c - 1\right) \cdot cosTheta}}} \]
    6. /-lowering-/.f32N/A

      \[\leadsto \frac{1}{\color{blue}{\frac{\left(c \cdot c - 1 \cdot 1\right) \cdot cosTheta + \left(c - 1\right) \cdot \left(\left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \sqrt{\left(1 - cosTheta\right) - cosTheta}\right) \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}\right)}{\left(c - 1\right) \cdot cosTheta}}} \]
  4. Applied egg-rr98.1%

    \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(c, c, -1\right), cosTheta, \left(c + -1\right) \cdot \left(\sqrt{\frac{\left(1 - cosTheta\right) - cosTheta}{\pi}} \cdot e^{cosTheta \cdot \left(-cosTheta\right)}\right)\right)}{\left(c + -1\right) \cdot cosTheta}}} \]
  5. Taylor expanded in c around 0

    \[\leadsto \color{blue}{-1 \cdot \frac{cosTheta}{-1 \cdot cosTheta + -1 \cdot \left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)}} \]
  6. Step-by-step derivation
    1. associate-*r/N/A

      \[\leadsto \color{blue}{\frac{-1 \cdot cosTheta}{-1 \cdot cosTheta + -1 \cdot \left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)}} \]
    2. /-lowering-/.f32N/A

      \[\leadsto \color{blue}{\frac{-1 \cdot cosTheta}{-1 \cdot cosTheta + -1 \cdot \left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)}} \]
    3. mul-1-negN/A

      \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(cosTheta\right)}}{-1 \cdot cosTheta + -1 \cdot \left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)} \]
    4. neg-lowering-neg.f32N/A

      \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(cosTheta\right)}}{-1 \cdot cosTheta + -1 \cdot \left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)} \]
    5. +-commutativeN/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\color{blue}{-1 \cdot \left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right) + -1 \cdot cosTheta}} \]
    6. mul-1-negN/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\color{blue}{\left(\mathsf{neg}\left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)\right)} + -1 \cdot cosTheta} \]
    7. mul-1-negN/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\left(\mathsf{neg}\left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)\right) + \color{blue}{\left(\mathsf{neg}\left(cosTheta\right)\right)}} \]
    8. distribute-neg-outN/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\color{blue}{\mathsf{neg}\left(\left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}} + cosTheta\right)\right)}} \]
    9. neg-lowering-neg.f32N/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\color{blue}{\mathsf{neg}\left(\left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}} + cosTheta\right)\right)}} \]
    10. *-commutativeN/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\mathsf{neg}\left(\left(\color{blue}{e^{-1 \cdot {cosTheta}^{2}} \cdot \sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}}} + cosTheta\right)\right)} \]
    11. accelerator-lowering-fma.f32N/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\mathsf{neg}\left(\color{blue}{\mathsf{fma}\left(e^{-1 \cdot {cosTheta}^{2}}, \sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}}, cosTheta\right)}\right)} \]
  7. Simplified97.9%

    \[\leadsto \color{blue}{\frac{-cosTheta}{-\mathsf{fma}\left(e^{cosTheta \cdot \left(-cosTheta\right)}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}, cosTheta\right)}} \]
  8. Step-by-step derivation
    1. frac-2negN/A

      \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(cosTheta\right)\right)\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}} + cosTheta\right)\right)\right)\right)}} \]
    2. div-invN/A

      \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(cosTheta\right)\right)\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}} + cosTheta\right)\right)\right)\right)}} \]
    3. remove-double-negN/A

      \[\leadsto \color{blue}{cosTheta} \cdot \frac{1}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}} + cosTheta\right)\right)\right)\right)} \]
    4. remove-double-negN/A

      \[\leadsto cosTheta \cdot \frac{1}{\color{blue}{e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}} + cosTheta}} \]
    5. *-lowering-*.f32N/A

      \[\leadsto \color{blue}{cosTheta \cdot \frac{1}{e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}} + cosTheta}} \]
    6. /-lowering-/.f32N/A

      \[\leadsto cosTheta \cdot \color{blue}{\frac{1}{e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}} + cosTheta}} \]
    7. *-lft-identityN/A

      \[\leadsto cosTheta \cdot \frac{1}{e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \color{blue}{\left(1 \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}}\right)} + cosTheta} \]
    8. accelerator-lowering-fma.f32N/A

      \[\leadsto cosTheta \cdot \frac{1}{\color{blue}{\mathsf{fma}\left(e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)}, 1 \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}}, cosTheta\right)}} \]
  9. Applied egg-rr98.6%

    \[\leadsto \color{blue}{cosTheta \cdot \frac{1}{\mathsf{fma}\left(e^{cosTheta \cdot \left(-cosTheta\right)}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}, cosTheta\right)}} \]
  10. Step-by-step derivation
    1. *-rgt-identityN/A

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(e^{\color{blue}{\left(cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)\right) \cdot 1}}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, cosTheta\right)} \]
    2. *-commutativeN/A

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(e^{\color{blue}{1 \cdot \left(cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)\right)}}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, cosTheta\right)} \]
    3. exp-prodN/A

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\color{blue}{{\left(e^{1}\right)}^{\left(cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)\right)}}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, cosTheta\right)} \]
    4. pow-lowering-pow.f32N/A

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\color{blue}{{\left(e^{1}\right)}^{\left(cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)\right)}}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, cosTheta\right)} \]
    5. exp-1-eN/A

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left({\color{blue}{\mathsf{E}\left(\right)}}^{\left(cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)\right)}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, cosTheta\right)} \]
    6. E-lowering-E.f32N/A

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left({\color{blue}{\mathsf{E}\left(\right)}}^{\left(cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)\right)}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, cosTheta\right)} \]
    7. *-lowering-*.f32N/A

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left({\mathsf{E}\left(\right)}^{\color{blue}{\left(cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)\right)}}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, cosTheta\right)} \]
    8. neg-lowering-neg.f3298.6

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left({e}^{\left(cosTheta \cdot \color{blue}{\left(-cosTheta\right)}\right)}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}, cosTheta\right)} \]
  11. Applied egg-rr98.6%

    \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\color{blue}{{e}^{\left(cosTheta \cdot \left(-cosTheta\right)\right)}}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}, cosTheta\right)} \]
  12. Add Preprocessing

Alternative 3: 98.3% accurate, 1.2× speedup?

\[\begin{array}{l} \\ cosTheta \cdot \frac{1}{\mathsf{fma}\left(e^{cosTheta \cdot \left(-cosTheta\right)}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}, cosTheta\right)} \end{array} \]
(FPCore (cosTheta c)
 :precision binary32
 (*
  cosTheta
  (/
   1.0
   (fma
    (exp (* cosTheta (- cosTheta)))
    (sqrt (/ (fma cosTheta -2.0 1.0) PI))
    cosTheta))))
float code(float cosTheta, float c) {
	return cosTheta * (1.0f / fmaf(expf((cosTheta * -cosTheta)), sqrtf((fmaf(cosTheta, -2.0f, 1.0f) / ((float) M_PI))), cosTheta));
}
function code(cosTheta, c)
	return Float32(cosTheta * Float32(Float32(1.0) / fma(exp(Float32(cosTheta * Float32(-cosTheta))), sqrt(Float32(fma(cosTheta, Float32(-2.0), Float32(1.0)) / Float32(pi))), cosTheta)))
end
\begin{array}{l}

\\
cosTheta \cdot \frac{1}{\mathsf{fma}\left(e^{cosTheta \cdot \left(-cosTheta\right)}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}, cosTheta\right)}
\end{array}
Derivation
  1. Initial program 97.6%

    \[\frac{1}{\left(1 + c\right) + \left(\frac{1}{\sqrt{\pi}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\left(-cosTheta\right) \cdot cosTheta}} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \frac{1}{\color{blue}{\left(c + 1\right)} + \left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}} \]
    2. flip-+N/A

      \[\leadsto \frac{1}{\color{blue}{\frac{c \cdot c - 1 \cdot 1}{c - 1}} + \left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}} \]
    3. associate-*r/N/A

      \[\leadsto \frac{1}{\frac{c \cdot c - 1 \cdot 1}{c - 1} + \color{blue}{\frac{\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}} \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}} \]
    4. associate-*l/N/A

      \[\leadsto \frac{1}{\frac{c \cdot c - 1 \cdot 1}{c - 1} + \color{blue}{\frac{\left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \sqrt{\left(1 - cosTheta\right) - cosTheta}\right) \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}}{cosTheta}}} \]
    5. frac-addN/A

      \[\leadsto \frac{1}{\color{blue}{\frac{\left(c \cdot c - 1 \cdot 1\right) \cdot cosTheta + \left(c - 1\right) \cdot \left(\left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \sqrt{\left(1 - cosTheta\right) - cosTheta}\right) \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}\right)}{\left(c - 1\right) \cdot cosTheta}}} \]
    6. /-lowering-/.f32N/A

      \[\leadsto \frac{1}{\color{blue}{\frac{\left(c \cdot c - 1 \cdot 1\right) \cdot cosTheta + \left(c - 1\right) \cdot \left(\left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \sqrt{\left(1 - cosTheta\right) - cosTheta}\right) \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}\right)}{\left(c - 1\right) \cdot cosTheta}}} \]
  4. Applied egg-rr98.1%

    \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(c, c, -1\right), cosTheta, \left(c + -1\right) \cdot \left(\sqrt{\frac{\left(1 - cosTheta\right) - cosTheta}{\pi}} \cdot e^{cosTheta \cdot \left(-cosTheta\right)}\right)\right)}{\left(c + -1\right) \cdot cosTheta}}} \]
  5. Taylor expanded in c around 0

    \[\leadsto \color{blue}{-1 \cdot \frac{cosTheta}{-1 \cdot cosTheta + -1 \cdot \left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)}} \]
  6. Step-by-step derivation
    1. associate-*r/N/A

      \[\leadsto \color{blue}{\frac{-1 \cdot cosTheta}{-1 \cdot cosTheta + -1 \cdot \left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)}} \]
    2. /-lowering-/.f32N/A

      \[\leadsto \color{blue}{\frac{-1 \cdot cosTheta}{-1 \cdot cosTheta + -1 \cdot \left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)}} \]
    3. mul-1-negN/A

      \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(cosTheta\right)}}{-1 \cdot cosTheta + -1 \cdot \left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)} \]
    4. neg-lowering-neg.f32N/A

      \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(cosTheta\right)}}{-1 \cdot cosTheta + -1 \cdot \left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)} \]
    5. +-commutativeN/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\color{blue}{-1 \cdot \left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right) + -1 \cdot cosTheta}} \]
    6. mul-1-negN/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\color{blue}{\left(\mathsf{neg}\left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)\right)} + -1 \cdot cosTheta} \]
    7. mul-1-negN/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\left(\mathsf{neg}\left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)\right) + \color{blue}{\left(\mathsf{neg}\left(cosTheta\right)\right)}} \]
    8. distribute-neg-outN/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\color{blue}{\mathsf{neg}\left(\left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}} + cosTheta\right)\right)}} \]
    9. neg-lowering-neg.f32N/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\color{blue}{\mathsf{neg}\left(\left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}} + cosTheta\right)\right)}} \]
    10. *-commutativeN/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\mathsf{neg}\left(\left(\color{blue}{e^{-1 \cdot {cosTheta}^{2}} \cdot \sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}}} + cosTheta\right)\right)} \]
    11. accelerator-lowering-fma.f32N/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\mathsf{neg}\left(\color{blue}{\mathsf{fma}\left(e^{-1 \cdot {cosTheta}^{2}}, \sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}}, cosTheta\right)}\right)} \]
  7. Simplified97.9%

    \[\leadsto \color{blue}{\frac{-cosTheta}{-\mathsf{fma}\left(e^{cosTheta \cdot \left(-cosTheta\right)}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}, cosTheta\right)}} \]
  8. Step-by-step derivation
    1. frac-2negN/A

      \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(cosTheta\right)\right)\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}} + cosTheta\right)\right)\right)\right)}} \]
    2. div-invN/A

      \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(cosTheta\right)\right)\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}} + cosTheta\right)\right)\right)\right)}} \]
    3. remove-double-negN/A

      \[\leadsto \color{blue}{cosTheta} \cdot \frac{1}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}} + cosTheta\right)\right)\right)\right)} \]
    4. remove-double-negN/A

      \[\leadsto cosTheta \cdot \frac{1}{\color{blue}{e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}} + cosTheta}} \]
    5. *-lowering-*.f32N/A

      \[\leadsto \color{blue}{cosTheta \cdot \frac{1}{e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}} + cosTheta}} \]
    6. /-lowering-/.f32N/A

      \[\leadsto cosTheta \cdot \color{blue}{\frac{1}{e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}} + cosTheta}} \]
    7. *-lft-identityN/A

      \[\leadsto cosTheta \cdot \frac{1}{e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \color{blue}{\left(1 \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}}\right)} + cosTheta} \]
    8. accelerator-lowering-fma.f32N/A

      \[\leadsto cosTheta \cdot \frac{1}{\color{blue}{\mathsf{fma}\left(e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)}, 1 \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}}, cosTheta\right)}} \]
  9. Applied egg-rr98.6%

    \[\leadsto \color{blue}{cosTheta \cdot \frac{1}{\mathsf{fma}\left(e^{cosTheta \cdot \left(-cosTheta\right)}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}, cosTheta\right)}} \]
  10. Add Preprocessing

Alternative 4: 98.2% accurate, 2.2× speedup?

\[\begin{array}{l} \\ cosTheta \cdot \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(cosTheta \cdot cosTheta, \mathsf{fma}\left(cosTheta \cdot cosTheta, \mathsf{fma}\left(cosTheta \cdot cosTheta, -0.16666666666666666, 0.5\right), -1\right), 1\right), \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}, cosTheta\right)} \end{array} \]
(FPCore (cosTheta c)
 :precision binary32
 (*
  cosTheta
  (/
   1.0
   (fma
    (fma
     (* cosTheta cosTheta)
     (fma
      (* cosTheta cosTheta)
      (fma (* cosTheta cosTheta) -0.16666666666666666 0.5)
      -1.0)
     1.0)
    (sqrt (/ (fma cosTheta -2.0 1.0) PI))
    cosTheta))))
float code(float cosTheta, float c) {
	return cosTheta * (1.0f / fmaf(fmaf((cosTheta * cosTheta), fmaf((cosTheta * cosTheta), fmaf((cosTheta * cosTheta), -0.16666666666666666f, 0.5f), -1.0f), 1.0f), sqrtf((fmaf(cosTheta, -2.0f, 1.0f) / ((float) M_PI))), cosTheta));
}
function code(cosTheta, c)
	return Float32(cosTheta * Float32(Float32(1.0) / fma(fma(Float32(cosTheta * cosTheta), fma(Float32(cosTheta * cosTheta), fma(Float32(cosTheta * cosTheta), Float32(-0.16666666666666666), Float32(0.5)), Float32(-1.0)), Float32(1.0)), sqrt(Float32(fma(cosTheta, Float32(-2.0), Float32(1.0)) / Float32(pi))), cosTheta)))
end
\begin{array}{l}

\\
cosTheta \cdot \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(cosTheta \cdot cosTheta, \mathsf{fma}\left(cosTheta \cdot cosTheta, \mathsf{fma}\left(cosTheta \cdot cosTheta, -0.16666666666666666, 0.5\right), -1\right), 1\right), \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}, cosTheta\right)}
\end{array}
Derivation
  1. Initial program 97.6%

    \[\frac{1}{\left(1 + c\right) + \left(\frac{1}{\sqrt{\pi}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\left(-cosTheta\right) \cdot cosTheta}} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \frac{1}{\color{blue}{\left(c + 1\right)} + \left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}} \]
    2. flip-+N/A

      \[\leadsto \frac{1}{\color{blue}{\frac{c \cdot c - 1 \cdot 1}{c - 1}} + \left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}} \]
    3. associate-*r/N/A

      \[\leadsto \frac{1}{\frac{c \cdot c - 1 \cdot 1}{c - 1} + \color{blue}{\frac{\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}} \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}} \]
    4. associate-*l/N/A

      \[\leadsto \frac{1}{\frac{c \cdot c - 1 \cdot 1}{c - 1} + \color{blue}{\frac{\left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \sqrt{\left(1 - cosTheta\right) - cosTheta}\right) \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}}{cosTheta}}} \]
    5. frac-addN/A

      \[\leadsto \frac{1}{\color{blue}{\frac{\left(c \cdot c - 1 \cdot 1\right) \cdot cosTheta + \left(c - 1\right) \cdot \left(\left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \sqrt{\left(1 - cosTheta\right) - cosTheta}\right) \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}\right)}{\left(c - 1\right) \cdot cosTheta}}} \]
    6. /-lowering-/.f32N/A

      \[\leadsto \frac{1}{\color{blue}{\frac{\left(c \cdot c - 1 \cdot 1\right) \cdot cosTheta + \left(c - 1\right) \cdot \left(\left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \sqrt{\left(1 - cosTheta\right) - cosTheta}\right) \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}\right)}{\left(c - 1\right) \cdot cosTheta}}} \]
  4. Applied egg-rr98.1%

    \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(c, c, -1\right), cosTheta, \left(c + -1\right) \cdot \left(\sqrt{\frac{\left(1 - cosTheta\right) - cosTheta}{\pi}} \cdot e^{cosTheta \cdot \left(-cosTheta\right)}\right)\right)}{\left(c + -1\right) \cdot cosTheta}}} \]
  5. Taylor expanded in c around 0

    \[\leadsto \color{blue}{-1 \cdot \frac{cosTheta}{-1 \cdot cosTheta + -1 \cdot \left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)}} \]
  6. Step-by-step derivation
    1. associate-*r/N/A

      \[\leadsto \color{blue}{\frac{-1 \cdot cosTheta}{-1 \cdot cosTheta + -1 \cdot \left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)}} \]
    2. /-lowering-/.f32N/A

      \[\leadsto \color{blue}{\frac{-1 \cdot cosTheta}{-1 \cdot cosTheta + -1 \cdot \left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)}} \]
    3. mul-1-negN/A

      \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(cosTheta\right)}}{-1 \cdot cosTheta + -1 \cdot \left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)} \]
    4. neg-lowering-neg.f32N/A

      \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(cosTheta\right)}}{-1 \cdot cosTheta + -1 \cdot \left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)} \]
    5. +-commutativeN/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\color{blue}{-1 \cdot \left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right) + -1 \cdot cosTheta}} \]
    6. mul-1-negN/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\color{blue}{\left(\mathsf{neg}\left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)\right)} + -1 \cdot cosTheta} \]
    7. mul-1-negN/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\left(\mathsf{neg}\left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)\right) + \color{blue}{\left(\mathsf{neg}\left(cosTheta\right)\right)}} \]
    8. distribute-neg-outN/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\color{blue}{\mathsf{neg}\left(\left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}} + cosTheta\right)\right)}} \]
    9. neg-lowering-neg.f32N/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\color{blue}{\mathsf{neg}\left(\left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}} + cosTheta\right)\right)}} \]
    10. *-commutativeN/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\mathsf{neg}\left(\left(\color{blue}{e^{-1 \cdot {cosTheta}^{2}} \cdot \sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}}} + cosTheta\right)\right)} \]
    11. accelerator-lowering-fma.f32N/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\mathsf{neg}\left(\color{blue}{\mathsf{fma}\left(e^{-1 \cdot {cosTheta}^{2}}, \sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}}, cosTheta\right)}\right)} \]
  7. Simplified97.9%

    \[\leadsto \color{blue}{\frac{-cosTheta}{-\mathsf{fma}\left(e^{cosTheta \cdot \left(-cosTheta\right)}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}, cosTheta\right)}} \]
  8. Step-by-step derivation
    1. frac-2negN/A

      \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(cosTheta\right)\right)\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}} + cosTheta\right)\right)\right)\right)}} \]
    2. div-invN/A

      \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(cosTheta\right)\right)\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}} + cosTheta\right)\right)\right)\right)}} \]
    3. remove-double-negN/A

      \[\leadsto \color{blue}{cosTheta} \cdot \frac{1}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}} + cosTheta\right)\right)\right)\right)} \]
    4. remove-double-negN/A

      \[\leadsto cosTheta \cdot \frac{1}{\color{blue}{e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}} + cosTheta}} \]
    5. *-lowering-*.f32N/A

      \[\leadsto \color{blue}{cosTheta \cdot \frac{1}{e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}} + cosTheta}} \]
    6. /-lowering-/.f32N/A

      \[\leadsto cosTheta \cdot \color{blue}{\frac{1}{e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}} + cosTheta}} \]
    7. *-lft-identityN/A

      \[\leadsto cosTheta \cdot \frac{1}{e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \color{blue}{\left(1 \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}}\right)} + cosTheta} \]
    8. accelerator-lowering-fma.f32N/A

      \[\leadsto cosTheta \cdot \frac{1}{\color{blue}{\mathsf{fma}\left(e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)}, 1 \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}}, cosTheta\right)}} \]
  9. Applied egg-rr98.6%

    \[\leadsto \color{blue}{cosTheta \cdot \frac{1}{\mathsf{fma}\left(e^{cosTheta \cdot \left(-cosTheta\right)}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}, cosTheta\right)}} \]
  10. Taylor expanded in cosTheta around 0

    \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\color{blue}{1 + {cosTheta}^{2} \cdot \left({cosTheta}^{2} \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot {cosTheta}^{2}\right) - 1\right)}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, cosTheta\right)} \]
  11. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\color{blue}{{cosTheta}^{2} \cdot \left({cosTheta}^{2} \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot {cosTheta}^{2}\right) - 1\right) + 1}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, cosTheta\right)} \]
    2. accelerator-lowering-fma.f32N/A

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left({cosTheta}^{2}, {cosTheta}^{2} \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot {cosTheta}^{2}\right) - 1, 1\right)}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, cosTheta\right)} \]
    3. unpow2N/A

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{cosTheta \cdot cosTheta}, {cosTheta}^{2} \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot {cosTheta}^{2}\right) - 1, 1\right), \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, cosTheta\right)} \]
    4. *-lowering-*.f32N/A

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{cosTheta \cdot cosTheta}, {cosTheta}^{2} \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot {cosTheta}^{2}\right) - 1, 1\right), \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, cosTheta\right)} \]
    5. sub-negN/A

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(cosTheta \cdot cosTheta, \color{blue}{{cosTheta}^{2} \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot {cosTheta}^{2}\right) + \left(\mathsf{neg}\left(1\right)\right)}, 1\right), \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, cosTheta\right)} \]
    6. metadata-evalN/A

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(cosTheta \cdot cosTheta, {cosTheta}^{2} \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot {cosTheta}^{2}\right) + \color{blue}{-1}, 1\right), \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, cosTheta\right)} \]
    7. accelerator-lowering-fma.f32N/A

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(cosTheta \cdot cosTheta, \color{blue}{\mathsf{fma}\left({cosTheta}^{2}, \frac{1}{2} + \frac{-1}{6} \cdot {cosTheta}^{2}, -1\right)}, 1\right), \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, cosTheta\right)} \]
    8. unpow2N/A

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(cosTheta \cdot cosTheta, \mathsf{fma}\left(\color{blue}{cosTheta \cdot cosTheta}, \frac{1}{2} + \frac{-1}{6} \cdot {cosTheta}^{2}, -1\right), 1\right), \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, cosTheta\right)} \]
    9. *-lowering-*.f32N/A

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(cosTheta \cdot cosTheta, \mathsf{fma}\left(\color{blue}{cosTheta \cdot cosTheta}, \frac{1}{2} + \frac{-1}{6} \cdot {cosTheta}^{2}, -1\right), 1\right), \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, cosTheta\right)} \]
    10. +-commutativeN/A

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(cosTheta \cdot cosTheta, \mathsf{fma}\left(cosTheta \cdot cosTheta, \color{blue}{\frac{-1}{6} \cdot {cosTheta}^{2} + \frac{1}{2}}, -1\right), 1\right), \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, cosTheta\right)} \]
    11. *-commutativeN/A

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(cosTheta \cdot cosTheta, \mathsf{fma}\left(cosTheta \cdot cosTheta, \color{blue}{{cosTheta}^{2} \cdot \frac{-1}{6}} + \frac{1}{2}, -1\right), 1\right), \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, cosTheta\right)} \]
    12. accelerator-lowering-fma.f32N/A

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(cosTheta \cdot cosTheta, \mathsf{fma}\left(cosTheta \cdot cosTheta, \color{blue}{\mathsf{fma}\left({cosTheta}^{2}, \frac{-1}{6}, \frac{1}{2}\right)}, -1\right), 1\right), \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, cosTheta\right)} \]
    13. unpow2N/A

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(cosTheta \cdot cosTheta, \mathsf{fma}\left(cosTheta \cdot cosTheta, \mathsf{fma}\left(\color{blue}{cosTheta \cdot cosTheta}, \frac{-1}{6}, \frac{1}{2}\right), -1\right), 1\right), \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, cosTheta\right)} \]
    14. *-lowering-*.f3298.6

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(cosTheta \cdot cosTheta, \mathsf{fma}\left(cosTheta \cdot cosTheta, \mathsf{fma}\left(\color{blue}{cosTheta \cdot cosTheta}, -0.16666666666666666, 0.5\right), -1\right), 1\right), \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}, cosTheta\right)} \]
  12. Simplified98.6%

    \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(cosTheta \cdot cosTheta, \mathsf{fma}\left(cosTheta \cdot cosTheta, \mathsf{fma}\left(cosTheta \cdot cosTheta, -0.16666666666666666, 0.5\right), -1\right), 1\right)}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}, cosTheta\right)} \]
  13. Add Preprocessing

Alternative 5: 97.9% accurate, 2.5× speedup?

\[\begin{array}{l} \\ cosTheta \cdot \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(cosTheta \cdot cosTheta, \mathsf{fma}\left(cosTheta \cdot cosTheta, 0.5, -1\right), 1\right), \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}, cosTheta\right)} \end{array} \]
(FPCore (cosTheta c)
 :precision binary32
 (*
  cosTheta
  (/
   1.0
   (fma
    (fma (* cosTheta cosTheta) (fma (* cosTheta cosTheta) 0.5 -1.0) 1.0)
    (sqrt (/ (fma cosTheta -2.0 1.0) PI))
    cosTheta))))
float code(float cosTheta, float c) {
	return cosTheta * (1.0f / fmaf(fmaf((cosTheta * cosTheta), fmaf((cosTheta * cosTheta), 0.5f, -1.0f), 1.0f), sqrtf((fmaf(cosTheta, -2.0f, 1.0f) / ((float) M_PI))), cosTheta));
}
function code(cosTheta, c)
	return Float32(cosTheta * Float32(Float32(1.0) / fma(fma(Float32(cosTheta * cosTheta), fma(Float32(cosTheta * cosTheta), Float32(0.5), Float32(-1.0)), Float32(1.0)), sqrt(Float32(fma(cosTheta, Float32(-2.0), Float32(1.0)) / Float32(pi))), cosTheta)))
end
\begin{array}{l}

\\
cosTheta \cdot \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(cosTheta \cdot cosTheta, \mathsf{fma}\left(cosTheta \cdot cosTheta, 0.5, -1\right), 1\right), \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}, cosTheta\right)}
\end{array}
Derivation
  1. Initial program 97.6%

    \[\frac{1}{\left(1 + c\right) + \left(\frac{1}{\sqrt{\pi}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\left(-cosTheta\right) \cdot cosTheta}} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \frac{1}{\color{blue}{\left(c + 1\right)} + \left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}} \]
    2. flip-+N/A

      \[\leadsto \frac{1}{\color{blue}{\frac{c \cdot c - 1 \cdot 1}{c - 1}} + \left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}} \]
    3. associate-*r/N/A

      \[\leadsto \frac{1}{\frac{c \cdot c - 1 \cdot 1}{c - 1} + \color{blue}{\frac{\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}} \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}} \]
    4. associate-*l/N/A

      \[\leadsto \frac{1}{\frac{c \cdot c - 1 \cdot 1}{c - 1} + \color{blue}{\frac{\left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \sqrt{\left(1 - cosTheta\right) - cosTheta}\right) \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}}{cosTheta}}} \]
    5. frac-addN/A

      \[\leadsto \frac{1}{\color{blue}{\frac{\left(c \cdot c - 1 \cdot 1\right) \cdot cosTheta + \left(c - 1\right) \cdot \left(\left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \sqrt{\left(1 - cosTheta\right) - cosTheta}\right) \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}\right)}{\left(c - 1\right) \cdot cosTheta}}} \]
    6. /-lowering-/.f32N/A

      \[\leadsto \frac{1}{\color{blue}{\frac{\left(c \cdot c - 1 \cdot 1\right) \cdot cosTheta + \left(c - 1\right) \cdot \left(\left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \sqrt{\left(1 - cosTheta\right) - cosTheta}\right) \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}\right)}{\left(c - 1\right) \cdot cosTheta}}} \]
  4. Applied egg-rr98.1%

    \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(c, c, -1\right), cosTheta, \left(c + -1\right) \cdot \left(\sqrt{\frac{\left(1 - cosTheta\right) - cosTheta}{\pi}} \cdot e^{cosTheta \cdot \left(-cosTheta\right)}\right)\right)}{\left(c + -1\right) \cdot cosTheta}}} \]
  5. Taylor expanded in c around 0

    \[\leadsto \color{blue}{-1 \cdot \frac{cosTheta}{-1 \cdot cosTheta + -1 \cdot \left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)}} \]
  6. Step-by-step derivation
    1. associate-*r/N/A

      \[\leadsto \color{blue}{\frac{-1 \cdot cosTheta}{-1 \cdot cosTheta + -1 \cdot \left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)}} \]
    2. /-lowering-/.f32N/A

      \[\leadsto \color{blue}{\frac{-1 \cdot cosTheta}{-1 \cdot cosTheta + -1 \cdot \left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)}} \]
    3. mul-1-negN/A

      \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(cosTheta\right)}}{-1 \cdot cosTheta + -1 \cdot \left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)} \]
    4. neg-lowering-neg.f32N/A

      \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(cosTheta\right)}}{-1 \cdot cosTheta + -1 \cdot \left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)} \]
    5. +-commutativeN/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\color{blue}{-1 \cdot \left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right) + -1 \cdot cosTheta}} \]
    6. mul-1-negN/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\color{blue}{\left(\mathsf{neg}\left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)\right)} + -1 \cdot cosTheta} \]
    7. mul-1-negN/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\left(\mathsf{neg}\left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)\right) + \color{blue}{\left(\mathsf{neg}\left(cosTheta\right)\right)}} \]
    8. distribute-neg-outN/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\color{blue}{\mathsf{neg}\left(\left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}} + cosTheta\right)\right)}} \]
    9. neg-lowering-neg.f32N/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\color{blue}{\mathsf{neg}\left(\left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}} + cosTheta\right)\right)}} \]
    10. *-commutativeN/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\mathsf{neg}\left(\left(\color{blue}{e^{-1 \cdot {cosTheta}^{2}} \cdot \sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}}} + cosTheta\right)\right)} \]
    11. accelerator-lowering-fma.f32N/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\mathsf{neg}\left(\color{blue}{\mathsf{fma}\left(e^{-1 \cdot {cosTheta}^{2}}, \sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}}, cosTheta\right)}\right)} \]
  7. Simplified97.9%

    \[\leadsto \color{blue}{\frac{-cosTheta}{-\mathsf{fma}\left(e^{cosTheta \cdot \left(-cosTheta\right)}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}, cosTheta\right)}} \]
  8. Step-by-step derivation
    1. frac-2negN/A

      \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(cosTheta\right)\right)\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}} + cosTheta\right)\right)\right)\right)}} \]
    2. div-invN/A

      \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(cosTheta\right)\right)\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}} + cosTheta\right)\right)\right)\right)}} \]
    3. remove-double-negN/A

      \[\leadsto \color{blue}{cosTheta} \cdot \frac{1}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}} + cosTheta\right)\right)\right)\right)} \]
    4. remove-double-negN/A

      \[\leadsto cosTheta \cdot \frac{1}{\color{blue}{e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}} + cosTheta}} \]
    5. *-lowering-*.f32N/A

      \[\leadsto \color{blue}{cosTheta \cdot \frac{1}{e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}} + cosTheta}} \]
    6. /-lowering-/.f32N/A

      \[\leadsto cosTheta \cdot \color{blue}{\frac{1}{e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}} + cosTheta}} \]
    7. *-lft-identityN/A

      \[\leadsto cosTheta \cdot \frac{1}{e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \color{blue}{\left(1 \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}}\right)} + cosTheta} \]
    8. accelerator-lowering-fma.f32N/A

      \[\leadsto cosTheta \cdot \frac{1}{\color{blue}{\mathsf{fma}\left(e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)}, 1 \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}}, cosTheta\right)}} \]
  9. Applied egg-rr98.6%

    \[\leadsto \color{blue}{cosTheta \cdot \frac{1}{\mathsf{fma}\left(e^{cosTheta \cdot \left(-cosTheta\right)}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}, cosTheta\right)}} \]
  10. Taylor expanded in cosTheta around 0

    \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\color{blue}{1 + {cosTheta}^{2} \cdot \left(\frac{1}{2} \cdot {cosTheta}^{2} - 1\right)}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, cosTheta\right)} \]
  11. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\color{blue}{{cosTheta}^{2} \cdot \left(\frac{1}{2} \cdot {cosTheta}^{2} - 1\right) + 1}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, cosTheta\right)} \]
    2. accelerator-lowering-fma.f32N/A

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left({cosTheta}^{2}, \frac{1}{2} \cdot {cosTheta}^{2} - 1, 1\right)}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, cosTheta\right)} \]
    3. unpow2N/A

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{cosTheta \cdot cosTheta}, \frac{1}{2} \cdot {cosTheta}^{2} - 1, 1\right), \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, cosTheta\right)} \]
    4. *-lowering-*.f32N/A

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{cosTheta \cdot cosTheta}, \frac{1}{2} \cdot {cosTheta}^{2} - 1, 1\right), \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, cosTheta\right)} \]
    5. sub-negN/A

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(cosTheta \cdot cosTheta, \color{blue}{\frac{1}{2} \cdot {cosTheta}^{2} + \left(\mathsf{neg}\left(1\right)\right)}, 1\right), \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, cosTheta\right)} \]
    6. *-commutativeN/A

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(cosTheta \cdot cosTheta, \color{blue}{{cosTheta}^{2} \cdot \frac{1}{2}} + \left(\mathsf{neg}\left(1\right)\right), 1\right), \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, cosTheta\right)} \]
    7. metadata-evalN/A

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(cosTheta \cdot cosTheta, {cosTheta}^{2} \cdot \frac{1}{2} + \color{blue}{-1}, 1\right), \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, cosTheta\right)} \]
    8. accelerator-lowering-fma.f32N/A

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(cosTheta \cdot cosTheta, \color{blue}{\mathsf{fma}\left({cosTheta}^{2}, \frac{1}{2}, -1\right)}, 1\right), \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, cosTheta\right)} \]
    9. unpow2N/A

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(cosTheta \cdot cosTheta, \mathsf{fma}\left(\color{blue}{cosTheta \cdot cosTheta}, \frac{1}{2}, -1\right), 1\right), \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, cosTheta\right)} \]
    10. *-lowering-*.f3298.5

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(cosTheta \cdot cosTheta, \mathsf{fma}\left(\color{blue}{cosTheta \cdot cosTheta}, 0.5, -1\right), 1\right), \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}, cosTheta\right)} \]
  12. Simplified98.5%

    \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(cosTheta \cdot cosTheta, \mathsf{fma}\left(cosTheta \cdot cosTheta, 0.5, -1\right), 1\right)}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}, cosTheta\right)} \]
  13. Add Preprocessing

Alternative 6: 97.3% accurate, 3.2× speedup?

\[\begin{array}{l} \\ cosTheta \cdot \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(cosTheta, -cosTheta, 1\right), \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}, cosTheta\right)} \end{array} \]
(FPCore (cosTheta c)
 :precision binary32
 (*
  cosTheta
  (/
   1.0
   (fma
    (fma cosTheta (- cosTheta) 1.0)
    (sqrt (/ (fma cosTheta -2.0 1.0) PI))
    cosTheta))))
float code(float cosTheta, float c) {
	return cosTheta * (1.0f / fmaf(fmaf(cosTheta, -cosTheta, 1.0f), sqrtf((fmaf(cosTheta, -2.0f, 1.0f) / ((float) M_PI))), cosTheta));
}
function code(cosTheta, c)
	return Float32(cosTheta * Float32(Float32(1.0) / fma(fma(cosTheta, Float32(-cosTheta), Float32(1.0)), sqrt(Float32(fma(cosTheta, Float32(-2.0), Float32(1.0)) / Float32(pi))), cosTheta)))
end
\begin{array}{l}

\\
cosTheta \cdot \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(cosTheta, -cosTheta, 1\right), \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}, cosTheta\right)}
\end{array}
Derivation
  1. Initial program 97.6%

    \[\frac{1}{\left(1 + c\right) + \left(\frac{1}{\sqrt{\pi}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\left(-cosTheta\right) \cdot cosTheta}} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \frac{1}{\color{blue}{\left(c + 1\right)} + \left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}} \]
    2. flip-+N/A

      \[\leadsto \frac{1}{\color{blue}{\frac{c \cdot c - 1 \cdot 1}{c - 1}} + \left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}} \]
    3. associate-*r/N/A

      \[\leadsto \frac{1}{\frac{c \cdot c - 1 \cdot 1}{c - 1} + \color{blue}{\frac{\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}} \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}} \]
    4. associate-*l/N/A

      \[\leadsto \frac{1}{\frac{c \cdot c - 1 \cdot 1}{c - 1} + \color{blue}{\frac{\left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \sqrt{\left(1 - cosTheta\right) - cosTheta}\right) \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}}{cosTheta}}} \]
    5. frac-addN/A

      \[\leadsto \frac{1}{\color{blue}{\frac{\left(c \cdot c - 1 \cdot 1\right) \cdot cosTheta + \left(c - 1\right) \cdot \left(\left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \sqrt{\left(1 - cosTheta\right) - cosTheta}\right) \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}\right)}{\left(c - 1\right) \cdot cosTheta}}} \]
    6. /-lowering-/.f32N/A

      \[\leadsto \frac{1}{\color{blue}{\frac{\left(c \cdot c - 1 \cdot 1\right) \cdot cosTheta + \left(c - 1\right) \cdot \left(\left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \sqrt{\left(1 - cosTheta\right) - cosTheta}\right) \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}\right)}{\left(c - 1\right) \cdot cosTheta}}} \]
  4. Applied egg-rr98.1%

    \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(c, c, -1\right), cosTheta, \left(c + -1\right) \cdot \left(\sqrt{\frac{\left(1 - cosTheta\right) - cosTheta}{\pi}} \cdot e^{cosTheta \cdot \left(-cosTheta\right)}\right)\right)}{\left(c + -1\right) \cdot cosTheta}}} \]
  5. Taylor expanded in c around 0

    \[\leadsto \color{blue}{-1 \cdot \frac{cosTheta}{-1 \cdot cosTheta + -1 \cdot \left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)}} \]
  6. Step-by-step derivation
    1. associate-*r/N/A

      \[\leadsto \color{blue}{\frac{-1 \cdot cosTheta}{-1 \cdot cosTheta + -1 \cdot \left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)}} \]
    2. /-lowering-/.f32N/A

      \[\leadsto \color{blue}{\frac{-1 \cdot cosTheta}{-1 \cdot cosTheta + -1 \cdot \left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)}} \]
    3. mul-1-negN/A

      \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(cosTheta\right)}}{-1 \cdot cosTheta + -1 \cdot \left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)} \]
    4. neg-lowering-neg.f32N/A

      \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(cosTheta\right)}}{-1 \cdot cosTheta + -1 \cdot \left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)} \]
    5. +-commutativeN/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\color{blue}{-1 \cdot \left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right) + -1 \cdot cosTheta}} \]
    6. mul-1-negN/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\color{blue}{\left(\mathsf{neg}\left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)\right)} + -1 \cdot cosTheta} \]
    7. mul-1-negN/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\left(\mathsf{neg}\left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)\right) + \color{blue}{\left(\mathsf{neg}\left(cosTheta\right)\right)}} \]
    8. distribute-neg-outN/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\color{blue}{\mathsf{neg}\left(\left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}} + cosTheta\right)\right)}} \]
    9. neg-lowering-neg.f32N/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\color{blue}{\mathsf{neg}\left(\left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}} + cosTheta\right)\right)}} \]
    10. *-commutativeN/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\mathsf{neg}\left(\left(\color{blue}{e^{-1 \cdot {cosTheta}^{2}} \cdot \sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}}} + cosTheta\right)\right)} \]
    11. accelerator-lowering-fma.f32N/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\mathsf{neg}\left(\color{blue}{\mathsf{fma}\left(e^{-1 \cdot {cosTheta}^{2}}, \sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}}, cosTheta\right)}\right)} \]
  7. Simplified97.9%

    \[\leadsto \color{blue}{\frac{-cosTheta}{-\mathsf{fma}\left(e^{cosTheta \cdot \left(-cosTheta\right)}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}, cosTheta\right)}} \]
  8. Step-by-step derivation
    1. frac-2negN/A

      \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(cosTheta\right)\right)\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}} + cosTheta\right)\right)\right)\right)}} \]
    2. div-invN/A

      \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(cosTheta\right)\right)\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}} + cosTheta\right)\right)\right)\right)}} \]
    3. remove-double-negN/A

      \[\leadsto \color{blue}{cosTheta} \cdot \frac{1}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}} + cosTheta\right)\right)\right)\right)} \]
    4. remove-double-negN/A

      \[\leadsto cosTheta \cdot \frac{1}{\color{blue}{e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}} + cosTheta}} \]
    5. *-lowering-*.f32N/A

      \[\leadsto \color{blue}{cosTheta \cdot \frac{1}{e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}} + cosTheta}} \]
    6. /-lowering-/.f32N/A

      \[\leadsto cosTheta \cdot \color{blue}{\frac{1}{e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}} + cosTheta}} \]
    7. *-lft-identityN/A

      \[\leadsto cosTheta \cdot \frac{1}{e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \color{blue}{\left(1 \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}}\right)} + cosTheta} \]
    8. accelerator-lowering-fma.f32N/A

      \[\leadsto cosTheta \cdot \frac{1}{\color{blue}{\mathsf{fma}\left(e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)}, 1 \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}}, cosTheta\right)}} \]
  9. Applied egg-rr98.6%

    \[\leadsto \color{blue}{cosTheta \cdot \frac{1}{\mathsf{fma}\left(e^{cosTheta \cdot \left(-cosTheta\right)}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}, cosTheta\right)}} \]
  10. Taylor expanded in cosTheta around 0

    \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\color{blue}{1 + -1 \cdot {cosTheta}^{2}}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, cosTheta\right)} \]
  11. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\color{blue}{-1 \cdot {cosTheta}^{2} + 1}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, cosTheta\right)} \]
    2. mul-1-negN/A

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left({cosTheta}^{2}\right)\right)} + 1, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, cosTheta\right)} \]
    3. unpow2N/A

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\color{blue}{cosTheta \cdot cosTheta}\right)\right) + 1, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, cosTheta\right)} \]
    4. distribute-rgt-neg-inN/A

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\color{blue}{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} + 1, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, cosTheta\right)} \]
    5. mul-1-negN/A

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(cosTheta \cdot \color{blue}{\left(-1 \cdot cosTheta\right)} + 1, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, cosTheta\right)} \]
    6. accelerator-lowering-fma.f32N/A

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(cosTheta, -1 \cdot cosTheta, 1\right)}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, cosTheta\right)} \]
    7. mul-1-negN/A

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(cosTheta, \color{blue}{\mathsf{neg}\left(cosTheta\right)}, 1\right), \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, cosTheta\right)} \]
    8. neg-lowering-neg.f3297.9

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(cosTheta, \color{blue}{-cosTheta}, 1\right), \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}, cosTheta\right)} \]
  12. Simplified97.9%

    \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(cosTheta, -cosTheta, 1\right)}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}, cosTheta\right)} \]
  13. Add Preprocessing

Alternative 7: 95.7% accurate, 3.7× speedup?

\[\begin{array}{l} \\ cosTheta \cdot \frac{1}{\mathsf{fma}\left(1, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}, cosTheta\right)} \end{array} \]
(FPCore (cosTheta c)
 :precision binary32
 (* cosTheta (/ 1.0 (fma 1.0 (sqrt (/ (fma cosTheta -2.0 1.0) PI)) cosTheta))))
float code(float cosTheta, float c) {
	return cosTheta * (1.0f / fmaf(1.0f, sqrtf((fmaf(cosTheta, -2.0f, 1.0f) / ((float) M_PI))), cosTheta));
}
function code(cosTheta, c)
	return Float32(cosTheta * Float32(Float32(1.0) / fma(Float32(1.0), sqrt(Float32(fma(cosTheta, Float32(-2.0), Float32(1.0)) / Float32(pi))), cosTheta)))
end
\begin{array}{l}

\\
cosTheta \cdot \frac{1}{\mathsf{fma}\left(1, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}, cosTheta\right)}
\end{array}
Derivation
  1. Initial program 97.6%

    \[\frac{1}{\left(1 + c\right) + \left(\frac{1}{\sqrt{\pi}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\left(-cosTheta\right) \cdot cosTheta}} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \frac{1}{\color{blue}{\left(c + 1\right)} + \left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}} \]
    2. flip-+N/A

      \[\leadsto \frac{1}{\color{blue}{\frac{c \cdot c - 1 \cdot 1}{c - 1}} + \left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}} \]
    3. associate-*r/N/A

      \[\leadsto \frac{1}{\frac{c \cdot c - 1 \cdot 1}{c - 1} + \color{blue}{\frac{\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}} \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}} \]
    4. associate-*l/N/A

      \[\leadsto \frac{1}{\frac{c \cdot c - 1 \cdot 1}{c - 1} + \color{blue}{\frac{\left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \sqrt{\left(1 - cosTheta\right) - cosTheta}\right) \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}}{cosTheta}}} \]
    5. frac-addN/A

      \[\leadsto \frac{1}{\color{blue}{\frac{\left(c \cdot c - 1 \cdot 1\right) \cdot cosTheta + \left(c - 1\right) \cdot \left(\left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \sqrt{\left(1 - cosTheta\right) - cosTheta}\right) \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}\right)}{\left(c - 1\right) \cdot cosTheta}}} \]
    6. /-lowering-/.f32N/A

      \[\leadsto \frac{1}{\color{blue}{\frac{\left(c \cdot c - 1 \cdot 1\right) \cdot cosTheta + \left(c - 1\right) \cdot \left(\left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \sqrt{\left(1 - cosTheta\right) - cosTheta}\right) \cdot e^{\left(\mathsf{neg}\left(cosTheta\right)\right) \cdot cosTheta}\right)}{\left(c - 1\right) \cdot cosTheta}}} \]
  4. Applied egg-rr98.1%

    \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(c, c, -1\right), cosTheta, \left(c + -1\right) \cdot \left(\sqrt{\frac{\left(1 - cosTheta\right) - cosTheta}{\pi}} \cdot e^{cosTheta \cdot \left(-cosTheta\right)}\right)\right)}{\left(c + -1\right) \cdot cosTheta}}} \]
  5. Taylor expanded in c around 0

    \[\leadsto \color{blue}{-1 \cdot \frac{cosTheta}{-1 \cdot cosTheta + -1 \cdot \left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)}} \]
  6. Step-by-step derivation
    1. associate-*r/N/A

      \[\leadsto \color{blue}{\frac{-1 \cdot cosTheta}{-1 \cdot cosTheta + -1 \cdot \left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)}} \]
    2. /-lowering-/.f32N/A

      \[\leadsto \color{blue}{\frac{-1 \cdot cosTheta}{-1 \cdot cosTheta + -1 \cdot \left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)}} \]
    3. mul-1-negN/A

      \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(cosTheta\right)}}{-1 \cdot cosTheta + -1 \cdot \left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)} \]
    4. neg-lowering-neg.f32N/A

      \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(cosTheta\right)}}{-1 \cdot cosTheta + -1 \cdot \left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)} \]
    5. +-commutativeN/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\color{blue}{-1 \cdot \left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right) + -1 \cdot cosTheta}} \]
    6. mul-1-negN/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\color{blue}{\left(\mathsf{neg}\left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)\right)} + -1 \cdot cosTheta} \]
    7. mul-1-negN/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\left(\mathsf{neg}\left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}}\right)\right) + \color{blue}{\left(\mathsf{neg}\left(cosTheta\right)\right)}} \]
    8. distribute-neg-outN/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\color{blue}{\mathsf{neg}\left(\left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}} + cosTheta\right)\right)}} \]
    9. neg-lowering-neg.f32N/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\color{blue}{\mathsf{neg}\left(\left(\sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}} \cdot e^{-1 \cdot {cosTheta}^{2}} + cosTheta\right)\right)}} \]
    10. *-commutativeN/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\mathsf{neg}\left(\left(\color{blue}{e^{-1 \cdot {cosTheta}^{2}} \cdot \sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}}} + cosTheta\right)\right)} \]
    11. accelerator-lowering-fma.f32N/A

      \[\leadsto \frac{\mathsf{neg}\left(cosTheta\right)}{\mathsf{neg}\left(\color{blue}{\mathsf{fma}\left(e^{-1 \cdot {cosTheta}^{2}}, \sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}}, cosTheta\right)}\right)} \]
  7. Simplified97.9%

    \[\leadsto \color{blue}{\frac{-cosTheta}{-\mathsf{fma}\left(e^{cosTheta \cdot \left(-cosTheta\right)}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}, cosTheta\right)}} \]
  8. Step-by-step derivation
    1. frac-2negN/A

      \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(cosTheta\right)\right)\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}} + cosTheta\right)\right)\right)\right)}} \]
    2. div-invN/A

      \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(cosTheta\right)\right)\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}} + cosTheta\right)\right)\right)\right)}} \]
    3. remove-double-negN/A

      \[\leadsto \color{blue}{cosTheta} \cdot \frac{1}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}} + cosTheta\right)\right)\right)\right)} \]
    4. remove-double-negN/A

      \[\leadsto cosTheta \cdot \frac{1}{\color{blue}{e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}} + cosTheta}} \]
    5. *-lowering-*.f32N/A

      \[\leadsto \color{blue}{cosTheta \cdot \frac{1}{e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}} + cosTheta}} \]
    6. /-lowering-/.f32N/A

      \[\leadsto cosTheta \cdot \color{blue}{\frac{1}{e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}} + cosTheta}} \]
    7. *-lft-identityN/A

      \[\leadsto cosTheta \cdot \frac{1}{e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)} \cdot \color{blue}{\left(1 \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}}\right)} + cosTheta} \]
    8. accelerator-lowering-fma.f32N/A

      \[\leadsto cosTheta \cdot \frac{1}{\color{blue}{\mathsf{fma}\left(e^{cosTheta \cdot \left(\mathsf{neg}\left(cosTheta\right)\right)}, 1 \cdot \sqrt{\frac{cosTheta \cdot -2 + 1}{\mathsf{PI}\left(\right)}}, cosTheta\right)}} \]
  9. Applied egg-rr98.6%

    \[\leadsto \color{blue}{cosTheta \cdot \frac{1}{\mathsf{fma}\left(e^{cosTheta \cdot \left(-cosTheta\right)}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}, cosTheta\right)}} \]
  10. Taylor expanded in cosTheta around 0

    \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\color{blue}{1}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, cosTheta\right)} \]
  11. Step-by-step derivation
    1. Simplified96.3%

      \[\leadsto cosTheta \cdot \frac{1}{\mathsf{fma}\left(\color{blue}{1}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}, cosTheta\right)} \]
    2. Add Preprocessing

    Alternative 8: 95.5% accurate, 4.1× speedup?

    \[\begin{array}{l} \\ cosTheta \cdot \mathsf{fma}\left(\pi + \mathsf{fma}\left(\pi, c, -\sqrt{\pi}\right), -cosTheta, \sqrt{\pi}\right) \end{array} \]
    (FPCore (cosTheta c)
     :precision binary32
     (* cosTheta (fma (+ PI (fma PI c (- (sqrt PI)))) (- cosTheta) (sqrt PI))))
    float code(float cosTheta, float c) {
    	return cosTheta * fmaf((((float) M_PI) + fmaf(((float) M_PI), c, -sqrtf(((float) M_PI)))), -cosTheta, sqrtf(((float) M_PI)));
    }
    
    function code(cosTheta, c)
    	return Float32(cosTheta * fma(Float32(Float32(pi) + fma(Float32(pi), c, Float32(-sqrt(Float32(pi))))), Float32(-cosTheta), sqrt(Float32(pi))))
    end
    
    \begin{array}{l}
    
    \\
    cosTheta \cdot \mathsf{fma}\left(\pi + \mathsf{fma}\left(\pi, c, -\sqrt{\pi}\right), -cosTheta, \sqrt{\pi}\right)
    \end{array}
    
    Derivation
    1. Initial program 97.6%

      \[\frac{1}{\left(1 + c\right) + \left(\frac{1}{\sqrt{\pi}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\left(-cosTheta\right) \cdot cosTheta}} \]
    2. Add Preprocessing
    3. Taylor expanded in cosTheta around 0

      \[\leadsto \color{blue}{cosTheta \cdot \left(\sqrt{\mathsf{PI}\left(\right)} + -1 \cdot \left(cosTheta \cdot \left(\mathsf{PI}\left(\right) \cdot \left(1 + \left(c + -1 \cdot \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)\right)\right)\right)\right)} \]
    4. Step-by-step derivation
      1. *-lowering-*.f32N/A

        \[\leadsto \color{blue}{cosTheta \cdot \left(\sqrt{\mathsf{PI}\left(\right)} + -1 \cdot \left(cosTheta \cdot \left(\mathsf{PI}\left(\right) \cdot \left(1 + \left(c + -1 \cdot \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)\right)\right)\right)\right)} \]
      2. +-commutativeN/A

        \[\leadsto cosTheta \cdot \color{blue}{\left(-1 \cdot \left(cosTheta \cdot \left(\mathsf{PI}\left(\right) \cdot \left(1 + \left(c + -1 \cdot \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)\right)\right)\right) + \sqrt{\mathsf{PI}\left(\right)}\right)} \]
      3. associate-*r*N/A

        \[\leadsto cosTheta \cdot \left(\color{blue}{\left(-1 \cdot cosTheta\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \left(1 + \left(c + -1 \cdot \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)\right)\right)} + \sqrt{\mathsf{PI}\left(\right)}\right) \]
      4. *-commutativeN/A

        \[\leadsto cosTheta \cdot \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot \left(1 + \left(c + -1 \cdot \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)\right)\right) \cdot \left(-1 \cdot cosTheta\right)} + \sqrt{\mathsf{PI}\left(\right)}\right) \]
      5. accelerator-lowering-fma.f32N/A

        \[\leadsto cosTheta \cdot \color{blue}{\mathsf{fma}\left(\mathsf{PI}\left(\right) \cdot \left(1 + \left(c + -1 \cdot \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)\right), -1 \cdot cosTheta, \sqrt{\mathsf{PI}\left(\right)}\right)} \]
    5. Simplified96.1%

      \[\leadsto \color{blue}{cosTheta \cdot \mathsf{fma}\left(\mathsf{fma}\left(\pi, c - \sqrt{\frac{1}{\pi}}, \pi\right), -cosTheta, \sqrt{\pi}\right)} \]
    6. Taylor expanded in c around 0

      \[\leadsto cosTheta \cdot \mathsf{fma}\left(\color{blue}{\mathsf{PI}\left(\right) + \left(-1 \cdot \sqrt{\mathsf{PI}\left(\right)} + c \cdot \mathsf{PI}\left(\right)\right)}, \mathsf{neg}\left(cosTheta\right), \sqrt{\mathsf{PI}\left(\right)}\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f32N/A

        \[\leadsto cosTheta \cdot \mathsf{fma}\left(\color{blue}{\mathsf{PI}\left(\right) + \left(-1 \cdot \sqrt{\mathsf{PI}\left(\right)} + c \cdot \mathsf{PI}\left(\right)\right)}, \mathsf{neg}\left(cosTheta\right), \sqrt{\mathsf{PI}\left(\right)}\right) \]
      2. PI-lowering-PI.f32N/A

        \[\leadsto cosTheta \cdot \mathsf{fma}\left(\color{blue}{\mathsf{PI}\left(\right)} + \left(-1 \cdot \sqrt{\mathsf{PI}\left(\right)} + c \cdot \mathsf{PI}\left(\right)\right), \mathsf{neg}\left(cosTheta\right), \sqrt{\mathsf{PI}\left(\right)}\right) \]
      3. +-commutativeN/A

        \[\leadsto cosTheta \cdot \mathsf{fma}\left(\mathsf{PI}\left(\right) + \color{blue}{\left(c \cdot \mathsf{PI}\left(\right) + -1 \cdot \sqrt{\mathsf{PI}\left(\right)}\right)}, \mathsf{neg}\left(cosTheta\right), \sqrt{\mathsf{PI}\left(\right)}\right) \]
      4. *-commutativeN/A

        \[\leadsto cosTheta \cdot \mathsf{fma}\left(\mathsf{PI}\left(\right) + \left(\color{blue}{\mathsf{PI}\left(\right) \cdot c} + -1 \cdot \sqrt{\mathsf{PI}\left(\right)}\right), \mathsf{neg}\left(cosTheta\right), \sqrt{\mathsf{PI}\left(\right)}\right) \]
      5. accelerator-lowering-fma.f32N/A

        \[\leadsto cosTheta \cdot \mathsf{fma}\left(\mathsf{PI}\left(\right) + \color{blue}{\mathsf{fma}\left(\mathsf{PI}\left(\right), c, -1 \cdot \sqrt{\mathsf{PI}\left(\right)}\right)}, \mathsf{neg}\left(cosTheta\right), \sqrt{\mathsf{PI}\left(\right)}\right) \]
      6. PI-lowering-PI.f32N/A

        \[\leadsto cosTheta \cdot \mathsf{fma}\left(\mathsf{PI}\left(\right) + \mathsf{fma}\left(\color{blue}{\mathsf{PI}\left(\right)}, c, -1 \cdot \sqrt{\mathsf{PI}\left(\right)}\right), \mathsf{neg}\left(cosTheta\right), \sqrt{\mathsf{PI}\left(\right)}\right) \]
      7. mul-1-negN/A

        \[\leadsto cosTheta \cdot \mathsf{fma}\left(\mathsf{PI}\left(\right) + \mathsf{fma}\left(\mathsf{PI}\left(\right), c, \color{blue}{\mathsf{neg}\left(\sqrt{\mathsf{PI}\left(\right)}\right)}\right), \mathsf{neg}\left(cosTheta\right), \sqrt{\mathsf{PI}\left(\right)}\right) \]
      8. neg-lowering-neg.f32N/A

        \[\leadsto cosTheta \cdot \mathsf{fma}\left(\mathsf{PI}\left(\right) + \mathsf{fma}\left(\mathsf{PI}\left(\right), c, \color{blue}{\mathsf{neg}\left(\sqrt{\mathsf{PI}\left(\right)}\right)}\right), \mathsf{neg}\left(cosTheta\right), \sqrt{\mathsf{PI}\left(\right)}\right) \]
      9. sqrt-lowering-sqrt.f32N/A

        \[\leadsto cosTheta \cdot \mathsf{fma}\left(\mathsf{PI}\left(\right) + \mathsf{fma}\left(\mathsf{PI}\left(\right), c, \mathsf{neg}\left(\color{blue}{\sqrt{\mathsf{PI}\left(\right)}}\right)\right), \mathsf{neg}\left(cosTheta\right), \sqrt{\mathsf{PI}\left(\right)}\right) \]
      10. PI-lowering-PI.f3296.1

        \[\leadsto cosTheta \cdot \mathsf{fma}\left(\pi + \mathsf{fma}\left(\pi, c, -\sqrt{\color{blue}{\pi}}\right), -cosTheta, \sqrt{\pi}\right) \]
    8. Simplified96.1%

      \[\leadsto cosTheta \cdot \mathsf{fma}\left(\color{blue}{\pi + \mathsf{fma}\left(\pi, c, -\sqrt{\pi}\right)}, -cosTheta, \sqrt{\pi}\right) \]
    9. Add Preprocessing

    Alternative 9: 95.4% accurate, 4.9× speedup?

    \[\begin{array}{l} \\ cosTheta \cdot \mathsf{fma}\left(\pi - \sqrt{\pi}, -cosTheta, \sqrt{\pi}\right) \end{array} \]
    (FPCore (cosTheta c)
     :precision binary32
     (* cosTheta (fma (- PI (sqrt PI)) (- cosTheta) (sqrt PI))))
    float code(float cosTheta, float c) {
    	return cosTheta * fmaf((((float) M_PI) - sqrtf(((float) M_PI))), -cosTheta, sqrtf(((float) M_PI)));
    }
    
    function code(cosTheta, c)
    	return Float32(cosTheta * fma(Float32(Float32(pi) - sqrt(Float32(pi))), Float32(-cosTheta), sqrt(Float32(pi))))
    end
    
    \begin{array}{l}
    
    \\
    cosTheta \cdot \mathsf{fma}\left(\pi - \sqrt{\pi}, -cosTheta, \sqrt{\pi}\right)
    \end{array}
    
    Derivation
    1. Initial program 97.6%

      \[\frac{1}{\left(1 + c\right) + \left(\frac{1}{\sqrt{\pi}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\left(-cosTheta\right) \cdot cosTheta}} \]
    2. Add Preprocessing
    3. Taylor expanded in cosTheta around 0

      \[\leadsto \color{blue}{cosTheta \cdot \left(\sqrt{\mathsf{PI}\left(\right)} + -1 \cdot \left(cosTheta \cdot \left(\mathsf{PI}\left(\right) \cdot \left(1 + \left(c + -1 \cdot \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)\right)\right)\right)\right)} \]
    4. Step-by-step derivation
      1. *-lowering-*.f32N/A

        \[\leadsto \color{blue}{cosTheta \cdot \left(\sqrt{\mathsf{PI}\left(\right)} + -1 \cdot \left(cosTheta \cdot \left(\mathsf{PI}\left(\right) \cdot \left(1 + \left(c + -1 \cdot \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)\right)\right)\right)\right)} \]
      2. +-commutativeN/A

        \[\leadsto cosTheta \cdot \color{blue}{\left(-1 \cdot \left(cosTheta \cdot \left(\mathsf{PI}\left(\right) \cdot \left(1 + \left(c + -1 \cdot \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)\right)\right)\right) + \sqrt{\mathsf{PI}\left(\right)}\right)} \]
      3. associate-*r*N/A

        \[\leadsto cosTheta \cdot \left(\color{blue}{\left(-1 \cdot cosTheta\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \left(1 + \left(c + -1 \cdot \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)\right)\right)} + \sqrt{\mathsf{PI}\left(\right)}\right) \]
      4. *-commutativeN/A

        \[\leadsto cosTheta \cdot \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot \left(1 + \left(c + -1 \cdot \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)\right)\right) \cdot \left(-1 \cdot cosTheta\right)} + \sqrt{\mathsf{PI}\left(\right)}\right) \]
      5. accelerator-lowering-fma.f32N/A

        \[\leadsto cosTheta \cdot \color{blue}{\mathsf{fma}\left(\mathsf{PI}\left(\right) \cdot \left(1 + \left(c + -1 \cdot \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)\right), -1 \cdot cosTheta, \sqrt{\mathsf{PI}\left(\right)}\right)} \]
    5. Simplified96.1%

      \[\leadsto \color{blue}{cosTheta \cdot \mathsf{fma}\left(\mathsf{fma}\left(\pi, c - \sqrt{\frac{1}{\pi}}, \pi\right), -cosTheta, \sqrt{\pi}\right)} \]
    6. Taylor expanded in c around 0

      \[\leadsto cosTheta \cdot \mathsf{fma}\left(\color{blue}{\mathsf{PI}\left(\right) + -1 \cdot \sqrt{\mathsf{PI}\left(\right)}}, \mathsf{neg}\left(cosTheta\right), \sqrt{\mathsf{PI}\left(\right)}\right) \]
    7. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto cosTheta \cdot \mathsf{fma}\left(\mathsf{PI}\left(\right) + \color{blue}{\left(\mathsf{neg}\left(\sqrt{\mathsf{PI}\left(\right)}\right)\right)}, \mathsf{neg}\left(cosTheta\right), \sqrt{\mathsf{PI}\left(\right)}\right) \]
      2. unsub-negN/A

        \[\leadsto cosTheta \cdot \mathsf{fma}\left(\color{blue}{\mathsf{PI}\left(\right) - \sqrt{\mathsf{PI}\left(\right)}}, \mathsf{neg}\left(cosTheta\right), \sqrt{\mathsf{PI}\left(\right)}\right) \]
      3. --lowering--.f32N/A

        \[\leadsto cosTheta \cdot \mathsf{fma}\left(\color{blue}{\mathsf{PI}\left(\right) - \sqrt{\mathsf{PI}\left(\right)}}, \mathsf{neg}\left(cosTheta\right), \sqrt{\mathsf{PI}\left(\right)}\right) \]
      4. PI-lowering-PI.f32N/A

        \[\leadsto cosTheta \cdot \mathsf{fma}\left(\color{blue}{\mathsf{PI}\left(\right)} - \sqrt{\mathsf{PI}\left(\right)}, \mathsf{neg}\left(cosTheta\right), \sqrt{\mathsf{PI}\left(\right)}\right) \]
      5. sqrt-lowering-sqrt.f32N/A

        \[\leadsto cosTheta \cdot \mathsf{fma}\left(\mathsf{PI}\left(\right) - \color{blue}{\sqrt{\mathsf{PI}\left(\right)}}, \mathsf{neg}\left(cosTheta\right), \sqrt{\mathsf{PI}\left(\right)}\right) \]
      6. PI-lowering-PI.f3296.1

        \[\leadsto cosTheta \cdot \mathsf{fma}\left(\pi - \sqrt{\color{blue}{\pi}}, -cosTheta, \sqrt{\pi}\right) \]
    8. Simplified96.1%

      \[\leadsto cosTheta \cdot \mathsf{fma}\left(\color{blue}{\pi - \sqrt{\pi}}, -cosTheta, \sqrt{\pi}\right) \]
    9. Add Preprocessing

    Alternative 10: 92.7% accurate, 6.3× speedup?

    \[\begin{array}{l} \\ cosTheta \cdot \mathsf{fma}\left(c \cdot \pi, -cosTheta, \sqrt{\pi}\right) \end{array} \]
    (FPCore (cosTheta c)
     :precision binary32
     (* cosTheta (fma (* c PI) (- cosTheta) (sqrt PI))))
    float code(float cosTheta, float c) {
    	return cosTheta * fmaf((c * ((float) M_PI)), -cosTheta, sqrtf(((float) M_PI)));
    }
    
    function code(cosTheta, c)
    	return Float32(cosTheta * fma(Float32(c * Float32(pi)), Float32(-cosTheta), sqrt(Float32(pi))))
    end
    
    \begin{array}{l}
    
    \\
    cosTheta \cdot \mathsf{fma}\left(c \cdot \pi, -cosTheta, \sqrt{\pi}\right)
    \end{array}
    
    Derivation
    1. Initial program 97.6%

      \[\frac{1}{\left(1 + c\right) + \left(\frac{1}{\sqrt{\pi}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\left(-cosTheta\right) \cdot cosTheta}} \]
    2. Add Preprocessing
    3. Taylor expanded in cosTheta around 0

      \[\leadsto \color{blue}{cosTheta \cdot \left(\sqrt{\mathsf{PI}\left(\right)} + -1 \cdot \left(cosTheta \cdot \left(\mathsf{PI}\left(\right) \cdot \left(1 + \left(c + -1 \cdot \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)\right)\right)\right)\right)} \]
    4. Step-by-step derivation
      1. *-lowering-*.f32N/A

        \[\leadsto \color{blue}{cosTheta \cdot \left(\sqrt{\mathsf{PI}\left(\right)} + -1 \cdot \left(cosTheta \cdot \left(\mathsf{PI}\left(\right) \cdot \left(1 + \left(c + -1 \cdot \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)\right)\right)\right)\right)} \]
      2. +-commutativeN/A

        \[\leadsto cosTheta \cdot \color{blue}{\left(-1 \cdot \left(cosTheta \cdot \left(\mathsf{PI}\left(\right) \cdot \left(1 + \left(c + -1 \cdot \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)\right)\right)\right) + \sqrt{\mathsf{PI}\left(\right)}\right)} \]
      3. associate-*r*N/A

        \[\leadsto cosTheta \cdot \left(\color{blue}{\left(-1 \cdot cosTheta\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \left(1 + \left(c + -1 \cdot \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)\right)\right)} + \sqrt{\mathsf{PI}\left(\right)}\right) \]
      4. *-commutativeN/A

        \[\leadsto cosTheta \cdot \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot \left(1 + \left(c + -1 \cdot \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)\right)\right) \cdot \left(-1 \cdot cosTheta\right)} + \sqrt{\mathsf{PI}\left(\right)}\right) \]
      5. accelerator-lowering-fma.f32N/A

        \[\leadsto cosTheta \cdot \color{blue}{\mathsf{fma}\left(\mathsf{PI}\left(\right) \cdot \left(1 + \left(c + -1 \cdot \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)\right), -1 \cdot cosTheta, \sqrt{\mathsf{PI}\left(\right)}\right)} \]
    5. Simplified96.1%

      \[\leadsto \color{blue}{cosTheta \cdot \mathsf{fma}\left(\mathsf{fma}\left(\pi, c - \sqrt{\frac{1}{\pi}}, \pi\right), -cosTheta, \sqrt{\pi}\right)} \]
    6. Taylor expanded in c around inf

      \[\leadsto cosTheta \cdot \mathsf{fma}\left(\color{blue}{c \cdot \mathsf{PI}\left(\right)}, \mathsf{neg}\left(cosTheta\right), \sqrt{\mathsf{PI}\left(\right)}\right) \]
    7. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto cosTheta \cdot \mathsf{fma}\left(\color{blue}{\mathsf{PI}\left(\right) \cdot c}, \mathsf{neg}\left(cosTheta\right), \sqrt{\mathsf{PI}\left(\right)}\right) \]
      2. *-lowering-*.f32N/A

        \[\leadsto cosTheta \cdot \mathsf{fma}\left(\color{blue}{\mathsf{PI}\left(\right) \cdot c}, \mathsf{neg}\left(cosTheta\right), \sqrt{\mathsf{PI}\left(\right)}\right) \]
      3. PI-lowering-PI.f3294.0

        \[\leadsto cosTheta \cdot \mathsf{fma}\left(\color{blue}{\pi} \cdot c, -cosTheta, \sqrt{\pi}\right) \]
    8. Simplified94.0%

      \[\leadsto cosTheta \cdot \mathsf{fma}\left(\color{blue}{\pi \cdot c}, -cosTheta, \sqrt{\pi}\right) \]
    9. Final simplification94.0%

      \[\leadsto cosTheta \cdot \mathsf{fma}\left(c \cdot \pi, -cosTheta, \sqrt{\pi}\right) \]
    10. Add Preprocessing

    Alternative 11: 92.7% accurate, 11.4× speedup?

    \[\begin{array}{l} \\ cosTheta \cdot \sqrt{\pi} \end{array} \]
    (FPCore (cosTheta c) :precision binary32 (* cosTheta (sqrt PI)))
    float code(float cosTheta, float c) {
    	return cosTheta * sqrtf(((float) M_PI));
    }
    
    function code(cosTheta, c)
    	return Float32(cosTheta * sqrt(Float32(pi)))
    end
    
    function tmp = code(cosTheta, c)
    	tmp = cosTheta * sqrt(single(pi));
    end
    
    \begin{array}{l}
    
    \\
    cosTheta \cdot \sqrt{\pi}
    \end{array}
    
    Derivation
    1. Initial program 97.6%

      \[\frac{1}{\left(1 + c\right) + \left(\frac{1}{\sqrt{\pi}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\left(-cosTheta\right) \cdot cosTheta}} \]
    2. Add Preprocessing
    3. Taylor expanded in cosTheta around 0

      \[\leadsto \color{blue}{cosTheta \cdot \sqrt{\mathsf{PI}\left(\right)}} \]
    4. Step-by-step derivation
      1. *-lowering-*.f32N/A

        \[\leadsto \color{blue}{cosTheta \cdot \sqrt{\mathsf{PI}\left(\right)}} \]
      2. sqrt-lowering-sqrt.f32N/A

        \[\leadsto cosTheta \cdot \color{blue}{\sqrt{\mathsf{PI}\left(\right)}} \]
      3. PI-lowering-PI.f3294.0

        \[\leadsto cosTheta \cdot \sqrt{\color{blue}{\pi}} \]
    5. Simplified94.0%

      \[\leadsto \color{blue}{cosTheta \cdot \sqrt{\pi}} \]
    6. Add Preprocessing

    Alternative 12: 5.0% accurate, 15.3× speedup?

    \[\begin{array}{l} \\ \frac{1}{c} \end{array} \]
    (FPCore (cosTheta c) :precision binary32 (/ 1.0 c))
    float code(float cosTheta, float c) {
    	return 1.0f / c;
    }
    
    real(4) function code(costheta, c)
        real(4), intent (in) :: costheta
        real(4), intent (in) :: c
        code = 1.0e0 / c
    end function
    
    function code(cosTheta, c)
    	return Float32(Float32(1.0) / c)
    end
    
    function tmp = code(cosTheta, c)
    	tmp = single(1.0) / c;
    end
    
    \begin{array}{l}
    
    \\
    \frac{1}{c}
    \end{array}
    
    Derivation
    1. Initial program 97.6%

      \[\frac{1}{\left(1 + c\right) + \left(\frac{1}{\sqrt{\pi}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\left(-cosTheta\right) \cdot cosTheta}} \]
    2. Add Preprocessing
    3. Taylor expanded in c around inf

      \[\leadsto \color{blue}{\frac{1}{c}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f324.7

        \[\leadsto \color{blue}{\frac{1}{c}} \]
    5. Simplified4.7%

      \[\leadsto \color{blue}{\frac{1}{c}} \]
    6. Add Preprocessing

    Reproduce

    ?
    herbie shell --seed 2024199 
    (FPCore (cosTheta c)
      :name "Beckmann Sample, normalization factor"
      :precision binary32
      :pre (and (and (< 0.0 cosTheta) (< cosTheta 0.9999)) (and (< -1.0 c) (< c 1.0)))
      (/ 1.0 (+ (+ 1.0 c) (* (* (/ 1.0 (sqrt PI)) (/ (sqrt (- (- 1.0 cosTheta) cosTheta)) cosTheta)) (exp (* (- cosTheta) cosTheta))))))