(FPCore (sinTheta_O h eta)
:precision binary32
(asin
(/
h
(sqrt
(-
(* eta eta)
(/
(* sinTheta_O sinTheta_O)
(sqrt (- 1.0 (* sinTheta_O sinTheta_O)))))))))(FPCore (sinTheta_O h eta) :precision binary32 (let* ((t_0 (cbrt (log (* sinTheta_O (/ sinTheta_O eta)))))) (asin (/ h (+ eta (* (exp (* t_0 (pow t_0 2.0))) -0.5))))))
float code(float sinTheta_O, float h, float eta) {
return asinf((h / sqrtf(((eta * eta) - ((sinTheta_O * sinTheta_O) / sqrtf((1.0f - (sinTheta_O * sinTheta_O))))))));
}
float code(float sinTheta_O, float h, float eta) {
float t_0 = cbrtf(logf((sinTheta_O * (sinTheta_O / eta))));
return asinf((h / (eta + (expf((t_0 * powf(t_0, 2.0f))) * -0.5f))));
}
function code(sinTheta_O, h, eta) return asin(Float32(h / sqrt(Float32(Float32(eta * eta) - Float32(Float32(sinTheta_O * sinTheta_O) / sqrt(Float32(Float32(1.0) - Float32(sinTheta_O * sinTheta_O)))))))) end
function code(sinTheta_O, h, eta) t_0 = cbrt(log(Float32(sinTheta_O * Float32(sinTheta_O / eta)))) return asin(Float32(h / Float32(eta + Float32(exp(Float32(t_0 * (t_0 ^ Float32(2.0)))) * Float32(-0.5))))) end
\sin^{-1} \left(\frac{h}{\sqrt{eta \cdot eta - \frac{sinTheta_O \cdot sinTheta_O}{\sqrt{1 - sinTheta_O \cdot sinTheta_O}}}}\right)
\begin{array}{l}
t_0 := \sqrt[3]{\log \left(sinTheta_O \cdot \frac{sinTheta_O}{eta}\right)}\\
\sin^{-1} \left(\frac{h}{eta + e^{t_0 \cdot {t_0}^{2}} \cdot -0.5}\right)
\end{array}



Bits error versus sinTheta_O



Bits error versus h



Bits error versus eta
Results
Initial program 2.5
Taylor expanded in sinTheta_O around 0 0.8
Applied egg-rr0.7
Applied egg-rr0.7
Final simplification0.7
herbie shell --seed 2022162
(FPCore (sinTheta_O h eta)
:name "HairBSDF, gamma for a refracted ray"
:precision binary32
:pre (and (and (and (<= -1.0 sinTheta_O) (<= sinTheta_O 1.0)) (and (<= -1.0 h) (<= h 1.0))) (and (<= 0.0 eta) (<= eta 10.0)))
(asin (/ h (sqrt (- (* eta eta) (/ (* sinTheta_O sinTheta_O) (sqrt (- 1.0 (* sinTheta_O sinTheta_O)))))))))