
(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 13 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}
cosTheta_i\_m = (fabs.f32 cosTheta_i)
cosTheta_i\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_i)
cosTheta_O\_m = (fabs.f32 cosTheta_O)
cosTheta_O\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_O)
NOTE: cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
(FPCore (cosTheta_O_s cosTheta_i_s cosTheta_i_m cosTheta_O_m sinTheta_i sinTheta_O v)
:precision binary32
(let* ((t_0 (* (sinh (/ 1.0 v)) 2.0)))
(*
cosTheta_O_s
(*
cosTheta_i_s
(fma
(/ cosTheta_i_m (* v v))
(/ cosTheta_O_m t_0)
(-
(/
(/
(* (* (* sinTheta_O sinTheta_i) cosTheta_i_m) cosTheta_O_m)
(pow v 3.0))
t_0)))))))cosTheta_i\_m = fabs(cosTheta_i);
cosTheta_i\_s = copysign(1.0, cosTheta_i);
cosTheta_O\_m = fabs(cosTheta_O);
cosTheta_O\_s = copysign(1.0, cosTheta_O);
assert(cosTheta_i_m < cosTheta_O_m && cosTheta_O_m < sinTheta_i && sinTheta_i < sinTheta_O && sinTheta_O < v);
float code(float cosTheta_O_s, float cosTheta_i_s, float cosTheta_i_m, float cosTheta_O_m, float sinTheta_i, float sinTheta_O, float v) {
float t_0 = sinhf((1.0f / v)) * 2.0f;
return cosTheta_O_s * (cosTheta_i_s * fmaf((cosTheta_i_m / (v * v)), (cosTheta_O_m / t_0), -(((((sinTheta_O * sinTheta_i) * cosTheta_i_m) * cosTheta_O_m) / powf(v, 3.0f)) / t_0)));
}
cosTheta_i\_m = abs(cosTheta_i) cosTheta_i\_s = copysign(1.0, cosTheta_i) cosTheta_O\_m = abs(cosTheta_O) cosTheta_O\_s = copysign(1.0, cosTheta_O) cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v = sort([cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v]) function code(cosTheta_O_s, cosTheta_i_s, cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v) t_0 = Float32(sinh(Float32(Float32(1.0) / v)) * Float32(2.0)) return Float32(cosTheta_O_s * Float32(cosTheta_i_s * fma(Float32(cosTheta_i_m / Float32(v * v)), Float32(cosTheta_O_m / t_0), Float32(-Float32(Float32(Float32(Float32(Float32(sinTheta_O * sinTheta_i) * cosTheta_i_m) * cosTheta_O_m) / (v ^ Float32(3.0))) / t_0))))) end
\begin{array}{l}
cosTheta_i\_m = \left|cosTheta\_i\right|
\\
cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right)
\\
cosTheta_O\_m = \left|cosTheta\_O\right|
\\
cosTheta_O\_s = \mathsf{copysign}\left(1, cosTheta\_O\right)
\\
[cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v])\\
\\
\begin{array}{l}
t_0 := \sinh \left(\frac{1}{v}\right) \cdot 2\\
cosTheta\_O\_s \cdot \left(cosTheta\_i\_s \cdot \mathsf{fma}\left(\frac{cosTheta\_i\_m}{v \cdot v}, \frac{cosTheta\_O\_m}{t\_0}, -\frac{\frac{\left(\left(sinTheta\_O \cdot sinTheta\_i\right) \cdot cosTheta\_i\_m\right) \cdot cosTheta\_O\_m}{{v}^{3}}}{t\_0}\right)\right)
\end{array}
\end{array}
Initial program 98.6%
Taylor expanded in sinTheta_i around 0
+-commutativeN/A
*-commutativeN/A
times-fracN/A
lower-fma.f32N/A
Applied rewrites98.5%
cosTheta_i\_m = (fabs.f32 cosTheta_i)
cosTheta_i\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_i)
cosTheta_O\_m = (fabs.f32 cosTheta_O)
cosTheta_O\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_O)
NOTE: cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
(FPCore (cosTheta_O_s cosTheta_i_s cosTheta_i_m cosTheta_O_m sinTheta_i sinTheta_O v)
:precision binary32
(*
cosTheta_O_s
(*
cosTheta_i_s
(*
(exp (/ (* sinTheta_O sinTheta_i) (- v)))
(/ (/ (* cosTheta_O_m cosTheta_i_m) v) (* (sinh (/ 1.0 v)) (* 2.0 v)))))))cosTheta_i\_m = fabs(cosTheta_i);
cosTheta_i\_s = copysign(1.0, cosTheta_i);
cosTheta_O\_m = fabs(cosTheta_O);
cosTheta_O\_s = copysign(1.0, cosTheta_O);
assert(cosTheta_i_m < cosTheta_O_m && cosTheta_O_m < sinTheta_i && sinTheta_i < sinTheta_O && sinTheta_O < v);
float code(float cosTheta_O_s, float cosTheta_i_s, float cosTheta_i_m, float cosTheta_O_m, float sinTheta_i, float sinTheta_O, float v) {
return cosTheta_O_s * (cosTheta_i_s * (expf(((sinTheta_O * sinTheta_i) / -v)) * (((cosTheta_O_m * cosTheta_i_m) / v) / (sinhf((1.0f / v)) * (2.0f * v)))));
}
cosTheta_i\_m = private
cosTheta_i\_s = private
cosTheta_O\_m = private
cosTheta_O\_s = private
NOTE: cosTheta_i_m, cosTheta_O_m, 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_o_s, costheta_i_s, costheta_i_m, costheta_o_m, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
real(4), intent (in) :: costheta_o_s
real(4), intent (in) :: costheta_i_s
real(4), intent (in) :: costheta_i_m
real(4), intent (in) :: costheta_o_m
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
code = costheta_o_s * (costheta_i_s * (exp(((sintheta_o * sintheta_i) / -v)) * (((costheta_o_m * costheta_i_m) / v) / (sinh((1.0e0 / v)) * (2.0e0 * v)))))
end function
cosTheta_i\_m = abs(cosTheta_i) cosTheta_i\_s = copysign(1.0, cosTheta_i) cosTheta_O\_m = abs(cosTheta_O) cosTheta_O\_s = copysign(1.0, cosTheta_O) cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v = sort([cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v]) function code(cosTheta_O_s, cosTheta_i_s, cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v) return Float32(cosTheta_O_s * Float32(cosTheta_i_s * Float32(exp(Float32(Float32(sinTheta_O * sinTheta_i) / Float32(-v))) * Float32(Float32(Float32(cosTheta_O_m * cosTheta_i_m) / v) / Float32(sinh(Float32(Float32(1.0) / v)) * Float32(Float32(2.0) * v)))))) end
cosTheta_i\_m = abs(cosTheta_i);
cosTheta_i\_s = sign(cosTheta_i) * abs(1.0);
cosTheta_O\_m = abs(cosTheta_O);
cosTheta_O\_s = sign(cosTheta_O) * abs(1.0);
cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v = num2cell(sort([cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v])){:}
function tmp = code(cosTheta_O_s, cosTheta_i_s, cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v)
tmp = cosTheta_O_s * (cosTheta_i_s * (exp(((sinTheta_O * sinTheta_i) / -v)) * (((cosTheta_O_m * cosTheta_i_m) / v) / (sinh((single(1.0) / v)) * (single(2.0) * v)))));
end
\begin{array}{l}
cosTheta_i\_m = \left|cosTheta\_i\right|
\\
cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right)
\\
cosTheta_O\_m = \left|cosTheta\_O\right|
\\
cosTheta_O\_s = \mathsf{copysign}\left(1, cosTheta\_O\right)
\\
[cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v])\\
\\
cosTheta\_O\_s \cdot \left(cosTheta\_i\_s \cdot \left(e^{\frac{sinTheta\_O \cdot sinTheta\_i}{-v}} \cdot \frac{\frac{cosTheta\_O\_m \cdot cosTheta\_i\_m}{v}}{\sinh \left(\frac{1}{v}\right) \cdot \left(2 \cdot v\right)}\right)\right)
\end{array}
Initial program 98.6%
lift-/.f32N/A
lift-*.f32N/A
lift-exp.f32N/A
lift-neg.f32N/A
lift-*.f32N/A
lift-/.f32N/A
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
Applied rewrites98.6%
cosTheta_i\_m = (fabs.f32 cosTheta_i)
cosTheta_i\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_i)
cosTheta_O\_m = (fabs.f32 cosTheta_O)
cosTheta_O\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_O)
NOTE: cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
(FPCore (cosTheta_O_s cosTheta_i_s cosTheta_i_m cosTheta_O_m sinTheta_i sinTheta_O v)
:precision binary32
(*
cosTheta_O_s
(*
cosTheta_i_s
(*
(/
(/
(- (* cosTheta_O_m v) (* (* sinTheta_O sinTheta_i) cosTheta_O_m))
(* 2.0 (sinh (/ 1.0 v))))
(pow v 3.0))
cosTheta_i_m))))cosTheta_i\_m = fabs(cosTheta_i);
cosTheta_i\_s = copysign(1.0, cosTheta_i);
cosTheta_O\_m = fabs(cosTheta_O);
cosTheta_O\_s = copysign(1.0, cosTheta_O);
assert(cosTheta_i_m < cosTheta_O_m && cosTheta_O_m < sinTheta_i && sinTheta_i < sinTheta_O && sinTheta_O < v);
float code(float cosTheta_O_s, float cosTheta_i_s, float cosTheta_i_m, float cosTheta_O_m, float sinTheta_i, float sinTheta_O, float v) {
return cosTheta_O_s * (cosTheta_i_s * (((((cosTheta_O_m * v) - ((sinTheta_O * sinTheta_i) * cosTheta_O_m)) / (2.0f * sinhf((1.0f / v)))) / powf(v, 3.0f)) * cosTheta_i_m));
}
cosTheta_i\_m = private
cosTheta_i\_s = private
cosTheta_O\_m = private
cosTheta_O\_s = private
NOTE: cosTheta_i_m, cosTheta_O_m, 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_o_s, costheta_i_s, costheta_i_m, costheta_o_m, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
real(4), intent (in) :: costheta_o_s
real(4), intent (in) :: costheta_i_s
real(4), intent (in) :: costheta_i_m
real(4), intent (in) :: costheta_o_m
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
code = costheta_o_s * (costheta_i_s * (((((costheta_o_m * v) - ((sintheta_o * sintheta_i) * costheta_o_m)) / (2.0e0 * sinh((1.0e0 / v)))) / (v ** 3.0e0)) * costheta_i_m))
end function
cosTheta_i\_m = abs(cosTheta_i) cosTheta_i\_s = copysign(1.0, cosTheta_i) cosTheta_O\_m = abs(cosTheta_O) cosTheta_O\_s = copysign(1.0, cosTheta_O) cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v = sort([cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v]) function code(cosTheta_O_s, cosTheta_i_s, cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v) return Float32(cosTheta_O_s * Float32(cosTheta_i_s * Float32(Float32(Float32(Float32(Float32(cosTheta_O_m * v) - Float32(Float32(sinTheta_O * sinTheta_i) * cosTheta_O_m)) / Float32(Float32(2.0) * sinh(Float32(Float32(1.0) / v)))) / (v ^ Float32(3.0))) * cosTheta_i_m))) end
cosTheta_i\_m = abs(cosTheta_i);
cosTheta_i\_s = sign(cosTheta_i) * abs(1.0);
cosTheta_O\_m = abs(cosTheta_O);
cosTheta_O\_s = sign(cosTheta_O) * abs(1.0);
cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v = num2cell(sort([cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v])){:}
function tmp = code(cosTheta_O_s, cosTheta_i_s, cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v)
tmp = cosTheta_O_s * (cosTheta_i_s * (((((cosTheta_O_m * v) - ((sinTheta_O * sinTheta_i) * cosTheta_O_m)) / (single(2.0) * sinh((single(1.0) / v)))) / (v ^ single(3.0))) * cosTheta_i_m));
end
\begin{array}{l}
cosTheta_i\_m = \left|cosTheta\_i\right|
\\
cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right)
\\
cosTheta_O\_m = \left|cosTheta\_O\right|
\\
cosTheta_O\_s = \mathsf{copysign}\left(1, cosTheta\_O\right)
\\
[cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v])\\
\\
cosTheta\_O\_s \cdot \left(cosTheta\_i\_s \cdot \left(\frac{\frac{cosTheta\_O\_m \cdot v - \left(sinTheta\_O \cdot sinTheta\_i\right) \cdot cosTheta\_O\_m}{2 \cdot \sinh \left(\frac{1}{v}\right)}}{{v}^{3}} \cdot cosTheta\_i\_m\right)\right)
\end{array}
Initial program 98.6%
Taylor expanded in sinTheta_i around 0
+-commutativeN/A
*-commutativeN/A
times-fracN/A
lower-fma.f32N/A
Applied rewrites98.5%
Taylor expanded in cosTheta_i around 0
*-commutativeN/A
lower-*.f32N/A
Applied rewrites98.5%
Taylor expanded in v around 0
lower-/.f32N/A
Applied rewrites98.5%
cosTheta_i\_m = (fabs.f32 cosTheta_i)
cosTheta_i\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_i)
cosTheta_O\_m = (fabs.f32 cosTheta_O)
cosTheta_O\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_O)
NOTE: cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
(FPCore (cosTheta_O_s cosTheta_i_s cosTheta_i_m cosTheta_O_m sinTheta_i sinTheta_O v)
:precision binary32
(*
cosTheta_O_s
(*
cosTheta_i_s
(/
(*
(fma -1.0 (/ (* sinTheta_O sinTheta_i) v) 1.0)
(/ (* cosTheta_i_m cosTheta_O_m) v))
(* (* (sinh (/ 1.0 v)) 2.0) v)))))cosTheta_i\_m = fabs(cosTheta_i);
cosTheta_i\_s = copysign(1.0, cosTheta_i);
cosTheta_O\_m = fabs(cosTheta_O);
cosTheta_O\_s = copysign(1.0, cosTheta_O);
assert(cosTheta_i_m < cosTheta_O_m && cosTheta_O_m < sinTheta_i && sinTheta_i < sinTheta_O && sinTheta_O < v);
float code(float cosTheta_O_s, float cosTheta_i_s, float cosTheta_i_m, float cosTheta_O_m, float sinTheta_i, float sinTheta_O, float v) {
return cosTheta_O_s * (cosTheta_i_s * ((fmaf(-1.0f, ((sinTheta_O * sinTheta_i) / v), 1.0f) * ((cosTheta_i_m * cosTheta_O_m) / v)) / ((sinhf((1.0f / v)) * 2.0f) * v)));
}
cosTheta_i\_m = abs(cosTheta_i) cosTheta_i\_s = copysign(1.0, cosTheta_i) cosTheta_O\_m = abs(cosTheta_O) cosTheta_O\_s = copysign(1.0, cosTheta_O) cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v = sort([cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v]) function code(cosTheta_O_s, cosTheta_i_s, cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v) return Float32(cosTheta_O_s * Float32(cosTheta_i_s * Float32(Float32(fma(Float32(-1.0), Float32(Float32(sinTheta_O * sinTheta_i) / v), Float32(1.0)) * Float32(Float32(cosTheta_i_m * cosTheta_O_m) / v)) / Float32(Float32(sinh(Float32(Float32(1.0) / v)) * Float32(2.0)) * v)))) end
\begin{array}{l}
cosTheta_i\_m = \left|cosTheta\_i\right|
\\
cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right)
\\
cosTheta_O\_m = \left|cosTheta\_O\right|
\\
cosTheta_O\_s = \mathsf{copysign}\left(1, cosTheta\_O\right)
\\
[cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v])\\
\\
cosTheta\_O\_s \cdot \left(cosTheta\_i\_s \cdot \frac{\mathsf{fma}\left(-1, \frac{sinTheta\_O \cdot sinTheta\_i}{v}, 1\right) \cdot \frac{cosTheta\_i\_m \cdot cosTheta\_O\_m}{v}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}\right)
\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%
cosTheta_i\_m = (fabs.f32 cosTheta_i)
cosTheta_i\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_i)
cosTheta_O\_m = (fabs.f32 cosTheta_O)
cosTheta_O\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_O)
NOTE: cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
(FPCore (cosTheta_O_s cosTheta_i_s cosTheta_i_m cosTheta_O_m sinTheta_i sinTheta_O v)
:precision binary32
(*
cosTheta_O_s
(*
cosTheta_i_s
(*
(fma (/ sinTheta_i (- v)) sinTheta_O 1.0)
(/ (* (/ cosTheta_i_m v) cosTheta_O_m) (* (sinh (/ 1.0 v)) (* 2.0 v)))))))cosTheta_i\_m = fabs(cosTheta_i);
cosTheta_i\_s = copysign(1.0, cosTheta_i);
cosTheta_O\_m = fabs(cosTheta_O);
cosTheta_O\_s = copysign(1.0, cosTheta_O);
assert(cosTheta_i_m < cosTheta_O_m && cosTheta_O_m < sinTheta_i && sinTheta_i < sinTheta_O && sinTheta_O < v);
float code(float cosTheta_O_s, float cosTheta_i_s, float cosTheta_i_m, float cosTheta_O_m, float sinTheta_i, float sinTheta_O, float v) {
return cosTheta_O_s * (cosTheta_i_s * (fmaf((sinTheta_i / -v), sinTheta_O, 1.0f) * (((cosTheta_i_m / v) * cosTheta_O_m) / (sinhf((1.0f / v)) * (2.0f * v)))));
}
cosTheta_i\_m = abs(cosTheta_i) cosTheta_i\_s = copysign(1.0, cosTheta_i) cosTheta_O\_m = abs(cosTheta_O) cosTheta_O\_s = copysign(1.0, cosTheta_O) cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v = sort([cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v]) function code(cosTheta_O_s, cosTheta_i_s, cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v) return Float32(cosTheta_O_s * Float32(cosTheta_i_s * Float32(fma(Float32(sinTheta_i / Float32(-v)), sinTheta_O, Float32(1.0)) * Float32(Float32(Float32(cosTheta_i_m / v) * cosTheta_O_m) / Float32(sinh(Float32(Float32(1.0) / v)) * Float32(Float32(2.0) * v)))))) end
\begin{array}{l}
cosTheta_i\_m = \left|cosTheta\_i\right|
\\
cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right)
\\
cosTheta_O\_m = \left|cosTheta\_O\right|
\\
cosTheta_O\_s = \mathsf{copysign}\left(1, cosTheta\_O\right)
\\
[cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v])\\
\\
cosTheta\_O\_s \cdot \left(cosTheta\_i\_s \cdot \left(\mathsf{fma}\left(\frac{sinTheta\_i}{-v}, sinTheta\_O, 1\right) \cdot \frac{\frac{cosTheta\_i\_m}{v} \cdot cosTheta\_O\_m}{\sinh \left(\frac{1}{v}\right) \cdot \left(2 \cdot v\right)}\right)\right)
\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%
lift-fma.f32N/A
lift-*.f32N/A
lift-/.f32N/A
mul-1-negN/A
distribute-frac-neg2N/A
associate-/l*N/A
lower-fma.f32N/A
lower-/.f32N/A
lift-neg.f3298.5
Applied rewrites98.5%
Applied rewrites98.5%
lift-/.f32N/A
lift-*.f32N/A
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
Applied rewrites98.5%
cosTheta_i\_m = (fabs.f32 cosTheta_i) cosTheta_i\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_i) cosTheta_O\_m = (fabs.f32 cosTheta_O) cosTheta_O\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_O) NOTE: cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function. (FPCore (cosTheta_O_s cosTheta_i_s cosTheta_i_m cosTheta_O_m sinTheta_i sinTheta_O v) :precision binary32 (* cosTheta_O_s (* cosTheta_i_s (* (/ (/ cosTheta_i_m v) v) (/ (/ cosTheta_O_m (sinh (/ 1.0 v))) 2.0)))))
cosTheta_i\_m = fabs(cosTheta_i);
cosTheta_i\_s = copysign(1.0, cosTheta_i);
cosTheta_O\_m = fabs(cosTheta_O);
cosTheta_O\_s = copysign(1.0, cosTheta_O);
assert(cosTheta_i_m < cosTheta_O_m && cosTheta_O_m < sinTheta_i && sinTheta_i < sinTheta_O && sinTheta_O < v);
float code(float cosTheta_O_s, float cosTheta_i_s, float cosTheta_i_m, float cosTheta_O_m, float sinTheta_i, float sinTheta_O, float v) {
return cosTheta_O_s * (cosTheta_i_s * (((cosTheta_i_m / v) / v) * ((cosTheta_O_m / sinhf((1.0f / v))) / 2.0f)));
}
cosTheta_i\_m = private
cosTheta_i\_s = private
cosTheta_O\_m = private
cosTheta_O\_s = private
NOTE: cosTheta_i_m, cosTheta_O_m, 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_o_s, costheta_i_s, costheta_i_m, costheta_o_m, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
real(4), intent (in) :: costheta_o_s
real(4), intent (in) :: costheta_i_s
real(4), intent (in) :: costheta_i_m
real(4), intent (in) :: costheta_o_m
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
code = costheta_o_s * (costheta_i_s * (((costheta_i_m / v) / v) * ((costheta_o_m / sinh((1.0e0 / v))) / 2.0e0)))
end function
cosTheta_i\_m = abs(cosTheta_i) cosTheta_i\_s = copysign(1.0, cosTheta_i) cosTheta_O\_m = abs(cosTheta_O) cosTheta_O\_s = copysign(1.0, cosTheta_O) cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v = sort([cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v]) function code(cosTheta_O_s, cosTheta_i_s, cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v) return Float32(cosTheta_O_s * Float32(cosTheta_i_s * Float32(Float32(Float32(cosTheta_i_m / v) / v) * Float32(Float32(cosTheta_O_m / sinh(Float32(Float32(1.0) / v))) / Float32(2.0))))) end
cosTheta_i\_m = abs(cosTheta_i);
cosTheta_i\_s = sign(cosTheta_i) * abs(1.0);
cosTheta_O\_m = abs(cosTheta_O);
cosTheta_O\_s = sign(cosTheta_O) * abs(1.0);
cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v = num2cell(sort([cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v])){:}
function tmp = code(cosTheta_O_s, cosTheta_i_s, cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v)
tmp = cosTheta_O_s * (cosTheta_i_s * (((cosTheta_i_m / v) / v) * ((cosTheta_O_m / sinh((single(1.0) / v))) / single(2.0))));
end
\begin{array}{l}
cosTheta_i\_m = \left|cosTheta\_i\right|
\\
cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right)
\\
cosTheta_O\_m = \left|cosTheta\_O\right|
\\
cosTheta_O\_s = \mathsf{copysign}\left(1, cosTheta\_O\right)
\\
[cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v])\\
\\
cosTheta\_O\_s \cdot \left(cosTheta\_i\_s \cdot \left(\frac{\frac{cosTheta\_i\_m}{v}}{v} \cdot \frac{\frac{cosTheta\_O\_m}{\sinh \left(\frac{1}{v}\right)}}{2}\right)\right)
\end{array}
Initial program 98.6%
Taylor expanded in sinTheta_i around 0
+-commutativeN/A
*-commutativeN/A
times-fracN/A
lower-fma.f32N/A
Applied rewrites98.5%
lift-*.f32N/A
lift-/.f32N/A
lift-sinh.f32N/A
*-commutativeN/A
sinh-undefN/A
lift-exp.f32N/A
lift-/.f32N/A
lift-/.f32N/A
lift-neg.f32N/A
lift-exp.f32N/A
lift--.f3298.5
lift-neg.f32N/A
lift-/.f32N/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f3298.5
Applied rewrites98.5%
Taylor expanded in sinTheta_i around 0
associate-/r*N/A
pow2N/A
frac-timesN/A
lower-/.f32N/A
frac-timesN/A
pow2N/A
associate-/l*N/A
pow2N/A
lower-*.f32N/A
associate-/r*N/A
lift-/.f32N/A
lower-/.f32N/A
rec-expN/A
sinh-undef-revN/A
lower-*.f32N/A
lift-sinh.f32N/A
lift-/.f3298.3
Applied rewrites98.3%
lift-/.f32N/A
lift-*.f32N/A
lift-*.f32N/A
lift-/.f32N/A
lift-sinh.f32N/A
*-commutativeN/A
lift-/.f32N/A
lift-/.f32N/A
associate-/r*N/A
*-commutativeN/A
associate-*r/N/A
associate-/r*N/A
lift-/.f32N/A
lift-/.f32N/A
lower-*.f32N/A
associate-/r*N/A
lower-/.f32N/A
lower-/.f32N/A
lift-sinh.f32N/A
lift-/.f3298.3
Applied rewrites98.3%
cosTheta_i\_m = (fabs.f32 cosTheta_i) cosTheta_i\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_i) cosTheta_O\_m = (fabs.f32 cosTheta_O) cosTheta_O\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_O) NOTE: cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function. (FPCore (cosTheta_O_s cosTheta_i_s cosTheta_i_m cosTheta_O_m sinTheta_i sinTheta_O v) :precision binary32 (* cosTheta_O_s (* cosTheta_i_s (/ (/ (* cosTheta_O_m cosTheta_i_m) v) (* (* (sinh (/ 1.0 v)) 2.0) v)))))
cosTheta_i\_m = fabs(cosTheta_i);
cosTheta_i\_s = copysign(1.0, cosTheta_i);
cosTheta_O\_m = fabs(cosTheta_O);
cosTheta_O\_s = copysign(1.0, cosTheta_O);
assert(cosTheta_i_m < cosTheta_O_m && cosTheta_O_m < sinTheta_i && sinTheta_i < sinTheta_O && sinTheta_O < v);
float code(float cosTheta_O_s, float cosTheta_i_s, float cosTheta_i_m, float cosTheta_O_m, float sinTheta_i, float sinTheta_O, float v) {
return cosTheta_O_s * (cosTheta_i_s * (((cosTheta_O_m * cosTheta_i_m) / v) / ((sinhf((1.0f / v)) * 2.0f) * v)));
}
cosTheta_i\_m = private
cosTheta_i\_s = private
cosTheta_O\_m = private
cosTheta_O\_s = private
NOTE: cosTheta_i_m, cosTheta_O_m, 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_o_s, costheta_i_s, costheta_i_m, costheta_o_m, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
real(4), intent (in) :: costheta_o_s
real(4), intent (in) :: costheta_i_s
real(4), intent (in) :: costheta_i_m
real(4), intent (in) :: costheta_o_m
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
code = costheta_o_s * (costheta_i_s * (((costheta_o_m * costheta_i_m) / v) / ((sinh((1.0e0 / v)) * 2.0e0) * v)))
end function
cosTheta_i\_m = abs(cosTheta_i) cosTheta_i\_s = copysign(1.0, cosTheta_i) cosTheta_O\_m = abs(cosTheta_O) cosTheta_O\_s = copysign(1.0, cosTheta_O) cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v = sort([cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v]) function code(cosTheta_O_s, cosTheta_i_s, cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v) return Float32(cosTheta_O_s * Float32(cosTheta_i_s * Float32(Float32(Float32(cosTheta_O_m * cosTheta_i_m) / v) / Float32(Float32(sinh(Float32(Float32(1.0) / v)) * Float32(2.0)) * v)))) end
cosTheta_i\_m = abs(cosTheta_i);
cosTheta_i\_s = sign(cosTheta_i) * abs(1.0);
cosTheta_O\_m = abs(cosTheta_O);
cosTheta_O\_s = sign(cosTheta_O) * abs(1.0);
cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v = num2cell(sort([cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v])){:}
function tmp = code(cosTheta_O_s, cosTheta_i_s, cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v)
tmp = cosTheta_O_s * (cosTheta_i_s * (((cosTheta_O_m * cosTheta_i_m) / v) / ((sinh((single(1.0) / v)) * single(2.0)) * v)));
end
\begin{array}{l}
cosTheta_i\_m = \left|cosTheta\_i\right|
\\
cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right)
\\
cosTheta_O\_m = \left|cosTheta\_O\right|
\\
cosTheta_O\_s = \mathsf{copysign}\left(1, cosTheta\_O\right)
\\
[cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v])\\
\\
cosTheta\_O\_s \cdot \left(cosTheta\_i\_s \cdot \frac{\frac{cosTheta\_O\_m \cdot cosTheta\_i\_m}{v}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}\right)
\end{array}
Initial program 98.6%
Taylor expanded in sinTheta_i around 0
lower-/.f32N/A
lower-*.f3298.3
Applied rewrites98.3%
cosTheta_i\_m = (fabs.f32 cosTheta_i) cosTheta_i\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_i) cosTheta_O\_m = (fabs.f32 cosTheta_O) cosTheta_O\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_O) NOTE: cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function. (FPCore (cosTheta_O_s cosTheta_i_s cosTheta_i_m cosTheta_O_m sinTheta_i sinTheta_O v) :precision binary32 (* cosTheta_O_s (* cosTheta_i_s (/ (* (/ cosTheta_i_m v) cosTheta_O_m) (* (* (sinh (/ 1.0 v)) 2.0) v)))))
cosTheta_i\_m = fabs(cosTheta_i);
cosTheta_i\_s = copysign(1.0, cosTheta_i);
cosTheta_O\_m = fabs(cosTheta_O);
cosTheta_O\_s = copysign(1.0, cosTheta_O);
assert(cosTheta_i_m < cosTheta_O_m && cosTheta_O_m < sinTheta_i && sinTheta_i < sinTheta_O && sinTheta_O < v);
float code(float cosTheta_O_s, float cosTheta_i_s, float cosTheta_i_m, float cosTheta_O_m, float sinTheta_i, float sinTheta_O, float v) {
return cosTheta_O_s * (cosTheta_i_s * (((cosTheta_i_m / v) * cosTheta_O_m) / ((sinhf((1.0f / v)) * 2.0f) * v)));
}
cosTheta_i\_m = private
cosTheta_i\_s = private
cosTheta_O\_m = private
cosTheta_O\_s = private
NOTE: cosTheta_i_m, cosTheta_O_m, 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_o_s, costheta_i_s, costheta_i_m, costheta_o_m, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
real(4), intent (in) :: costheta_o_s
real(4), intent (in) :: costheta_i_s
real(4), intent (in) :: costheta_i_m
real(4), intent (in) :: costheta_o_m
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
code = costheta_o_s * (costheta_i_s * (((costheta_i_m / v) * costheta_o_m) / ((sinh((1.0e0 / v)) * 2.0e0) * v)))
end function
cosTheta_i\_m = abs(cosTheta_i) cosTheta_i\_s = copysign(1.0, cosTheta_i) cosTheta_O\_m = abs(cosTheta_O) cosTheta_O\_s = copysign(1.0, cosTheta_O) cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v = sort([cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v]) function code(cosTheta_O_s, cosTheta_i_s, cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v) return Float32(cosTheta_O_s * Float32(cosTheta_i_s * Float32(Float32(Float32(cosTheta_i_m / v) * cosTheta_O_m) / Float32(Float32(sinh(Float32(Float32(1.0) / v)) * Float32(2.0)) * v)))) end
cosTheta_i\_m = abs(cosTheta_i);
cosTheta_i\_s = sign(cosTheta_i) * abs(1.0);
cosTheta_O\_m = abs(cosTheta_O);
cosTheta_O\_s = sign(cosTheta_O) * abs(1.0);
cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v = num2cell(sort([cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v])){:}
function tmp = code(cosTheta_O_s, cosTheta_i_s, cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v)
tmp = cosTheta_O_s * (cosTheta_i_s * (((cosTheta_i_m / v) * cosTheta_O_m) / ((sinh((single(1.0) / v)) * single(2.0)) * v)));
end
\begin{array}{l}
cosTheta_i\_m = \left|cosTheta\_i\right|
\\
cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right)
\\
cosTheta_O\_m = \left|cosTheta\_O\right|
\\
cosTheta_O\_s = \mathsf{copysign}\left(1, cosTheta\_O\right)
\\
[cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v])\\
\\
cosTheta\_O\_s \cdot \left(cosTheta\_i\_s \cdot \frac{\frac{cosTheta\_i\_m}{v} \cdot cosTheta\_O\_m}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}\right)
\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%
lift-fma.f32N/A
lift-*.f32N/A
lift-/.f32N/A
mul-1-negN/A
distribute-frac-neg2N/A
associate-/l*N/A
lower-fma.f32N/A
lower-/.f32N/A
lift-neg.f3298.5
Applied rewrites98.5%
Taylor expanded in sinTheta_i around 0
associate-*r/N/A
lift-/.f32N/A
*-commutativeN/A
lower-*.f3298.3
Applied rewrites98.3%
cosTheta_i\_m = (fabs.f32 cosTheta_i) cosTheta_i\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_i) cosTheta_O\_m = (fabs.f32 cosTheta_O) cosTheta_O\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_O) NOTE: cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function. (FPCore (cosTheta_O_s cosTheta_i_s cosTheta_i_m cosTheta_O_m sinTheta_i sinTheta_O v) :precision binary32 (* cosTheta_O_s (* cosTheta_i_s (/ (* cosTheta_O_m cosTheta_i_m) (* (* 2.0 (sinh (/ 1.0 v))) (* v v))))))
cosTheta_i\_m = fabs(cosTheta_i);
cosTheta_i\_s = copysign(1.0, cosTheta_i);
cosTheta_O\_m = fabs(cosTheta_O);
cosTheta_O\_s = copysign(1.0, cosTheta_O);
assert(cosTheta_i_m < cosTheta_O_m && cosTheta_O_m < sinTheta_i && sinTheta_i < sinTheta_O && sinTheta_O < v);
float code(float cosTheta_O_s, float cosTheta_i_s, float cosTheta_i_m, float cosTheta_O_m, float sinTheta_i, float sinTheta_O, float v) {
return cosTheta_O_s * (cosTheta_i_s * ((cosTheta_O_m * cosTheta_i_m) / ((2.0f * sinhf((1.0f / v))) * (v * v))));
}
cosTheta_i\_m = private
cosTheta_i\_s = private
cosTheta_O\_m = private
cosTheta_O\_s = private
NOTE: cosTheta_i_m, cosTheta_O_m, 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_o_s, costheta_i_s, costheta_i_m, costheta_o_m, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
real(4), intent (in) :: costheta_o_s
real(4), intent (in) :: costheta_i_s
real(4), intent (in) :: costheta_i_m
real(4), intent (in) :: costheta_o_m
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
code = costheta_o_s * (costheta_i_s * ((costheta_o_m * costheta_i_m) / ((2.0e0 * sinh((1.0e0 / v))) * (v * v))))
end function
cosTheta_i\_m = abs(cosTheta_i) cosTheta_i\_s = copysign(1.0, cosTheta_i) cosTheta_O\_m = abs(cosTheta_O) cosTheta_O\_s = copysign(1.0, cosTheta_O) cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v = sort([cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v]) function code(cosTheta_O_s, cosTheta_i_s, cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v) return Float32(cosTheta_O_s * Float32(cosTheta_i_s * Float32(Float32(cosTheta_O_m * cosTheta_i_m) / Float32(Float32(Float32(2.0) * sinh(Float32(Float32(1.0) / v))) * Float32(v * v))))) end
cosTheta_i\_m = abs(cosTheta_i);
cosTheta_i\_s = sign(cosTheta_i) * abs(1.0);
cosTheta_O\_m = abs(cosTheta_O);
cosTheta_O\_s = sign(cosTheta_O) * abs(1.0);
cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v = num2cell(sort([cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v])){:}
function tmp = code(cosTheta_O_s, cosTheta_i_s, cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v)
tmp = cosTheta_O_s * (cosTheta_i_s * ((cosTheta_O_m * cosTheta_i_m) / ((single(2.0) * sinh((single(1.0) / v))) * (v * v))));
end
\begin{array}{l}
cosTheta_i\_m = \left|cosTheta\_i\right|
\\
cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right)
\\
cosTheta_O\_m = \left|cosTheta\_O\right|
\\
cosTheta_O\_s = \mathsf{copysign}\left(1, cosTheta\_O\right)
\\
[cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v])\\
\\
cosTheta\_O\_s \cdot \left(cosTheta\_i\_s \cdot \frac{cosTheta\_O\_m \cdot cosTheta\_i\_m}{\left(2 \cdot \sinh \left(\frac{1}{v}\right)\right) \cdot \left(v \cdot v\right)}\right)
\end{array}
Initial program 98.6%
Taylor expanded in sinTheta_i around 0
+-commutativeN/A
*-commutativeN/A
times-fracN/A
lower-fma.f32N/A
Applied rewrites98.5%
lift-*.f32N/A
lift-/.f32N/A
lift-sinh.f32N/A
*-commutativeN/A
sinh-undefN/A
lift-exp.f32N/A
lift-/.f32N/A
lift-/.f32N/A
lift-neg.f32N/A
lift-exp.f32N/A
lift--.f3298.5
lift-neg.f32N/A
lift-/.f32N/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f3298.5
Applied rewrites98.5%
Taylor expanded in sinTheta_i around 0
associate-/r*N/A
pow2N/A
frac-timesN/A
lower-/.f32N/A
frac-timesN/A
pow2N/A
associate-/l*N/A
pow2N/A
lower-*.f32N/A
associate-/r*N/A
lift-/.f32N/A
lower-/.f32N/A
rec-expN/A
sinh-undef-revN/A
lower-*.f32N/A
lift-sinh.f32N/A
lift-/.f3298.3
Applied rewrites98.3%
lift-/.f32N/A
lift-*.f32N/A
lift-*.f32N/A
lift-/.f32N/A
lift-sinh.f32N/A
associate-/l*N/A
lift-/.f32N/A
lift-/.f32N/A
associate-/r*N/A
pow2N/A
sinh-undef-revN/A
rec-expN/A
associate-/r*N/A
associate-/l*N/A
lower-/.f32N/A
lower-*.f32N/A
*-commutativeN/A
Applied rewrites98.3%
cosTheta_i\_m = (fabs.f32 cosTheta_i)
cosTheta_i\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_i)
cosTheta_O\_m = (fabs.f32 cosTheta_O)
cosTheta_O\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_O)
NOTE: cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
(FPCore (cosTheta_O_s cosTheta_i_s cosTheta_i_m cosTheta_O_m sinTheta_i sinTheta_O v)
:precision binary32
(*
cosTheta_O_s
(*
cosTheta_i_s
(/
(fma
(/ (* (* (* sinTheta_O sinTheta_i) cosTheta_i_m) cosTheta_O_m) v)
-0.5
(* 0.5 (* cosTheta_O_m cosTheta_i_m)))
v))))cosTheta_i\_m = fabs(cosTheta_i);
cosTheta_i\_s = copysign(1.0, cosTheta_i);
cosTheta_O\_m = fabs(cosTheta_O);
cosTheta_O\_s = copysign(1.0, cosTheta_O);
assert(cosTheta_i_m < cosTheta_O_m && cosTheta_O_m < sinTheta_i && sinTheta_i < sinTheta_O && sinTheta_O < v);
float code(float cosTheta_O_s, float cosTheta_i_s, float cosTheta_i_m, float cosTheta_O_m, float sinTheta_i, float sinTheta_O, float v) {
return cosTheta_O_s * (cosTheta_i_s * (fmaf(((((sinTheta_O * sinTheta_i) * cosTheta_i_m) * cosTheta_O_m) / v), -0.5f, (0.5f * (cosTheta_O_m * cosTheta_i_m))) / v));
}
cosTheta_i\_m = abs(cosTheta_i) cosTheta_i\_s = copysign(1.0, cosTheta_i) cosTheta_O\_m = abs(cosTheta_O) cosTheta_O\_s = copysign(1.0, cosTheta_O) cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v = sort([cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v]) function code(cosTheta_O_s, cosTheta_i_s, cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v) return Float32(cosTheta_O_s * Float32(cosTheta_i_s * Float32(fma(Float32(Float32(Float32(Float32(sinTheta_O * sinTheta_i) * cosTheta_i_m) * cosTheta_O_m) / v), Float32(-0.5), Float32(Float32(0.5) * Float32(cosTheta_O_m * cosTheta_i_m))) / v))) end
\begin{array}{l}
cosTheta_i\_m = \left|cosTheta\_i\right|
\\
cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right)
\\
cosTheta_O\_m = \left|cosTheta\_O\right|
\\
cosTheta_O\_s = \mathsf{copysign}\left(1, cosTheta\_O\right)
\\
[cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v])\\
\\
cosTheta\_O\_s \cdot \left(cosTheta\_i\_s \cdot \frac{\mathsf{fma}\left(\frac{\left(\left(sinTheta\_O \cdot sinTheta\_i\right) \cdot cosTheta\_i\_m\right) \cdot cosTheta\_O\_m}{v}, -0.5, 0.5 \cdot \left(cosTheta\_O\_m \cdot cosTheta\_i\_m\right)\right)}{v}\right)
\end{array}
Initial program 98.6%
Taylor expanded in v around inf
lower-/.f32N/A
*-commutativeN/A
lower-fma.f32N/A
lower-/.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f3258.4
Applied rewrites58.4%
cosTheta_i\_m = (fabs.f32 cosTheta_i) cosTheta_i\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_i) cosTheta_O\_m = (fabs.f32 cosTheta_O) cosTheta_O\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_O) NOTE: cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function. (FPCore (cosTheta_O_s cosTheta_i_s cosTheta_i_m cosTheta_O_m sinTheta_i sinTheta_O v) :precision binary32 (* cosTheta_O_s (* cosTheta_i_s (/ (* (* cosTheta_O_m cosTheta_i_m) 0.5) v))))
cosTheta_i\_m = fabs(cosTheta_i);
cosTheta_i\_s = copysign(1.0, cosTheta_i);
cosTheta_O\_m = fabs(cosTheta_O);
cosTheta_O\_s = copysign(1.0, cosTheta_O);
assert(cosTheta_i_m < cosTheta_O_m && cosTheta_O_m < sinTheta_i && sinTheta_i < sinTheta_O && sinTheta_O < v);
float code(float cosTheta_O_s, float cosTheta_i_s, float cosTheta_i_m, float cosTheta_O_m, float sinTheta_i, float sinTheta_O, float v) {
return cosTheta_O_s * (cosTheta_i_s * (((cosTheta_O_m * cosTheta_i_m) * 0.5f) / v));
}
cosTheta_i\_m = private
cosTheta_i\_s = private
cosTheta_O\_m = private
cosTheta_O\_s = private
NOTE: cosTheta_i_m, cosTheta_O_m, 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_o_s, costheta_i_s, costheta_i_m, costheta_o_m, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
real(4), intent (in) :: costheta_o_s
real(4), intent (in) :: costheta_i_s
real(4), intent (in) :: costheta_i_m
real(4), intent (in) :: costheta_o_m
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
code = costheta_o_s * (costheta_i_s * (((costheta_o_m * costheta_i_m) * 0.5e0) / v))
end function
cosTheta_i\_m = abs(cosTheta_i) cosTheta_i\_s = copysign(1.0, cosTheta_i) cosTheta_O\_m = abs(cosTheta_O) cosTheta_O\_s = copysign(1.0, cosTheta_O) cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v = sort([cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v]) function code(cosTheta_O_s, cosTheta_i_s, cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v) return Float32(cosTheta_O_s * Float32(cosTheta_i_s * Float32(Float32(Float32(cosTheta_O_m * cosTheta_i_m) * Float32(0.5)) / v))) end
cosTheta_i\_m = abs(cosTheta_i);
cosTheta_i\_s = sign(cosTheta_i) * abs(1.0);
cosTheta_O\_m = abs(cosTheta_O);
cosTheta_O\_s = sign(cosTheta_O) * abs(1.0);
cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v = num2cell(sort([cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v])){:}
function tmp = code(cosTheta_O_s, cosTheta_i_s, cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v)
tmp = cosTheta_O_s * (cosTheta_i_s * (((cosTheta_O_m * cosTheta_i_m) * single(0.5)) / v));
end
\begin{array}{l}
cosTheta_i\_m = \left|cosTheta\_i\right|
\\
cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right)
\\
cosTheta_O\_m = \left|cosTheta\_O\right|
\\
cosTheta_O\_s = \mathsf{copysign}\left(1, cosTheta\_O\right)
\\
[cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v])\\
\\
cosTheta\_O\_s \cdot \left(cosTheta\_i\_s \cdot \frac{\left(cosTheta\_O\_m \cdot cosTheta\_i\_m\right) \cdot 0.5}{v}\right)
\end{array}
Initial program 98.6%
Taylor expanded in v around inf
lower-*.f32N/A
lower-/.f32N/A
lower-*.f3258.4
Applied rewrites58.4%
lift-*.f32N/A
lift-*.f32N/A
lift-/.f32N/A
associate-*r/N/A
lower-/.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-*.f3258.4
Applied rewrites58.4%
cosTheta_i\_m = (fabs.f32 cosTheta_i) cosTheta_i\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_i) cosTheta_O\_m = (fabs.f32 cosTheta_O) cosTheta_O\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_O) NOTE: cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function. (FPCore (cosTheta_O_s cosTheta_i_s cosTheta_i_m cosTheta_O_m sinTheta_i sinTheta_O v) :precision binary32 (* cosTheta_O_s (* cosTheta_i_s (* 0.5 (/ (* cosTheta_O_m cosTheta_i_m) v)))))
cosTheta_i\_m = fabs(cosTheta_i);
cosTheta_i\_s = copysign(1.0, cosTheta_i);
cosTheta_O\_m = fabs(cosTheta_O);
cosTheta_O\_s = copysign(1.0, cosTheta_O);
assert(cosTheta_i_m < cosTheta_O_m && cosTheta_O_m < sinTheta_i && sinTheta_i < sinTheta_O && sinTheta_O < v);
float code(float cosTheta_O_s, float cosTheta_i_s, float cosTheta_i_m, float cosTheta_O_m, float sinTheta_i, float sinTheta_O, float v) {
return cosTheta_O_s * (cosTheta_i_s * (0.5f * ((cosTheta_O_m * cosTheta_i_m) / v)));
}
cosTheta_i\_m = private
cosTheta_i\_s = private
cosTheta_O\_m = private
cosTheta_O\_s = private
NOTE: cosTheta_i_m, cosTheta_O_m, 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_o_s, costheta_i_s, costheta_i_m, costheta_o_m, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
real(4), intent (in) :: costheta_o_s
real(4), intent (in) :: costheta_i_s
real(4), intent (in) :: costheta_i_m
real(4), intent (in) :: costheta_o_m
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
code = costheta_o_s * (costheta_i_s * (0.5e0 * ((costheta_o_m * costheta_i_m) / v)))
end function
cosTheta_i\_m = abs(cosTheta_i) cosTheta_i\_s = copysign(1.0, cosTheta_i) cosTheta_O\_m = abs(cosTheta_O) cosTheta_O\_s = copysign(1.0, cosTheta_O) cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v = sort([cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v]) function code(cosTheta_O_s, cosTheta_i_s, cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v) return Float32(cosTheta_O_s * Float32(cosTheta_i_s * Float32(Float32(0.5) * Float32(Float32(cosTheta_O_m * cosTheta_i_m) / v)))) end
cosTheta_i\_m = abs(cosTheta_i);
cosTheta_i\_s = sign(cosTheta_i) * abs(1.0);
cosTheta_O\_m = abs(cosTheta_O);
cosTheta_O\_s = sign(cosTheta_O) * abs(1.0);
cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v = num2cell(sort([cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v])){:}
function tmp = code(cosTheta_O_s, cosTheta_i_s, cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v)
tmp = cosTheta_O_s * (cosTheta_i_s * (single(0.5) * ((cosTheta_O_m * cosTheta_i_m) / v)));
end
\begin{array}{l}
cosTheta_i\_m = \left|cosTheta\_i\right|
\\
cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right)
\\
cosTheta_O\_m = \left|cosTheta\_O\right|
\\
cosTheta_O\_s = \mathsf{copysign}\left(1, cosTheta\_O\right)
\\
[cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v])\\
\\
cosTheta\_O\_s \cdot \left(cosTheta\_i\_s \cdot \left(0.5 \cdot \frac{cosTheta\_O\_m \cdot cosTheta\_i\_m}{v}\right)\right)
\end{array}
Initial program 98.6%
Taylor expanded in v around inf
lower-*.f32N/A
lower-/.f32N/A
lower-*.f3258.4
Applied rewrites58.4%
cosTheta_i\_m = (fabs.f32 cosTheta_i) cosTheta_i\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_i) cosTheta_O\_m = (fabs.f32 cosTheta_O) cosTheta_O\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_O) NOTE: cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function. (FPCore (cosTheta_O_s cosTheta_i_s cosTheta_i_m cosTheta_O_m sinTheta_i sinTheta_O v) :precision binary32 (* cosTheta_O_s (* cosTheta_i_s (* 0.5 (* cosTheta_O_m (/ cosTheta_i_m v))))))
cosTheta_i\_m = fabs(cosTheta_i);
cosTheta_i\_s = copysign(1.0, cosTheta_i);
cosTheta_O\_m = fabs(cosTheta_O);
cosTheta_O\_s = copysign(1.0, cosTheta_O);
assert(cosTheta_i_m < cosTheta_O_m && cosTheta_O_m < sinTheta_i && sinTheta_i < sinTheta_O && sinTheta_O < v);
float code(float cosTheta_O_s, float cosTheta_i_s, float cosTheta_i_m, float cosTheta_O_m, float sinTheta_i, float sinTheta_O, float v) {
return cosTheta_O_s * (cosTheta_i_s * (0.5f * (cosTheta_O_m * (cosTheta_i_m / v))));
}
cosTheta_i\_m = private
cosTheta_i\_s = private
cosTheta_O\_m = private
cosTheta_O\_s = private
NOTE: cosTheta_i_m, cosTheta_O_m, 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_o_s, costheta_i_s, costheta_i_m, costheta_o_m, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
real(4), intent (in) :: costheta_o_s
real(4), intent (in) :: costheta_i_s
real(4), intent (in) :: costheta_i_m
real(4), intent (in) :: costheta_o_m
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
code = costheta_o_s * (costheta_i_s * (0.5e0 * (costheta_o_m * (costheta_i_m / v))))
end function
cosTheta_i\_m = abs(cosTheta_i) cosTheta_i\_s = copysign(1.0, cosTheta_i) cosTheta_O\_m = abs(cosTheta_O) cosTheta_O\_s = copysign(1.0, cosTheta_O) cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v = sort([cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v]) function code(cosTheta_O_s, cosTheta_i_s, cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v) return Float32(cosTheta_O_s * Float32(cosTheta_i_s * Float32(Float32(0.5) * Float32(cosTheta_O_m * Float32(cosTheta_i_m / v))))) end
cosTheta_i\_m = abs(cosTheta_i);
cosTheta_i\_s = sign(cosTheta_i) * abs(1.0);
cosTheta_O\_m = abs(cosTheta_O);
cosTheta_O\_s = sign(cosTheta_O) * abs(1.0);
cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v = num2cell(sort([cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v])){:}
function tmp = code(cosTheta_O_s, cosTheta_i_s, cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v)
tmp = cosTheta_O_s * (cosTheta_i_s * (single(0.5) * (cosTheta_O_m * (cosTheta_i_m / v))));
end
\begin{array}{l}
cosTheta_i\_m = \left|cosTheta\_i\right|
\\
cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right)
\\
cosTheta_O\_m = \left|cosTheta\_O\right|
\\
cosTheta_O\_s = \mathsf{copysign}\left(1, cosTheta\_O\right)
\\
[cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O_m, sinTheta_i, sinTheta_O, v])\\
\\
cosTheta\_O\_s \cdot \left(cosTheta\_i\_s \cdot \left(0.5 \cdot \left(cosTheta\_O\_m \cdot \frac{cosTheta\_i\_m}{v}\right)\right)\right)
\end{array}
Initial program 98.6%
Taylor expanded in v around inf
lower-*.f32N/A
lower-/.f32N/A
lower-*.f3258.4
Applied rewrites58.4%
lift-*.f32N/A
lift-/.f32N/A
associate-/l*N/A
lower-*.f32N/A
lift-/.f3258.4
Applied rewrites58.4%
herbie shell --seed 2025091
(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)))