
(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}
Sampling outcomes in binary32 precision:
Herbie found 19 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
(*
cosTheta_O
(*
(/ cosTheta_i v)
(/
(/ (pow (exp sinTheta_O) (/ (- sinTheta_i) v)) (* 2.0 v))
(sinh (/ 1.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 / v) * ((powf(expf(sinTheta_O), (-sinTheta_i / v)) / (2.0f * v)) / sinhf((1.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 * ((costheta_i / v) * (((exp(sintheta_o) ** (-sintheta_i / v)) / (2.0e0 * v)) / sinh((1.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(cosTheta_O * Float32(Float32(cosTheta_i / v) * Float32(Float32((exp(sinTheta_O) ^ Float32(Float32(-sinTheta_i) / v)) / Float32(Float32(2.0) * v)) / sinh(Float32(Float32(1.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 * ((cosTheta_i / v) * (((exp(sinTheta_O) ^ (-sinTheta_i / v)) / (single(2.0) * v)) / sinh((single(1.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])\\
\\
cosTheta\_O \cdot \left(\frac{cosTheta\_i}{v} \cdot \frac{\frac{{\left(e^{sinTheta\_O}\right)}^{\left(\frac{-sinTheta\_i}{v}\right)}}{2 \cdot v}}{\sinh \left(\frac{1}{v}\right)}\right)
\end{array}
Initial program 98.6%
lift-/.f32N/A
lift-*.f32N/A
*-commutativeN/A
associate-/l*N/A
lift-/.f32N/A
lift-*.f32N/A
*-commutativeN/A
associate-/l*N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f32N/A
lower-/.f32N/A
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
Applied rewrites99.0%
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) (/ (pow (exp sinTheta_O) (/ (- sinTheta_i) 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 ((cosTheta_O * cosTheta_i) * (powf(expf(sinTheta_O), (-sinTheta_i / v)) / v)) / ((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 * costheta_i) * ((exp(sintheta_o) ** (-sintheta_i / v)) / v)) / ((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 * cosTheta_i) * Float32((exp(sinTheta_O) ^ Float32(Float32(-sinTheta_i) / v)) / v)) / 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 * cosTheta_i) * ((exp(sinTheta_O) ^ (-sinTheta_i / v)) / v)) / ((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{\left(cosTheta\_O \cdot cosTheta\_i\right) \cdot \frac{{\left(e^{sinTheta\_O}\right)}^{\left(\frac{-sinTheta\_i}{v}\right)}}{v}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}
\end{array}
Initial program 98.6%
lift-*.f32N/A
*-commutativeN/A
lift-/.f32N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f32N/A
lift-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-/.f3298.9
lift-exp.f32N/A
lift-neg.f32N/A
lift-/.f32N/A
distribute-neg-frac2N/A
lift-*.f32N/A
*-commutativeN/A
associate-/l*N/A
exp-prodN/A
lower-pow.f32N/A
lower-exp.f32N/A
frac-2negN/A
remove-double-negN/A
lower-/.f32N/A
lower-neg.f3298.9
Applied rewrites98.9%
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 (* (/ (* (exp (* sinTheta_O (/ (- sinTheta_i) v))) cosTheta_i) (+ v v)) (/ cosTheta_O (* (sinh (/ 1.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 ((expf((sinTheta_O * (-sinTheta_i / v))) * cosTheta_i) / (v + v)) * (cosTheta_O / (sinhf((1.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 = ((exp((sintheta_o * (-sintheta_i / v))) * costheta_i) / (v + v)) * (costheta_o / (sinh((1.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(Float32(Float32(exp(Float32(sinTheta_O * Float32(Float32(-sinTheta_i) / v))) * cosTheta_i) / Float32(v + v)) * Float32(cosTheta_O / Float32(sinh(Float32(Float32(1.0) / 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 = ((exp((sinTheta_O * (-sinTheta_i / v))) * cosTheta_i) / (v + v)) * (cosTheta_O / (sinh((single(1.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])\\
\\
\frac{e^{sinTheta\_O \cdot \frac{-sinTheta\_i}{v}} \cdot cosTheta\_i}{v + v} \cdot \frac{cosTheta\_O}{\sinh \left(\frac{1}{v}\right) \cdot v}
\end{array}
Initial program 98.6%
Taylor expanded in sinTheta_i around 0
Applied rewrites98.6%
Applied rewrites98.2%
Taylor expanded in sinTheta_i around inf
mul-1-negN/A
lower-exp.f32N/A
mul-1-negN/A
associate-/l*N/A
distribute-lft-neg-inN/A
lower-*.f32N/A
lower-neg.f32N/A
lower-/.f3298.7
Applied rewrites98.7%
lift-*.f32N/A
count-2-revN/A
lower-+.f3298.7
Applied rewrites98.7%
Final simplification98.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
(*
(/
(*
(-
1.0
(/
(fma
(* (* sinTheta_O sinTheta_O) (/ (* sinTheta_i sinTheta_i) v))
-0.5
(* sinTheta_O sinTheta_i))
v))
cosTheta_i)
(* 2.0 v))
(/ cosTheta_O (* (sinh (/ 1.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 (((1.0f - (fmaf(((sinTheta_O * sinTheta_O) * ((sinTheta_i * sinTheta_i) / v)), -0.5f, (sinTheta_O * sinTheta_i)) / v)) * cosTheta_i) / (2.0f * v)) * (cosTheta_O / (sinhf((1.0f / v)) * 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(Float32(Float32(1.0) - Float32(fma(Float32(Float32(sinTheta_O * sinTheta_O) * Float32(Float32(sinTheta_i * sinTheta_i) / v)), Float32(-0.5), Float32(sinTheta_O * sinTheta_i)) / v)) * cosTheta_i) / Float32(Float32(2.0) * v)) * Float32(cosTheta_O / Float32(sinh(Float32(Float32(1.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])\\
\\
\frac{\left(1 - \frac{\mathsf{fma}\left(\left(sinTheta\_O \cdot sinTheta\_O\right) \cdot \frac{sinTheta\_i \cdot sinTheta\_i}{v}, -0.5, sinTheta\_O \cdot sinTheta\_i\right)}{v}\right) \cdot cosTheta\_i}{2 \cdot v} \cdot \frac{cosTheta\_O}{\sinh \left(\frac{1}{v}\right) \cdot v}
\end{array}
Initial program 98.6%
Taylor expanded in sinTheta_i around 0
Applied rewrites98.6%
Applied rewrites98.2%
Taylor expanded in sinTheta_i around inf
mul-1-negN/A
lower-exp.f32N/A
mul-1-negN/A
associate-/l*N/A
distribute-lft-neg-inN/A
lower-*.f32N/A
lower-neg.f32N/A
lower-/.f3298.7
Applied rewrites98.7%
Taylor expanded in v around -inf
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f32N/A
lower-/.f32N/A
*-commutativeN/A
lower-fma.f32N/A
associate-/l*N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-/.f32N/A
unpow2N/A
lower-*.f32N/A
lower-*.f3298.7
Applied rewrites98.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
(*
cosTheta_O
(*
(/ cosTheta_i v)
(/
(fma (/ (* -0.5 sinTheta_O) v) (/ sinTheta_i v) (/ 0.5 v))
(sinh (/ 1.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 / v) * (fmaf(((-0.5f * sinTheta_O) / v), (sinTheta_i / v), (0.5f / v)) / sinhf((1.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(cosTheta_O * Float32(Float32(cosTheta_i / v) * Float32(fma(Float32(Float32(Float32(-0.5) * sinTheta_O) / v), Float32(sinTheta_i / v), Float32(Float32(0.5) / v)) / sinh(Float32(Float32(1.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])\\
\\
cosTheta\_O \cdot \left(\frac{cosTheta\_i}{v} \cdot \frac{\mathsf{fma}\left(\frac{-0.5 \cdot sinTheta\_O}{v}, \frac{sinTheta\_i}{v}, \frac{0.5}{v}\right)}{\sinh \left(\frac{1}{v}\right)}\right)
\end{array}
Initial program 98.6%
lift-/.f32N/A
lift-*.f32N/A
*-commutativeN/A
associate-/l*N/A
lift-/.f32N/A
lift-*.f32N/A
*-commutativeN/A
associate-/l*N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f32N/A
lower-/.f32N/A
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
Applied rewrites99.0%
Taylor expanded in sinTheta_i around 0
associate-*r/N/A
associate-*r*N/A
metadata-evalN/A
unpow2N/A
times-fracN/A
associate-*r/N/A
metadata-evalN/A
lower-fma.f32N/A
lower-/.f32N/A
metadata-evalN/A
lower-*.f32N/A
lower-/.f32N/A
lower-/.f3298.8
Applied rewrites98.8%
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_i sinTheta_O) v) (/ sinTheta_i v)) (/ cosTheta_i v))) (/ cosTheta_O (* (sinh (/ 1.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 (-0.5f * ((((cosTheta_i * sinTheta_O) / v) * (sinTheta_i / v)) - (cosTheta_i / v))) * (cosTheta_O / (sinhf((1.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 = ((-0.5e0) * ((((costheta_i * sintheta_o) / v) * (sintheta_i / v)) - (costheta_i / v))) * (costheta_o / (sinh((1.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(Float32(Float32(-0.5) * Float32(Float32(Float32(Float32(cosTheta_i * sinTheta_O) / v) * Float32(sinTheta_i / v)) - Float32(cosTheta_i / v))) * Float32(cosTheta_O / Float32(sinh(Float32(Float32(1.0) / 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 = (single(-0.5) * ((((cosTheta_i * sinTheta_O) / v) * (sinTheta_i / v)) - (cosTheta_i / v))) * (cosTheta_O / (sinh((single(1.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])\\
\\
\left(-0.5 \cdot \left(\frac{cosTheta\_i \cdot sinTheta\_O}{v} \cdot \frac{sinTheta\_i}{v} - \frac{cosTheta\_i}{v}\right)\right) \cdot \frac{cosTheta\_O}{\sinh \left(\frac{1}{v}\right) \cdot v}
\end{array}
Initial program 98.6%
Taylor expanded in sinTheta_i around 0
Applied rewrites98.6%
Applied rewrites98.2%
Taylor expanded in sinTheta_i around inf
mul-1-negN/A
lower-exp.f32N/A
mul-1-negN/A
associate-/l*N/A
distribute-lft-neg-inN/A
lower-*.f32N/A
lower-neg.f32N/A
lower-/.f3298.7
Applied rewrites98.7%
Taylor expanded in sinTheta_i around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
distribute-lft-out--N/A
lower-*.f32N/A
lower--.f32N/A
associate-*r*N/A
unpow2N/A
times-fracN/A
lower-*.f32N/A
lower-/.f32N/A
lower-*.f32N/A
lower-/.f32N/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 (* (* cosTheta_O (- 1.0 (/ (* sinTheta_i sinTheta_O) v))) (/ cosTheta_i (* (* v (* 2.0 v)) (sinh (/ 1.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 * (1.0f - ((sinTheta_i * sinTheta_O) / v))) * (cosTheta_i / ((v * (2.0f * v)) * sinhf((1.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 * (1.0e0 - ((sintheta_i * sintheta_o) / v))) * (costheta_i / ((v * (2.0e0 * v)) * sinh((1.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(cosTheta_O * Float32(Float32(1.0) - Float32(Float32(sinTheta_i * sinTheta_O) / v))) * Float32(cosTheta_i / Float32(Float32(v * Float32(Float32(2.0) * v)) * sinh(Float32(Float32(1.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 * (single(1.0) - ((sinTheta_i * sinTheta_O) / v))) * (cosTheta_i / ((v * (single(2.0) * v)) * sinh((single(1.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])\\
\\
\left(cosTheta\_O \cdot \left(1 - \frac{sinTheta\_i \cdot sinTheta\_O}{v}\right)\right) \cdot \frac{cosTheta\_i}{\left(v \cdot \left(2 \cdot v\right)\right) \cdot \sinh \left(\frac{1}{v}\right)}
\end{array}
Initial program 98.6%
lift-/.f32N/A
lift-*.f32N/A
lift-/.f32N/A
associate-*r/N/A
associate-/l/N/A
lift-*.f32N/A
*-commutativeN/A
associate-*r*N/A
associate-/l*N/A
lower-*.f32N/A
Applied rewrites98.7%
Taylor expanded in sinTheta_i around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f32N/A
lower-/.f32N/A
*-commutativeN/A
lower-*.f3298.5
Applied rewrites98.5%
Final simplification98.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 (* (/ cosTheta_i v) (/ (/ 0.5 v) (sinh (/ 1.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 / v) * ((0.5f / v) / sinhf((1.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 * ((costheta_i / v) * ((0.5e0 / v) / sinh((1.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(cosTheta_O * Float32(Float32(cosTheta_i / v) * Float32(Float32(Float32(0.5) / v) / sinh(Float32(Float32(1.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 * ((cosTheta_i / v) * ((single(0.5) / v) / sinh((single(1.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])\\
\\
cosTheta\_O \cdot \left(\frac{cosTheta\_i}{v} \cdot \frac{\frac{0.5}{v}}{\sinh \left(\frac{1}{v}\right)}\right)
\end{array}
Initial program 98.6%
lift-/.f32N/A
lift-*.f32N/A
*-commutativeN/A
associate-/l*N/A
lift-/.f32N/A
lift-*.f32N/A
*-commutativeN/A
associate-/l*N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f32N/A
lower-/.f32N/A
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
Applied rewrites99.0%
Taylor expanded in sinTheta_i around 0
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 (* (* 0.5 (/ cosTheta_i v)) (/ cosTheta_O (* (sinh (/ 1.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 (0.5f * (cosTheta_i / v)) * (cosTheta_O / (sinhf((1.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 = (0.5e0 * (costheta_i / v)) * (costheta_o / (sinh((1.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(Float32(Float32(0.5) * Float32(cosTheta_i / v)) * Float32(cosTheta_O / Float32(sinh(Float32(Float32(1.0) / 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 = (single(0.5) * (cosTheta_i / v)) * (cosTheta_O / (sinh((single(1.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])\\
\\
\left(0.5 \cdot \frac{cosTheta\_i}{v}\right) \cdot \frac{cosTheta\_O}{\sinh \left(\frac{1}{v}\right) \cdot v}
\end{array}
Initial program 98.6%
Taylor expanded in sinTheta_i around 0
Applied rewrites98.6%
Applied rewrites98.2%
Taylor expanded in sinTheta_i around 0
lower-*.f32N/A
lower-/.f3298.2
Applied rewrites98.2%
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 1.0) (/ cosTheta_i (* 2.0 (* v (* (sinh (/ 1.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 * 1.0f) * (cosTheta_i / (2.0f * (v * (sinhf((1.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 * 1.0e0) * (costheta_i / (2.0e0 * (v * (sinh((1.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(Float32(cosTheta_O * Float32(1.0)) * Float32(cosTheta_i / Float32(Float32(2.0) * Float32(v * Float32(sinh(Float32(Float32(1.0) / 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 * single(1.0)) * (cosTheta_i / (single(2.0) * (v * (sinh((single(1.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])\\
\\
\left(cosTheta\_O \cdot 1\right) \cdot \frac{cosTheta\_i}{2 \cdot \left(v \cdot \left(\sinh \left(\frac{1}{v}\right) \cdot v\right)\right)}
\end{array}
Initial program 98.6%
lift-/.f32N/A
lift-*.f32N/A
lift-/.f32N/A
associate-*r/N/A
associate-/l/N/A
lift-*.f32N/A
*-commutativeN/A
associate-*r*N/A
associate-/l*N/A
lower-*.f32N/A
Applied rewrites98.7%
Taylor expanded in sinTheta_i around 0
Applied rewrites98.3%
lift-*.f32N/A
lift-*.f32N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f3298.3
Applied rewrites98.3%
Final simplification98.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
(/
(*
(fma
(/
(fma
-1.0
sinTheta_i
(/ (* (* (* sinTheta_i sinTheta_i) sinTheta_O) 0.5) v))
v)
sinTheta_O
1.0)
(/ (* cosTheta_i cosTheta_O) v))
(*
(/
(-
(/
(fma (/ 0.016666666666666666 (* v v)) -1.0 -0.3333333333333333)
(* v 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 (fmaf((fmaf(-1.0f, sinTheta_i, ((((sinTheta_i * sinTheta_i) * sinTheta_O) * 0.5f) / v)) / v), sinTheta_O, 1.0f) * ((cosTheta_i * cosTheta_O) / v)) / ((((fmaf((0.016666666666666666f / (v * v)), -1.0f, -0.3333333333333333f) / (v * v)) - 2.0f) / -v) * 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(-1.0), sinTheta_i, Float32(Float32(Float32(Float32(sinTheta_i * sinTheta_i) * sinTheta_O) * Float32(0.5)) / v)) / v), sinTheta_O, Float32(1.0)) * Float32(Float32(cosTheta_i * cosTheta_O) / v)) / Float32(Float32(Float32(Float32(fma(Float32(Float32(0.016666666666666666) / Float32(v * v)), Float32(-1.0), Float32(-0.3333333333333333)) / Float32(v * v)) - Float32(2.0)) / Float32(-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{\mathsf{fma}\left(\frac{\mathsf{fma}\left(-1, sinTheta\_i, \frac{\left(\left(sinTheta\_i \cdot sinTheta\_i\right) \cdot sinTheta\_O\right) \cdot 0.5}{v}\right)}{v}, sinTheta\_O, 1\right) \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}{\frac{\frac{\mathsf{fma}\left(\frac{0.016666666666666666}{v \cdot v}, -1, -0.3333333333333333\right)}{v \cdot v} - 2}{-v} \cdot v}
\end{array}
Initial program 98.6%
Taylor expanded in sinTheta_i around 0
Applied rewrites98.6%
Taylor expanded in v around -inf
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f32N/A
Applied rewrites72.0%
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 1.0)
(/
cosTheta_i
(*
2.0
(*
v
(*
(/
(-
(/
(fma (/ 0.008333333333333333 (* v v)) -1.0 -0.16666666666666666)
(* (- v) v))
-1.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 * 1.0f) * (cosTheta_i / (2.0f * (v * ((((fmaf((0.008333333333333333f / (v * v)), -1.0f, -0.16666666666666666f) / (-v * v)) - -1.0f) / v) * 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 * Float32(1.0)) * Float32(cosTheta_i / Float32(Float32(2.0) * Float32(v * Float32(Float32(Float32(Float32(fma(Float32(Float32(0.008333333333333333) / Float32(v * v)), Float32(-1.0), Float32(-0.16666666666666666)) / Float32(Float32(-v) * v)) - Float32(-1.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])\\
\\
\left(cosTheta\_O \cdot 1\right) \cdot \frac{cosTheta\_i}{2 \cdot \left(v \cdot \left(\frac{\frac{\mathsf{fma}\left(\frac{0.008333333333333333}{v \cdot v}, -1, -0.16666666666666666\right)}{\left(-v\right) \cdot v} - -1}{v} \cdot v\right)\right)}
\end{array}
Initial program 98.6%
lift-/.f32N/A
lift-*.f32N/A
lift-/.f32N/A
associate-*r/N/A
associate-/l/N/A
lift-*.f32N/A
*-commutativeN/A
associate-*r*N/A
associate-/l*N/A
lower-*.f32N/A
Applied rewrites98.7%
Taylor expanded in sinTheta_i around 0
Applied rewrites98.3%
lift-*.f32N/A
lift-*.f32N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f3298.3
Applied rewrites98.3%
Taylor expanded in v around -inf
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f32N/A
Applied rewrites72.0%
Final simplification72.0%
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 1.0)
(/
cosTheta_i
(*
(- v)
(-
(/
(fma (/ 0.016666666666666666 (* v v)) -1.0 -0.3333333333333333)
(* v 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 * 1.0f) * (cosTheta_i / (-v * ((fmaf((0.016666666666666666f / (v * v)), -1.0f, -0.3333333333333333f) / (v * v)) - 2.0f)));
}
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(1.0)) * Float32(cosTheta_i / Float32(Float32(-v) * Float32(Float32(fma(Float32(Float32(0.016666666666666666) / Float32(v * v)), Float32(-1.0), Float32(-0.3333333333333333)) / Float32(v * v)) - Float32(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])\\
\\
\left(cosTheta\_O \cdot 1\right) \cdot \frac{cosTheta\_i}{\left(-v\right) \cdot \left(\frac{\mathsf{fma}\left(\frac{0.016666666666666666}{v \cdot v}, -1, -0.3333333333333333\right)}{v \cdot v} - 2\right)}
\end{array}
Initial program 98.6%
lift-/.f32N/A
lift-*.f32N/A
lift-/.f32N/A
associate-*r/N/A
associate-/l/N/A
lift-*.f32N/A
*-commutativeN/A
associate-*r*N/A
associate-/l*N/A
lower-*.f32N/A
Applied rewrites98.7%
Taylor expanded in sinTheta_i around 0
Applied rewrites98.3%
Taylor expanded in v around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f32N/A
lower-neg.f32N/A
lower--.f32N/A
Applied rewrites72.0%
Final simplification72.0%
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 1.0) (/ cosTheta_i (* 2.0 (* v (* (/ (+ (/ 0.16666666666666666 (* v v)) 1.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 * 1.0f) * (cosTheta_i / (2.0f * (v * ((((0.16666666666666666f / (v * v)) + 1.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 * 1.0e0) * (costheta_i / (2.0e0 * (v * ((((0.16666666666666666e0 / (v * v)) + 1.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(Float32(cosTheta_O * Float32(1.0)) * Float32(cosTheta_i / Float32(Float32(2.0) * Float32(v * Float32(Float32(Float32(Float32(Float32(0.16666666666666666) / Float32(v * v)) + Float32(1.0)) / 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 * single(1.0)) * (cosTheta_i / (single(2.0) * (v * ((((single(0.16666666666666666) / (v * v)) + single(1.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])\\
\\
\left(cosTheta\_O \cdot 1\right) \cdot \frac{cosTheta\_i}{2 \cdot \left(v \cdot \left(\frac{\frac{0.16666666666666666}{v \cdot v} + 1}{v} \cdot v\right)\right)}
\end{array}
Initial program 98.6%
lift-/.f32N/A
lift-*.f32N/A
lift-/.f32N/A
associate-*r/N/A
associate-/l/N/A
lift-*.f32N/A
*-commutativeN/A
associate-*r*N/A
associate-/l*N/A
lower-*.f32N/A
Applied rewrites98.7%
Taylor expanded in sinTheta_i around 0
Applied rewrites98.3%
lift-*.f32N/A
lift-*.f32N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f3298.3
Applied rewrites98.3%
Taylor expanded in v around inf
lower-/.f32N/A
+-commutativeN/A
lower-+.f32N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f32N/A
unpow2N/A
lower-*.f3265.8
Applied rewrites65.8%
Final simplification65.8%
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 1.0) (/ cosTheta_i (* (+ (/ 0.3333333333333333 (* v 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 * 1.0f) * (cosTheta_i / (((0.3333333333333333f / (v * 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 * 1.0e0) * (costheta_i / (((0.3333333333333333e0 / (v * 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(cosTheta_O * Float32(1.0)) * Float32(cosTheta_i / Float32(Float32(Float32(Float32(0.3333333333333333) / Float32(v * 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 * single(1.0)) * (cosTheta_i / (((single(0.3333333333333333) / (v * 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])\\
\\
\left(cosTheta\_O \cdot 1\right) \cdot \frac{cosTheta\_i}{\left(\frac{0.3333333333333333}{v \cdot v} + 2\right) \cdot v}
\end{array}
Initial program 98.6%
lift-/.f32N/A
lift-*.f32N/A
lift-/.f32N/A
associate-*r/N/A
associate-/l/N/A
lift-*.f32N/A
*-commutativeN/A
associate-*r*N/A
associate-/l*N/A
lower-*.f32N/A
Applied rewrites98.7%
Taylor expanded in sinTheta_i around 0
Applied rewrites98.3%
Taylor expanded in v around inf
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-+.f32N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f32N/A
unpow2N/A
lower-*.f3265.8
Applied rewrites65.8%
Final simplification65.8%
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_i cosTheta_O) 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_i * cosTheta_O) * 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_i * costheta_o) * 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(cosTheta_i * cosTheta_O) * 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_i * cosTheta_O) * 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{\left(cosTheta\_i \cdot cosTheta\_O\right) \cdot 0.5}{v}
\end{array}
Initial program 98.6%
Taylor expanded in v around inf
lower-*.f32N/A
lower-/.f32N/A
lower-*.f3260.0
Applied rewrites60.0%
Applied rewrites60.1%
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_i) cosTheta_O) 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_i) * cosTheta_O) / 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_i) * costheta_o) / 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(0.5) * cosTheta_i) * cosTheta_O) / 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_i) * cosTheta_O) / 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(0.5 \cdot cosTheta\_i\right) \cdot cosTheta\_O}{v}
\end{array}
Initial program 98.6%
Taylor expanded in v around inf
lower-*.f32N/A
lower-/.f32N/A
lower-*.f3260.0
Applied rewrites60.0%
Applied rewrites60.0%
Applied rewrites60.1%
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_i) (/ cosTheta_O 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_i) * (cosTheta_O / 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_i) * (costheta_o / 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(0.5) * cosTheta_i) * Float32(cosTheta_O / 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_i) * (cosTheta_O / 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])\\
\\
\left(0.5 \cdot cosTheta\_i\right) \cdot \frac{cosTheta\_O}{v}
\end{array}
Initial program 98.6%
Taylor expanded in v around inf
lower-*.f32N/A
lower-/.f32N/A
lower-*.f3260.0
Applied rewrites60.0%
Applied rewrites60.0%
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-*.f3260.0
Applied rewrites60.0%
herbie shell --seed 2024351
(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)))