| Alternative 1 | |
|---|---|
| Error | 0.5 |
| Cost | 9888 |
\[\sin^{-1} \left(\frac{h}{\sqrt{eta + sinTheta_O} \cdot \sqrt{eta - sinTheta_O}}\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 (* (/ (sqrt (/ 1.0 (- eta sinTheta_O))) (sqrt (+ eta sinTheta_O))) h)))
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(((sqrtf((1.0f / (eta - sinTheta_O))) / sqrtf((eta + sinTheta_O))) * h));
}
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
code = asin(((sqrt((1.0e0 / (eta - sintheta_o))) / sqrt((eta + sintheta_o))) * h))
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) return asin(Float32(Float32(sqrt(Float32(Float32(1.0) / Float32(eta - sinTheta_O))) / sqrt(Float32(eta + sinTheta_O))) * h)) 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 = code(sinTheta_O, h, eta) tmp = asin(((sqrt((single(1.0) / (eta - sinTheta_O))) / sqrt((eta + sinTheta_O))) * h)); end
\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{\sqrt{\frac{1}{eta - sinTheta_O}}}{\sqrt{eta + sinTheta_O}} \cdot h\right)
Results
Initial program 2.7
Taylor expanded in sinTheta_O around 0 2.8
Simplified2.8
Applied egg-rr0.5
Taylor expanded in h around 0 4.0
Applied egg-rr0.5
Final simplification0.5
| Alternative 1 | |
|---|---|
| Error | 0.5 |
| Cost | 9888 |
| Alternative 2 | |
|---|---|
| Error | 0.8 |
| Cost | 3552 |
| Alternative 3 | |
|---|---|
| Error | 0.6 |
| Cost | 3552 |
| Alternative 4 | |
|---|---|
| Error | 1.4 |
| Cost | 3296 |

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