
(FPCore (sinTheta_O h eta)
:precision binary32
(asin
(/
h
(sqrt
(-
(* eta eta)
(/
(* sinTheta_O sinTheta_O)
(sqrt (- 1.0 (* sinTheta_O sinTheta_O)))))))))
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))))))));
}
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
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 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
\begin{array}{l}
\\
\sin^{-1} \left(\frac{h}{\sqrt{eta \cdot eta - \frac{sinTheta\_O \cdot sinTheta\_O}{\sqrt{1 - sinTheta\_O \cdot sinTheta\_O}}}}\right)
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (sinTheta_O h eta)
:precision binary32
(asin
(/
h
(sqrt
(-
(* eta eta)
(/
(* sinTheta_O sinTheta_O)
(sqrt (- 1.0 (* sinTheta_O sinTheta_O)))))))))
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))))))));
}
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
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 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
\begin{array}{l}
\\
\sin^{-1} \left(\frac{h}{\sqrt{eta \cdot eta - \frac{sinTheta\_O \cdot sinTheta\_O}{\sqrt{1 - sinTheta\_O \cdot sinTheta\_O}}}}\right)
\end{array}
sinTheta_O_m = (fabs.f32 sinTheta_O) (FPCore (sinTheta_O_m h eta) :precision binary32 (asin (/ h (+ eta (* -0.5 (pow (pow E (log (/ sinTheta_O_m (sqrt eta)))) 2.0))))))
sinTheta_O_m = fabs(sinTheta_O);
float code(float sinTheta_O_m, float h, float eta) {
return asinf((h / (eta + (-0.5f * powf(powf(((float) M_E), logf((sinTheta_O_m / sqrtf(eta)))), 2.0f)))));
}
sinTheta_O_m = abs(sinTheta_O) function code(sinTheta_O_m, h, eta) return asin(Float32(h / Float32(eta + Float32(Float32(-0.5) * ((Float32(exp(1)) ^ log(Float32(sinTheta_O_m / sqrt(eta)))) ^ Float32(2.0)))))) end
sinTheta_O_m = abs(sinTheta_O); function tmp = code(sinTheta_O_m, h, eta) tmp = asin((h / (eta + (single(-0.5) * ((single(2.71828182845904523536) ^ log((sinTheta_O_m / sqrt(eta)))) ^ single(2.0)))))); end
\begin{array}{l}
sinTheta_O_m = \left|sinTheta\_O\right|
\\
\sin^{-1} \left(\frac{h}{eta + -0.5 \cdot {\left({e}^{\log \left(\frac{sinTheta\_O\_m}{\sqrt{eta}}\right)}\right)}^{2}}\right)
\end{array}
Initial program 92.4%
Taylor expanded in sinTheta_O around 0 97.8%
add-sqr-sqrt97.8%
pow297.8%
div-inv97.8%
sqrt-prod97.8%
sqrt-pow198.3%
metadata-eval98.3%
pow198.3%
Applied egg-rr98.3%
add-cbrt-cube96.0%
pow1/396.0%
add-sqr-sqrt96.0%
pow196.0%
pow1/296.0%
pow-prod-up96.0%
metadata-eval96.0%
Applied egg-rr96.0%
pow-pow98.3%
metadata-eval98.3%
pow1/298.3%
sqrt-div98.3%
metadata-eval98.3%
div-inv98.3%
rem-exp-log49.3%
add-exp-log49.3%
*-un-lft-identity49.3%
exp-prod49.3%
rem-exp-log49.3%
Applied egg-rr49.3%
exp-1-e49.3%
Simplified49.3%
sinTheta_O_m = (fabs.f32 sinTheta_O) (FPCore (sinTheta_O_m h eta) :precision binary32 (asin (/ h (+ eta (* -0.5 (pow (exp (log (/ sinTheta_O_m (sqrt eta)))) 2.0))))))
sinTheta_O_m = fabs(sinTheta_O);
float code(float sinTheta_O_m, float h, float eta) {
return asinf((h / (eta + (-0.5f * powf(expf(logf((sinTheta_O_m / sqrtf(eta)))), 2.0f)))));
}
sinTheta_O_m = abs(sintheta_o)
real(4) function code(sintheta_o_m, h, eta)
real(4), intent (in) :: sintheta_o_m
real(4), intent (in) :: h
real(4), intent (in) :: eta
code = asin((h / (eta + ((-0.5e0) * (exp(log((sintheta_o_m / sqrt(eta)))) ** 2.0e0)))))
end function
sinTheta_O_m = abs(sinTheta_O) function code(sinTheta_O_m, h, eta) return asin(Float32(h / Float32(eta + Float32(Float32(-0.5) * (exp(log(Float32(sinTheta_O_m / sqrt(eta)))) ^ Float32(2.0)))))) end
sinTheta_O_m = abs(sinTheta_O); function tmp = code(sinTheta_O_m, h, eta) tmp = asin((h / (eta + (single(-0.5) * (exp(log((sinTheta_O_m / sqrt(eta)))) ^ single(2.0)))))); end
\begin{array}{l}
sinTheta_O_m = \left|sinTheta\_O\right|
\\
\sin^{-1} \left(\frac{h}{eta + -0.5 \cdot {\left(e^{\log \left(\frac{sinTheta\_O\_m}{\sqrt{eta}}\right)}\right)}^{2}}\right)
\end{array}
Initial program 92.4%
Taylor expanded in sinTheta_O around 0 97.8%
add-sqr-sqrt97.8%
pow297.8%
div-inv97.8%
sqrt-prod97.8%
sqrt-pow198.3%
metadata-eval98.3%
pow198.3%
Applied egg-rr98.3%
add-exp-log49.3%
add-sqr-sqrt49.3%
sqrt-prod97.8%
sqrt-prod97.8%
div-inv97.8%
sqrt-div97.8%
sqrt-prod49.3%
add-sqr-sqrt49.3%
Applied egg-rr49.3%
sinTheta_O_m = (fabs.f32 sinTheta_O) (FPCore (sinTheta_O_m h eta) :precision binary32 (asin (/ h (+ eta (* -0.5 (pow (* sinTheta_O_m (exp (* (log eta) (- 0.5)))) 2.0))))))
sinTheta_O_m = fabs(sinTheta_O);
float code(float sinTheta_O_m, float h, float eta) {
return asinf((h / (eta + (-0.5f * powf((sinTheta_O_m * expf((logf(eta) * -0.5f))), 2.0f)))));
}
sinTheta_O_m = abs(sintheta_o)
real(4) function code(sintheta_o_m, h, eta)
real(4), intent (in) :: sintheta_o_m
real(4), intent (in) :: h
real(4), intent (in) :: eta
code = asin((h / (eta + ((-0.5e0) * ((sintheta_o_m * exp((log(eta) * -0.5e0))) ** 2.0e0)))))
end function
sinTheta_O_m = abs(sinTheta_O) function code(sinTheta_O_m, h, eta) return asin(Float32(h / Float32(eta + Float32(Float32(-0.5) * (Float32(sinTheta_O_m * exp(Float32(log(eta) * Float32(-Float32(0.5))))) ^ Float32(2.0)))))) end
sinTheta_O_m = abs(sinTheta_O); function tmp = code(sinTheta_O_m, h, eta) tmp = asin((h / (eta + (single(-0.5) * ((sinTheta_O_m * exp((log(eta) * -single(0.5)))) ^ single(2.0)))))); end
\begin{array}{l}
sinTheta_O_m = \left|sinTheta\_O\right|
\\
\sin^{-1} \left(\frac{h}{eta + -0.5 \cdot {\left(sinTheta\_O\_m \cdot e^{\log eta \cdot \left(-0.5\right)}\right)}^{2}}\right)
\end{array}
Initial program 92.4%
Taylor expanded in sinTheta_O around 0 97.8%
add-sqr-sqrt97.8%
pow297.8%
div-inv97.8%
sqrt-prod97.8%
sqrt-pow198.3%
metadata-eval98.3%
pow198.3%
Applied egg-rr98.3%
pow1/298.3%
pow-to-exp98.3%
log-rec98.3%
Applied egg-rr98.3%
Final simplification98.3%
sinTheta_O_m = (fabs.f32 sinTheta_O) (FPCore (sinTheta_O_m h eta) :precision binary32 (asin (/ h (+ eta (* -0.5 (pow (* sinTheta_O_m (sqrt (/ 1.0 eta))) 2.0))))))
sinTheta_O_m = fabs(sinTheta_O);
float code(float sinTheta_O_m, float h, float eta) {
return asinf((h / (eta + (-0.5f * powf((sinTheta_O_m * sqrtf((1.0f / eta))), 2.0f)))));
}
sinTheta_O_m = abs(sintheta_o)
real(4) function code(sintheta_o_m, h, eta)
real(4), intent (in) :: sintheta_o_m
real(4), intent (in) :: h
real(4), intent (in) :: eta
code = asin((h / (eta + ((-0.5e0) * ((sintheta_o_m * sqrt((1.0e0 / eta))) ** 2.0e0)))))
end function
sinTheta_O_m = abs(sinTheta_O) function code(sinTheta_O_m, h, eta) return asin(Float32(h / Float32(eta + Float32(Float32(-0.5) * (Float32(sinTheta_O_m * sqrt(Float32(Float32(1.0) / eta))) ^ Float32(2.0)))))) end
sinTheta_O_m = abs(sinTheta_O); function tmp = code(sinTheta_O_m, h, eta) tmp = asin((h / (eta + (single(-0.5) * ((sinTheta_O_m * sqrt((single(1.0) / eta))) ^ single(2.0)))))); end
\begin{array}{l}
sinTheta_O_m = \left|sinTheta\_O\right|
\\
\sin^{-1} \left(\frac{h}{eta + -0.5 \cdot {\left(sinTheta\_O\_m \cdot \sqrt{\frac{1}{eta}}\right)}^{2}}\right)
\end{array}
Initial program 92.4%
Taylor expanded in sinTheta_O around 0 97.8%
add-sqr-sqrt97.8%
pow297.8%
div-inv97.8%
sqrt-prod97.8%
sqrt-pow198.3%
metadata-eval98.3%
pow198.3%
Applied egg-rr98.3%
sinTheta_O_m = (fabs.f32 sinTheta_O) (FPCore (sinTheta_O_m h eta) :precision binary32 (asin (/ h (+ eta (* -0.5 (* sinTheta_O_m (/ sinTheta_O_m eta)))))))
sinTheta_O_m = fabs(sinTheta_O);
float code(float sinTheta_O_m, float h, float eta) {
return asinf((h / (eta + (-0.5f * (sinTheta_O_m * (sinTheta_O_m / eta))))));
}
sinTheta_O_m = abs(sintheta_o)
real(4) function code(sintheta_o_m, h, eta)
real(4), intent (in) :: sintheta_o_m
real(4), intent (in) :: h
real(4), intent (in) :: eta
code = asin((h / (eta + ((-0.5e0) * (sintheta_o_m * (sintheta_o_m / eta))))))
end function
sinTheta_O_m = abs(sinTheta_O) function code(sinTheta_O_m, h, eta) return asin(Float32(h / Float32(eta + Float32(Float32(-0.5) * Float32(sinTheta_O_m * Float32(sinTheta_O_m / eta)))))) end
sinTheta_O_m = abs(sinTheta_O); function tmp = code(sinTheta_O_m, h, eta) tmp = asin((h / (eta + (single(-0.5) * (sinTheta_O_m * (sinTheta_O_m / eta)))))); end
\begin{array}{l}
sinTheta_O_m = \left|sinTheta\_O\right|
\\
\sin^{-1} \left(\frac{h}{eta + -0.5 \cdot \left(sinTheta\_O\_m \cdot \frac{sinTheta\_O\_m}{eta}\right)}\right)
\end{array}
Initial program 92.4%
Taylor expanded in sinTheta_O around 0 97.8%
add-sqr-sqrt97.8%
pow297.8%
div-inv97.8%
sqrt-prod97.8%
sqrt-pow198.3%
metadata-eval98.3%
pow198.3%
Applied egg-rr98.3%
unpow298.3%
swap-sqr97.8%
add-sqr-sqrt97.8%
div-inv97.8%
associate-/l*98.3%
*-commutative98.3%
Applied egg-rr98.3%
Final simplification98.3%
sinTheta_O_m = (fabs.f32 sinTheta_O) (FPCore (sinTheta_O_m h eta) :precision binary32 (asin (/ h eta)))
sinTheta_O_m = fabs(sinTheta_O);
float code(float sinTheta_O_m, float h, float eta) {
return asinf((h / eta));
}
sinTheta_O_m = abs(sintheta_o)
real(4) function code(sintheta_o_m, h, eta)
real(4), intent (in) :: sintheta_o_m
real(4), intent (in) :: h
real(4), intent (in) :: eta
code = asin((h / eta))
end function
sinTheta_O_m = abs(sinTheta_O) function code(sinTheta_O_m, h, eta) return asin(Float32(h / eta)) end
sinTheta_O_m = abs(sinTheta_O); function tmp = code(sinTheta_O_m, h, eta) tmp = asin((h / eta)); end
\begin{array}{l}
sinTheta_O_m = \left|sinTheta\_O\right|
\\
\sin^{-1} \left(\frac{h}{eta}\right)
\end{array}
Initial program 92.4%
Taylor expanded in eta around inf 95.2%
herbie shell --seed 2024172
(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)))))))))