Beckmann Sample, normalization factor

Percentage Accurate: 97.9% → 98.5%
Time: 14.3s
Alternatives: 14
Speedup: 1.5×

Specification

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

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

Sampling outcomes in binary32 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 14 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.9% accurate, 1.0× speedup?

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

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

Alternative 1: 98.5% accurate, 1.0× speedup?

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

\\
\frac{1}{c + \left(1 + \frac{\sqrt{1 - cosTheta \cdot 2}}{\sqrt{\pi} \cdot \left(cosTheta \cdot e^{cosTheta \cdot cosTheta}\right)}\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. Step-by-step derivation
    1. /-lowering-/.f32N/A

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

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

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

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

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

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

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

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \left(\left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\mathsf{neg}\left(cosTheta \cdot cosTheta\right)}\right)\right)\right)\right) \]
    9. exp-negN/A

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

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

Alternative 2: 98.1% accurate, 1.5× speedup?

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

\\
\frac{1}{\left(1 + c\right) + \frac{\sqrt{\frac{1 + cosTheta \cdot -2}{\pi}}}{cosTheta \cdot e^{cosTheta \cdot cosTheta}}}
\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. Step-by-step derivation
    1. /-lowering-/.f32N/A

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

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

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

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

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

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

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

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \left(\left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\mathsf{neg}\left(cosTheta \cdot cosTheta\right)}\right)\right)\right)\right) \]
    9. exp-negN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 98.1% accurate, 1.5× speedup?

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

\\
\frac{1}{1 + \left(c + \frac{\sqrt{\frac{1 + cosTheta \cdot -2}{\pi}}}{cosTheta \cdot e^{cosTheta \cdot cosTheta}}\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. Step-by-step derivation
    1. /-lowering-/.f32N/A

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

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

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

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

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

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

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

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \left(\left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\mathsf{neg}\left(cosTheta \cdot cosTheta\right)}\right)\right)\right)\right) \]
    9. exp-negN/A

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

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

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

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

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

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

    \[\leadsto \frac{1}{\color{blue}{1 + \left(\frac{\sqrt{\frac{1 + cosTheta \cdot -2}{\pi}}}{cosTheta \cdot e^{cosTheta \cdot cosTheta}} + c\right)}} \]
  8. Final simplification98.0%

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

Alternative 4: 97.6% accurate, 2.6× speedup?

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

\\
\frac{1}{c + \left(1 + \frac{\frac{1}{cosTheta \cdot \sqrt{\frac{\pi}{1 + cosTheta \cdot -2}}}}{1 + cosTheta \cdot cosTheta}\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. Step-by-step derivation
    1. /-lowering-/.f32N/A

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

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

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

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

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

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

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

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \left(\left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\mathsf{neg}\left(cosTheta \cdot cosTheta\right)}\right)\right)\right)\right) \]
    9. exp-negN/A

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

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

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

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, 2\right)\right)\right), \left(\left(\sqrt{\mathsf{PI}\left(\right)} + {cosTheta}^{2} \cdot \sqrt{\mathsf{PI}\left(\right)}\right) \cdot \color{blue}{cosTheta}\right)\right)\right)\right)\right) \]
    2. distribute-rgt1-inN/A

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, 2\right)\right)\right), \left(\left(\left({cosTheta}^{2} + 1\right) \cdot \sqrt{\mathsf{PI}\left(\right)}\right) \cdot cosTheta\right)\right)\right)\right)\right) \]
    3. associate-*l*N/A

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

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

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

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, 2\right)\right)\right), \mathsf{*.f32}\left(\mathsf{+.f32}\left(\left({cosTheta}^{2}\right), 1\right), \left(\color{blue}{cosTheta} \cdot \sqrt{\mathsf{PI}\left(\right)}\right)\right)\right)\right)\right)\right) \]
    7. unpow2N/A

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, 2\right)\right)\right), \mathsf{*.f32}\left(\mathsf{+.f32}\left(\left(cosTheta \cdot cosTheta\right), 1\right), \left(cosTheta \cdot \sqrt{\mathsf{PI}\left(\right)}\right)\right)\right)\right)\right)\right) \]
    8. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, 2\right)\right)\right), \mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(cosTheta, cosTheta\right), 1\right), \left(cosTheta \cdot \sqrt{\mathsf{PI}\left(\right)}\right)\right)\right)\right)\right)\right) \]
    9. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, 2\right)\right)\right), \mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(cosTheta, cosTheta\right), 1\right), \mathsf{*.f32}\left(cosTheta, \color{blue}{\left(\sqrt{\mathsf{PI}\left(\right)}\right)}\right)\right)\right)\right)\right)\right) \]
    10. sqrt-lowering-sqrt.f32N/A

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, 2\right)\right)\right), \mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(cosTheta, cosTheta\right), 1\right), \mathsf{*.f32}\left(cosTheta, \mathsf{sqrt.f32}\left(\mathsf{PI}\left(\right)\right)\right)\right)\right)\right)\right)\right) \]
    11. PI-lowering-PI.f3298.0%

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, 2\right)\right)\right), \mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(cosTheta, cosTheta\right), 1\right), \mathsf{*.f32}\left(cosTheta, \mathsf{sqrt.f32}\left(\mathsf{PI.f32}\left(\right)\right)\right)\right)\right)\right)\right)\right) \]
  7. Simplified98.0%

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

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

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

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

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \left(\frac{\frac{{\left(1 - 2 \cdot cosTheta\right)}^{\frac{1}{2}}}{cosTheta \cdot \sqrt{\mathsf{PI}\left(\right)}}}{cosTheta \cdot cosTheta + 1}\right)\right)\right)\right) \]
    5. cancel-sign-sub-invN/A

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

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

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \left(\frac{\frac{{\left(1 + cosTheta \cdot -2\right)}^{\frac{1}{2}}}{cosTheta \cdot \sqrt{\mathsf{PI}\left(\right)}}}{cosTheta \cdot cosTheta + 1}\right)\right)\right)\right) \]
    8. pow1/2N/A

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \left(\frac{\frac{{\left(1 + cosTheta \cdot -2\right)}^{\frac{1}{2}}}{cosTheta \cdot {\mathsf{PI}\left(\right)}^{\frac{1}{2}}}}{cosTheta \cdot cosTheta + 1}\right)\right)\right)\right) \]
    9. *-commutativeN/A

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

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

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

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

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

Alternative 5: 97.3% accurate, 2.6× speedup?

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

\\
\frac{1}{1 + \frac{\frac{1 + cosTheta \cdot \left(-1 + cosTheta \cdot \left(-1.5 + cosTheta \cdot 0.5\right)\right)}{cosTheta}}{{\pi}^{0.5}}}
\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. Applied egg-rr98.5%

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

    \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\color{blue}{1}, \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{neg.f32}\left(\mathsf{*.f32}\left(cosTheta, cosTheta\right)\right)\right), \mathsf{*.f32}\left(cosTheta, \mathsf{pow.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(cosTheta, -2\right)\right), \frac{-1}{2}\right)\right)\right), \mathsf{pow.f32}\left(\mathsf{PI.f32}\left(\right), \frac{1}{2}\right)\right)\right)\right) \]
  5. Step-by-step derivation
    1. Simplified98.3%

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

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\color{blue}{\left(\frac{1 + cosTheta \cdot \left(cosTheta \cdot \left(\frac{1}{2} \cdot cosTheta - \frac{3}{2}\right) - 1\right)}{cosTheta}\right)}, \mathsf{pow.f32}\left(\mathsf{PI.f32}\left(\right), \frac{1}{2}\right)\right)\right)\right) \]
    3. Step-by-step derivation
      1. /-lowering-/.f32N/A

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(1 + cosTheta \cdot \left(cosTheta \cdot \left(\frac{1}{2} \cdot cosTheta - \frac{3}{2}\right) - 1\right)\right), cosTheta\right), \mathsf{pow.f32}\left(\color{blue}{\mathsf{PI.f32}\left(\right)}, \frac{1}{2}\right)\right)\right)\right) \]
      2. +-lowering-+.f32N/A

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \left(cosTheta \cdot \left(cosTheta \cdot \left(\frac{1}{2} \cdot cosTheta - \frac{3}{2}\right) - 1\right)\right)\right), cosTheta\right), \mathsf{pow.f32}\left(\mathsf{PI.f32}\left(\right), \frac{1}{2}\right)\right)\right)\right) \]
      3. *-lowering-*.f32N/A

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(cosTheta, \left(cosTheta \cdot \left(\frac{1}{2} \cdot cosTheta - \frac{3}{2}\right) - 1\right)\right)\right), cosTheta\right), \mathsf{pow.f32}\left(\mathsf{PI.f32}\left(\right), \frac{1}{2}\right)\right)\right)\right) \]
      4. sub-negN/A

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(cosTheta, \left(cosTheta \cdot \left(\frac{1}{2} \cdot cosTheta - \frac{3}{2}\right) + \left(\mathsf{neg}\left(1\right)\right)\right)\right)\right), cosTheta\right), \mathsf{pow.f32}\left(\mathsf{PI.f32}\left(\right), \frac{1}{2}\right)\right)\right)\right) \]
      5. metadata-evalN/A

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(cosTheta, \left(cosTheta \cdot \left(\frac{1}{2} \cdot cosTheta - \frac{3}{2}\right) + -1\right)\right)\right), cosTheta\right), \mathsf{pow.f32}\left(\mathsf{PI.f32}\left(\right), \frac{1}{2}\right)\right)\right)\right) \]
      6. +-commutativeN/A

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(cosTheta, \left(-1 + cosTheta \cdot \left(\frac{1}{2} \cdot cosTheta - \frac{3}{2}\right)\right)\right)\right), cosTheta\right), \mathsf{pow.f32}\left(\mathsf{PI.f32}\left(\right), \frac{1}{2}\right)\right)\right)\right) \]
      7. +-lowering-+.f32N/A

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(cosTheta, \mathsf{+.f32}\left(-1, \left(cosTheta \cdot \left(\frac{1}{2} \cdot cosTheta - \frac{3}{2}\right)\right)\right)\right)\right), cosTheta\right), \mathsf{pow.f32}\left(\mathsf{PI.f32}\left(\right), \frac{1}{2}\right)\right)\right)\right) \]
      8. *-lowering-*.f32N/A

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(cosTheta, \mathsf{+.f32}\left(-1, \mathsf{*.f32}\left(cosTheta, \left(\frac{1}{2} \cdot cosTheta - \frac{3}{2}\right)\right)\right)\right)\right), cosTheta\right), \mathsf{pow.f32}\left(\mathsf{PI.f32}\left(\right), \frac{1}{2}\right)\right)\right)\right) \]
      9. sub-negN/A

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(cosTheta, \mathsf{+.f32}\left(-1, \mathsf{*.f32}\left(cosTheta, \left(\frac{1}{2} \cdot cosTheta + \left(\mathsf{neg}\left(\frac{3}{2}\right)\right)\right)\right)\right)\right)\right), cosTheta\right), \mathsf{pow.f32}\left(\mathsf{PI.f32}\left(\right), \frac{1}{2}\right)\right)\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(cosTheta, \mathsf{+.f32}\left(-1, \mathsf{*.f32}\left(cosTheta, \left(\frac{1}{2} \cdot cosTheta + \frac{-3}{2}\right)\right)\right)\right)\right), cosTheta\right), \mathsf{pow.f32}\left(\mathsf{PI.f32}\left(\right), \frac{1}{2}\right)\right)\right)\right) \]
      11. +-commutativeN/A

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(cosTheta, \mathsf{+.f32}\left(-1, \mathsf{*.f32}\left(cosTheta, \left(\frac{-3}{2} + \frac{1}{2} \cdot cosTheta\right)\right)\right)\right)\right), cosTheta\right), \mathsf{pow.f32}\left(\mathsf{PI.f32}\left(\right), \frac{1}{2}\right)\right)\right)\right) \]
      12. +-lowering-+.f32N/A

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(cosTheta, \mathsf{+.f32}\left(-1, \mathsf{*.f32}\left(cosTheta, \mathsf{+.f32}\left(\frac{-3}{2}, \left(\frac{1}{2} \cdot cosTheta\right)\right)\right)\right)\right)\right), cosTheta\right), \mathsf{pow.f32}\left(\mathsf{PI.f32}\left(\right), \frac{1}{2}\right)\right)\right)\right) \]
      13. *-commutativeN/A

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(cosTheta, \mathsf{+.f32}\left(-1, \mathsf{*.f32}\left(cosTheta, \mathsf{+.f32}\left(\frac{-3}{2}, \left(cosTheta \cdot \frac{1}{2}\right)\right)\right)\right)\right)\right), cosTheta\right), \mathsf{pow.f32}\left(\mathsf{PI.f32}\left(\right), \frac{1}{2}\right)\right)\right)\right) \]
      14. *-lowering-*.f3297.9%

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(cosTheta, \mathsf{+.f32}\left(-1, \mathsf{*.f32}\left(cosTheta, \mathsf{+.f32}\left(\frac{-3}{2}, \mathsf{*.f32}\left(cosTheta, \frac{1}{2}\right)\right)\right)\right)\right)\right), cosTheta\right), \mathsf{pow.f32}\left(\mathsf{PI.f32}\left(\right), \frac{1}{2}\right)\right)\right)\right) \]
    4. Simplified97.9%

      \[\leadsto \frac{1}{1 + \frac{\color{blue}{\frac{1 + cosTheta \cdot \left(-1 + cosTheta \cdot \left(-1.5 + cosTheta \cdot 0.5\right)\right)}{cosTheta}}}{{\pi}^{0.5}}} \]
    5. Add Preprocessing

    Alternative 6: 97.1% accurate, 2.7× speedup?

    \[\begin{array}{l} \\ \frac{1}{\left(1 + c\right) + \frac{\sqrt{\frac{1 + cosTheta \cdot -2}{\pi}}}{cosTheta \cdot \left(1 + cosTheta \cdot cosTheta\right)}} \end{array} \]
    (FPCore (cosTheta c)
     :precision binary32
     (/
      1.0
      (+
       (+ 1.0 c)
       (/
        (sqrt (/ (+ 1.0 (* cosTheta -2.0)) PI))
        (* cosTheta (+ 1.0 (* cosTheta cosTheta)))))))
    float code(float cosTheta, float c) {
    	return 1.0f / ((1.0f + c) + (sqrtf(((1.0f + (cosTheta * -2.0f)) / ((float) M_PI))) / (cosTheta * (1.0f + (cosTheta * cosTheta)))));
    }
    
    function code(cosTheta, c)
    	return Float32(Float32(1.0) / Float32(Float32(Float32(1.0) + c) + Float32(sqrt(Float32(Float32(Float32(1.0) + Float32(cosTheta * Float32(-2.0))) / Float32(pi))) / Float32(cosTheta * Float32(Float32(1.0) + Float32(cosTheta * cosTheta))))))
    end
    
    function tmp = code(cosTheta, c)
    	tmp = single(1.0) / ((single(1.0) + c) + (sqrt(((single(1.0) + (cosTheta * single(-2.0))) / single(pi))) / (cosTheta * (single(1.0) + (cosTheta * cosTheta)))));
    end
    
    \begin{array}{l}
    
    \\
    \frac{1}{\left(1 + c\right) + \frac{\sqrt{\frac{1 + cosTheta \cdot -2}{\pi}}}{cosTheta \cdot \left(1 + cosTheta \cdot cosTheta\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. Step-by-step derivation
      1. /-lowering-/.f32N/A

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \left(\left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\mathsf{neg}\left(cosTheta \cdot cosTheta\right)}\right)\right)\right)\right) \]
      9. exp-negN/A

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

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

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

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, 2\right)\right)\right), \left(\left(\sqrt{\mathsf{PI}\left(\right)} + {cosTheta}^{2} \cdot \sqrt{\mathsf{PI}\left(\right)}\right) \cdot \color{blue}{cosTheta}\right)\right)\right)\right)\right) \]
      2. distribute-rgt1-inN/A

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, 2\right)\right)\right), \left(\left(\left({cosTheta}^{2} + 1\right) \cdot \sqrt{\mathsf{PI}\left(\right)}\right) \cdot cosTheta\right)\right)\right)\right)\right) \]
      3. associate-*l*N/A

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

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

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

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, 2\right)\right)\right), \mathsf{*.f32}\left(\mathsf{+.f32}\left(\left({cosTheta}^{2}\right), 1\right), \left(\color{blue}{cosTheta} \cdot \sqrt{\mathsf{PI}\left(\right)}\right)\right)\right)\right)\right)\right) \]
      7. unpow2N/A

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, 2\right)\right)\right), \mathsf{*.f32}\left(\mathsf{+.f32}\left(\left(cosTheta \cdot cosTheta\right), 1\right), \left(cosTheta \cdot \sqrt{\mathsf{PI}\left(\right)}\right)\right)\right)\right)\right)\right) \]
      8. *-lowering-*.f32N/A

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, 2\right)\right)\right), \mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(cosTheta, cosTheta\right), 1\right), \left(cosTheta \cdot \sqrt{\mathsf{PI}\left(\right)}\right)\right)\right)\right)\right)\right) \]
      9. *-lowering-*.f32N/A

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, 2\right)\right)\right), \mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(cosTheta, cosTheta\right), 1\right), \mathsf{*.f32}\left(cosTheta, \color{blue}{\left(\sqrt{\mathsf{PI}\left(\right)}\right)}\right)\right)\right)\right)\right)\right) \]
      10. sqrt-lowering-sqrt.f32N/A

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, 2\right)\right)\right), \mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(cosTheta, cosTheta\right), 1\right), \mathsf{*.f32}\left(cosTheta, \mathsf{sqrt.f32}\left(\mathsf{PI}\left(\right)\right)\right)\right)\right)\right)\right)\right) \]
      11. PI-lowering-PI.f3298.0%

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, 2\right)\right)\right), \mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(cosTheta, cosTheta\right), 1\right), \mathsf{*.f32}\left(cosTheta, \mathsf{sqrt.f32}\left(\mathsf{PI.f32}\left(\right)\right)\right)\right)\right)\right)\right)\right) \]
    7. Simplified98.0%

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

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

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

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

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

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{+.f32}\left(1, c\right), \left(\frac{1 \cdot \sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}}}{\color{blue}{cosTheta \cdot \left(1 + {cosTheta}^{2}\right)}}\right)\right)\right) \]
      5. cancel-sign-sub-invN/A

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

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

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

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

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

    Alternative 7: 96.8% accurate, 2.7× speedup?

    \[\begin{array}{l} \\ \frac{1}{1 + \frac{\sqrt{\frac{1 + cosTheta \cdot -2}{\pi}}}{cosTheta \cdot \left(1 + cosTheta \cdot cosTheta\right)}} \end{array} \]
    (FPCore (cosTheta c)
     :precision binary32
     (/
      1.0
      (+
       1.0
       (/
        (sqrt (/ (+ 1.0 (* cosTheta -2.0)) PI))
        (* cosTheta (+ 1.0 (* cosTheta cosTheta)))))))
    float code(float cosTheta, float c) {
    	return 1.0f / (1.0f + (sqrtf(((1.0f + (cosTheta * -2.0f)) / ((float) M_PI))) / (cosTheta * (1.0f + (cosTheta * cosTheta)))));
    }
    
    function code(cosTheta, c)
    	return Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(sqrt(Float32(Float32(Float32(1.0) + Float32(cosTheta * Float32(-2.0))) / Float32(pi))) / Float32(cosTheta * Float32(Float32(1.0) + Float32(cosTheta * cosTheta))))))
    end
    
    function tmp = code(cosTheta, c)
    	tmp = single(1.0) / (single(1.0) + (sqrt(((single(1.0) + (cosTheta * single(-2.0))) / single(pi))) / (cosTheta * (single(1.0) + (cosTheta * cosTheta)))));
    end
    
    \begin{array}{l}
    
    \\
    \frac{1}{1 + \frac{\sqrt{\frac{1 + cosTheta \cdot -2}{\pi}}}{cosTheta \cdot \left(1 + cosTheta \cdot cosTheta\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. Step-by-step derivation
      1. /-lowering-/.f32N/A

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \left(\left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\mathsf{neg}\left(cosTheta \cdot cosTheta\right)}\right)\right)\right)\right) \]
      9. exp-negN/A

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

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

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

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, 2\right)\right)\right), \left(\left(\sqrt{\mathsf{PI}\left(\right)} + {cosTheta}^{2} \cdot \sqrt{\mathsf{PI}\left(\right)}\right) \cdot \color{blue}{cosTheta}\right)\right)\right)\right)\right) \]
      2. distribute-rgt1-inN/A

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, 2\right)\right)\right), \left(\left(\left({cosTheta}^{2} + 1\right) \cdot \sqrt{\mathsf{PI}\left(\right)}\right) \cdot cosTheta\right)\right)\right)\right)\right) \]
      3. associate-*l*N/A

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

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

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

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, 2\right)\right)\right), \mathsf{*.f32}\left(\mathsf{+.f32}\left(\left({cosTheta}^{2}\right), 1\right), \left(\color{blue}{cosTheta} \cdot \sqrt{\mathsf{PI}\left(\right)}\right)\right)\right)\right)\right)\right) \]
      7. unpow2N/A

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, 2\right)\right)\right), \mathsf{*.f32}\left(\mathsf{+.f32}\left(\left(cosTheta \cdot cosTheta\right), 1\right), \left(cosTheta \cdot \sqrt{\mathsf{PI}\left(\right)}\right)\right)\right)\right)\right)\right) \]
      8. *-lowering-*.f32N/A

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, 2\right)\right)\right), \mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(cosTheta, cosTheta\right), 1\right), \left(cosTheta \cdot \sqrt{\mathsf{PI}\left(\right)}\right)\right)\right)\right)\right)\right) \]
      9. *-lowering-*.f32N/A

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, 2\right)\right)\right), \mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(cosTheta, cosTheta\right), 1\right), \mathsf{*.f32}\left(cosTheta, \color{blue}{\left(\sqrt{\mathsf{PI}\left(\right)}\right)}\right)\right)\right)\right)\right)\right) \]
      10. sqrt-lowering-sqrt.f32N/A

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, 2\right)\right)\right), \mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(cosTheta, cosTheta\right), 1\right), \mathsf{*.f32}\left(cosTheta, \mathsf{sqrt.f32}\left(\mathsf{PI}\left(\right)\right)\right)\right)\right)\right)\right)\right) \]
      11. PI-lowering-PI.f3298.0%

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, 2\right)\right)\right), \mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(cosTheta, cosTheta\right), 1\right), \mathsf{*.f32}\left(cosTheta, \mathsf{sqrt.f32}\left(\mathsf{PI.f32}\left(\right)\right)\right)\right)\right)\right)\right)\right) \]
    7. Simplified98.0%

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

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

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

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

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \left(\frac{1 \cdot \sqrt{\frac{1 - 2 \cdot cosTheta}{\mathsf{PI}\left(\right)}}}{\color{blue}{cosTheta \cdot \left(1 + {cosTheta}^{2}\right)}}\right)\right)\right) \]
      4. cancel-sign-sub-invN/A

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

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \left(\frac{1 \cdot \sqrt{\frac{1 + -2 \cdot cosTheta}{\mathsf{PI}\left(\right)}}}{cosTheta \cdot \left(1 + {cosTheta}^{2}\right)}\right)\right)\right) \]
      6. *-lft-identityN/A

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

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\left(\sqrt{\frac{1 + -2 \cdot cosTheta}{\mathsf{PI}\left(\right)}}\right), \color{blue}{\left(cosTheta \cdot \left(1 + {cosTheta}^{2}\right)\right)}\right)\right)\right) \]
    10. Simplified97.4%

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

    Alternative 8: 96.8% accurate, 2.7× speedup?

    \[\begin{array}{l} \\ \frac{1}{1 + \frac{\frac{1 + cosTheta \cdot \left(-1 + cosTheta \cdot -1.5\right)}{cosTheta}}{{\pi}^{0.5}}} \end{array} \]
    (FPCore (cosTheta c)
     :precision binary32
     (/
      1.0
      (+
       1.0
       (/
        (/ (+ 1.0 (* cosTheta (+ -1.0 (* cosTheta -1.5)))) cosTheta)
        (pow PI 0.5)))))
    float code(float cosTheta, float c) {
    	return 1.0f / (1.0f + (((1.0f + (cosTheta * (-1.0f + (cosTheta * -1.5f)))) / cosTheta) / powf(((float) M_PI), 0.5f)));
    }
    
    function code(cosTheta, c)
    	return Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(Float32(Float32(Float32(1.0) + Float32(cosTheta * Float32(Float32(-1.0) + Float32(cosTheta * Float32(-1.5))))) / cosTheta) / (Float32(pi) ^ Float32(0.5)))))
    end
    
    function tmp = code(cosTheta, c)
    	tmp = single(1.0) / (single(1.0) + (((single(1.0) + (cosTheta * (single(-1.0) + (cosTheta * single(-1.5))))) / cosTheta) / (single(pi) ^ single(0.5))));
    end
    
    \begin{array}{l}
    
    \\
    \frac{1}{1 + \frac{\frac{1 + cosTheta \cdot \left(-1 + cosTheta \cdot -1.5\right)}{cosTheta}}{{\pi}^{0.5}}}
    \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. Applied egg-rr98.5%

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

      \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\color{blue}{1}, \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{neg.f32}\left(\mathsf{*.f32}\left(cosTheta, cosTheta\right)\right)\right), \mathsf{*.f32}\left(cosTheta, \mathsf{pow.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(cosTheta, -2\right)\right), \frac{-1}{2}\right)\right)\right), \mathsf{pow.f32}\left(\mathsf{PI.f32}\left(\right), \frac{1}{2}\right)\right)\right)\right) \]
    5. Step-by-step derivation
      1. Simplified98.3%

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

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\color{blue}{\left(\frac{1 + cosTheta \cdot \left(\frac{-3}{2} \cdot cosTheta - 1\right)}{cosTheta}\right)}, \mathsf{pow.f32}\left(\mathsf{PI.f32}\left(\right), \frac{1}{2}\right)\right)\right)\right) \]
      3. Step-by-step derivation
        1. /-lowering-/.f32N/A

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(1 + cosTheta \cdot \left(\frac{-3}{2} \cdot cosTheta - 1\right)\right), cosTheta\right), \mathsf{pow.f32}\left(\color{blue}{\mathsf{PI.f32}\left(\right)}, \frac{1}{2}\right)\right)\right)\right) \]
        2. +-lowering-+.f32N/A

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \left(cosTheta \cdot \left(\frac{-3}{2} \cdot cosTheta - 1\right)\right)\right), cosTheta\right), \mathsf{pow.f32}\left(\mathsf{PI.f32}\left(\right), \frac{1}{2}\right)\right)\right)\right) \]
        3. *-lowering-*.f32N/A

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(cosTheta, \left(\frac{-3}{2} \cdot cosTheta - 1\right)\right)\right), cosTheta\right), \mathsf{pow.f32}\left(\mathsf{PI.f32}\left(\right), \frac{1}{2}\right)\right)\right)\right) \]
        4. sub-negN/A

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(cosTheta, \left(\frac{-3}{2} \cdot cosTheta + \left(\mathsf{neg}\left(1\right)\right)\right)\right)\right), cosTheta\right), \mathsf{pow.f32}\left(\mathsf{PI.f32}\left(\right), \frac{1}{2}\right)\right)\right)\right) \]
        5. metadata-evalN/A

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(cosTheta, \left(\frac{-3}{2} \cdot cosTheta + -1\right)\right)\right), cosTheta\right), \mathsf{pow.f32}\left(\mathsf{PI.f32}\left(\right), \frac{1}{2}\right)\right)\right)\right) \]
        6. +-commutativeN/A

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(cosTheta, \left(-1 + \frac{-3}{2} \cdot cosTheta\right)\right)\right), cosTheta\right), \mathsf{pow.f32}\left(\mathsf{PI.f32}\left(\right), \frac{1}{2}\right)\right)\right)\right) \]
        7. +-lowering-+.f32N/A

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(cosTheta, \mathsf{+.f32}\left(-1, \left(\frac{-3}{2} \cdot cosTheta\right)\right)\right)\right), cosTheta\right), \mathsf{pow.f32}\left(\mathsf{PI.f32}\left(\right), \frac{1}{2}\right)\right)\right)\right) \]
        8. *-commutativeN/A

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(cosTheta, \mathsf{+.f32}\left(-1, \left(cosTheta \cdot \frac{-3}{2}\right)\right)\right)\right), cosTheta\right), \mathsf{pow.f32}\left(\mathsf{PI.f32}\left(\right), \frac{1}{2}\right)\right)\right)\right) \]
        9. *-lowering-*.f3297.4%

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(cosTheta, \mathsf{+.f32}\left(-1, \mathsf{*.f32}\left(cosTheta, \frac{-3}{2}\right)\right)\right)\right), cosTheta\right), \mathsf{pow.f32}\left(\mathsf{PI.f32}\left(\right), \frac{1}{2}\right)\right)\right)\right) \]
      4. Simplified97.4%

        \[\leadsto \frac{1}{1 + \frac{\color{blue}{\frac{1 + cosTheta \cdot \left(-1 + cosTheta \cdot -1.5\right)}{cosTheta}}}{{\pi}^{0.5}}} \]
      5. Add Preprocessing

      Alternative 9: 95.5% accurate, 2.9× speedup?

      \[\begin{array}{l} \\ \frac{1}{1 + \frac{-1 + \frac{1}{cosTheta}}{{\pi}^{0.5}}} \end{array} \]
      (FPCore (cosTheta c)
       :precision binary32
       (/ 1.0 (+ 1.0 (/ (+ -1.0 (/ 1.0 cosTheta)) (pow PI 0.5)))))
      float code(float cosTheta, float c) {
      	return 1.0f / (1.0f + ((-1.0f + (1.0f / cosTheta)) / powf(((float) M_PI), 0.5f)));
      }
      
      function code(cosTheta, c)
      	return Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(Float32(Float32(-1.0) + Float32(Float32(1.0) / cosTheta)) / (Float32(pi) ^ Float32(0.5)))))
      end
      
      function tmp = code(cosTheta, c)
      	tmp = single(1.0) / (single(1.0) + ((single(-1.0) + (single(1.0) / cosTheta)) / (single(pi) ^ single(0.5))));
      end
      
      \begin{array}{l}
      
      \\
      \frac{1}{1 + \frac{-1 + \frac{1}{cosTheta}}{{\pi}^{0.5}}}
      \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 \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{+.f32}\left(1, c\right), \color{blue}{\left(\frac{\sqrt{\frac{1}{\mathsf{PI}\left(\right)}} + -1 \cdot \left(cosTheta \cdot \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)}{cosTheta}\right)}\right)\right) \]
      4. Step-by-step derivation
        1. associate-*r*N/A

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

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

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

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

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{+.f32}\left(1, c\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(\left(1 + -1 \cdot cosTheta\right), \left(\sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)\right), cosTheta\right)\right)\right) \]
        6. mul-1-negN/A

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{+.f32}\left(1, c\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(\left(1 + \left(\mathsf{neg}\left(cosTheta\right)\right)\right), \left(\sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)\right), cosTheta\right)\right)\right) \]
        7. unsub-negN/A

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{+.f32}\left(1, c\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(\left(1 - cosTheta\right), \left(\sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)\right), cosTheta\right)\right)\right) \]
        8. --lowering--.f32N/A

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{+.f32}\left(1, c\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, cosTheta\right), \left(\sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)\right), cosTheta\right)\right)\right) \]
        9. sqrt-lowering-sqrt.f32N/A

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{+.f32}\left(1, c\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, cosTheta\right), \mathsf{sqrt.f32}\left(\left(\frac{1}{\mathsf{PI}\left(\right)}\right)\right)\right), cosTheta\right)\right)\right) \]
        10. /-lowering-/.f32N/A

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{+.f32}\left(1, c\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, cosTheta\right), \mathsf{sqrt.f32}\left(\mathsf{/.f32}\left(1, \mathsf{PI}\left(\right)\right)\right)\right), cosTheta\right)\right)\right) \]
        11. PI-lowering-PI.f3295.5%

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{+.f32}\left(1, c\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, cosTheta\right), \mathsf{sqrt.f32}\left(\mathsf{/.f32}\left(1, \mathsf{PI.f32}\left(\right)\right)\right)\right), cosTheta\right)\right)\right) \]
      5. Simplified95.5%

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{/.f32}\left(1, \mathsf{PI.f32}\left(\right)\right)\right), \left(\frac{1 - cosTheta}{cosTheta}\right)\right)\right)\right) \]
        8. div-subN/A

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{/.f32}\left(1, \mathsf{PI.f32}\left(\right)\right)\right), \left(\frac{1}{cosTheta} - \color{blue}{\frac{cosTheta}{cosTheta}}\right)\right)\right)\right) \]
        9. sub-negN/A

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{/.f32}\left(1, \mathsf{PI.f32}\left(\right)\right)\right), \left(\frac{1}{cosTheta} + \color{blue}{\left(\mathsf{neg}\left(\frac{cosTheta}{cosTheta}\right)\right)}\right)\right)\right)\right) \]
        10. *-inversesN/A

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{/.f32}\left(1, \mathsf{PI.f32}\left(\right)\right)\right), \left(\frac{1}{cosTheta} + \left(\mathsf{neg}\left(1\right)\right)\right)\right)\right)\right) \]
        11. metadata-evalN/A

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{/.f32}\left(1, \mathsf{PI.f32}\left(\right)\right)\right), \left(\frac{1}{cosTheta} + -1\right)\right)\right)\right) \]
        12. +-lowering-+.f32N/A

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{/.f32}\left(1, \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{+.f32}\left(\left(\frac{1}{cosTheta}\right), \color{blue}{-1}\right)\right)\right)\right) \]
        13. /-lowering-/.f3295.5%

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{/.f32}\left(1, \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{+.f32}\left(\mathsf{/.f32}\left(1, cosTheta\right), -1\right)\right)\right)\right) \]
      8. Simplified95.5%

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

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

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

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\left(\left(\frac{1}{cosTheta} + -1\right) \cdot \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right), 1\right)\right) \]
        4. sqrt-divN/A

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\left(\left(\frac{1}{cosTheta} + -1\right) \cdot \frac{\sqrt{1}}{\sqrt{\mathsf{PI}\left(\right)}}\right), 1\right)\right) \]
        5. metadata-evalN/A

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\left(\left(\frac{1}{cosTheta} + -1\right) \cdot \frac{1}{\sqrt{\mathsf{PI}\left(\right)}}\right), 1\right)\right) \]
        6. unpow1/2N/A

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\left(\left(\frac{1}{cosTheta} + -1\right) \cdot \frac{1}{{\mathsf{PI}\left(\right)}^{\frac{1}{2}}}\right), 1\right)\right) \]
        7. un-div-invN/A

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\left(\frac{\frac{1}{cosTheta} + -1}{{\mathsf{PI}\left(\right)}^{\frac{1}{2}}}\right), 1\right)\right) \]
        8. /-lowering-/.f32N/A

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{/.f32}\left(\left(\frac{1}{cosTheta} + -1\right), \left({\mathsf{PI}\left(\right)}^{\frac{1}{2}}\right)\right), 1\right)\right) \]
        9. +-lowering-+.f32N/A

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(\left(\frac{1}{cosTheta}\right), -1\right), \left({\mathsf{PI}\left(\right)}^{\frac{1}{2}}\right)\right), 1\right)\right) \]
        10. /-lowering-/.f32N/A

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, cosTheta\right), -1\right), \left({\mathsf{PI}\left(\right)}^{\frac{1}{2}}\right)\right), 1\right)\right) \]
        11. pow-lowering-pow.f32N/A

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, cosTheta\right), -1\right), \mathsf{pow.f32}\left(\mathsf{PI}\left(\right), \frac{1}{2}\right)\right), 1\right)\right) \]
        12. PI-lowering-PI.f3296.0%

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, cosTheta\right), -1\right), \mathsf{pow.f32}\left(\mathsf{PI.f32}\left(\right), \frac{1}{2}\right)\right), 1\right)\right) \]
      10. Applied egg-rr96.0%

        \[\leadsto \frac{1}{\color{blue}{\frac{\frac{1}{cosTheta} + -1}{{\pi}^{0.5}} + 1}} \]
      11. Final simplification96.0%

        \[\leadsto \frac{1}{1 + \frac{-1 + \frac{1}{cosTheta}}{{\pi}^{0.5}}} \]
      12. Add Preprocessing

      Alternative 10: 95.4% accurate, 2.9× speedup?

      \[\begin{array}{l} \\ \frac{1}{1 + \frac{\frac{1 - cosTheta}{cosTheta}}{{\pi}^{0.5}}} \end{array} \]
      (FPCore (cosTheta c)
       :precision binary32
       (/ 1.0 (+ 1.0 (/ (/ (- 1.0 cosTheta) cosTheta) (pow PI 0.5)))))
      float code(float cosTheta, float c) {
      	return 1.0f / (1.0f + (((1.0f - cosTheta) / cosTheta) / powf(((float) M_PI), 0.5f)));
      }
      
      function code(cosTheta, c)
      	return Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(Float32(Float32(Float32(1.0) - cosTheta) / cosTheta) / (Float32(pi) ^ Float32(0.5)))))
      end
      
      function tmp = code(cosTheta, c)
      	tmp = single(1.0) / (single(1.0) + (((single(1.0) - cosTheta) / cosTheta) / (single(pi) ^ single(0.5))));
      end
      
      \begin{array}{l}
      
      \\
      \frac{1}{1 + \frac{\frac{1 - cosTheta}{cosTheta}}{{\pi}^{0.5}}}
      \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. Applied egg-rr98.5%

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

        \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\color{blue}{1}, \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{exp.f32}\left(\mathsf{neg.f32}\left(\mathsf{*.f32}\left(cosTheta, cosTheta\right)\right)\right), \mathsf{*.f32}\left(cosTheta, \mathsf{pow.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(cosTheta, -2\right)\right), \frac{-1}{2}\right)\right)\right), \mathsf{pow.f32}\left(\mathsf{PI.f32}\left(\right), \frac{1}{2}\right)\right)\right)\right) \]
      5. Step-by-step derivation
        1. Simplified98.3%

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

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\color{blue}{\left(\frac{1 + -1 \cdot cosTheta}{cosTheta}\right)}, \mathsf{pow.f32}\left(\mathsf{PI.f32}\left(\right), \frac{1}{2}\right)\right)\right)\right) \]
        3. Step-by-step derivation
          1. /-lowering-/.f32N/A

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

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(1 + \left(\mathsf{neg}\left(cosTheta\right)\right)\right), cosTheta\right), \mathsf{pow.f32}\left(\mathsf{PI.f32}\left(\right), \frac{1}{2}\right)\right)\right)\right) \]
          3. unsub-negN/A

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(1 - cosTheta\right), cosTheta\right), \mathsf{pow.f32}\left(\mathsf{PI.f32}\left(\right), \frac{1}{2}\right)\right)\right)\right) \]
          4. --lowering--.f3296.0%

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, cosTheta\right), cosTheta\right), \mathsf{pow.f32}\left(\mathsf{PI.f32}\left(\right), \frac{1}{2}\right)\right)\right)\right) \]
        4. Simplified96.0%

          \[\leadsto \frac{1}{1 + \frac{\color{blue}{\frac{1 - cosTheta}{cosTheta}}}{{\pi}^{0.5}}} \]
        5. Add Preprocessing

        Alternative 11: 95.0% accurate, 2.9× speedup?

        \[\begin{array}{l} \\ \frac{1}{1 + \left(-1 + \frac{1}{cosTheta}\right) \cdot {\pi}^{-0.5}} \end{array} \]
        (FPCore (cosTheta c)
         :precision binary32
         (/ 1.0 (+ 1.0 (* (+ -1.0 (/ 1.0 cosTheta)) (pow PI -0.5)))))
        float code(float cosTheta, float c) {
        	return 1.0f / (1.0f + ((-1.0f + (1.0f / cosTheta)) * powf(((float) M_PI), -0.5f)));
        }
        
        function code(cosTheta, c)
        	return Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(Float32(Float32(-1.0) + Float32(Float32(1.0) / cosTheta)) * (Float32(pi) ^ Float32(-0.5)))))
        end
        
        function tmp = code(cosTheta, c)
        	tmp = single(1.0) / (single(1.0) + ((single(-1.0) + (single(1.0) / cosTheta)) * (single(pi) ^ single(-0.5))));
        end
        
        \begin{array}{l}
        
        \\
        \frac{1}{1 + \left(-1 + \frac{1}{cosTheta}\right) \cdot {\pi}^{-0.5}}
        \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 \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{+.f32}\left(1, c\right), \color{blue}{\left(\frac{\sqrt{\frac{1}{\mathsf{PI}\left(\right)}} + -1 \cdot \left(cosTheta \cdot \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)}{cosTheta}\right)}\right)\right) \]
        4. Step-by-step derivation
          1. associate-*r*N/A

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

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

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

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

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{+.f32}\left(1, c\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(\left(1 + -1 \cdot cosTheta\right), \left(\sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)\right), cosTheta\right)\right)\right) \]
          6. mul-1-negN/A

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{+.f32}\left(1, c\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(\left(1 + \left(\mathsf{neg}\left(cosTheta\right)\right)\right), \left(\sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)\right), cosTheta\right)\right)\right) \]
          7. unsub-negN/A

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{+.f32}\left(1, c\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(\left(1 - cosTheta\right), \left(\sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)\right), cosTheta\right)\right)\right) \]
          8. --lowering--.f32N/A

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{+.f32}\left(1, c\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, cosTheta\right), \left(\sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)\right), cosTheta\right)\right)\right) \]
          9. sqrt-lowering-sqrt.f32N/A

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{+.f32}\left(1, c\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, cosTheta\right), \mathsf{sqrt.f32}\left(\left(\frac{1}{\mathsf{PI}\left(\right)}\right)\right)\right), cosTheta\right)\right)\right) \]
          10. /-lowering-/.f32N/A

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{+.f32}\left(1, c\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, cosTheta\right), \mathsf{sqrt.f32}\left(\mathsf{/.f32}\left(1, \mathsf{PI}\left(\right)\right)\right)\right), cosTheta\right)\right)\right) \]
          11. PI-lowering-PI.f3295.5%

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(\mathsf{+.f32}\left(1, c\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, cosTheta\right), \mathsf{sqrt.f32}\left(\mathsf{/.f32}\left(1, \mathsf{PI.f32}\left(\right)\right)\right)\right), cosTheta\right)\right)\right) \]
        5. Simplified95.5%

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{/.f32}\left(1, \mathsf{PI.f32}\left(\right)\right)\right), \left(\frac{1 - cosTheta}{cosTheta}\right)\right)\right)\right) \]
          8. div-subN/A

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{/.f32}\left(1, \mathsf{PI.f32}\left(\right)\right)\right), \left(\frac{1}{cosTheta} - \color{blue}{\frac{cosTheta}{cosTheta}}\right)\right)\right)\right) \]
          9. sub-negN/A

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{/.f32}\left(1, \mathsf{PI.f32}\left(\right)\right)\right), \left(\frac{1}{cosTheta} + \color{blue}{\left(\mathsf{neg}\left(\frac{cosTheta}{cosTheta}\right)\right)}\right)\right)\right)\right) \]
          10. *-inversesN/A

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{/.f32}\left(1, \mathsf{PI.f32}\left(\right)\right)\right), \left(\frac{1}{cosTheta} + \left(\mathsf{neg}\left(1\right)\right)\right)\right)\right)\right) \]
          11. metadata-evalN/A

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{/.f32}\left(1, \mathsf{PI.f32}\left(\right)\right)\right), \left(\frac{1}{cosTheta} + -1\right)\right)\right)\right) \]
          12. +-lowering-+.f32N/A

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{/.f32}\left(1, \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{+.f32}\left(\left(\frac{1}{cosTheta}\right), \color{blue}{-1}\right)\right)\right)\right) \]
          13. /-lowering-/.f3295.5%

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{/.f32}\left(1, \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{+.f32}\left(\mathsf{/.f32}\left(1, cosTheta\right), -1\right)\right)\right)\right) \]
        8. Simplified95.5%

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

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\left(\sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right), \color{blue}{\left(\frac{1}{cosTheta} + -1\right)}\right)\right)\right) \]
          2. inv-powN/A

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

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\left({\mathsf{PI}\left(\right)}^{\left(\frac{-1}{2}\right)}\right), \left(\color{blue}{\frac{1}{cosTheta}} + -1\right)\right)\right)\right) \]
          4. metadata-evalN/A

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

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

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{PI.f32}\left(\right), \frac{-1}{2}\right), \left(\frac{\color{blue}{1}}{cosTheta} + -1\right)\right)\right)\right) \]
          7. +-lowering-+.f32N/A

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{PI.f32}\left(\right), \frac{-1}{2}\right), \mathsf{+.f32}\left(\left(\frac{1}{cosTheta}\right), \color{blue}{-1}\right)\right)\right)\right) \]
          8. /-lowering-/.f3295.5%

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{PI.f32}\left(\right), \frac{-1}{2}\right), \mathsf{+.f32}\left(\mathsf{/.f32}\left(1, cosTheta\right), -1\right)\right)\right)\right) \]
        10. Applied egg-rr95.5%

          \[\leadsto \frac{1}{1 + \color{blue}{{\pi}^{-0.5} \cdot \left(\frac{1}{cosTheta} + -1\right)}} \]
        11. Final simplification95.5%

          \[\leadsto \frac{1}{1 + \left(-1 + \frac{1}{cosTheta}\right) \cdot {\pi}^{-0.5}} \]
        12. Add Preprocessing

        Alternative 12: 93.0% accurate, 3.1× 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. Step-by-step derivation
          1. /-lowering-/.f32N/A

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

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

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

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

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

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

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

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \left(\left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\mathsf{neg}\left(cosTheta \cdot cosTheta\right)}\right)\right)\right)\right) \]
          9. exp-negN/A

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

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

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

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

            \[\leadsto \mathsf{*.f32}\left(cosTheta, \mathsf{sqrt.f32}\left(\mathsf{PI}\left(\right)\right)\right) \]
          3. PI-lowering-PI.f3293.6%

            \[\leadsto \mathsf{*.f32}\left(cosTheta, \mathsf{sqrt.f32}\left(\mathsf{PI.f32}\left(\right)\right)\right) \]
        7. Simplified93.6%

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

        Alternative 13: 10.7% accurate, 107.3× speedup?

        \[\begin{array}{l} \\ 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}
        
        \\
        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. Step-by-step derivation
          1. /-lowering-/.f32N/A

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

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

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

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

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

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

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

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \left(\left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\mathsf{neg}\left(cosTheta \cdot cosTheta\right)}\right)\right)\right)\right) \]
          9. exp-negN/A

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

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

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

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, 2\right)\right)\right), \left(\left(\sqrt{\mathsf{PI}\left(\right)} + {cosTheta}^{2} \cdot \sqrt{\mathsf{PI}\left(\right)}\right) \cdot \color{blue}{cosTheta}\right)\right)\right)\right)\right) \]
          2. distribute-rgt1-inN/A

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, 2\right)\right)\right), \left(\left(\left({cosTheta}^{2} + 1\right) \cdot \sqrt{\mathsf{PI}\left(\right)}\right) \cdot cosTheta\right)\right)\right)\right)\right) \]
          3. associate-*l*N/A

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

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

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

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, 2\right)\right)\right), \mathsf{*.f32}\left(\mathsf{+.f32}\left(\left({cosTheta}^{2}\right), 1\right), \left(\color{blue}{cosTheta} \cdot \sqrt{\mathsf{PI}\left(\right)}\right)\right)\right)\right)\right)\right) \]
          7. unpow2N/A

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, 2\right)\right)\right), \mathsf{*.f32}\left(\mathsf{+.f32}\left(\left(cosTheta \cdot cosTheta\right), 1\right), \left(cosTheta \cdot \sqrt{\mathsf{PI}\left(\right)}\right)\right)\right)\right)\right)\right) \]
          8. *-lowering-*.f32N/A

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, 2\right)\right)\right), \mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(cosTheta, cosTheta\right), 1\right), \left(cosTheta \cdot \sqrt{\mathsf{PI}\left(\right)}\right)\right)\right)\right)\right)\right) \]
          9. *-lowering-*.f32N/A

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, 2\right)\right)\right), \mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(cosTheta, cosTheta\right), 1\right), \mathsf{*.f32}\left(cosTheta, \color{blue}{\left(\sqrt{\mathsf{PI}\left(\right)}\right)}\right)\right)\right)\right)\right)\right) \]
          10. sqrt-lowering-sqrt.f32N/A

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, 2\right)\right)\right), \mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(cosTheta, cosTheta\right), 1\right), \mathsf{*.f32}\left(cosTheta, \mathsf{sqrt.f32}\left(\mathsf{PI}\left(\right)\right)\right)\right)\right)\right)\right)\right) \]
          11. PI-lowering-PI.f3298.0%

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, 2\right)\right)\right), \mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(cosTheta, cosTheta\right), 1\right), \mathsf{*.f32}\left(cosTheta, \mathsf{sqrt.f32}\left(\mathsf{PI.f32}\left(\right)\right)\right)\right)\right)\right)\right)\right) \]
        7. Simplified98.0%

          \[\leadsto \frac{1}{c + \left(1 + \frac{\sqrt{1 - cosTheta \cdot 2}}{\color{blue}{\left(cosTheta \cdot cosTheta + 1\right) \cdot \left(cosTheta \cdot \sqrt{\pi}\right)}}\right)} \]
        8. Taylor expanded in cosTheta around inf

          \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \color{blue}{1}\right)\right) \]
        9. Step-by-step derivation
          1. Simplified10.7%

            \[\leadsto \frac{1}{c + \color{blue}{1}} \]
          2. Taylor expanded in c around 0

            \[\leadsto \color{blue}{1 + -1 \cdot c} \]
          3. Step-by-step derivation
            1. mul-1-negN/A

              \[\leadsto 1 + \left(\mathsf{neg}\left(c\right)\right) \]
            2. unsub-negN/A

              \[\leadsto 1 - \color{blue}{c} \]
            3. --lowering--.f3210.7%

              \[\leadsto \mathsf{\_.f32}\left(1, \color{blue}{c}\right) \]
          4. Simplified10.7%

            \[\leadsto \color{blue}{1 - c} \]
          5. Add Preprocessing

          Alternative 14: 10.7% accurate, 322.0× speedup?

          \[\begin{array}{l} \\ 1 \end{array} \]
          (FPCore (cosTheta c) :precision binary32 1.0)
          float code(float cosTheta, float c) {
          	return 1.0f;
          }
          
          real(4) function code(costheta, c)
              real(4), intent (in) :: costheta
              real(4), intent (in) :: c
              code = 1.0e0
          end function
          
          function code(cosTheta, c)
          	return Float32(1.0)
          end
          
          function tmp = code(cosTheta, c)
          	tmp = single(1.0);
          end
          
          \begin{array}{l}
          
          \\
          1
          \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. Step-by-step derivation
            1. /-lowering-/.f32N/A

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

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

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

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

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

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

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

              \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \left(\left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\mathsf{neg}\left(cosTheta \cdot cosTheta\right)}\right)\right)\right)\right) \]
            9. exp-negN/A

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

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

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

              \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, 2\right)\right)\right), \left(\left(\sqrt{\mathsf{PI}\left(\right)} + {cosTheta}^{2} \cdot \sqrt{\mathsf{PI}\left(\right)}\right) \cdot \color{blue}{cosTheta}\right)\right)\right)\right)\right) \]
            2. distribute-rgt1-inN/A

              \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, 2\right)\right)\right), \left(\left(\left({cosTheta}^{2} + 1\right) \cdot \sqrt{\mathsf{PI}\left(\right)}\right) \cdot cosTheta\right)\right)\right)\right)\right) \]
            3. associate-*l*N/A

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

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

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

              \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, 2\right)\right)\right), \mathsf{*.f32}\left(\mathsf{+.f32}\left(\left({cosTheta}^{2}\right), 1\right), \left(\color{blue}{cosTheta} \cdot \sqrt{\mathsf{PI}\left(\right)}\right)\right)\right)\right)\right)\right) \]
            7. unpow2N/A

              \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, 2\right)\right)\right), \mathsf{*.f32}\left(\mathsf{+.f32}\left(\left(cosTheta \cdot cosTheta\right), 1\right), \left(cosTheta \cdot \sqrt{\mathsf{PI}\left(\right)}\right)\right)\right)\right)\right)\right) \]
            8. *-lowering-*.f32N/A

              \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, 2\right)\right)\right), \mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(cosTheta, cosTheta\right), 1\right), \left(cosTheta \cdot \sqrt{\mathsf{PI}\left(\right)}\right)\right)\right)\right)\right)\right) \]
            9. *-lowering-*.f32N/A

              \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, 2\right)\right)\right), \mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(cosTheta, cosTheta\right), 1\right), \mathsf{*.f32}\left(cosTheta, \color{blue}{\left(\sqrt{\mathsf{PI}\left(\right)}\right)}\right)\right)\right)\right)\right)\right) \]
            10. sqrt-lowering-sqrt.f32N/A

              \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, 2\right)\right)\right), \mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(cosTheta, cosTheta\right), 1\right), \mathsf{*.f32}\left(cosTheta, \mathsf{sqrt.f32}\left(\mathsf{PI}\left(\right)\right)\right)\right)\right)\right)\right)\right) \]
            11. PI-lowering-PI.f3298.0%

              \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, 2\right)\right)\right), \mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(cosTheta, cosTheta\right), 1\right), \mathsf{*.f32}\left(cosTheta, \mathsf{sqrt.f32}\left(\mathsf{PI.f32}\left(\right)\right)\right)\right)\right)\right)\right)\right) \]
          7. Simplified98.0%

            \[\leadsto \frac{1}{c + \left(1 + \frac{\sqrt{1 - cosTheta \cdot 2}}{\color{blue}{\left(cosTheta \cdot cosTheta + 1\right) \cdot \left(cosTheta \cdot \sqrt{\pi}\right)}}\right)} \]
          8. Taylor expanded in cosTheta around inf

            \[\leadsto \mathsf{/.f32}\left(1, \mathsf{+.f32}\left(c, \color{blue}{1}\right)\right) \]
          9. Step-by-step derivation
            1. Simplified10.7%

              \[\leadsto \frac{1}{c + \color{blue}{1}} \]
            2. Taylor expanded in c around 0

              \[\leadsto \color{blue}{1} \]
            3. Step-by-step derivation
              1. Simplified10.7%

                \[\leadsto \color{blue}{1} \]
              2. Add Preprocessing

              Reproduce

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