
(FPCore (cosTheta_i u1 u2) :precision binary32 (* (sqrt (/ u1 (- 1.0 u1))) (cos (* 6.28318530718 u2))))
float code(float cosTheta_i, float u1, float u2) {
return sqrtf((u1 / (1.0f - u1))) * cosf((6.28318530718f * u2));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(4) function code(costheta_i, u1, u2)
use fmin_fmax_functions
real(4), intent (in) :: costheta_i
real(4), intent (in) :: u1
real(4), intent (in) :: u2
code = sqrt((u1 / (1.0e0 - u1))) * cos((6.28318530718e0 * u2))
end function
function code(cosTheta_i, u1, u2) return Float32(sqrt(Float32(u1 / Float32(Float32(1.0) - u1))) * cos(Float32(Float32(6.28318530718) * u2))) end
function tmp = code(cosTheta_i, u1, u2) tmp = sqrt((u1 / (single(1.0) - u1))) * cos((single(6.28318530718) * u2)); end
\begin{array}{l}
\\
\sqrt{\frac{u1}{1 - u1}} \cdot \cos \left(6.28318530718 \cdot u2\right)
\end{array}
Herbie found 18 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (cosTheta_i u1 u2) :precision binary32 (* (sqrt (/ u1 (- 1.0 u1))) (cos (* 6.28318530718 u2))))
float code(float cosTheta_i, float u1, float u2) {
return sqrtf((u1 / (1.0f - u1))) * cosf((6.28318530718f * u2));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(4) function code(costheta_i, u1, u2)
use fmin_fmax_functions
real(4), intent (in) :: costheta_i
real(4), intent (in) :: u1
real(4), intent (in) :: u2
code = sqrt((u1 / (1.0e0 - u1))) * cos((6.28318530718e0 * u2))
end function
function code(cosTheta_i, u1, u2) return Float32(sqrt(Float32(u1 / Float32(Float32(1.0) - u1))) * cos(Float32(Float32(6.28318530718) * u2))) end
function tmp = code(cosTheta_i, u1, u2) tmp = sqrt((u1 / (single(1.0) - u1))) * cos((single(6.28318530718) * u2)); end
\begin{array}{l}
\\
\sqrt{\frac{u1}{1 - u1}} \cdot \cos \left(6.28318530718 \cdot u2\right)
\end{array}
(FPCore (cosTheta_i u1 u2) :precision binary32 (* (pow (/ (* u1 u1) (* (pow u1 2.0) (+ 1.0 (* -1.0 (/ (- 2.0 (/ 1.0 u1)) u1))))) 0.25) (cos (* 6.28318530718 u2))))
float code(float cosTheta_i, float u1, float u2) {
return powf(((u1 * u1) / (powf(u1, 2.0f) * (1.0f + (-1.0f * ((2.0f - (1.0f / u1)) / u1))))), 0.25f) * cosf((6.28318530718f * u2));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(4) function code(costheta_i, u1, u2)
use fmin_fmax_functions
real(4), intent (in) :: costheta_i
real(4), intent (in) :: u1
real(4), intent (in) :: u2
code = (((u1 * u1) / ((u1 ** 2.0e0) * (1.0e0 + ((-1.0e0) * ((2.0e0 - (1.0e0 / u1)) / u1))))) ** 0.25e0) * cos((6.28318530718e0 * u2))
end function
function code(cosTheta_i, u1, u2) return Float32((Float32(Float32(u1 * u1) / Float32((u1 ^ Float32(2.0)) * Float32(Float32(1.0) + Float32(Float32(-1.0) * Float32(Float32(Float32(2.0) - Float32(Float32(1.0) / u1)) / u1))))) ^ Float32(0.25)) * cos(Float32(Float32(6.28318530718) * u2))) end
function tmp = code(cosTheta_i, u1, u2) tmp = (((u1 * u1) / ((u1 ^ single(2.0)) * (single(1.0) + (single(-1.0) * ((single(2.0) - (single(1.0) / u1)) / u1))))) ^ single(0.25)) * cos((single(6.28318530718) * u2)); end
\begin{array}{l}
\\
{\left(\frac{u1 \cdot u1}{{u1}^{2} \cdot \left(1 + -1 \cdot \frac{2 - \frac{1}{u1}}{u1}\right)}\right)}^{0.25} \cdot \cos \left(6.28318530718 \cdot u2\right)
\end{array}
Initial program 99.0%
lift-sqrt.f32N/A
pow1/2N/A
rem-square-sqrtN/A
sqrt-unprodN/A
sqrt-pow2N/A
lower-pow.f32N/A
lift-/.f32N/A
lift-/.f32N/A
frac-timesN/A
lower-*.f32N/A
lower-unsound-*.f32N/A
lower-/.f32N/A
lower-unsound-*.f32N/A
lower-*.f32N/A
metadata-eval99.0
Applied rewrites99.0%
Taylor expanded in u1 around -inf
lower-*.f32N/A
lower-pow.f32N/A
lower-+.f32N/A
lower-*.f32N/A
lower-/.f32N/A
lower--.f32N/A
lower-/.f3298.9
Applied rewrites98.9%
(FPCore (cosTheta_i u1 u2) :precision binary32 (* (pow (/ (* u1 u1) (* (- 1.0 u1) (- 1.0 u1))) 0.25) (cos (* 6.28318530718 u2))))
float code(float cosTheta_i, float u1, float u2) {
return powf(((u1 * u1) / ((1.0f - u1) * (1.0f - u1))), 0.25f) * cosf((6.28318530718f * u2));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(4) function code(costheta_i, u1, u2)
use fmin_fmax_functions
real(4), intent (in) :: costheta_i
real(4), intent (in) :: u1
real(4), intent (in) :: u2
code = (((u1 * u1) / ((1.0e0 - u1) * (1.0e0 - u1))) ** 0.25e0) * cos((6.28318530718e0 * u2))
end function
function code(cosTheta_i, u1, u2) return Float32((Float32(Float32(u1 * u1) / Float32(Float32(Float32(1.0) - u1) * Float32(Float32(1.0) - u1))) ^ Float32(0.25)) * cos(Float32(Float32(6.28318530718) * u2))) end
function tmp = code(cosTheta_i, u1, u2) tmp = (((u1 * u1) / ((single(1.0) - u1) * (single(1.0) - u1))) ^ single(0.25)) * cos((single(6.28318530718) * u2)); end
\begin{array}{l}
\\
{\left(\frac{u1 \cdot u1}{\left(1 - u1\right) \cdot \left(1 - u1\right)}\right)}^{0.25} \cdot \cos \left(6.28318530718 \cdot u2\right)
\end{array}
Initial program 99.0%
lift-sqrt.f32N/A
pow1/2N/A
rem-square-sqrtN/A
sqrt-unprodN/A
sqrt-pow2N/A
lower-pow.f32N/A
lift-/.f32N/A
lift-/.f32N/A
frac-timesN/A
lower-*.f32N/A
lower-unsound-*.f32N/A
lower-/.f32N/A
lower-unsound-*.f32N/A
lower-*.f32N/A
metadata-eval99.0
Applied rewrites99.0%
(FPCore (cosTheta_i u1 u2) :precision binary32 (* (sqrt (/ u1 (* u1 (- (/ 1.0 u1) 1.0)))) (sin (fma -6.28318530718 u2 (* 0.5 PI)))))
float code(float cosTheta_i, float u1, float u2) {
return sqrtf((u1 / (u1 * ((1.0f / u1) - 1.0f)))) * sinf(fmaf(-6.28318530718f, u2, (0.5f * ((float) M_PI))));
}
function code(cosTheta_i, u1, u2) return Float32(sqrt(Float32(u1 / Float32(u1 * Float32(Float32(Float32(1.0) / u1) - Float32(1.0))))) * sin(fma(Float32(-6.28318530718), u2, Float32(Float32(0.5) * Float32(pi))))) end
\begin{array}{l}
\\
\sqrt{\frac{u1}{u1 \cdot \left(\frac{1}{u1} - 1\right)}} \cdot \sin \left(\mathsf{fma}\left(-6.28318530718, u2, 0.5 \cdot \pi\right)\right)
\end{array}
Initial program 99.0%
Taylor expanded in u1 around inf
lower-*.f32N/A
lower--.f32N/A
lower-/.f3298.8
Applied rewrites98.8%
lift-cos.f32N/A
cos-neg-revN/A
sin-+PI/2-revN/A
lower-sin.f32N/A
lift-*.f32N/A
distribute-lft-neg-inN/A
lower-fma.f32N/A
metadata-evalN/A
lift-PI.f32N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f3299.0
Applied rewrites99.0%
(FPCore (cosTheta_i u1 u2) :precision binary32 (* (sqrt (/ u1 (* (/ (- 1.0 u1) u1) u1))) (sin (fma -6.28318530718 u2 (* 0.5 PI)))))
float code(float cosTheta_i, float u1, float u2) {
return sqrtf((u1 / (((1.0f - u1) / u1) * u1))) * sinf(fmaf(-6.28318530718f, u2, (0.5f * ((float) M_PI))));
}
function code(cosTheta_i, u1, u2) return Float32(sqrt(Float32(u1 / Float32(Float32(Float32(Float32(1.0) - u1) / u1) * u1))) * sin(fma(Float32(-6.28318530718), u2, Float32(Float32(0.5) * Float32(pi))))) end
\begin{array}{l}
\\
\sqrt{\frac{u1}{\frac{1 - u1}{u1} \cdot u1}} \cdot \sin \left(\mathsf{fma}\left(-6.28318530718, u2, 0.5 \cdot \pi\right)\right)
\end{array}
Initial program 99.0%
Taylor expanded in u1 around inf
lower-*.f32N/A
lower--.f32N/A
lower-/.f3298.8
Applied rewrites98.8%
lift-cos.f32N/A
cos-neg-revN/A
sin-+PI/2-revN/A
lower-sin.f32N/A
lift-*.f32N/A
distribute-lft-neg-inN/A
lower-fma.f32N/A
metadata-evalN/A
lift-PI.f32N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f3299.0
Applied rewrites99.0%
lift-*.f32N/A
*-commutativeN/A
lift--.f32N/A
lift-/.f32N/A
*-inversesN/A
div-subN/A
lift-/.f32N/A
lift--.f32N/A
lower-*.f3299.0
Applied rewrites99.0%
(FPCore (cosTheta_i u1 u2) :precision binary32 (* (sqrt (/ 1.0 (/ (- 1.0 u1) u1))) (cos (* 6.28318530718 u2))))
float code(float cosTheta_i, float u1, float u2) {
return sqrtf((1.0f / ((1.0f - u1) / u1))) * cosf((6.28318530718f * u2));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(4) function code(costheta_i, u1, u2)
use fmin_fmax_functions
real(4), intent (in) :: costheta_i
real(4), intent (in) :: u1
real(4), intent (in) :: u2
code = sqrt((1.0e0 / ((1.0e0 - u1) / u1))) * cos((6.28318530718e0 * u2))
end function
function code(cosTheta_i, u1, u2) return Float32(sqrt(Float32(Float32(1.0) / Float32(Float32(Float32(1.0) - u1) / u1))) * cos(Float32(Float32(6.28318530718) * u2))) end
function tmp = code(cosTheta_i, u1, u2) tmp = sqrt((single(1.0) / ((single(1.0) - u1) / u1))) * cos((single(6.28318530718) * u2)); end
\begin{array}{l}
\\
\sqrt{\frac{1}{\frac{1 - u1}{u1}}} \cdot \cos \left(6.28318530718 \cdot u2\right)
\end{array}
Initial program 99.0%
lift-/.f32N/A
div-flipN/A
lower-unsound-/.f32N/A
lower-unsound-/.f3298.9
Applied rewrites98.9%
(FPCore (cosTheta_i u1 u2) :precision binary32 (* (sqrt (/ u1 (- 1.0 u1))) (cos (* 6.28318530718 u2))))
float code(float cosTheta_i, float u1, float u2) {
return sqrtf((u1 / (1.0f - u1))) * cosf((6.28318530718f * u2));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(4) function code(costheta_i, u1, u2)
use fmin_fmax_functions
real(4), intent (in) :: costheta_i
real(4), intent (in) :: u1
real(4), intent (in) :: u2
code = sqrt((u1 / (1.0e0 - u1))) * cos((6.28318530718e0 * u2))
end function
function code(cosTheta_i, u1, u2) return Float32(sqrt(Float32(u1 / Float32(Float32(1.0) - u1))) * cos(Float32(Float32(6.28318530718) * u2))) end
function tmp = code(cosTheta_i, u1, u2) tmp = sqrt((u1 / (single(1.0) - u1))) * cos((single(6.28318530718) * u2)); end
\begin{array}{l}
\\
\sqrt{\frac{u1}{1 - u1}} \cdot \cos \left(6.28318530718 \cdot u2\right)
\end{array}
Initial program 99.0%
(FPCore (cosTheta_i u1 u2)
:precision binary32
(if (<= u2 0.014999999664723873)
(*
(sqrt (/ u1 (* u1 (- (/ 1.0 u1) 1.0))))
(+ 1.0 (* -19.739208802181317 (pow u2 2.0))))
(* (sqrt (* (- u1 -1.0) u1)) (cos (* 6.28318530718 u2)))))
float code(float cosTheta_i, float u1, float u2) {
float tmp;
if (u2 <= 0.014999999664723873f) {
tmp = sqrtf((u1 / (u1 * ((1.0f / u1) - 1.0f)))) * (1.0f + (-19.739208802181317f * powf(u2, 2.0f)));
} else {
tmp = sqrtf(((u1 - -1.0f) * u1)) * cosf((6.28318530718f * u2));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(4) function code(costheta_i, u1, u2)
use fmin_fmax_functions
real(4), intent (in) :: costheta_i
real(4), intent (in) :: u1
real(4), intent (in) :: u2
real(4) :: tmp
if (u2 <= 0.014999999664723873e0) then
tmp = sqrt((u1 / (u1 * ((1.0e0 / u1) - 1.0e0)))) * (1.0e0 + ((-19.739208802181317e0) * (u2 ** 2.0e0)))
else
tmp = sqrt(((u1 - (-1.0e0)) * u1)) * cos((6.28318530718e0 * u2))
end if
code = tmp
end function
function code(cosTheta_i, u1, u2) tmp = Float32(0.0) if (u2 <= Float32(0.014999999664723873)) tmp = Float32(sqrt(Float32(u1 / Float32(u1 * Float32(Float32(Float32(1.0) / u1) - Float32(1.0))))) * Float32(Float32(1.0) + Float32(Float32(-19.739208802181317) * (u2 ^ Float32(2.0))))); else tmp = Float32(sqrt(Float32(Float32(u1 - Float32(-1.0)) * u1)) * cos(Float32(Float32(6.28318530718) * u2))); end return tmp end
function tmp_2 = code(cosTheta_i, u1, u2) tmp = single(0.0); if (u2 <= single(0.014999999664723873)) tmp = sqrt((u1 / (u1 * ((single(1.0) / u1) - single(1.0))))) * (single(1.0) + (single(-19.739208802181317) * (u2 ^ single(2.0)))); else tmp = sqrt(((u1 - single(-1.0)) * u1)) * cos((single(6.28318530718) * u2)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;u2 \leq 0.014999999664723873:\\
\;\;\;\;\sqrt{\frac{u1}{u1 \cdot \left(\frac{1}{u1} - 1\right)}} \cdot \left(1 + -19.739208802181317 \cdot {u2}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(u1 - -1\right) \cdot u1} \cdot \cos \left(6.28318530718 \cdot u2\right)\\
\end{array}
\end{array}
if u2 < 0.0149999997Initial program 99.0%
Taylor expanded in u1 around inf
lower-*.f32N/A
lower--.f32N/A
lower-/.f3298.8
Applied rewrites98.8%
Taylor expanded in u2 around 0
lower-+.f32N/A
lower-*.f32N/A
lower-pow.f3287.8
Applied rewrites87.8%
if 0.0149999997 < u2 Initial program 99.0%
Taylor expanded in u1 around 0
lower-*.f32N/A
lower-+.f3286.4
Applied rewrites86.4%
lift-*.f32N/A
*-commutativeN/A
lower-*.f3286.4
lift-+.f32N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f3286.4
Applied rewrites86.4%
(FPCore (cosTheta_i u1 u2)
:precision binary32
(if (<= u2 0.014999999664723873)
(*
(sqrt (/ u1 (* u1 (- (/ 1.0 u1) 1.0))))
(+ 1.0 (* -19.739208802181317 (pow u2 2.0))))
(* (sqrt (fma u1 u1 u1)) (cos (* 6.28318530718 u2)))))
float code(float cosTheta_i, float u1, float u2) {
float tmp;
if (u2 <= 0.014999999664723873f) {
tmp = sqrtf((u1 / (u1 * ((1.0f / u1) - 1.0f)))) * (1.0f + (-19.739208802181317f * powf(u2, 2.0f)));
} else {
tmp = sqrtf(fmaf(u1, u1, u1)) * cosf((6.28318530718f * u2));
}
return tmp;
}
function code(cosTheta_i, u1, u2) tmp = Float32(0.0) if (u2 <= Float32(0.014999999664723873)) tmp = Float32(sqrt(Float32(u1 / Float32(u1 * Float32(Float32(Float32(1.0) / u1) - Float32(1.0))))) * Float32(Float32(1.0) + Float32(Float32(-19.739208802181317) * (u2 ^ Float32(2.0))))); else tmp = Float32(sqrt(fma(u1, u1, u1)) * cos(Float32(Float32(6.28318530718) * u2))); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;u2 \leq 0.014999999664723873:\\
\;\;\;\;\sqrt{\frac{u1}{u1 \cdot \left(\frac{1}{u1} - 1\right)}} \cdot \left(1 + -19.739208802181317 \cdot {u2}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(u1, u1, u1\right)} \cdot \cos \left(6.28318530718 \cdot u2\right)\\
\end{array}
\end{array}
if u2 < 0.0149999997Initial program 99.0%
Taylor expanded in u1 around inf
lower-*.f32N/A
lower--.f32N/A
lower-/.f3298.8
Applied rewrites98.8%
Taylor expanded in u2 around 0
lower-+.f32N/A
lower-*.f32N/A
lower-pow.f3287.8
Applied rewrites87.8%
if 0.0149999997 < u2 Initial program 99.0%
Taylor expanded in u1 around 0
lower-*.f32N/A
lower-+.f3286.4
Applied rewrites86.4%
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f3286.5
Applied rewrites86.5%
(FPCore (cosTheta_i u1 u2)
:precision binary32
(if (<= u2 0.0430000014603138)
(*
(sqrt (/ u1 (* u1 (- (/ 1.0 u1) 1.0))))
(+ 1.0 (* -19.739208802181317 (pow u2 2.0))))
(* (sqrt u1) (sin (fma -6.28318530718 u2 (* 0.5 PI))))))
float code(float cosTheta_i, float u1, float u2) {
float tmp;
if (u2 <= 0.0430000014603138f) {
tmp = sqrtf((u1 / (u1 * ((1.0f / u1) - 1.0f)))) * (1.0f + (-19.739208802181317f * powf(u2, 2.0f)));
} else {
tmp = sqrtf(u1) * sinf(fmaf(-6.28318530718f, u2, (0.5f * ((float) M_PI))));
}
return tmp;
}
function code(cosTheta_i, u1, u2) tmp = Float32(0.0) if (u2 <= Float32(0.0430000014603138)) tmp = Float32(sqrt(Float32(u1 / Float32(u1 * Float32(Float32(Float32(1.0) / u1) - Float32(1.0))))) * Float32(Float32(1.0) + Float32(Float32(-19.739208802181317) * (u2 ^ Float32(2.0))))); else tmp = Float32(sqrt(u1) * sin(fma(Float32(-6.28318530718), u2, Float32(Float32(0.5) * Float32(pi))))); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;u2 \leq 0.0430000014603138:\\
\;\;\;\;\sqrt{\frac{u1}{u1 \cdot \left(\frac{1}{u1} - 1\right)}} \cdot \left(1 + -19.739208802181317 \cdot {u2}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{u1} \cdot \sin \left(\mathsf{fma}\left(-6.28318530718, u2, 0.5 \cdot \pi\right)\right)\\
\end{array}
\end{array}
if u2 < 0.0430000015Initial program 99.0%
Taylor expanded in u1 around inf
lower-*.f32N/A
lower--.f32N/A
lower-/.f3298.8
Applied rewrites98.8%
Taylor expanded in u2 around 0
lower-+.f32N/A
lower-*.f32N/A
lower-pow.f3287.8
Applied rewrites87.8%
if 0.0430000015 < u2 Initial program 99.0%
Taylor expanded in u1 around inf
lower-*.f32N/A
lower--.f32N/A
lower-/.f3298.8
Applied rewrites98.8%
lift-cos.f32N/A
cos-neg-revN/A
sin-+PI/2-revN/A
lower-sin.f32N/A
lift-*.f32N/A
distribute-lft-neg-inN/A
lower-fma.f32N/A
metadata-evalN/A
lift-PI.f32N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f3299.0
Applied rewrites99.0%
Taylor expanded in u1 around 0
Applied rewrites74.0%
(FPCore (cosTheta_i u1 u2)
:precision binary32
(if (<= u2 0.0430000014603138)
(*
(sqrt (/ u1 (* u1 (- (/ 1.0 u1) 1.0))))
(+ 1.0 (* -19.739208802181317 (pow u2 2.0))))
(* (sqrt u1) (cos (* 6.28318530718 u2)))))
float code(float cosTheta_i, float u1, float u2) {
float tmp;
if (u2 <= 0.0430000014603138f) {
tmp = sqrtf((u1 / (u1 * ((1.0f / u1) - 1.0f)))) * (1.0f + (-19.739208802181317f * powf(u2, 2.0f)));
} else {
tmp = sqrtf(u1) * cosf((6.28318530718f * u2));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(4) function code(costheta_i, u1, u2)
use fmin_fmax_functions
real(4), intent (in) :: costheta_i
real(4), intent (in) :: u1
real(4), intent (in) :: u2
real(4) :: tmp
if (u2 <= 0.0430000014603138e0) then
tmp = sqrt((u1 / (u1 * ((1.0e0 / u1) - 1.0e0)))) * (1.0e0 + ((-19.739208802181317e0) * (u2 ** 2.0e0)))
else
tmp = sqrt(u1) * cos((6.28318530718e0 * u2))
end if
code = tmp
end function
function code(cosTheta_i, u1, u2) tmp = Float32(0.0) if (u2 <= Float32(0.0430000014603138)) tmp = Float32(sqrt(Float32(u1 / Float32(u1 * Float32(Float32(Float32(1.0) / u1) - Float32(1.0))))) * Float32(Float32(1.0) + Float32(Float32(-19.739208802181317) * (u2 ^ Float32(2.0))))); else tmp = Float32(sqrt(u1) * cos(Float32(Float32(6.28318530718) * u2))); end return tmp end
function tmp_2 = code(cosTheta_i, u1, u2) tmp = single(0.0); if (u2 <= single(0.0430000014603138)) tmp = sqrt((u1 / (u1 * ((single(1.0) / u1) - single(1.0))))) * (single(1.0) + (single(-19.739208802181317) * (u2 ^ single(2.0)))); else tmp = sqrt(u1) * cos((single(6.28318530718) * u2)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;u2 \leq 0.0430000014603138:\\
\;\;\;\;\sqrt{\frac{u1}{u1 \cdot \left(\frac{1}{u1} - 1\right)}} \cdot \left(1 + -19.739208802181317 \cdot {u2}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{u1} \cdot \cos \left(6.28318530718 \cdot u2\right)\\
\end{array}
\end{array}
if u2 < 0.0430000015Initial program 99.0%
Taylor expanded in u1 around inf
lower-*.f32N/A
lower--.f32N/A
lower-/.f3298.8
Applied rewrites98.8%
Taylor expanded in u2 around 0
lower-+.f32N/A
lower-*.f32N/A
lower-pow.f3287.8
Applied rewrites87.8%
if 0.0430000015 < u2 Initial program 99.0%
Taylor expanded in u1 around 0
Applied rewrites74.0%
(FPCore (cosTheta_i u1 u2) :precision binary32 (* (sqrt (/ u1 (* u1 (- (/ 1.0 u1) 1.0)))) (+ 1.0 (* -19.739208802181317 (pow u2 2.0)))))
float code(float cosTheta_i, float u1, float u2) {
return sqrtf((u1 / (u1 * ((1.0f / u1) - 1.0f)))) * (1.0f + (-19.739208802181317f * powf(u2, 2.0f)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(4) function code(costheta_i, u1, u2)
use fmin_fmax_functions
real(4), intent (in) :: costheta_i
real(4), intent (in) :: u1
real(4), intent (in) :: u2
code = sqrt((u1 / (u1 * ((1.0e0 / u1) - 1.0e0)))) * (1.0e0 + ((-19.739208802181317e0) * (u2 ** 2.0e0)))
end function
function code(cosTheta_i, u1, u2) return Float32(sqrt(Float32(u1 / Float32(u1 * Float32(Float32(Float32(1.0) / u1) - Float32(1.0))))) * Float32(Float32(1.0) + Float32(Float32(-19.739208802181317) * (u2 ^ Float32(2.0))))) end
function tmp = code(cosTheta_i, u1, u2) tmp = sqrt((u1 / (u1 * ((single(1.0) / u1) - single(1.0))))) * (single(1.0) + (single(-19.739208802181317) * (u2 ^ single(2.0)))); end
\begin{array}{l}
\\
\sqrt{\frac{u1}{u1 \cdot \left(\frac{1}{u1} - 1\right)}} \cdot \left(1 + -19.739208802181317 \cdot {u2}^{2}\right)
\end{array}
Initial program 99.0%
Taylor expanded in u1 around inf
lower-*.f32N/A
lower--.f32N/A
lower-/.f3298.8
Applied rewrites98.8%
Taylor expanded in u2 around 0
lower-+.f32N/A
lower-*.f32N/A
lower-pow.f3287.8
Applied rewrites87.8%
(FPCore (cosTheta_i u1 u2) :precision binary32 (* (sqrt (/ 1.0 (/ (- 1.0 u1) u1))) (+ 1.0 (* -19.739208802181317 (pow u2 2.0)))))
float code(float cosTheta_i, float u1, float u2) {
return sqrtf((1.0f / ((1.0f - u1) / u1))) * (1.0f + (-19.739208802181317f * powf(u2, 2.0f)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(4) function code(costheta_i, u1, u2)
use fmin_fmax_functions
real(4), intent (in) :: costheta_i
real(4), intent (in) :: u1
real(4), intent (in) :: u2
code = sqrt((1.0e0 / ((1.0e0 - u1) / u1))) * (1.0e0 + ((-19.739208802181317e0) * (u2 ** 2.0e0)))
end function
function code(cosTheta_i, u1, u2) return Float32(sqrt(Float32(Float32(1.0) / Float32(Float32(Float32(1.0) - u1) / u1))) * Float32(Float32(1.0) + Float32(Float32(-19.739208802181317) * (u2 ^ Float32(2.0))))) end
function tmp = code(cosTheta_i, u1, u2) tmp = sqrt((single(1.0) / ((single(1.0) - u1) / u1))) * (single(1.0) + (single(-19.739208802181317) * (u2 ^ single(2.0)))); end
\begin{array}{l}
\\
\sqrt{\frac{1}{\frac{1 - u1}{u1}}} \cdot \left(1 + -19.739208802181317 \cdot {u2}^{2}\right)
\end{array}
Initial program 99.0%
lift-/.f32N/A
div-flipN/A
lower-unsound-/.f32N/A
lower-unsound-/.f3298.9
Applied rewrites98.9%
Taylor expanded in u2 around 0
lower-+.f32N/A
lower-*.f32N/A
lower-pow.f3287.9
Applied rewrites87.9%
(FPCore (cosTheta_i u1 u2) :precision binary32 (* (sqrt (/ u1 (- 1.0 u1))) (+ 1.0 (* -19.739208802181317 (pow u2 2.0)))))
float code(float cosTheta_i, float u1, float u2) {
return sqrtf((u1 / (1.0f - u1))) * (1.0f + (-19.739208802181317f * powf(u2, 2.0f)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(4) function code(costheta_i, u1, u2)
use fmin_fmax_functions
real(4), intent (in) :: costheta_i
real(4), intent (in) :: u1
real(4), intent (in) :: u2
code = sqrt((u1 / (1.0e0 - u1))) * (1.0e0 + ((-19.739208802181317e0) * (u2 ** 2.0e0)))
end function
function code(cosTheta_i, u1, u2) return Float32(sqrt(Float32(u1 / Float32(Float32(1.0) - u1))) * Float32(Float32(1.0) + Float32(Float32(-19.739208802181317) * (u2 ^ Float32(2.0))))) end
function tmp = code(cosTheta_i, u1, u2) tmp = sqrt((u1 / (single(1.0) - u1))) * (single(1.0) + (single(-19.739208802181317) * (u2 ^ single(2.0)))); end
\begin{array}{l}
\\
\sqrt{\frac{u1}{1 - u1}} \cdot \left(1 + -19.739208802181317 \cdot {u2}^{2}\right)
\end{array}
Initial program 99.0%
Taylor expanded in u2 around 0
lower-+.f32N/A
lower-*.f32N/A
lower-pow.f3288.0
Applied rewrites88.0%
(FPCore (cosTheta_i u1 u2)
:precision binary32
(if (<= u2 0.00011999999696854502)
(sqrt (/ u1 (- 1.0 u1)))
(*
(sqrt (* u1 (+ 1.0 u1)))
(fma
(* (fma 64.93939402268539 (* u2 u2) -19.739208802181317) u2)
u2
1.0))))
float code(float cosTheta_i, float u1, float u2) {
float tmp;
if (u2 <= 0.00011999999696854502f) {
tmp = sqrtf((u1 / (1.0f - u1)));
} else {
tmp = sqrtf((u1 * (1.0f + u1))) * fmaf((fmaf(64.93939402268539f, (u2 * u2), -19.739208802181317f) * u2), u2, 1.0f);
}
return tmp;
}
function code(cosTheta_i, u1, u2) tmp = Float32(0.0) if (u2 <= Float32(0.00011999999696854502)) tmp = sqrt(Float32(u1 / Float32(Float32(1.0) - u1))); else tmp = Float32(sqrt(Float32(u1 * Float32(Float32(1.0) + u1))) * fma(Float32(fma(Float32(64.93939402268539), Float32(u2 * u2), Float32(-19.739208802181317)) * u2), u2, Float32(1.0))); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;u2 \leq 0.00011999999696854502:\\
\;\;\;\;\sqrt{\frac{u1}{1 - u1}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{u1 \cdot \left(1 + u1\right)} \cdot \mathsf{fma}\left(\mathsf{fma}\left(64.93939402268539, u2 \cdot u2, -19.739208802181317\right) \cdot u2, u2, 1\right)\\
\end{array}
\end{array}
if u2 < 1.19999997e-4Initial program 99.0%
Taylor expanded in u2 around 0
lower-sqrt.f32N/A
lower-/.f32N/A
lower--.f3279.3
Applied rewrites79.3%
if 1.19999997e-4 < u2 Initial program 99.0%
Taylor expanded in u1 around 0
lower-*.f32N/A
lower-+.f3286.4
Applied rewrites86.4%
Taylor expanded in u2 around 0
lower-+.f32N/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f32N/A
lower-*.f32N/A
lower-pow.f3280.2
Applied rewrites80.2%
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift-pow.f32N/A
unpow2N/A
associate-*r*N/A
lower-fma.f32N/A
lower-*.f3280.2
lift--.f32N/A
sub-flipN/A
lift-*.f32N/A
lower-fma.f32N/A
lift-pow.f32N/A
unpow2N/A
lower-*.f32N/A
metadata-eval80.2
Applied rewrites80.2%
(FPCore (cosTheta_i u1 u2)
:precision binary32
(if (<= u2 0.00011999999696854502)
(sqrt (/ u1 (- 1.0 u1)))
(*
(sqrt (fma u1 u1 u1))
(fma
(fma 64.93939402268539 (* u2 u2) -19.739208802181317)
(* u2 u2)
1.0))))
float code(float cosTheta_i, float u1, float u2) {
float tmp;
if (u2 <= 0.00011999999696854502f) {
tmp = sqrtf((u1 / (1.0f - u1)));
} else {
tmp = sqrtf(fmaf(u1, u1, u1)) * fmaf(fmaf(64.93939402268539f, (u2 * u2), -19.739208802181317f), (u2 * u2), 1.0f);
}
return tmp;
}
function code(cosTheta_i, u1, u2) tmp = Float32(0.0) if (u2 <= Float32(0.00011999999696854502)) tmp = sqrt(Float32(u1 / Float32(Float32(1.0) - u1))); else tmp = Float32(sqrt(fma(u1, u1, u1)) * fma(fma(Float32(64.93939402268539), Float32(u2 * u2), Float32(-19.739208802181317)), Float32(u2 * u2), Float32(1.0))); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;u2 \leq 0.00011999999696854502:\\
\;\;\;\;\sqrt{\frac{u1}{1 - u1}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(u1, u1, u1\right)} \cdot \mathsf{fma}\left(\mathsf{fma}\left(64.93939402268539, u2 \cdot u2, -19.739208802181317\right), u2 \cdot u2, 1\right)\\
\end{array}
\end{array}
if u2 < 1.19999997e-4Initial program 99.0%
Taylor expanded in u2 around 0
lower-sqrt.f32N/A
lower-/.f32N/A
lower--.f3279.3
Applied rewrites79.3%
if 1.19999997e-4 < u2 Initial program 99.0%
Taylor expanded in u1 around 0
lower-*.f32N/A
lower-+.f3286.4
Applied rewrites86.4%
Taylor expanded in u2 around 0
lower-+.f32N/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f32N/A
lower-*.f32N/A
lower-pow.f3280.2
Applied rewrites80.2%
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f3280.2
lower-fma.f32N/A
lower-fma.f32N/A
lower-fma.f32N/A
lower-fma.f32N/A
lower-fma.f32N/A
Applied rewrites80.2%
(FPCore (cosTheta_i u1 u2) :precision binary32 (sqrt (/ u1 (- 1.0 u1))))
float code(float cosTheta_i, float u1, float u2) {
return sqrtf((u1 / (1.0f - u1)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(4) function code(costheta_i, u1, u2)
use fmin_fmax_functions
real(4), intent (in) :: costheta_i
real(4), intent (in) :: u1
real(4), intent (in) :: u2
code = sqrt((u1 / (1.0e0 - u1)))
end function
function code(cosTheta_i, u1, u2) return sqrt(Float32(u1 / Float32(Float32(1.0) - u1))) end
function tmp = code(cosTheta_i, u1, u2) tmp = sqrt((u1 / (single(1.0) - u1))); end
\begin{array}{l}
\\
\sqrt{\frac{u1}{1 - u1}}
\end{array}
Initial program 99.0%
Taylor expanded in u2 around 0
lower-sqrt.f32N/A
lower-/.f32N/A
lower--.f3279.3
Applied rewrites79.3%
(FPCore (cosTheta_i u1 u2) :precision binary32 (sqrt (fma u1 u1 u1)))
float code(float cosTheta_i, float u1, float u2) {
return sqrtf(fmaf(u1, u1, u1));
}
function code(cosTheta_i, u1, u2) return sqrt(fma(u1, u1, u1)) end
\begin{array}{l}
\\
\sqrt{\mathsf{fma}\left(u1, u1, u1\right)}
\end{array}
Initial program 99.0%
Taylor expanded in u2 around 0
lower-sqrt.f32N/A
lower-/.f32N/A
lower--.f3279.3
Applied rewrites79.3%
Taylor expanded in u1 around 0
lower-*.f32N/A
lower-+.f3271.0
Applied rewrites71.0%
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f3271.0
Applied rewrites71.0%
(FPCore (cosTheta_i u1 u2) :precision binary32 (sqrt u1))
float code(float cosTheta_i, float u1, float u2) {
return sqrtf(u1);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(4) function code(costheta_i, u1, u2)
use fmin_fmax_functions
real(4), intent (in) :: costheta_i
real(4), intent (in) :: u1
real(4), intent (in) :: u2
code = sqrt(u1)
end function
function code(cosTheta_i, u1, u2) return sqrt(u1) end
function tmp = code(cosTheta_i, u1, u2) tmp = sqrt(u1); end
\begin{array}{l}
\\
\sqrt{u1}
\end{array}
Initial program 99.0%
Taylor expanded in u2 around 0
lower-sqrt.f32N/A
lower-/.f32N/A
lower--.f3279.3
Applied rewrites79.3%
Taylor expanded in u1 around 0
lower-sqrt.f3262.6
Applied rewrites62.6%
herbie shell --seed 2025155
(FPCore (cosTheta_i u1 u2)
:name "Trowbridge-Reitz Sample, near normal, slope_x"
:precision binary32
:pre (and (and (and (> cosTheta_i 0.9999) (<= cosTheta_i 1.0)) (and (<= 2.328306437e-10 u1) (<= u1 1.0))) (and (<= 2.328306437e-10 u2) (<= u2 1.0)))
(* (sqrt (/ u1 (- 1.0 u1))) (cos (* 6.28318530718 u2))))