Beckmann Sample, normalization factor

Percentage Accurate: 97.8% → 98.2%
Time: 13.8s
Alternatives: 12
Speedup: 2.2×

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.2% accurate, 2.1× speedup?

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

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

    \[\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 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\mathsf{fma}\left(\frac{\mathsf{fma}\left(cosTheta \cdot cosTheta, \mathsf{fma}\left(\color{blue}{cosTheta \cdot cosTheta}, \frac{1}{2}, -1\right), 1\right)}{cosTheta}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, 1 + c\right)} \]
    11. lower-*.f3297.9

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

    \[\leadsto \frac{1}{\mathsf{fma}\left(\color{blue}{\frac{\mathsf{fma}\left(cosTheta \cdot cosTheta, \mathsf{fma}\left(cosTheta \cdot cosTheta, 0.5, -1\right), 1\right)}{cosTheta}}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}, 1 + c\right)} \]
  9. Step-by-step derivation
    1. lift-*.f32N/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(cosTheta \cdot cosTheta, \mathsf{fma}\left(cosTheta \cdot cosTheta, \frac{1}{2}, -1\right), 1\right)}{cosTheta} \cdot \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}} + \color{blue}{\left(1 + c\right)}} \]
  10. Applied egg-rr98.0%

    \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(cosTheta, cosTheta \cdot \mathsf{fma}\left(cosTheta \cdot cosTheta, 0.5, -1\right), 1\right), \frac{\sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}}{cosTheta}, 1 + c\right)}} \]
  11. Step-by-step derivation
    1. lift-fma.f32N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 98.1% accurate, 2.2× speedup?

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

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

    \[\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 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\mathsf{fma}\left(\frac{\mathsf{fma}\left(cosTheta \cdot cosTheta, \mathsf{fma}\left(\color{blue}{cosTheta \cdot cosTheta}, \frac{1}{2}, -1\right), 1\right)}{cosTheta}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, 1 + c\right)} \]
    11. lower-*.f3297.9

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

    \[\leadsto \frac{1}{\mathsf{fma}\left(\color{blue}{\frac{\mathsf{fma}\left(cosTheta \cdot cosTheta, \mathsf{fma}\left(cosTheta \cdot cosTheta, 0.5, -1\right), 1\right)}{cosTheta}}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}, 1 + c\right)} \]
  9. Step-by-step derivation
    1. lift-*.f32N/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(cosTheta \cdot cosTheta, \mathsf{fma}\left(cosTheta \cdot cosTheta, \frac{1}{2}, -1\right), 1\right)}{cosTheta} \cdot \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}} + \color{blue}{\left(1 + c\right)}} \]
  10. Applied egg-rr98.0%

    \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(cosTheta, cosTheta \cdot \mathsf{fma}\left(cosTheta \cdot cosTheta, 0.5, -1\right), 1\right), \frac{\sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}}{cosTheta}, 1 + c\right)}} \]
  11. Step-by-step derivation
    1. lift-fma.f32N/A

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(cosTheta, cosTheta \cdot \mathsf{fma}\left(cosTheta \cdot cosTheta, \frac{1}{2}, -1\right), 1\right), \frac{\frac{\sqrt{\mathsf{fma}\left(cosTheta, -2, 1\right)}}{\color{blue}{\sqrt{\mathsf{PI}\left(\right)}}}}{cosTheta}, 1 + c\right)} \]
    9. associate-/l/N/A

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

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

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

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

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

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

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

Alternative 3: 97.6% accurate, 2.3× speedup?

\[\begin{array}{l} \\ \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(cosTheta, cosTheta \cdot \mathsf{fma}\left(cosTheta \cdot cosTheta, 0.5, -1\right), 1\right), \frac{\sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}}{cosTheta}, 1 + c\right)} \end{array} \]
(FPCore (cosTheta c)
 :precision binary32
 (/
  1.0
  (fma
   (fma cosTheta (* cosTheta (fma (* cosTheta cosTheta) 0.5 -1.0)) 1.0)
   (/ (sqrt (/ (fma cosTheta -2.0 1.0) PI)) cosTheta)
   (+ 1.0 c))))
float code(float cosTheta, float c) {
	return 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), (1.0f + c));
}
function code(cosTheta, c)
	return Float32(Float32(1.0) / fma(fma(cosTheta, Float32(cosTheta * fma(Float32(cosTheta * cosTheta), Float32(0.5), Float32(-1.0))), Float32(1.0)), Float32(sqrt(Float32(fma(cosTheta, Float32(-2.0), Float32(1.0)) / Float32(pi))) / cosTheta), Float32(Float32(1.0) + c)))
end
\begin{array}{l}

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

    \[\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 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\mathsf{fma}\left(\frac{\mathsf{fma}\left(cosTheta \cdot cosTheta, \mathsf{fma}\left(\color{blue}{cosTheta \cdot cosTheta}, \frac{1}{2}, -1\right), 1\right)}{cosTheta}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, 1 + c\right)} \]
    11. lower-*.f3297.9

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

    \[\leadsto \frac{1}{\mathsf{fma}\left(\color{blue}{\frac{\mathsf{fma}\left(cosTheta \cdot cosTheta, \mathsf{fma}\left(cosTheta \cdot cosTheta, 0.5, -1\right), 1\right)}{cosTheta}}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}, 1 + c\right)} \]
  9. Step-by-step derivation
    1. lift-*.f32N/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(cosTheta \cdot cosTheta, \mathsf{fma}\left(cosTheta \cdot cosTheta, \frac{1}{2}, -1\right), 1\right)}{cosTheta} \cdot \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}} + \color{blue}{\left(1 + c\right)}} \]
  10. Applied egg-rr98.0%

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

Alternative 4: 97.6% accurate, 2.3× speedup?

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

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

    \[\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 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\mathsf{fma}\left(\frac{\mathsf{fma}\left(cosTheta \cdot cosTheta, \mathsf{fma}\left(\color{blue}{cosTheta \cdot cosTheta}, \frac{1}{2}, -1\right), 1\right)}{cosTheta}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, 1 + c\right)} \]
    11. lower-*.f3297.9

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

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

Alternative 5: 97.2% accurate, 2.3× speedup?

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

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

    \[\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 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\mathsf{fma}\left(\frac{\mathsf{fma}\left(cosTheta \cdot cosTheta, \mathsf{fma}\left(\color{blue}{cosTheta \cdot cosTheta}, \frac{1}{2}, -1\right), 1\right)}{cosTheta}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, 1 + c\right)} \]
    11. lower-*.f3297.9

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

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

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

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

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

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

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

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

Alternative 6: 97.1% accurate, 2.7× speedup?

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

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

    \[\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 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\mathsf{fma}\left(\frac{\mathsf{fma}\left(cosTheta \cdot cosTheta, \mathsf{fma}\left(\color{blue}{cosTheta \cdot cosTheta}, \frac{1}{2}, -1\right), 1\right)}{cosTheta}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, 1 + c\right)} \]
    11. lower-*.f3297.9

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

    \[\leadsto \frac{1}{\mathsf{fma}\left(\color{blue}{\frac{\mathsf{fma}\left(cosTheta \cdot cosTheta, \mathsf{fma}\left(cosTheta \cdot cosTheta, 0.5, -1\right), 1\right)}{cosTheta}}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}, 1 + c\right)} \]
  9. Step-by-step derivation
    1. lift-*.f32N/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(cosTheta \cdot cosTheta, \mathsf{fma}\left(cosTheta \cdot cosTheta, \frac{1}{2}, -1\right), 1\right)}{cosTheta} \cdot \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}} + \color{blue}{\left(1 + c\right)}} \]
  10. Applied egg-rr98.0%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(cosTheta, \color{blue}{\mathsf{neg}\left(cosTheta\right)}, 1\right), \frac{\sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}}{cosTheta}, 1 + c\right)} \]
    8. lower-neg.f3297.5

      \[\leadsto \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(cosTheta, \color{blue}{-cosTheta}, 1\right), \frac{\sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}}{cosTheta}, 1 + c\right)} \]
  13. Simplified97.5%

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

Alternative 7: 97.0% accurate, 2.7× speedup?

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

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

    \[\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 0

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\mathsf{fma}\left(\frac{\mathsf{fma}\left(cosTheta, \color{blue}{\mathsf{neg}\left(cosTheta\right)}, 1\right)}{cosTheta}, \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\mathsf{PI}\left(\right)}}, 1 + c\right)} \]
    9. lower-neg.f3297.4

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

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

Alternative 8: 95.7% accurate, 2.7× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{-1}{\sqrt{\pi}}\\
\left(-cosTheta \cdot \pi\right) \cdot \mathsf{fma}\left(cosTheta, 1 + \left(c + t\_0\right), t\_0\right)
\end{array}
\end{array}
Derivation
  1. Initial program 97.9%

    \[\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 \frac{1}{\color{blue}{\frac{\sqrt{\frac{1}{\mathsf{PI}\left(\right)}} + cosTheta \cdot \left(1 + \left(c + -1 \cdot \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)\right)}{cosTheta}}} \]
  4. Step-by-step derivation
    1. lower-/.f32N/A

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

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

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

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

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

      \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(cosTheta, \color{blue}{\left(1 + c\right) - \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}}, \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)}{cosTheta}} \]
    7. lower--.f32N/A

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

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

      \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(cosTheta, \left(1 + c\right) - \color{blue}{\sqrt{\frac{1}{\mathsf{PI}\left(\right)}}}, \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)}{cosTheta}} \]
    10. lower-/.f32N/A

      \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(cosTheta, \left(1 + c\right) - \sqrt{\color{blue}{\frac{1}{\mathsf{PI}\left(\right)}}}, \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)}{cosTheta}} \]
    11. lower-PI.f32N/A

      \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(cosTheta, \left(1 + c\right) - \sqrt{\frac{1}{\color{blue}{\mathsf{PI}\left(\right)}}}, \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)}{cosTheta}} \]
    12. lower-sqrt.f32N/A

      \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(cosTheta, \left(1 + c\right) - \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}, \color{blue}{\sqrt{\frac{1}{\mathsf{PI}\left(\right)}}}\right)}{cosTheta}} \]
    13. lower-/.f32N/A

      \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(cosTheta, \left(1 + c\right) - \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}, \sqrt{\color{blue}{\frac{1}{\mathsf{PI}\left(\right)}}}\right)}{cosTheta}} \]
    14. lower-PI.f3295.4

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

    \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{fma}\left(cosTheta, \left(1 + c\right) - \sqrt{\frac{1}{\pi}}, \sqrt{\frac{1}{\pi}}\right)}{cosTheta}}} \]
  6. Applied egg-rr96.4%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 95.8% accurate, 3.4× speedup?

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

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

    \[\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. lower-*.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. lower-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.0%

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

Alternative 10: 95.7% accurate, 3.5× speedup?

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

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

    \[\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 \frac{1}{\color{blue}{\frac{\sqrt{\frac{1}{\mathsf{PI}\left(\right)}} + cosTheta \cdot \left(1 + \left(c + -1 \cdot \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)\right)}{cosTheta}}} \]
  4. Step-by-step derivation
    1. lower-/.f32N/A

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

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

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

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

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

      \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(cosTheta, \color{blue}{\left(1 + c\right) - \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}}, \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)}{cosTheta}} \]
    7. lower--.f32N/A

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

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

      \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(cosTheta, \left(1 + c\right) - \color{blue}{\sqrt{\frac{1}{\mathsf{PI}\left(\right)}}}, \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)}{cosTheta}} \]
    10. lower-/.f32N/A

      \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(cosTheta, \left(1 + c\right) - \sqrt{\color{blue}{\frac{1}{\mathsf{PI}\left(\right)}}}, \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)}{cosTheta}} \]
    11. lower-PI.f32N/A

      \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(cosTheta, \left(1 + c\right) - \sqrt{\frac{1}{\color{blue}{\mathsf{PI}\left(\right)}}}, \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)}{cosTheta}} \]
    12. lower-sqrt.f32N/A

      \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(cosTheta, \left(1 + c\right) - \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}, \color{blue}{\sqrt{\frac{1}{\mathsf{PI}\left(\right)}}}\right)}{cosTheta}} \]
    13. lower-/.f32N/A

      \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(cosTheta, \left(1 + c\right) - \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}, \sqrt{\color{blue}{\frac{1}{\mathsf{PI}\left(\right)}}}\right)}{cosTheta}} \]
    14. lower-PI.f3295.4

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{cosTheta}{\mathsf{fma}\left(cosTheta, 1 - \sqrt{\frac{1}{\color{blue}{\mathsf{PI}\left(\right)}}}, \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)} \]
    8. lower-sqrt.f32N/A

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

      \[\leadsto \frac{cosTheta}{\mathsf{fma}\left(cosTheta, 1 - \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}, \sqrt{\color{blue}{\frac{1}{\mathsf{PI}\left(\right)}}}\right)} \]
    10. lower-PI.f3295.1

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

    \[\leadsto \color{blue}{\frac{cosTheta}{\mathsf{fma}\left(cosTheta, 1 - \sqrt{\frac{1}{\pi}}, \sqrt{\frac{1}{\pi}}\right)}} \]
  9. 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 - \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)\right)\right)\right)} \]
  10. Step-by-step derivation
    1. lower-*.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 - \sqrt{\frac{1}{\mathsf{PI}\left(\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 - \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)\right)\right) + \sqrt{\mathsf{PI}\left(\right)}\right)} \]
    3. mul-1-negN/A

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

      \[\leadsto cosTheta \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\left(cosTheta \cdot \mathsf{PI}\left(\right)\right) \cdot \left(1 - \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)}\right)\right) + \sqrt{\mathsf{PI}\left(\right)}\right) \]
    5. distribute-lft-neg-inN/A

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

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

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

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

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

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

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

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

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

      \[\leadsto cosTheta \cdot \mathsf{fma}\left(\mathsf{neg}\left(cosTheta \cdot \mathsf{PI}\left(\right)\right), 1 - \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}, \color{blue}{\sqrt{\mathsf{PI}\left(\right)}}\right) \]
    15. lower-PI.f3295.8

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

    \[\leadsto \color{blue}{cosTheta \cdot \mathsf{fma}\left(-cosTheta \cdot \pi, 1 - \sqrt{\frac{1}{\pi}}, \sqrt{\pi}\right)} \]
  12. 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.9%

    \[\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. lower-*.f32N/A

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

      \[\leadsto cosTheta \cdot \color{blue}{\sqrt{\mathsf{PI}\left(\right)}} \]
    3. lower-PI.f3292.8

      \[\leadsto cosTheta \cdot \sqrt{\color{blue}{\pi}} \]
  5. Simplified92.8%

    \[\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.9%

    \[\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. lower-/.f325.0

      \[\leadsto \color{blue}{\frac{1}{c}} \]
  5. Simplified5.0%

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

Reproduce

?
herbie shell --seed 2024208 
(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))))))