(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
(/
(* sinTheta_O sinTheta_O)
(sqrt (- 1.0 (* sinTheta_O sinTheta_O))))))
(if (<= t_0 1.401298464324817e-44)
(asin (/ h eta))
(asin (/ h (sqrt (- (* eta eta) t_0)))))))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 = (sinTheta_O * sinTheta_O) / sqrtf((1.0f - (sinTheta_O * sinTheta_O)));
float tmp;
if (t_0 <= 1.401298464324817e-44f) {
tmp = asinf((h / eta));
} else {
tmp = asinf((h / sqrtf(((eta * eta) - t_0))));
}
return tmp;
}
real(4) function code(sintheta_o, h, eta)
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: h
real(4), intent (in) :: eta
code = asin((h / sqrt(((eta * eta) - ((sintheta_o * sintheta_o) / sqrt((1.0e0 - (sintheta_o * sintheta_o))))))))
end function
real(4) function code(sintheta_o, h, eta)
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: h
real(4), intent (in) :: eta
real(4) :: t_0
real(4) :: tmp
t_0 = (sintheta_o * sintheta_o) / sqrt((1.0e0 - (sintheta_o * sintheta_o)))
if (t_0 <= 1.401298464324817e-44) then
tmp = asin((h / eta))
else
tmp = asin((h / sqrt(((eta * eta) - t_0))))
end if
code = tmp
end function
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 = Float32(Float32(sinTheta_O * sinTheta_O) / sqrt(Float32(Float32(1.0) - Float32(sinTheta_O * sinTheta_O)))) tmp = Float32(0.0) if (t_0 <= Float32(1.401298464324817e-44)) tmp = asin(Float32(h / eta)); else tmp = asin(Float32(h / sqrt(Float32(Float32(eta * eta) - t_0)))); end return tmp end
function tmp = code(sinTheta_O, h, eta) tmp = asin((h / sqrt(((eta * eta) - ((sinTheta_O * sinTheta_O) / sqrt((single(1.0) - (sinTheta_O * sinTheta_O)))))))); end
function tmp_2 = code(sinTheta_O, h, eta) t_0 = (sinTheta_O * sinTheta_O) / sqrt((single(1.0) - (sinTheta_O * sinTheta_O))); tmp = single(0.0); if (t_0 <= single(1.401298464324817e-44)) tmp = asin((h / eta)); else tmp = asin((h / sqrt(((eta * eta) - t_0)))); end tmp_2 = tmp; 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 := \frac{sinTheta_O \cdot sinTheta_O}{\sqrt{1 - sinTheta_O \cdot sinTheta_O}}\\
\mathbf{if}\;t_0 \leq 1.401298464324817 \cdot 10^{-44}:\\
\;\;\;\;\sin^{-1} \left(\frac{h}{eta}\right)\\
\mathbf{else}:\\
\;\;\;\;\sin^{-1} \left(\frac{h}{\sqrt{eta \cdot eta - t_0}}\right)\\
\end{array}



Bits error versus sinTheta_O



Bits error versus h



Bits error versus eta
Results
if (/.f32 (*.f32 sinTheta_O sinTheta_O) (sqrt.f32 (-.f32 1 (*.f32 sinTheta_O sinTheta_O)))) < 1.4013e-44Initial program 4.4
Taylor expanded in eta around inf 0.5
if 1.4013e-44 < (/.f32 (*.f32 sinTheta_O sinTheta_O) (sqrt.f32 (-.f32 1 (*.f32 sinTheta_O sinTheta_O)))) Initial program 0.1
Final simplification0.3
herbie shell --seed 2022151
(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)))))))))