
(FPCore (normAngle u n0_i n1_i)
:precision binary32
(let* ((t_0 (/ 1.0 (sin normAngle))))
(+
(* (* (sin (* (- 1.0 u) normAngle)) t_0) n0_i)
(* (* (sin (* u normAngle)) t_0) n1_i))))
float code(float normAngle, float u, float n0_i, float n1_i) {
float t_0 = 1.0f / sinf(normAngle);
return ((sinf(((1.0f - u) * normAngle)) * t_0) * n0_i) + ((sinf((u * normAngle)) * t_0) * n1_i);
}
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(normangle, u, n0_i, n1_i)
use fmin_fmax_functions
real(4), intent (in) :: normangle
real(4), intent (in) :: u
real(4), intent (in) :: n0_i
real(4), intent (in) :: n1_i
real(4) :: t_0
t_0 = 1.0e0 / sin(normangle)
code = ((sin(((1.0e0 - u) * normangle)) * t_0) * n0_i) + ((sin((u * normangle)) * t_0) * n1_i)
end function
function code(normAngle, u, n0_i, n1_i) t_0 = Float32(Float32(1.0) / sin(normAngle)) return Float32(Float32(Float32(sin(Float32(Float32(Float32(1.0) - u) * normAngle)) * t_0) * n0_i) + Float32(Float32(sin(Float32(u * normAngle)) * t_0) * n1_i)) end
function tmp = code(normAngle, u, n0_i, n1_i) t_0 = single(1.0) / sin(normAngle); tmp = ((sin(((single(1.0) - u) * normAngle)) * t_0) * n0_i) + ((sin((u * normAngle)) * t_0) * n1_i); end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\sin normAngle}\\
\left(\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot t\_0\right) \cdot n0\_i + \left(\sin \left(u \cdot normAngle\right) \cdot t\_0\right) \cdot n1\_i
\end{array}
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (normAngle u n0_i n1_i)
:precision binary32
(let* ((t_0 (/ 1.0 (sin normAngle))))
(+
(* (* (sin (* (- 1.0 u) normAngle)) t_0) n0_i)
(* (* (sin (* u normAngle)) t_0) n1_i))))
float code(float normAngle, float u, float n0_i, float n1_i) {
float t_0 = 1.0f / sinf(normAngle);
return ((sinf(((1.0f - u) * normAngle)) * t_0) * n0_i) + ((sinf((u * normAngle)) * t_0) * n1_i);
}
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(normangle, u, n0_i, n1_i)
use fmin_fmax_functions
real(4), intent (in) :: normangle
real(4), intent (in) :: u
real(4), intent (in) :: n0_i
real(4), intent (in) :: n1_i
real(4) :: t_0
t_0 = 1.0e0 / sin(normangle)
code = ((sin(((1.0e0 - u) * normangle)) * t_0) * n0_i) + ((sin((u * normangle)) * t_0) * n1_i)
end function
function code(normAngle, u, n0_i, n1_i) t_0 = Float32(Float32(1.0) / sin(normAngle)) return Float32(Float32(Float32(sin(Float32(Float32(Float32(1.0) - u) * normAngle)) * t_0) * n0_i) + Float32(Float32(sin(Float32(u * normAngle)) * t_0) * n1_i)) end
function tmp = code(normAngle, u, n0_i, n1_i) t_0 = single(1.0) / sin(normAngle); tmp = ((sin(((single(1.0) - u) * normAngle)) * t_0) * n0_i) + ((sin((u * normAngle)) * t_0) * n1_i); end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\sin normAngle}\\
\left(\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot t\_0\right) \cdot n0\_i + \left(\sin \left(u \cdot normAngle\right) \cdot t\_0\right) \cdot n1\_i
\end{array}
\end{array}
(FPCore (normAngle u n0_i n1_i) :precision binary32 (+ (- n0_i (* (* (* (cos normAngle) u) normAngle) (/ n0_i (sin normAngle)))) (* (* (/ normAngle (sin normAngle)) u) n1_i)))
float code(float normAngle, float u, float n0_i, float n1_i) {
return (n0_i - (((cosf(normAngle) * u) * normAngle) * (n0_i / sinf(normAngle)))) + (((normAngle / sinf(normAngle)) * u) * n1_i);
}
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(normangle, u, n0_i, n1_i)
use fmin_fmax_functions
real(4), intent (in) :: normangle
real(4), intent (in) :: u
real(4), intent (in) :: n0_i
real(4), intent (in) :: n1_i
code = (n0_i - (((cos(normangle) * u) * normangle) * (n0_i / sin(normangle)))) + (((normangle / sin(normangle)) * u) * n1_i)
end function
function code(normAngle, u, n0_i, n1_i) return Float32(Float32(n0_i - Float32(Float32(Float32(cos(normAngle) * u) * normAngle) * Float32(n0_i / sin(normAngle)))) + Float32(Float32(Float32(normAngle / sin(normAngle)) * u) * n1_i)) end
function tmp = code(normAngle, u, n0_i, n1_i) tmp = (n0_i - (((cos(normAngle) * u) * normAngle) * (n0_i / sin(normAngle)))) + (((normAngle / sin(normAngle)) * u) * n1_i); end
\begin{array}{l}
\\
\left(n0\_i - \left(\left(\cos normAngle \cdot u\right) \cdot normAngle\right) \cdot \frac{n0\_i}{\sin normAngle}\right) + \left(\frac{normAngle}{\sin normAngle} \cdot u\right) \cdot n1\_i
\end{array}
Initial program 95.9%
Taylor expanded in u around 0
associate-*l/N/A
lower-*.f32N/A
lower-/.f32N/A
lower-sin.f3298.7
Applied rewrites98.7%
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f3298.8
lift-*.f32N/A
*-commutativeN/A
lift-*.f3298.8
Applied rewrites98.8%
Taylor expanded in u around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f32N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-cos.f32N/A
lower-/.f32N/A
lower-sin.f3299.1
Applied rewrites99.1%
(FPCore (normAngle u n0_i n1_i) :precision binary32 (+ (* (- 1.0 u) n0_i) (* (* (/ normAngle (sin normAngle)) u) n1_i)))
float code(float normAngle, float u, float n0_i, float n1_i) {
return ((1.0f - u) * n0_i) + (((normAngle / sinf(normAngle)) * u) * n1_i);
}
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(normangle, u, n0_i, n1_i)
use fmin_fmax_functions
real(4), intent (in) :: normangle
real(4), intent (in) :: u
real(4), intent (in) :: n0_i
real(4), intent (in) :: n1_i
code = ((1.0e0 - u) * n0_i) + (((normangle / sin(normangle)) * u) * n1_i)
end function
function code(normAngle, u, n0_i, n1_i) return Float32(Float32(Float32(Float32(1.0) - u) * n0_i) + Float32(Float32(Float32(normAngle / sin(normAngle)) * u) * n1_i)) end
function tmp = code(normAngle, u, n0_i, n1_i) tmp = ((single(1.0) - u) * n0_i) + (((normAngle / sin(normAngle)) * u) * n1_i); end
\begin{array}{l}
\\
\left(1 - u\right) \cdot n0\_i + \left(\frac{normAngle}{\sin normAngle} \cdot u\right) \cdot n1\_i
\end{array}
Initial program 95.9%
Taylor expanded in u around 0
associate-*l/N/A
lower-*.f32N/A
lower-/.f32N/A
lower-sin.f3298.7
Applied rewrites98.7%
Taylor expanded in normAngle around 0
lower--.f3298.7
Applied rewrites98.7%
(FPCore (normAngle u n0_i n1_i)
:precision binary32
(if (or (<= n0_i -4.499999841417633e-25)
(not (<= n0_i 4.999999999099794e-24)))
(- n0_i (* u n0_i))
(* n1_i u)))
float code(float normAngle, float u, float n0_i, float n1_i) {
float tmp;
if ((n0_i <= -4.499999841417633e-25f) || !(n0_i <= 4.999999999099794e-24f)) {
tmp = n0_i - (u * n0_i);
} else {
tmp = n1_i * 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(normangle, u, n0_i, n1_i)
use fmin_fmax_functions
real(4), intent (in) :: normangle
real(4), intent (in) :: u
real(4), intent (in) :: n0_i
real(4), intent (in) :: n1_i
real(4) :: tmp
if ((n0_i <= (-4.499999841417633e-25)) .or. (.not. (n0_i <= 4.999999999099794e-24))) then
tmp = n0_i - (u * n0_i)
else
tmp = n1_i * u
end if
code = tmp
end function
function code(normAngle, u, n0_i, n1_i) tmp = Float32(0.0) if ((n0_i <= Float32(-4.499999841417633e-25)) || !(n0_i <= Float32(4.999999999099794e-24))) tmp = Float32(n0_i - Float32(u * n0_i)); else tmp = Float32(n1_i * u); end return tmp end
function tmp_2 = code(normAngle, u, n0_i, n1_i) tmp = single(0.0); if ((n0_i <= single(-4.499999841417633e-25)) || ~((n0_i <= single(4.999999999099794e-24)))) tmp = n0_i - (u * n0_i); else tmp = n1_i * u; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n0\_i \leq -4.499999841417633 \cdot 10^{-25} \lor \neg \left(n0\_i \leq 4.999999999099794 \cdot 10^{-24}\right):\\
\;\;\;\;n0\_i - u \cdot n0\_i\\
\mathbf{else}:\\
\;\;\;\;n1\_i \cdot u\\
\end{array}
\end{array}
if n0_i < -4.49999984e-25 or 5e-24 < n0_i Initial program 97.8%
Taylor expanded in normAngle around 0
*-commutativeN/A
lower-fma.f32N/A
lower--.f32N/A
lower-*.f3219.8
Applied rewrites19.8%
Taylor expanded in u around inf
Applied rewrites97.3%
Taylor expanded in n1_i around 0
Applied rewrites76.0%
Taylor expanded in u around 0
Applied rewrites76.4%
if -4.49999984e-25 < n0_i < 5e-24Initial program 93.2%
Taylor expanded in n0_i around 0
*-commutativeN/A
associate-/l*N/A
lower-*.f32N/A
lower-sin.f32N/A
lower-*.f32N/A
lower-/.f32N/A
lower-sin.f3269.1
Applied rewrites69.1%
Taylor expanded in normAngle around 0
Applied rewrites73.1%
Final simplification75.1%
(FPCore (normAngle u n0_i n1_i)
:precision binary32
(if (or (<= n0_i -2.9999999047965676e-22)
(not (<= n0_i 4.999999999099794e-24)))
n0_i
(* n1_i u)))
float code(float normAngle, float u, float n0_i, float n1_i) {
float tmp;
if ((n0_i <= -2.9999999047965676e-22f) || !(n0_i <= 4.999999999099794e-24f)) {
tmp = n0_i;
} else {
tmp = n1_i * 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(normangle, u, n0_i, n1_i)
use fmin_fmax_functions
real(4), intent (in) :: normangle
real(4), intent (in) :: u
real(4), intent (in) :: n0_i
real(4), intent (in) :: n1_i
real(4) :: tmp
if ((n0_i <= (-2.9999999047965676e-22)) .or. (.not. (n0_i <= 4.999999999099794e-24))) then
tmp = n0_i
else
tmp = n1_i * u
end if
code = tmp
end function
function code(normAngle, u, n0_i, n1_i) tmp = Float32(0.0) if ((n0_i <= Float32(-2.9999999047965676e-22)) || !(n0_i <= Float32(4.999999999099794e-24))) tmp = n0_i; else tmp = Float32(n1_i * u); end return tmp end
function tmp_2 = code(normAngle, u, n0_i, n1_i) tmp = single(0.0); if ((n0_i <= single(-2.9999999047965676e-22)) || ~((n0_i <= single(4.999999999099794e-24)))) tmp = n0_i; else tmp = n1_i * u; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n0\_i \leq -2.9999999047965676 \cdot 10^{-22} \lor \neg \left(n0\_i \leq 4.999999999099794 \cdot 10^{-24}\right):\\
\;\;\;\;n0\_i\\
\mathbf{else}:\\
\;\;\;\;n1\_i \cdot u\\
\end{array}
\end{array}
if n0_i < -2.9999999e-22 or 5e-24 < n0_i Initial program 98.3%
Taylor expanded in normAngle around 0
lower--.f3297.4
Applied rewrites97.4%
lift-*.f32N/A
lift-/.f32N/A
associate-*r/N/A
frac-2negN/A
*-rgt-identityN/A
lower-/.f32N/A
lift-sin.f32N/A
sin-+PI-revN/A
lower-sin.f32N/A
lift-*.f32N/A
*-commutativeN/A
lower-fma.f32N/A
lower-PI.f32N/A
lift-sin.f32N/A
sin-neg-revN/A
lower-sin.f32N/A
lower-neg.f3237.6
Applied rewrites37.5%
Taylor expanded in u around 0
associate-/l*N/A
fp-cancel-sign-sub-invN/A
mul-1-negN/A
sin-PIN/A
div0N/A
mul0-rgtN/A
sin-PIN/A
lower--.f32N/A
sin-PI60.0
Applied rewrites60.0%
if -2.9999999e-22 < n0_i < 5e-24Initial program 93.0%
Taylor expanded in n0_i around 0
*-commutativeN/A
associate-/l*N/A
lower-*.f32N/A
lower-sin.f32N/A
lower-*.f32N/A
lower-/.f32N/A
lower-sin.f3266.8
Applied rewrites66.8%
Taylor expanded in normAngle around 0
Applied rewrites70.4%
Final simplification64.6%
(FPCore (normAngle u n0_i n1_i) :precision binary32 (+ (* n1_i u) (* n0_i (- 1.0 u))))
float code(float normAngle, float u, float n0_i, float n1_i) {
return (n1_i * u) + (n0_i * (1.0f - u));
}
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(normangle, u, n0_i, n1_i)
use fmin_fmax_functions
real(4), intent (in) :: normangle
real(4), intent (in) :: u
real(4), intent (in) :: n0_i
real(4), intent (in) :: n1_i
code = (n1_i * u) + (n0_i * (1.0e0 - u))
end function
function code(normAngle, u, n0_i, n1_i) return Float32(Float32(n1_i * u) + Float32(n0_i * Float32(Float32(1.0) - u))) end
function tmp = code(normAngle, u, n0_i, n1_i) tmp = (n1_i * u) + (n0_i * (single(1.0) - u)); end
\begin{array}{l}
\\
n1\_i \cdot u + n0\_i \cdot \left(1 - u\right)
\end{array}
Initial program 95.9%
Taylor expanded in normAngle around 0
*-commutativeN/A
lower-fma.f32N/A
lower--.f32N/A
lower-*.f3241.3
Applied rewrites41.2%
Applied rewrites98.0%
Final simplification98.0%
(FPCore (normAngle u n0_i n1_i) :precision binary32 n0_i)
float code(float normAngle, float u, float n0_i, float n1_i) {
return n0_i;
}
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(normangle, u, n0_i, n1_i)
use fmin_fmax_functions
real(4), intent (in) :: normangle
real(4), intent (in) :: u
real(4), intent (in) :: n0_i
real(4), intent (in) :: n1_i
code = n0_i
end function
function code(normAngle, u, n0_i, n1_i) return n0_i end
function tmp = code(normAngle, u, n0_i, n1_i) tmp = n0_i; end
\begin{array}{l}
\\
n0\_i
\end{array}
Initial program 95.9%
Taylor expanded in normAngle around 0
lower--.f3295.4
Applied rewrites95.4%
lift-*.f32N/A
lift-/.f32N/A
associate-*r/N/A
frac-2negN/A
*-rgt-identityN/A
lower-/.f32N/A
lift-sin.f32N/A
sin-+PI-revN/A
lower-sin.f32N/A
lift-*.f32N/A
*-commutativeN/A
lower-fma.f32N/A
lower-PI.f32N/A
lift-sin.f32N/A
sin-neg-revN/A
lower-sin.f32N/A
lower-neg.f3227.1
Applied rewrites27.0%
Taylor expanded in u around 0
associate-/l*N/A
fp-cancel-sign-sub-invN/A
mul-1-negN/A
sin-PIN/A
div0N/A
mul0-rgtN/A
sin-PIN/A
lower--.f32N/A
sin-PI43.7
Applied rewrites43.7%
Final simplification43.7%
(FPCore (normAngle u n0_i n1_i) :precision binary32 0.0)
float code(float normAngle, float u, float n0_i, float n1_i) {
return 0.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(normangle, u, n0_i, n1_i)
use fmin_fmax_functions
real(4), intent (in) :: normangle
real(4), intent (in) :: u
real(4), intent (in) :: n0_i
real(4), intent (in) :: n1_i
code = 0.0e0
end function
function code(normAngle, u, n0_i, n1_i) return Float32(0.0) end
function tmp = code(normAngle, u, n0_i, n1_i) tmp = single(0.0); end
\begin{array}{l}
\\
0
\end{array}
Initial program 95.9%
Taylor expanded in normAngle around 0
lower--.f3295.4
Applied rewrites95.4%
lift-*.f32N/A
lift-/.f32N/A
associate-*r/N/A
frac-2negN/A
*-rgt-identityN/A
lower-/.f32N/A
lift-sin.f32N/A
sin-+PI-revN/A
lower-sin.f32N/A
lift-*.f32N/A
*-commutativeN/A
lower-fma.f32N/A
lower-PI.f32N/A
lift-sin.f32N/A
sin-neg-revN/A
lower-sin.f32N/A
lower-neg.f3227.2
Applied rewrites26.9%
Taylor expanded in normAngle around 0
mul-1-negN/A
associate-/l*N/A
distribute-rgt-neg-inN/A
distribute-neg-fracN/A
sin-PIN/A
metadata-evalN/A
div0N/A
mul0-rgt9.0
Applied rewrites9.0%
herbie shell --seed 2024346
(FPCore (normAngle u n0_i n1_i)
:name "Curve intersection, scale width based on ribbon orientation"
:precision binary32
:pre (and (and (and (and (<= 0.0 normAngle) (<= normAngle (/ (PI) 2.0))) (and (<= -1.0 n0_i) (<= n0_i 1.0))) (and (<= -1.0 n1_i) (<= n1_i 1.0))) (and (<= 2.328306437e-10 u) (<= u 1.0)))
(+ (* (* (sin (* (- 1.0 u) normAngle)) (/ 1.0 (sin normAngle))) n0_i) (* (* (sin (* u normAngle)) (/ 1.0 (sin normAngle))) n1_i)))