
(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
(fma
(-
(fma
(fma
0.5
n0_i
(fma
(* 0.019444444444444445 n1_i)
(* normAngle normAngle)
(* 0.16666666666666666 (- n1_i n0_i))))
(* normAngle normAngle)
n1_i)
n0_i)
u
n0_i))
float code(float normAngle, float u, float n0_i, float n1_i) {
return fmaf((fmaf(fmaf(0.5f, n0_i, fmaf((0.019444444444444445f * n1_i), (normAngle * normAngle), (0.16666666666666666f * (n1_i - n0_i)))), (normAngle * normAngle), n1_i) - n0_i), u, n0_i);
}
function code(normAngle, u, n0_i, n1_i) return fma(Float32(fma(fma(Float32(0.5), n0_i, fma(Float32(Float32(0.019444444444444445) * n1_i), Float32(normAngle * normAngle), Float32(Float32(0.16666666666666666) * Float32(n1_i - n0_i)))), Float32(normAngle * normAngle), n1_i) - n0_i), u, n0_i) end
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.5, n0\_i, \mathsf{fma}\left(0.019444444444444445 \cdot n1\_i, normAngle \cdot normAngle, 0.16666666666666666 \cdot \left(n1\_i - n0\_i\right)\right)\right), normAngle \cdot normAngle, n1\_i\right) - n0\_i, u, n0\_i\right)
\end{array}
Initial program 97.1%
Taylor expanded in u around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites90.3%
Taylor expanded in normAngle around 0
Applied rewrites99.6%
Taylor expanded in n0_i around 0
Applied rewrites99.6%
(FPCore (normAngle u n0_i n1_i)
:precision binary32
(fma
(-
(fma
(fma 0.5 n0_i (* 0.16666666666666666 (- n1_i n0_i)))
(* normAngle normAngle)
n1_i)
n0_i)
u
n0_i))
float code(float normAngle, float u, float n0_i, float n1_i) {
return fmaf((fmaf(fmaf(0.5f, n0_i, (0.16666666666666666f * (n1_i - n0_i))), (normAngle * normAngle), n1_i) - n0_i), u, n0_i);
}
function code(normAngle, u, n0_i, n1_i) return fma(Float32(fma(fma(Float32(0.5), n0_i, Float32(Float32(0.16666666666666666) * Float32(n1_i - n0_i))), Float32(normAngle * normAngle), n1_i) - n0_i), u, n0_i) end
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.5, n0\_i, 0.16666666666666666 \cdot \left(n1\_i - n0\_i\right)\right), normAngle \cdot normAngle, n1\_i\right) - n0\_i, u, n0\_i\right)
\end{array}
Initial program 97.1%
Taylor expanded in u around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites90.3%
Taylor expanded in normAngle around 0
Applied rewrites99.5%
(FPCore (normAngle u n0_i n1_i)
:precision binary32
(if (or (<= n0_i -4.999999918875795e-18)
(not (<= n0_i 9.999999998199587e-24)))
(fma (- n0_i) u n0_i)
(* u n1_i)))
float code(float normAngle, float u, float n0_i, float n1_i) {
float tmp;
if ((n0_i <= -4.999999918875795e-18f) || !(n0_i <= 9.999999998199587e-24f)) {
tmp = fmaf(-n0_i, u, n0_i);
} else {
tmp = u * n1_i;
}
return tmp;
}
function code(normAngle, u, n0_i, n1_i) tmp = Float32(0.0) if ((n0_i <= Float32(-4.999999918875795e-18)) || !(n0_i <= Float32(9.999999998199587e-24))) tmp = fma(Float32(-n0_i), u, n0_i); else tmp = Float32(u * n1_i); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n0\_i \leq -4.999999918875795 \cdot 10^{-18} \lor \neg \left(n0\_i \leq 9.999999998199587 \cdot 10^{-24}\right):\\
\;\;\;\;\mathsf{fma}\left(-n0\_i, u, n0\_i\right)\\
\mathbf{else}:\\
\;\;\;\;u \cdot n1\_i\\
\end{array}
\end{array}
if n0_i < -4.99999992e-18 or 1e-23 < n0_i Initial program 97.9%
Taylor expanded in u around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites97.5%
Taylor expanded in normAngle around 0
Applied rewrites99.3%
Taylor expanded in n0_i around inf
Applied rewrites82.1%
if -4.99999992e-18 < n0_i < 1e-23Initial program 96.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.f3266.2
Applied rewrites66.2%
Taylor expanded in normAngle around 0
Applied rewrites67.1%
Final simplification75.3%
(FPCore (normAngle u n0_i n1_i)
:precision binary32
(if (or (<= n0_i -4.999999918875795e-18)
(not (<= n0_i 9.999999998199587e-24)))
(* (- 1.0 u) n0_i)
(* u n1_i)))
float code(float normAngle, float u, float n0_i, float n1_i) {
float tmp;
if ((n0_i <= -4.999999918875795e-18f) || !(n0_i <= 9.999999998199587e-24f)) {
tmp = (1.0f - u) * n0_i;
} else {
tmp = u * n1_i;
}
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.999999918875795e-18)) .or. (.not. (n0_i <= 9.999999998199587e-24))) then
tmp = (1.0e0 - u) * n0_i
else
tmp = u * n1_i
end if
code = tmp
end function
function code(normAngle, u, n0_i, n1_i) tmp = Float32(0.0) if ((n0_i <= Float32(-4.999999918875795e-18)) || !(n0_i <= Float32(9.999999998199587e-24))) tmp = Float32(Float32(Float32(1.0) - u) * n0_i); else tmp = Float32(u * n1_i); end return tmp end
function tmp_2 = code(normAngle, u, n0_i, n1_i) tmp = single(0.0); if ((n0_i <= single(-4.999999918875795e-18)) || ~((n0_i <= single(9.999999998199587e-24)))) tmp = (single(1.0) - u) * n0_i; else tmp = u * n1_i; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n0\_i \leq -4.999999918875795 \cdot 10^{-18} \lor \neg \left(n0\_i \leq 9.999999998199587 \cdot 10^{-24}\right):\\
\;\;\;\;\left(1 - u\right) \cdot n0\_i\\
\mathbf{else}:\\
\;\;\;\;u \cdot n1\_i\\
\end{array}
\end{array}
if n0_i < -4.99999992e-18 or 1e-23 < n0_i Initial program 97.9%
Taylor expanded in normAngle around 0
*-commutativeN/A
lower-fma.f32N/A
lower--.f32N/A
lower-*.f3298.9
Applied rewrites98.9%
Taylor expanded in n0_i around inf
Applied rewrites98.7%
Taylor expanded in n0_i around inf
Applied rewrites81.9%
if -4.99999992e-18 < n0_i < 1e-23Initial program 96.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.f3266.2
Applied rewrites66.2%
Taylor expanded in normAngle around 0
Applied rewrites67.1%
Final simplification75.2%
(FPCore (normAngle u n0_i n1_i)
:precision binary32
(if (or (<= n0_i -1.999999967550318e-17)
(not (<= n0_i 9.999999998199587e-24)))
(* 1.0 n0_i)
(* u n1_i)))
float code(float normAngle, float u, float n0_i, float n1_i) {
float tmp;
if ((n0_i <= -1.999999967550318e-17f) || !(n0_i <= 9.999999998199587e-24f)) {
tmp = 1.0f * n0_i;
} else {
tmp = u * n1_i;
}
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 <= (-1.999999967550318e-17)) .or. (.not. (n0_i <= 9.999999998199587e-24))) then
tmp = 1.0e0 * n0_i
else
tmp = u * n1_i
end if
code = tmp
end function
function code(normAngle, u, n0_i, n1_i) tmp = Float32(0.0) if ((n0_i <= Float32(-1.999999967550318e-17)) || !(n0_i <= Float32(9.999999998199587e-24))) tmp = Float32(Float32(1.0) * n0_i); else tmp = Float32(u * n1_i); end return tmp end
function tmp_2 = code(normAngle, u, n0_i, n1_i) tmp = single(0.0); if ((n0_i <= single(-1.999999967550318e-17)) || ~((n0_i <= single(9.999999998199587e-24)))) tmp = single(1.0) * n0_i; else tmp = u * n1_i; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n0\_i \leq -1.999999967550318 \cdot 10^{-17} \lor \neg \left(n0\_i \leq 9.999999998199587 \cdot 10^{-24}\right):\\
\;\;\;\;1 \cdot n0\_i\\
\mathbf{else}:\\
\;\;\;\;u \cdot n1\_i\\
\end{array}
\end{array}
if n0_i < -1.99999997e-17 or 1e-23 < n0_i Initial program 97.9%
Taylor expanded in normAngle around 0
*-commutativeN/A
lower-fma.f32N/A
lower--.f32N/A
lower-*.f3298.9
Applied rewrites98.9%
Taylor expanded in n0_i around inf
Applied rewrites98.7%
Taylor expanded in u around 0
Applied rewrites65.9%
if -1.99999997e-17 < n0_i < 1e-23Initial program 96.3%
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.f3265.8
Applied rewrites65.8%
Taylor expanded in normAngle around 0
Applied rewrites66.7%
Final simplification66.3%
(FPCore (normAngle u n0_i n1_i) :precision binary32 (fma (- n1_i n0_i) u n0_i))
float code(float normAngle, float u, float n0_i, float n1_i) {
return fmaf((n1_i - n0_i), u, n0_i);
}
function code(normAngle, u, n0_i, n1_i) return fma(Float32(n1_i - n0_i), u, n0_i) end
\begin{array}{l}
\\
\mathsf{fma}\left(n1\_i - n0\_i, u, n0\_i\right)
\end{array}
Initial program 97.1%
Taylor expanded in u around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites90.3%
Taylor expanded in normAngle around 0
Applied rewrites98.8%
(FPCore (normAngle u n0_i n1_i) :precision binary32 (* u n1_i))
float code(float normAngle, float u, float n0_i, float n1_i) {
return 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 = u * n1_i
end function
function code(normAngle, u, n0_i, n1_i) return Float32(u * n1_i) end
function tmp = code(normAngle, u, n0_i, n1_i) tmp = u * n1_i; end
\begin{array}{l}
\\
u \cdot n1\_i
\end{array}
Initial program 97.1%
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.f3239.4
Applied rewrites39.4%
Taylor expanded in normAngle around 0
Applied rewrites40.2%
herbie shell --seed 2024356
(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)))