\sin^{-1} \left(\frac{h}{\sqrt{eta \cdot eta - \frac{sinTheta_O \cdot sinTheta_O}{\sqrt{1 - sinTheta_O \cdot sinTheta_O}}}}\right)
\sin^{-1} \left(\frac{h}{eta - 0.5 \cdot \frac{{sinTheta_O}^{2}}{eta}}\right)
(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 (asin (/ h (- eta (* 0.5 (/ (pow sinTheta_O 2.0) eta))))))
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) {
return asinf((h / (eta - (0.5f * (powf(sinTheta_O, 2.0f) / eta)))));
}



Bits error versus sinTheta_O



Bits error versus h



Bits error versus eta
Results
Initial program 2.6
Taylor expanded in sinTheta_O around 0 0.8
Final simplification0.8
herbie shell --seed 2022127
(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)))))))))