
(FPCore (u v) :precision binary32 (+ 1.0 (* v (log (+ u (* (- 1.0 u) (exp (/ -2.0 v))))))))
float code(float u, float v) {
return 1.0f + (v * logf((u + ((1.0f - u) * expf((-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(u, v)
use fmin_fmax_functions
real(4), intent (in) :: u
real(4), intent (in) :: v
code = 1.0e0 + (v * log((u + ((1.0e0 - u) * exp(((-2.0e0) / v))))))
end function
function code(u, v) return Float32(Float32(1.0) + Float32(v * log(Float32(u + Float32(Float32(Float32(1.0) - u) * exp(Float32(Float32(-2.0) / v))))))) end
function tmp = code(u, v) tmp = single(1.0) + (v * log((u + ((single(1.0) - u) * exp((single(-2.0) / v)))))); end
1 + v \cdot \log \left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right)
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (u v) :precision binary32 (+ 1.0 (* v (log (+ u (* (- 1.0 u) (exp (/ -2.0 v))))))))
float code(float u, float v) {
return 1.0f + (v * logf((u + ((1.0f - u) * expf((-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(u, v)
use fmin_fmax_functions
real(4), intent (in) :: u
real(4), intent (in) :: v
code = 1.0e0 + (v * log((u + ((1.0e0 - u) * exp(((-2.0e0) / v))))))
end function
function code(u, v) return Float32(Float32(1.0) + Float32(v * log(Float32(u + Float32(Float32(Float32(1.0) - u) * exp(Float32(Float32(-2.0) / v))))))) end
function tmp = code(u, v) tmp = single(1.0) + (v * log((u + ((single(1.0) - u) * exp((single(-2.0) / v)))))); end
1 + v \cdot \log \left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right)
(FPCore (u v) :precision binary32 (+ 1.0 (* v (log (+ u (* (- 1.0 u) (exp (/ (- (- v) v) (* v v)))))))))
float code(float u, float v) {
return 1.0f + (v * logf((u + ((1.0f - u) * expf(((-v - v) / (v * 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(u, v)
use fmin_fmax_functions
real(4), intent (in) :: u
real(4), intent (in) :: v
code = 1.0e0 + (v * log((u + ((1.0e0 - u) * exp(((-v - v) / (v * v)))))))
end function
function code(u, v) return Float32(Float32(1.0) + Float32(v * log(Float32(u + Float32(Float32(Float32(1.0) - u) * exp(Float32(Float32(Float32(-v) - v) / Float32(v * v)))))))) end
function tmp = code(u, v) tmp = single(1.0) + (v * log((u + ((single(1.0) - u) * exp(((-v - v) / (v * v))))))); end
1 + v \cdot \log \left(u + \left(1 - u\right) \cdot e^{\frac{\left(-v\right) - v}{v \cdot v}}\right)
Initial program 99.5%
lift-/.f32N/A
metadata-evalN/A
div-add-revN/A
frac-addN/A
lower-/.f32N/A
lower-+.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f3299.5%
Applied rewrites99.5%
lift-+.f32N/A
lift-*.f32N/A
*-commutativeN/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f3299.5%
lift-*.f32N/A
mul-1-negN/A
lower-neg.f3299.5%
Applied rewrites99.5%
(FPCore (u v) :precision binary32 (+ 1.0 (* v (log (+ u (exp (/ -2.0 v)))))))
float code(float u, float v) {
return 1.0f + (v * logf((u + expf((-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(u, v)
use fmin_fmax_functions
real(4), intent (in) :: u
real(4), intent (in) :: v
code = 1.0e0 + (v * log((u + exp(((-2.0e0) / v)))))
end function
function code(u, v) return Float32(Float32(1.0) + Float32(v * log(Float32(u + exp(Float32(Float32(-2.0) / v)))))) end
function tmp = code(u, v) tmp = single(1.0) + (v * log((u + exp((single(-2.0) / v))))); end
1 + v \cdot \log \left(u + e^{\frac{-2}{v}}\right)
Initial program 99.5%
Taylor expanded in u around 0
lower-exp.f32N/A
lower-/.f3296.1%
Applied rewrites96.1%
(FPCore (u v)
:precision binary32
(if (<=
(+ 1.0 (* v (log (+ u (* (- 1.0 u) (exp (/ -2.0 v)))))))
-0.10000000149011612)
(-
(*
u
(+
2.0
(*
-1.0
(/
(-
(*
-1.0
(/
(+ 1.3333333333333333 (* 0.6666666666666666 (/ 1.0 v)))
v))
2.0)
v))))
1.0)
(+ 1.0 (* v (log (+ u (- 1.0 u)))))))float code(float u, float v) {
float tmp;
if ((1.0f + (v * logf((u + ((1.0f - u) * expf((-2.0f / v))))))) <= -0.10000000149011612f) {
tmp = (u * (2.0f + (-1.0f * (((-1.0f * ((1.3333333333333333f + (0.6666666666666666f * (1.0f / v))) / v)) - 2.0f) / v)))) - 1.0f;
} else {
tmp = 1.0f + (v * logf((u + (1.0f - u))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(4) function code(u, v)
use fmin_fmax_functions
real(4), intent (in) :: u
real(4), intent (in) :: v
real(4) :: tmp
if ((1.0e0 + (v * log((u + ((1.0e0 - u) * exp(((-2.0e0) / v))))))) <= (-0.10000000149011612e0)) then
tmp = (u * (2.0e0 + ((-1.0e0) * ((((-1.0e0) * ((1.3333333333333333e0 + (0.6666666666666666e0 * (1.0e0 / v))) / v)) - 2.0e0) / v)))) - 1.0e0
else
tmp = 1.0e0 + (v * log((u + (1.0e0 - u))))
end if
code = tmp
end function
function code(u, v) tmp = Float32(0.0) if (Float32(Float32(1.0) + Float32(v * log(Float32(u + Float32(Float32(Float32(1.0) - u) * exp(Float32(Float32(-2.0) / v))))))) <= Float32(-0.10000000149011612)) tmp = Float32(Float32(u * Float32(Float32(2.0) + Float32(Float32(-1.0) * Float32(Float32(Float32(Float32(-1.0) * Float32(Float32(Float32(1.3333333333333333) + Float32(Float32(0.6666666666666666) * Float32(Float32(1.0) / v))) / v)) - Float32(2.0)) / v)))) - Float32(1.0)); else tmp = Float32(Float32(1.0) + Float32(v * log(Float32(u + Float32(Float32(1.0) - u))))); end return tmp end
function tmp_2 = code(u, v) tmp = single(0.0); if ((single(1.0) + (v * log((u + ((single(1.0) - u) * exp((single(-2.0) / v))))))) <= single(-0.10000000149011612)) tmp = (u * (single(2.0) + (single(-1.0) * (((single(-1.0) * ((single(1.3333333333333333) + (single(0.6666666666666666) * (single(1.0) / v))) / v)) - single(2.0)) / v)))) - single(1.0); else tmp = single(1.0) + (v * log((u + (single(1.0) - u)))); end tmp_2 = tmp; end
\begin{array}{l}
\mathbf{if}\;1 + v \cdot \log \left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right) \leq -0.10000000149011612:\\
\;\;\;\;u \cdot \left(2 + -1 \cdot \frac{-1 \cdot \frac{1.3333333333333333 + 0.6666666666666666 \cdot \frac{1}{v}}{v} - 2}{v}\right) - 1\\
\mathbf{else}:\\
\;\;\;\;1 + v \cdot \log \left(u + \left(1 - u\right)\right)\\
\end{array}
if (+.f32 #s(literal 1 binary32) (*.f32 v (log.f32 (+.f32 u (*.f32 (-.f32 #s(literal 1 binary32) u) (exp.f32 (/.f32 #s(literal -2 binary32) v))))))) < -0.100000001Initial program 99.5%
Taylor expanded in u around 0
lower--.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower--.f32N/A
lower-/.f32N/A
lower-exp.f32N/A
lower-/.f3210.4%
Applied rewrites10.4%
Taylor expanded in v around inf
lower-/.f32N/A
lower-+.f32N/A
lower-*.f32N/A
lower-/.f3213.2%
Applied rewrites13.2%
Taylor expanded in v around -inf
lower-+.f32N/A
lower-*.f32N/A
lower-/.f32N/A
lower--.f32N/A
lower-*.f32N/A
lower-/.f32N/A
lower-+.f32N/A
lower-*.f32N/A
lower-/.f3211.6%
Applied rewrites11.6%
if -0.100000001 < (+.f32 #s(literal 1 binary32) (*.f32 v (log.f32 (+.f32 u (*.f32 (-.f32 #s(literal 1 binary32) u) (exp.f32 (/.f32 #s(literal -2 binary32) v))))))) Initial program 99.5%
Taylor expanded in v around inf
lower--.f3286.9%
Applied rewrites86.9%
(FPCore (u v)
:precision binary32
(if (<= (* v (log (+ u (* (- 1.0 u) (exp (/ -2.0 v)))))) -1.0)
(-
(*
u
(+
2.0
(*
-1.0
(/
(-
(*
-1.0
(/
(+ 1.3333333333333333 (* 0.6666666666666666 (/ 1.0 v)))
v))
2.0)
v))))
1.0)
(+ 1.0 (* -2.0 (* -1.0 u)))))float code(float u, float v) {
float tmp;
if ((v * logf((u + ((1.0f - u) * expf((-2.0f / v)))))) <= -1.0f) {
tmp = (u * (2.0f + (-1.0f * (((-1.0f * ((1.3333333333333333f + (0.6666666666666666f * (1.0f / v))) / v)) - 2.0f) / v)))) - 1.0f;
} else {
tmp = 1.0f + (-2.0f * (-1.0f * u));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(4) function code(u, v)
use fmin_fmax_functions
real(4), intent (in) :: u
real(4), intent (in) :: v
real(4) :: tmp
if ((v * log((u + ((1.0e0 - u) * exp(((-2.0e0) / v)))))) <= (-1.0e0)) then
tmp = (u * (2.0e0 + ((-1.0e0) * ((((-1.0e0) * ((1.3333333333333333e0 + (0.6666666666666666e0 * (1.0e0 / v))) / v)) - 2.0e0) / v)))) - 1.0e0
else
tmp = 1.0e0 + ((-2.0e0) * ((-1.0e0) * u))
end if
code = tmp
end function
function code(u, v) tmp = Float32(0.0) if (Float32(v * log(Float32(u + Float32(Float32(Float32(1.0) - u) * exp(Float32(Float32(-2.0) / v)))))) <= Float32(-1.0)) tmp = Float32(Float32(u * Float32(Float32(2.0) + Float32(Float32(-1.0) * Float32(Float32(Float32(Float32(-1.0) * Float32(Float32(Float32(1.3333333333333333) + Float32(Float32(0.6666666666666666) * Float32(Float32(1.0) / v))) / v)) - Float32(2.0)) / v)))) - Float32(1.0)); else tmp = Float32(Float32(1.0) + Float32(Float32(-2.0) * Float32(Float32(-1.0) * u))); end return tmp end
function tmp_2 = code(u, v) tmp = single(0.0); if ((v * log((u + ((single(1.0) - u) * exp((single(-2.0) / v)))))) <= single(-1.0)) tmp = (u * (single(2.0) + (single(-1.0) * (((single(-1.0) * ((single(1.3333333333333333) + (single(0.6666666666666666) * (single(1.0) / v))) / v)) - single(2.0)) / v)))) - single(1.0); else tmp = single(1.0) + (single(-2.0) * (single(-1.0) * u)); end tmp_2 = tmp; end
\begin{array}{l}
\mathbf{if}\;v \cdot \log \left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right) \leq -1:\\
\;\;\;\;u \cdot \left(2 + -1 \cdot \frac{-1 \cdot \frac{1.3333333333333333 + 0.6666666666666666 \cdot \frac{1}{v}}{v} - 2}{v}\right) - 1\\
\mathbf{else}:\\
\;\;\;\;1 + -2 \cdot \left(-1 \cdot u\right)\\
\end{array}
if (*.f32 v (log.f32 (+.f32 u (*.f32 (-.f32 #s(literal 1 binary32) u) (exp.f32 (/.f32 #s(literal -2 binary32) v)))))) < -1Initial program 99.5%
Taylor expanded in u around 0
lower--.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower--.f32N/A
lower-/.f32N/A
lower-exp.f32N/A
lower-/.f3210.4%
Applied rewrites10.4%
Taylor expanded in v around inf
lower-/.f32N/A
lower-+.f32N/A
lower-*.f32N/A
lower-/.f3213.2%
Applied rewrites13.2%
Taylor expanded in v around -inf
lower-+.f32N/A
lower-*.f32N/A
lower-/.f32N/A
lower--.f32N/A
lower-*.f32N/A
lower-/.f32N/A
lower-+.f32N/A
lower-*.f32N/A
lower-/.f3211.6%
Applied rewrites11.6%
if -1 < (*.f32 v (log.f32 (+.f32 u (*.f32 (-.f32 #s(literal 1 binary32) u) (exp.f32 (/.f32 #s(literal -2 binary32) v)))))) Initial program 99.5%
lift-/.f32N/A
metadata-evalN/A
div-add-revN/A
frac-addN/A
lower-/.f32N/A
lower-+.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f3299.5%
Applied rewrites99.5%
lift-+.f32N/A
lift-*.f32N/A
*-commutativeN/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f3299.5%
lift-*.f32N/A
mul-1-negN/A
lower-neg.f3299.5%
Applied rewrites99.5%
Taylor expanded in v around inf
lower-*.f32N/A
lower--.f327.9%
Applied rewrites7.9%
Taylor expanded in u around inf
lower-*.f3246.6%
Applied rewrites46.6%
(FPCore (u v)
:precision binary32
(if (<= (* v (log (+ u (* (- 1.0 u) (exp (/ -2.0 v)))))) -1.0)
(-
(+
(+
(/
(+
(/
(- (* 1.3333333333333333 u) (* -0.6666666666666666 (/ u v)))
v)
(+ u u))
v)
u)
u)
1.0)
(+ 1.0 (* -2.0 (* -1.0 u)))))float code(float u, float v) {
float tmp;
if ((v * logf((u + ((1.0f - u) * expf((-2.0f / v)))))) <= -1.0f) {
tmp = (((((((1.3333333333333333f * u) - (-0.6666666666666666f * (u / v))) / v) + (u + u)) / v) + u) + u) - 1.0f;
} else {
tmp = 1.0f + (-2.0f * (-1.0f * u));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(4) function code(u, v)
use fmin_fmax_functions
real(4), intent (in) :: u
real(4), intent (in) :: v
real(4) :: tmp
if ((v * log((u + ((1.0e0 - u) * exp(((-2.0e0) / v)))))) <= (-1.0e0)) then
tmp = (((((((1.3333333333333333e0 * u) - ((-0.6666666666666666e0) * (u / v))) / v) + (u + u)) / v) + u) + u) - 1.0e0
else
tmp = 1.0e0 + ((-2.0e0) * ((-1.0e0) * u))
end if
code = tmp
end function
function code(u, v) tmp = Float32(0.0) if (Float32(v * log(Float32(u + Float32(Float32(Float32(1.0) - u) * exp(Float32(Float32(-2.0) / v)))))) <= Float32(-1.0)) tmp = Float32(Float32(Float32(Float32(Float32(Float32(Float32(Float32(Float32(1.3333333333333333) * u) - Float32(Float32(-0.6666666666666666) * Float32(u / v))) / v) + Float32(u + u)) / v) + u) + u) - Float32(1.0)); else tmp = Float32(Float32(1.0) + Float32(Float32(-2.0) * Float32(Float32(-1.0) * u))); end return tmp end
function tmp_2 = code(u, v) tmp = single(0.0); if ((v * log((u + ((single(1.0) - u) * exp((single(-2.0) / v)))))) <= single(-1.0)) tmp = (((((((single(1.3333333333333333) * u) - (single(-0.6666666666666666) * (u / v))) / v) + (u + u)) / v) + u) + u) - single(1.0); else tmp = single(1.0) + (single(-2.0) * (single(-1.0) * u)); end tmp_2 = tmp; end
\begin{array}{l}
\mathbf{if}\;v \cdot \log \left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right) \leq -1:\\
\;\;\;\;\left(\left(\frac{\frac{1.3333333333333333 \cdot u - -0.6666666666666666 \cdot \frac{u}{v}}{v} + \left(u + u\right)}{v} + u\right) + u\right) - 1\\
\mathbf{else}:\\
\;\;\;\;1 + -2 \cdot \left(-1 \cdot u\right)\\
\end{array}
if (*.f32 v (log.f32 (+.f32 u (*.f32 (-.f32 #s(literal 1 binary32) u) (exp.f32 (/.f32 #s(literal -2 binary32) v)))))) < -1Initial program 99.5%
Taylor expanded in u around 0
lower--.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower--.f32N/A
lower-/.f32N/A
lower-exp.f32N/A
lower-/.f3210.4%
Applied rewrites10.4%
Taylor expanded in v around -inf
lower-+.f32N/A
Applied rewrites11.6%
lift-+.f32N/A
lift-*.f32N/A
count-2-revN/A
associate-+r+N/A
lower-+.f32N/A
Applied rewrites11.6%
if -1 < (*.f32 v (log.f32 (+.f32 u (*.f32 (-.f32 #s(literal 1 binary32) u) (exp.f32 (/.f32 #s(literal -2 binary32) v)))))) Initial program 99.5%
lift-/.f32N/A
metadata-evalN/A
div-add-revN/A
frac-addN/A
lower-/.f32N/A
lower-+.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f3299.5%
Applied rewrites99.5%
lift-+.f32N/A
lift-*.f32N/A
*-commutativeN/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f3299.5%
lift-*.f32N/A
mul-1-negN/A
lower-neg.f3299.5%
Applied rewrites99.5%
Taylor expanded in v around inf
lower-*.f32N/A
lower--.f327.9%
Applied rewrites7.9%
Taylor expanded in u around inf
lower-*.f3246.6%
Applied rewrites46.6%
(FPCore (u v) :precision binary32 (if (<= (* v (log (+ u (* (- 1.0 u) (exp (/ -2.0 v)))))) -1.0) (- (+ (+ (/ (+ (* 1.3333333333333333 (/ u v)) (+ u u)) v) u) u) 1.0) (+ 1.0 (* -2.0 (* -1.0 u)))))
float code(float u, float v) {
float tmp;
if ((v * logf((u + ((1.0f - u) * expf((-2.0f / v)))))) <= -1.0f) {
tmp = (((((1.3333333333333333f * (u / v)) + (u + u)) / v) + u) + u) - 1.0f;
} else {
tmp = 1.0f + (-2.0f * (-1.0f * u));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(4) function code(u, v)
use fmin_fmax_functions
real(4), intent (in) :: u
real(4), intent (in) :: v
real(4) :: tmp
if ((v * log((u + ((1.0e0 - u) * exp(((-2.0e0) / v)))))) <= (-1.0e0)) then
tmp = (((((1.3333333333333333e0 * (u / v)) + (u + u)) / v) + u) + u) - 1.0e0
else
tmp = 1.0e0 + ((-2.0e0) * ((-1.0e0) * u))
end if
code = tmp
end function
function code(u, v) tmp = Float32(0.0) if (Float32(v * log(Float32(u + Float32(Float32(Float32(1.0) - u) * exp(Float32(Float32(-2.0) / v)))))) <= Float32(-1.0)) tmp = Float32(Float32(Float32(Float32(Float32(Float32(Float32(1.3333333333333333) * Float32(u / v)) + Float32(u + u)) / v) + u) + u) - Float32(1.0)); else tmp = Float32(Float32(1.0) + Float32(Float32(-2.0) * Float32(Float32(-1.0) * u))); end return tmp end
function tmp_2 = code(u, v) tmp = single(0.0); if ((v * log((u + ((single(1.0) - u) * exp((single(-2.0) / v)))))) <= single(-1.0)) tmp = (((((single(1.3333333333333333) * (u / v)) + (u + u)) / v) + u) + u) - single(1.0); else tmp = single(1.0) + (single(-2.0) * (single(-1.0) * u)); end tmp_2 = tmp; end
\begin{array}{l}
\mathbf{if}\;v \cdot \log \left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right) \leq -1:\\
\;\;\;\;\left(\left(\frac{1.3333333333333333 \cdot \frac{u}{v} + \left(u + u\right)}{v} + u\right) + u\right) - 1\\
\mathbf{else}:\\
\;\;\;\;1 + -2 \cdot \left(-1 \cdot u\right)\\
\end{array}
if (*.f32 v (log.f32 (+.f32 u (*.f32 (-.f32 #s(literal 1 binary32) u) (exp.f32 (/.f32 #s(literal -2 binary32) v)))))) < -1Initial program 99.5%
Taylor expanded in u around 0
lower--.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower--.f32N/A
lower-/.f32N/A
lower-exp.f32N/A
lower-/.f3210.4%
Applied rewrites10.4%
Taylor expanded in v around -inf
lower-+.f32N/A
lower-*.f32N/A
lower-/.f32N/A
lower-+.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-/.f32N/A
lower-*.f3212.2%
Applied rewrites12.2%
lift-+.f32N/A
lift-*.f32N/A
count-2-revN/A
associate-+r+N/A
lower-+.f32N/A
Applied rewrites12.2%
if -1 < (*.f32 v (log.f32 (+.f32 u (*.f32 (-.f32 #s(literal 1 binary32) u) (exp.f32 (/.f32 #s(literal -2 binary32) v)))))) Initial program 99.5%
lift-/.f32N/A
metadata-evalN/A
div-add-revN/A
frac-addN/A
lower-/.f32N/A
lower-+.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f3299.5%
Applied rewrites99.5%
lift-+.f32N/A
lift-*.f32N/A
*-commutativeN/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f3299.5%
lift-*.f32N/A
mul-1-negN/A
lower-neg.f3299.5%
Applied rewrites99.5%
Taylor expanded in v around inf
lower-*.f32N/A
lower--.f327.9%
Applied rewrites7.9%
Taylor expanded in u around inf
lower-*.f3246.6%
Applied rewrites46.6%
(FPCore (u v) :precision binary32 (if (<= (* v (log (+ u (* (- 1.0 u) (exp (/ -2.0 v)))))) -1.0) (- (* u (+ 2.0 (* 2.0 (/ 1.0 v)))) 1.0) (+ 1.0 (* -2.0 (* -1.0 u)))))
float code(float u, float v) {
float tmp;
if ((v * logf((u + ((1.0f - u) * expf((-2.0f / v)))))) <= -1.0f) {
tmp = (u * (2.0f + (2.0f * (1.0f / v)))) - 1.0f;
} else {
tmp = 1.0f + (-2.0f * (-1.0f * u));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(4) function code(u, v)
use fmin_fmax_functions
real(4), intent (in) :: u
real(4), intent (in) :: v
real(4) :: tmp
if ((v * log((u + ((1.0e0 - u) * exp(((-2.0e0) / v)))))) <= (-1.0e0)) then
tmp = (u * (2.0e0 + (2.0e0 * (1.0e0 / v)))) - 1.0e0
else
tmp = 1.0e0 + ((-2.0e0) * ((-1.0e0) * u))
end if
code = tmp
end function
function code(u, v) tmp = Float32(0.0) if (Float32(v * log(Float32(u + Float32(Float32(Float32(1.0) - u) * exp(Float32(Float32(-2.0) / v)))))) <= Float32(-1.0)) tmp = Float32(Float32(u * Float32(Float32(2.0) + Float32(Float32(2.0) * Float32(Float32(1.0) / v)))) - Float32(1.0)); else tmp = Float32(Float32(1.0) + Float32(Float32(-2.0) * Float32(Float32(-1.0) * u))); end return tmp end
function tmp_2 = code(u, v) tmp = single(0.0); if ((v * log((u + ((single(1.0) - u) * exp((single(-2.0) / v)))))) <= single(-1.0)) tmp = (u * (single(2.0) + (single(2.0) * (single(1.0) / v)))) - single(1.0); else tmp = single(1.0) + (single(-2.0) * (single(-1.0) * u)); end tmp_2 = tmp; end
\begin{array}{l}
\mathbf{if}\;v \cdot \log \left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right) \leq -1:\\
\;\;\;\;u \cdot \left(2 + 2 \cdot \frac{1}{v}\right) - 1\\
\mathbf{else}:\\
\;\;\;\;1 + -2 \cdot \left(-1 \cdot u\right)\\
\end{array}
if (*.f32 v (log.f32 (+.f32 u (*.f32 (-.f32 #s(literal 1 binary32) u) (exp.f32 (/.f32 #s(literal -2 binary32) v)))))) < -1Initial program 99.5%
Taylor expanded in u around 0
lower--.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower--.f32N/A
lower-/.f32N/A
lower-exp.f32N/A
lower-/.f3210.4%
Applied rewrites10.4%
Taylor expanded in v around inf
Applied rewrites7.9%
Taylor expanded in v around inf
lower-+.f32N/A
lower-*.f32N/A
lower-/.f3214.1%
Applied rewrites14.1%
if -1 < (*.f32 v (log.f32 (+.f32 u (*.f32 (-.f32 #s(literal 1 binary32) u) (exp.f32 (/.f32 #s(literal -2 binary32) v)))))) Initial program 99.5%
lift-/.f32N/A
metadata-evalN/A
div-add-revN/A
frac-addN/A
lower-/.f32N/A
lower-+.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f3299.5%
Applied rewrites99.5%
lift-+.f32N/A
lift-*.f32N/A
*-commutativeN/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f3299.5%
lift-*.f32N/A
mul-1-negN/A
lower-neg.f3299.5%
Applied rewrites99.5%
Taylor expanded in v around inf
lower-*.f32N/A
lower--.f327.9%
Applied rewrites7.9%
Taylor expanded in u around inf
lower-*.f3246.6%
Applied rewrites46.6%
(FPCore (u v) :precision binary32 (if (<= (* v (log (+ u (* (- 1.0 u) (exp (/ -2.0 v)))))) -1.0) (- (+ (* 2.0 u) (* 2.0 (/ u v))) 1.0) (+ 1.0 (* -2.0 (* -1.0 u)))))
float code(float u, float v) {
float tmp;
if ((v * logf((u + ((1.0f - u) * expf((-2.0f / v)))))) <= -1.0f) {
tmp = ((2.0f * u) + (2.0f * (u / v))) - 1.0f;
} else {
tmp = 1.0f + (-2.0f * (-1.0f * u));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(4) function code(u, v)
use fmin_fmax_functions
real(4), intent (in) :: u
real(4), intent (in) :: v
real(4) :: tmp
if ((v * log((u + ((1.0e0 - u) * exp(((-2.0e0) / v)))))) <= (-1.0e0)) then
tmp = ((2.0e0 * u) + (2.0e0 * (u / v))) - 1.0e0
else
tmp = 1.0e0 + ((-2.0e0) * ((-1.0e0) * u))
end if
code = tmp
end function
function code(u, v) tmp = Float32(0.0) if (Float32(v * log(Float32(u + Float32(Float32(Float32(1.0) - u) * exp(Float32(Float32(-2.0) / v)))))) <= Float32(-1.0)) tmp = Float32(Float32(Float32(Float32(2.0) * u) + Float32(Float32(2.0) * Float32(u / v))) - Float32(1.0)); else tmp = Float32(Float32(1.0) + Float32(Float32(-2.0) * Float32(Float32(-1.0) * u))); end return tmp end
function tmp_2 = code(u, v) tmp = single(0.0); if ((v * log((u + ((single(1.0) - u) * exp((single(-2.0) / v)))))) <= single(-1.0)) tmp = ((single(2.0) * u) + (single(2.0) * (u / v))) - single(1.0); else tmp = single(1.0) + (single(-2.0) * (single(-1.0) * u)); end tmp_2 = tmp; end
\begin{array}{l}
\mathbf{if}\;v \cdot \log \left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right) \leq -1:\\
\;\;\;\;\left(2 \cdot u + 2 \cdot \frac{u}{v}\right) - 1\\
\mathbf{else}:\\
\;\;\;\;1 + -2 \cdot \left(-1 \cdot u\right)\\
\end{array}
if (*.f32 v (log.f32 (+.f32 u (*.f32 (-.f32 #s(literal 1 binary32) u) (exp.f32 (/.f32 #s(literal -2 binary32) v)))))) < -1Initial program 99.5%
Taylor expanded in u around 0
lower--.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower--.f32N/A
lower-/.f32N/A
lower-exp.f32N/A
lower-/.f3210.4%
Applied rewrites10.4%
Taylor expanded in v around inf
Applied rewrites7.9%
Taylor expanded in v around inf
lower-+.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-/.f3214.1%
Applied rewrites14.1%
if -1 < (*.f32 v (log.f32 (+.f32 u (*.f32 (-.f32 #s(literal 1 binary32) u) (exp.f32 (/.f32 #s(literal -2 binary32) v)))))) Initial program 99.5%
lift-/.f32N/A
metadata-evalN/A
div-add-revN/A
frac-addN/A
lower-/.f32N/A
lower-+.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f3299.5%
Applied rewrites99.5%
lift-+.f32N/A
lift-*.f32N/A
*-commutativeN/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f3299.5%
lift-*.f32N/A
mul-1-negN/A
lower-neg.f3299.5%
Applied rewrites99.5%
Taylor expanded in v around inf
lower-*.f32N/A
lower--.f327.9%
Applied rewrites7.9%
Taylor expanded in u around inf
lower-*.f3246.6%
Applied rewrites46.6%
(FPCore (u v) :precision binary32 (if (<= (* v (log (+ u (* (- 1.0 u) (exp (/ -2.0 v)))))) -1.0) (- (* u 2.0) 1.0) (+ 1.0 (* -2.0 (* -1.0 u)))))
float code(float u, float v) {
float tmp;
if ((v * logf((u + ((1.0f - u) * expf((-2.0f / v)))))) <= -1.0f) {
tmp = (u * 2.0f) - 1.0f;
} else {
tmp = 1.0f + (-2.0f * (-1.0f * u));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(4) function code(u, v)
use fmin_fmax_functions
real(4), intent (in) :: u
real(4), intent (in) :: v
real(4) :: tmp
if ((v * log((u + ((1.0e0 - u) * exp(((-2.0e0) / v)))))) <= (-1.0e0)) then
tmp = (u * 2.0e0) - 1.0e0
else
tmp = 1.0e0 + ((-2.0e0) * ((-1.0e0) * u))
end if
code = tmp
end function
function code(u, v) tmp = Float32(0.0) if (Float32(v * log(Float32(u + Float32(Float32(Float32(1.0) - u) * exp(Float32(Float32(-2.0) / v)))))) <= Float32(-1.0)) tmp = Float32(Float32(u * Float32(2.0)) - Float32(1.0)); else tmp = Float32(Float32(1.0) + Float32(Float32(-2.0) * Float32(Float32(-1.0) * u))); end return tmp end
function tmp_2 = code(u, v) tmp = single(0.0); if ((v * log((u + ((single(1.0) - u) * exp((single(-2.0) / v)))))) <= single(-1.0)) tmp = (u * single(2.0)) - single(1.0); else tmp = single(1.0) + (single(-2.0) * (single(-1.0) * u)); end tmp_2 = tmp; end
\begin{array}{l}
\mathbf{if}\;v \cdot \log \left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right) \leq -1:\\
\;\;\;\;u \cdot 2 - 1\\
\mathbf{else}:\\
\;\;\;\;1 + -2 \cdot \left(-1 \cdot u\right)\\
\end{array}
if (*.f32 v (log.f32 (+.f32 u (*.f32 (-.f32 #s(literal 1 binary32) u) (exp.f32 (/.f32 #s(literal -2 binary32) v)))))) < -1Initial program 99.5%
Taylor expanded in u around 0
lower--.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower--.f32N/A
lower-/.f32N/A
lower-exp.f32N/A
lower-/.f3210.4%
Applied rewrites10.4%
Taylor expanded in v around inf
Applied rewrites7.9%
if -1 < (*.f32 v (log.f32 (+.f32 u (*.f32 (-.f32 #s(literal 1 binary32) u) (exp.f32 (/.f32 #s(literal -2 binary32) v)))))) Initial program 99.5%
lift-/.f32N/A
metadata-evalN/A
div-add-revN/A
frac-addN/A
lower-/.f32N/A
lower-+.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f3299.5%
Applied rewrites99.5%
lift-+.f32N/A
lift-*.f32N/A
*-commutativeN/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f3299.5%
lift-*.f32N/A
mul-1-negN/A
lower-neg.f3299.5%
Applied rewrites99.5%
Taylor expanded in v around inf
lower-*.f32N/A
lower--.f327.9%
Applied rewrites7.9%
Taylor expanded in u around inf
lower-*.f3246.6%
Applied rewrites46.6%
(FPCore (u v) :precision binary32 (- (* u 2.0) 1.0))
float code(float u, float v) {
return (u * 2.0f) - 1.0f;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(4) function code(u, v)
use fmin_fmax_functions
real(4), intent (in) :: u
real(4), intent (in) :: v
code = (u * 2.0e0) - 1.0e0
end function
function code(u, v) return Float32(Float32(u * Float32(2.0)) - Float32(1.0)) end
function tmp = code(u, v) tmp = (u * single(2.0)) - single(1.0); end
u \cdot 2 - 1
Initial program 99.5%
Taylor expanded in u around 0
lower--.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower--.f32N/A
lower-/.f32N/A
lower-exp.f32N/A
lower-/.f3210.4%
Applied rewrites10.4%
Taylor expanded in v around inf
Applied rewrites7.9%
(FPCore (u v) :precision binary32 -1.0)
float code(float u, float v) {
return -1.0f;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(4) function code(u, v)
use fmin_fmax_functions
real(4), intent (in) :: u
real(4), intent (in) :: v
code = -1.0e0
end function
function code(u, v) return Float32(-1.0) end
function tmp = code(u, v) tmp = single(-1.0); end
-1
Initial program 99.5%
Taylor expanded in u around 0
Applied rewrites5.8%
herbie shell --seed 2025258
(FPCore (u v)
:name "HairBSDF, sample_f, cosTheta"
:precision binary32
:pre (and (and (<= 1e-5 u) (<= u 1.0)) (and (<= 0.0 v) (<= v 109.746574)))
(+ 1.0 (* v (log (+ u (* (- 1.0 u) (exp (/ -2.0 v))))))))