
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (/ (* (exp (- (/ (* sinTheta_i sinTheta_O) v))) (/ (* cosTheta_i cosTheta_O) v)) (* (* (sinh (/ 1.0 v)) 2.0) v)))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return (expf(-((sinTheta_i * sinTheta_O) / v)) * ((cosTheta_i * cosTheta_O) / v)) / ((sinhf((1.0f / v)) * 2.0f) * v);
}
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, costheta_o, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
real(4), intent (in) :: costheta_i
real(4), intent (in) :: costheta_o
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
code = (exp(-((sintheta_i * sintheta_o) / v)) * ((costheta_i * costheta_o) / v)) / ((sinh((1.0e0 / v)) * 2.0e0) * v)
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(exp(Float32(-Float32(Float32(sinTheta_i * sinTheta_O) / v))) * Float32(Float32(cosTheta_i * cosTheta_O) / v)) / Float32(Float32(sinh(Float32(Float32(1.0) / v)) * Float32(2.0)) * v)) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = (exp(-((sinTheta_i * sinTheta_O) / v)) * ((cosTheta_i * cosTheta_O) / v)) / ((sinh((single(1.0) / v)) * single(2.0)) * v); end
\begin{array}{l}
\\
\frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}
\end{array}
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (/ (* (exp (- (/ (* sinTheta_i sinTheta_O) v))) (/ (* cosTheta_i cosTheta_O) v)) (* (* (sinh (/ 1.0 v)) 2.0) v)))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return (expf(-((sinTheta_i * sinTheta_O) / v)) * ((cosTheta_i * cosTheta_O) / v)) / ((sinhf((1.0f / v)) * 2.0f) * v);
}
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, costheta_o, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
real(4), intent (in) :: costheta_i
real(4), intent (in) :: costheta_o
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
code = (exp(-((sintheta_i * sintheta_o) / v)) * ((costheta_i * costheta_o) / v)) / ((sinh((1.0e0 / v)) * 2.0e0) * v)
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(exp(Float32(-Float32(Float32(sinTheta_i * sinTheta_O) / v))) * Float32(Float32(cosTheta_i * cosTheta_O) / v)) / Float32(Float32(sinh(Float32(Float32(1.0) / v)) * Float32(2.0)) * v)) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = (exp(-((sinTheta_i * sinTheta_O) / v)) * ((cosTheta_i * cosTheta_O) / v)) / ((sinh((single(1.0) / v)) * single(2.0)) * v); end
\begin{array}{l}
\\
\frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}
\end{array}
NOTE: cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:precision binary32
(/
(*
(*
(fma
(/
(fma (* 0.5 sinTheta_O) (* sinTheta_i sinTheta_i) (* (- sinTheta_i) v))
(* v v))
sinTheta_O
1.0)
cosTheta_i)
(/ cosTheta_O v))
(* (* (sinh (/ 1.0 v)) 2.0) v)))assert(cosTheta_i < cosTheta_O && cosTheta_O < sinTheta_i && sinTheta_i < sinTheta_O && sinTheta_O < v);
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return ((fmaf((fmaf((0.5f * sinTheta_O), (sinTheta_i * sinTheta_i), (-sinTheta_i * v)) / (v * v)), sinTheta_O, 1.0f) * cosTheta_i) * (cosTheta_O / v)) / ((sinhf((1.0f / v)) * 2.0f) * v);
}
cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v = sort([cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v]) function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(Float32(fma(Float32(fma(Float32(Float32(0.5) * sinTheta_O), Float32(sinTheta_i * sinTheta_i), Float32(Float32(-sinTheta_i) * v)) / Float32(v * v)), sinTheta_O, Float32(1.0)) * cosTheta_i) * Float32(cosTheta_O / v)) / Float32(Float32(sinh(Float32(Float32(1.0) / v)) * Float32(2.0)) * v)) end
\begin{array}{l}
[cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v])\\
\\
\frac{\left(\mathsf{fma}\left(\frac{\mathsf{fma}\left(0.5 \cdot sinTheta\_O, sinTheta\_i \cdot sinTheta\_i, \left(-sinTheta\_i\right) \cdot v\right)}{v \cdot v}, sinTheta\_O, 1\right) \cdot cosTheta\_i\right) \cdot \frac{cosTheta\_O}{v}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}
\end{array}
Initial program 98.6%
lift-*.f32N/A
lift-/.f32N/A
associate-/l*N/A
lower-*.f32N/A
lower-/.f3298.6
Applied rewrites98.6%
Taylor expanded in sinTheta_O around 0
distribute-neg-frac2N/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites98.6%
lift-*.f32N/A
lift-*.f32N/A
associate-*r*N/A
lower-*.f32N/A
Applied rewrites98.6%
Taylor expanded in v around 0
lower-/.f32N/A
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
pow2N/A
lift-*.f32N/A
associate-*r*N/A
mul-1-negN/A
lower-*.f32N/A
lower-neg.f32N/A
pow2N/A
lift-*.f3298.6
Applied rewrites98.6%
NOTE: cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:precision binary32
(/
(*
(fma
(/
(fma (* 0.5 sinTheta_O) (* sinTheta_i sinTheta_i) (* (- sinTheta_i) v))
(* v v))
sinTheta_O
1.0)
(* cosTheta_i (/ cosTheta_O v)))
(* (* (sinh (/ 1.0 v)) 2.0) v)))assert(cosTheta_i < cosTheta_O && cosTheta_O < sinTheta_i && sinTheta_i < sinTheta_O && sinTheta_O < v);
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return (fmaf((fmaf((0.5f * sinTheta_O), (sinTheta_i * sinTheta_i), (-sinTheta_i * v)) / (v * v)), sinTheta_O, 1.0f) * (cosTheta_i * (cosTheta_O / v))) / ((sinhf((1.0f / v)) * 2.0f) * v);
}
cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v = sort([cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v]) function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(fma(Float32(fma(Float32(Float32(0.5) * sinTheta_O), Float32(sinTheta_i * sinTheta_i), Float32(Float32(-sinTheta_i) * v)) / Float32(v * v)), sinTheta_O, Float32(1.0)) * Float32(cosTheta_i * Float32(cosTheta_O / v))) / Float32(Float32(sinh(Float32(Float32(1.0) / v)) * Float32(2.0)) * v)) end
\begin{array}{l}
[cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v])\\
\\
\frac{\mathsf{fma}\left(\frac{\mathsf{fma}\left(0.5 \cdot sinTheta\_O, sinTheta\_i \cdot sinTheta\_i, \left(-sinTheta\_i\right) \cdot v\right)}{v \cdot v}, sinTheta\_O, 1\right) \cdot \left(cosTheta\_i \cdot \frac{cosTheta\_O}{v}\right)}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}
\end{array}
Initial program 98.6%
lift-*.f32N/A
lift-/.f32N/A
associate-/l*N/A
lower-*.f32N/A
lower-/.f3298.6
Applied rewrites98.6%
Taylor expanded in sinTheta_O around 0
distribute-neg-frac2N/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites98.6%
Taylor expanded in v around 0
lower-/.f32N/A
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
pow2N/A
lift-*.f32N/A
associate-*r*N/A
mul-1-negN/A
lower-*.f32N/A
lower-neg.f32N/A
pow2N/A
lift-*.f3298.6
Applied rewrites98.6%
NOTE: cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function. (FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (/ (fma cosTheta_O (/ cosTheta_i v) (/ (- (* (* (* sinTheta_O sinTheta_i) cosTheta_i) cosTheta_O)) (* v v))) (* (* (sinh (/ 1.0 v)) 2.0) v)))
assert(cosTheta_i < cosTheta_O && cosTheta_O < sinTheta_i && sinTheta_i < sinTheta_O && sinTheta_O < v);
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return fmaf(cosTheta_O, (cosTheta_i / v), (-(((sinTheta_O * sinTheta_i) * cosTheta_i) * cosTheta_O) / (v * v))) / ((sinhf((1.0f / v)) * 2.0f) * v);
}
cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v = sort([cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v]) function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(fma(cosTheta_O, Float32(cosTheta_i / v), Float32(Float32(-Float32(Float32(Float32(sinTheta_O * sinTheta_i) * cosTheta_i) * cosTheta_O)) / Float32(v * v))) / Float32(Float32(sinh(Float32(Float32(1.0) / v)) * Float32(2.0)) * v)) end
\begin{array}{l}
[cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v])\\
\\
\frac{\mathsf{fma}\left(cosTheta\_O, \frac{cosTheta\_i}{v}, \frac{-\left(\left(sinTheta\_O \cdot sinTheta\_i\right) \cdot cosTheta\_i\right) \cdot cosTheta\_O}{v \cdot v}\right)}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}
\end{array}
Initial program 98.6%
Taylor expanded in sinTheta_i around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f32N/A
lower-/.f32N/A
associate-*r/N/A
lower-/.f32N/A
mul-1-negN/A
lower-neg.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f3298.5
Applied rewrites98.5%
NOTE: cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function. (FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (* (/ (fma sinTheta_O (/ sinTheta_i (- v)) 1.0) (* (sinh (/ 1.0 v)) 2.0)) (/ (* (/ cosTheta_O v) cosTheta_i) v)))
assert(cosTheta_i < cosTheta_O && cosTheta_O < sinTheta_i && sinTheta_i < sinTheta_O && sinTheta_O < v);
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return (fmaf(sinTheta_O, (sinTheta_i / -v), 1.0f) / (sinhf((1.0f / v)) * 2.0f)) * (((cosTheta_O / v) * cosTheta_i) / v);
}
cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v = sort([cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v]) function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(fma(sinTheta_O, Float32(sinTheta_i / Float32(-v)), Float32(1.0)) / Float32(sinh(Float32(Float32(1.0) / v)) * Float32(2.0))) * Float32(Float32(Float32(cosTheta_O / v) * cosTheta_i) / v)) end
\begin{array}{l}
[cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v])\\
\\
\frac{\mathsf{fma}\left(sinTheta\_O, \frac{sinTheta\_i}{-v}, 1\right)}{\sinh \left(\frac{1}{v}\right) \cdot 2} \cdot \frac{\frac{cosTheta\_O}{v} \cdot cosTheta\_i}{v}
\end{array}
Initial program 98.6%
Taylor expanded in sinTheta_i around 0
+-commutativeN/A
lower-fma.f32N/A
lower-/.f32N/A
lower-*.f3298.5
Applied rewrites98.5%
Applied rewrites98.5%
NOTE: cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function. (FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (* (/ cosTheta_O v) (/ (/ cosTheta_i v) (* (sinh (/ 1.0 v)) 2.0))))
assert(cosTheta_i < cosTheta_O && cosTheta_O < sinTheta_i && sinTheta_i < sinTheta_O && sinTheta_O < v);
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return (cosTheta_O / v) * ((cosTheta_i / v) / (sinhf((1.0f / v)) * 2.0f));
}
NOTE: cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
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, costheta_o, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
real(4), intent (in) :: costheta_i
real(4), intent (in) :: costheta_o
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
code = (costheta_o / v) * ((costheta_i / v) / (sinh((1.0e0 / v)) * 2.0e0))
end function
cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v = sort([cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v]) function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(cosTheta_O / v) * Float32(Float32(cosTheta_i / v) / Float32(sinh(Float32(Float32(1.0) / v)) * Float32(2.0)))) end
cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v = num2cell(sort([cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v])){:}
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
tmp = (cosTheta_O / v) * ((cosTheta_i / v) / (sinh((single(1.0) / v)) * single(2.0)));
end
\begin{array}{l}
[cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v])\\
\\
\frac{cosTheta\_O}{v} \cdot \frac{\frac{cosTheta\_i}{v}}{\sinh \left(\frac{1}{v}\right) \cdot 2}
\end{array}
Initial program 98.6%
Taylor expanded in sinTheta_i around 0
associate-/r*N/A
lower-/.f32N/A
unpow2N/A
times-fracN/A
lower-*.f32N/A
lower-/.f32N/A
lower-/.f32N/A
rec-expN/A
sinh-undef-revN/A
*-commutativeN/A
lift-sinh.f32N/A
lift-/.f32N/A
lift-*.f3298.4
Applied rewrites98.4%
lift-/.f32N/A
lift-*.f32N/A
lift-/.f32N/A
lift-*.f32N/A
lift-/.f32N/A
lift-sinh.f32N/A
associate-/l*N/A
lower-*.f32N/A
*-commutativeN/A
sinh-undef-revN/A
rec-expN/A
lower-/.f32N/A
lift-/.f32N/A
rec-expN/A
sinh-undef-revN/A
*-commutativeN/A
lift-sinh.f32N/A
lift-/.f32N/A
lift-*.f3298.4
Applied rewrites98.4%
NOTE: cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function. (FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (/ (* (/ cosTheta_O v) cosTheta_i) (* (* (sinh (/ 1.0 v)) 2.0) v)))
assert(cosTheta_i < cosTheta_O && cosTheta_O < sinTheta_i && sinTheta_i < sinTheta_O && sinTheta_O < v);
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return ((cosTheta_O / v) * cosTheta_i) / ((sinhf((1.0f / v)) * 2.0f) * v);
}
NOTE: cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
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, costheta_o, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
real(4), intent (in) :: costheta_i
real(4), intent (in) :: costheta_o
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
code = ((costheta_o / v) * costheta_i) / ((sinh((1.0e0 / v)) * 2.0e0) * v)
end function
cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v = sort([cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v]) function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(Float32(cosTheta_O / v) * cosTheta_i) / Float32(Float32(sinh(Float32(Float32(1.0) / v)) * Float32(2.0)) * v)) end
cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v = num2cell(sort([cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v])){:}
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
tmp = ((cosTheta_O / v) * cosTheta_i) / ((sinh((single(1.0) / v)) * single(2.0)) * v);
end
\begin{array}{l}
[cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v])\\
\\
\frac{\frac{cosTheta\_O}{v} \cdot cosTheta\_i}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}
\end{array}
Initial program 98.6%
lift-*.f32N/A
lift-/.f32N/A
associate-/l*N/A
lower-*.f32N/A
lower-/.f3298.6
Applied rewrites98.6%
Taylor expanded in sinTheta_i around 0
*-commutativeN/A
associate-*r/N/A
*-commutativeN/A
lower-*.f32N/A
lift-/.f3298.4
Applied rewrites98.4%
NOTE: cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function. (FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (* (/ cosTheta_O (* (sinh (/ 1.0 v)) 2.0)) (/ cosTheta_i (* v v))))
assert(cosTheta_i < cosTheta_O && cosTheta_O < sinTheta_i && sinTheta_i < sinTheta_O && sinTheta_O < v);
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return (cosTheta_O / (sinhf((1.0f / v)) * 2.0f)) * (cosTheta_i / (v * v));
}
NOTE: cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
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, costheta_o, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
real(4), intent (in) :: costheta_i
real(4), intent (in) :: costheta_o
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
code = (costheta_o / (sinh((1.0e0 / v)) * 2.0e0)) * (costheta_i / (v * v))
end function
cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v = sort([cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v]) function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(cosTheta_O / Float32(sinh(Float32(Float32(1.0) / v)) * Float32(2.0))) * Float32(cosTheta_i / Float32(v * v))) end
cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v = num2cell(sort([cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v])){:}
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
tmp = (cosTheta_O / (sinh((single(1.0) / v)) * single(2.0))) * (cosTheta_i / (v * v));
end
\begin{array}{l}
[cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v])\\
\\
\frac{cosTheta\_O}{\sinh \left(\frac{1}{v}\right) \cdot 2} \cdot \frac{cosTheta\_i}{v \cdot v}
\end{array}
Initial program 98.6%
Taylor expanded in sinTheta_i around 0
associate-/r*N/A
lower-/.f32N/A
unpow2N/A
times-fracN/A
lower-*.f32N/A
lower-/.f32N/A
lower-/.f32N/A
rec-expN/A
sinh-undef-revN/A
*-commutativeN/A
lift-sinh.f32N/A
lift-/.f32N/A
lift-*.f3298.4
Applied rewrites98.4%
lift-/.f32N/A
lift-*.f32N/A
lift-/.f32N/A
lift-/.f32N/A
frac-timesN/A
pow2N/A
lift-*.f32N/A
lift-/.f32N/A
lift-sinh.f32N/A
*-commutativeN/A
sinh-undef-revN/A
rec-expN/A
associate-/r*N/A
lower-/.f32N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
Applied rewrites98.3%
lift-*.f32N/A
lift-/.f32N/A
lift-*.f32N/A
lift-*.f32N/A
lift-/.f32N/A
lift-sinh.f32N/A
lift-*.f32N/A
pow2N/A
times-fracN/A
lower-*.f32N/A
Applied rewrites98.4%
NOTE: cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function. (FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (* cosTheta_O (/ cosTheta_i (* (* (sinh (/ 1.0 v)) 2.0) (* v v)))))
assert(cosTheta_i < cosTheta_O && cosTheta_O < sinTheta_i && sinTheta_i < sinTheta_O && sinTheta_O < v);
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return cosTheta_O * (cosTheta_i / ((sinhf((1.0f / v)) * 2.0f) * (v * v)));
}
NOTE: cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
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, costheta_o, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
real(4), intent (in) :: costheta_i
real(4), intent (in) :: costheta_o
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
code = costheta_o * (costheta_i / ((sinh((1.0e0 / v)) * 2.0e0) * (v * v)))
end function
cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v = sort([cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v]) function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(cosTheta_O * Float32(cosTheta_i / Float32(Float32(sinh(Float32(Float32(1.0) / v)) * Float32(2.0)) * Float32(v * v)))) end
cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v = num2cell(sort([cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v])){:}
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
tmp = cosTheta_O * (cosTheta_i / ((sinh((single(1.0) / v)) * single(2.0)) * (v * v)));
end
\begin{array}{l}
[cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v])\\
\\
cosTheta\_O \cdot \frac{cosTheta\_i}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot \left(v \cdot v\right)}
\end{array}
Initial program 98.6%
Taylor expanded in sinTheta_i around 0
associate-/r*N/A
lower-/.f32N/A
unpow2N/A
times-fracN/A
lower-*.f32N/A
lower-/.f32N/A
lower-/.f32N/A
rec-expN/A
sinh-undef-revN/A
*-commutativeN/A
lift-sinh.f32N/A
lift-/.f32N/A
lift-*.f3298.4
Applied rewrites98.4%
lift-/.f32N/A
lift-*.f32N/A
lift-/.f32N/A
lift-/.f32N/A
frac-timesN/A
pow2N/A
lift-*.f32N/A
lift-/.f32N/A
lift-sinh.f32N/A
*-commutativeN/A
sinh-undef-revN/A
rec-expN/A
associate-/r*N/A
associate-/l*N/A
lower-*.f32N/A
lower-/.f32N/A
*-commutativeN/A
lower-*.f32N/A
Applied rewrites98.4%
NOTE: cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function. (FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (/ (* cosTheta_O cosTheta_i) (* (fma 0.3333333333333333 (pow v -2.0) 2.0) v)))
assert(cosTheta_i < cosTheta_O && cosTheta_O < sinTheta_i && sinTheta_i < sinTheta_O && sinTheta_O < v);
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return (cosTheta_O * cosTheta_i) / (fmaf(0.3333333333333333f, powf(v, -2.0f), 2.0f) * v);
}
cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v = sort([cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v]) function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(cosTheta_O * cosTheta_i) / Float32(fma(Float32(0.3333333333333333), (v ^ Float32(-2.0)), Float32(2.0)) * v)) end
\begin{array}{l}
[cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v])\\
\\
\frac{cosTheta\_O \cdot cosTheta\_i}{\mathsf{fma}\left(0.3333333333333333, {v}^{-2}, 2\right) \cdot v}
\end{array}
Initial program 98.6%
Taylor expanded in sinTheta_i around 0
associate-/r*N/A
lower-/.f32N/A
unpow2N/A
times-fracN/A
lower-*.f32N/A
lower-/.f32N/A
lower-/.f32N/A
rec-expN/A
sinh-undef-revN/A
*-commutativeN/A
lift-sinh.f32N/A
lift-/.f32N/A
lift-*.f3298.4
Applied rewrites98.4%
lift-/.f32N/A
lift-*.f32N/A
lift-/.f32N/A
lift-/.f32N/A
frac-timesN/A
pow2N/A
lift-*.f32N/A
lift-/.f32N/A
lift-sinh.f32N/A
*-commutativeN/A
sinh-undef-revN/A
rec-expN/A
associate-/r*N/A
lower-/.f32N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
Applied rewrites98.3%
Taylor expanded in v around inf
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f32N/A
pow-flipN/A
lower-pow.f32N/A
metadata-eval64.3
Applied rewrites64.3%
NOTE: cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function. (FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (* (/ (/ (* cosTheta_O cosTheta_i) v) v) (* 0.5 v)))
assert(cosTheta_i < cosTheta_O && cosTheta_O < sinTheta_i && sinTheta_i < sinTheta_O && sinTheta_O < v);
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return (((cosTheta_O * cosTheta_i) / v) / v) * (0.5f * v);
}
NOTE: cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
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, costheta_o, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
real(4), intent (in) :: costheta_i
real(4), intent (in) :: costheta_o
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
code = (((costheta_o * costheta_i) / v) / v) * (0.5e0 * v)
end function
cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v = sort([cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v]) function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(Float32(Float32(cosTheta_O * cosTheta_i) / v) / v) * Float32(Float32(0.5) * v)) end
cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v = num2cell(sort([cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v])){:}
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
tmp = (((cosTheta_O * cosTheta_i) / v) / v) * (single(0.5) * v);
end
\begin{array}{l}
[cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v])\\
\\
\frac{\frac{cosTheta\_O \cdot cosTheta\_i}{v}}{v} \cdot \left(0.5 \cdot v\right)
\end{array}
Initial program 98.6%
Applied rewrites98.5%
Taylor expanded in v around inf
lower-*.f3258.6
Applied rewrites58.6%
NOTE: cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function. (FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (/ (* cosTheta_O (* cosTheta_i 0.5)) v))
assert(cosTheta_i < cosTheta_O && cosTheta_O < sinTheta_i && sinTheta_i < sinTheta_O && sinTheta_O < v);
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return (cosTheta_O * (cosTheta_i * 0.5f)) / v;
}
NOTE: cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
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, costheta_o, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
real(4), intent (in) :: costheta_i
real(4), intent (in) :: costheta_o
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
code = (costheta_o * (costheta_i * 0.5e0)) / v
end function
cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v = sort([cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v]) function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(cosTheta_O * Float32(cosTheta_i * Float32(0.5))) / v) end
cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v = num2cell(sort([cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v])){:}
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
tmp = (cosTheta_O * (cosTheta_i * single(0.5))) / v;
end
\begin{array}{l}
[cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v])\\
\\
\frac{cosTheta\_O \cdot \left(cosTheta\_i \cdot 0.5\right)}{v}
\end{array}
Initial program 98.6%
Taylor expanded in v around inf
lower-*.f32N/A
lower-/.f32N/A
lower-*.f3258.6
Applied rewrites58.6%
lift-*.f32N/A
lift-*.f32N/A
lift-/.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
associate-*r/N/A
*-commutativeN/A
lower-*.f32N/A
lift-/.f3258.6
Applied rewrites58.6%
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f3258.6
Applied rewrites58.6%
lift-*.f32N/A
lift-/.f32N/A
associate-*l/N/A
lower-/.f32N/A
lower-*.f3258.7
Applied rewrites58.7%
NOTE: cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function. (FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v) :precision binary32 (* 0.5 (/ (* cosTheta_O cosTheta_i) v)))
assert(cosTheta_i < cosTheta_O && cosTheta_O < sinTheta_i && sinTheta_i < sinTheta_O && sinTheta_O < v);
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return 0.5f * ((cosTheta_O * cosTheta_i) / v);
}
NOTE: cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
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, costheta_o, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
real(4), intent (in) :: costheta_i
real(4), intent (in) :: costheta_o
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
code = 0.5e0 * ((costheta_o * costheta_i) / v)
end function
cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v = sort([cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v]) function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(0.5) * Float32(Float32(cosTheta_O * cosTheta_i) / v)) end
cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v = num2cell(sort([cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v])){:}
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
tmp = single(0.5) * ((cosTheta_O * cosTheta_i) / v);
end
\begin{array}{l}
[cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v])\\
\\
0.5 \cdot \frac{cosTheta\_O \cdot cosTheta\_i}{v}
\end{array}
Initial program 98.6%
Taylor expanded in v around inf
lower-*.f32N/A
lower-/.f32N/A
lower-*.f3258.6
Applied rewrites58.6%
herbie shell --seed 2025093
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:name "HairBSDF, Mp, upper"
:precision binary32
:pre (and (and (and (and (and (and (<= -1.0 cosTheta_i) (<= cosTheta_i 1.0)) (and (<= -1.0 cosTheta_O) (<= cosTheta_O 1.0))) (and (<= -1.0 sinTheta_i) (<= sinTheta_i 1.0))) (and (<= -1.0 sinTheta_O) (<= sinTheta_O 1.0))) (< 0.1 v)) (<= v 1.5707964))
(/ (* (exp (- (/ (* sinTheta_i sinTheta_O) v))) (/ (* cosTheta_i cosTheta_O) v)) (* (* (sinh (/ 1.0 v)) 2.0) v)))