| Alternative 1 | |
|---|---|
| Error | 0.0 |
| Cost | 224 |
\[\left(1 - ux\right) + ux \cdot maxCos
\]
(FPCore (ux uy maxCos) :precision binary32 (+ (- 1.0 ux) (* ux maxCos)))
(FPCore (ux uy maxCos) :precision binary32 (+ 1.0 (* ux (+ maxCos -1.0))))
float code(float ux, float uy, float maxCos) {
return (1.0f - ux) + (ux * maxCos);
}
float code(float ux, float uy, float maxCos) {
return 1.0f + (ux * (maxCos + -1.0f));
}
real(4) function code(ux, uy, maxcos)
real(4), intent (in) :: ux
real(4), intent (in) :: uy
real(4), intent (in) :: maxcos
code = (1.0e0 - ux) + (ux * maxcos)
end function
real(4) function code(ux, uy, maxcos)
real(4), intent (in) :: ux
real(4), intent (in) :: uy
real(4), intent (in) :: maxcos
code = 1.0e0 + (ux * (maxcos + (-1.0e0)))
end function
function code(ux, uy, maxCos) return Float32(Float32(Float32(1.0) - ux) + Float32(ux * maxCos)) end
function code(ux, uy, maxCos) return Float32(Float32(1.0) + Float32(ux * Float32(maxCos + Float32(-1.0)))) end
function tmp = code(ux, uy, maxCos) tmp = (single(1.0) - ux) + (ux * maxCos); end
function tmp = code(ux, uy, maxCos) tmp = single(1.0) + (ux * (maxCos + single(-1.0))); end
\left(1 - ux\right) + ux \cdot maxCos
1 + ux \cdot \left(maxCos + -1\right)
Results
Initial program 0.0
Applied egg-rr0.0
Final simplification0.0
| Alternative 1 | |
|---|---|
| Error | 0.0 |
| Cost | 224 |
| Alternative 2 | |
|---|---|
| Error | 0.6 |
| Cost | 96 |
| Alternative 3 | |
|---|---|
| Error | 9.2 |
| Cost | 32 |
herbie shell --seed 2023053
(FPCore (ux uy maxCos)
:name "UniformSampleCone, z"
:precision binary32
:pre (and (and (and (<= 2.328306437e-10 ux) (<= ux 1.0)) (and (<= 2.328306437e-10 uy) (<= uy 1.0))) (and (<= 0.0 maxCos) (<= maxCos 1.0)))
(+ (- 1.0 ux) (* ux maxCos)))