
(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 8 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 (- n1_i n0_i) u n0_i) (* (* (* normAngle normAngle) u) (fma (fma -1.0 n0_i n1_i) 0.16666666666666666 (* 0.5 n0_i)))))
float code(float normAngle, float u, float n0_i, float n1_i) {
return fmaf((n1_i - n0_i), u, n0_i) + (((normAngle * normAngle) * u) * fmaf(fmaf(-1.0f, n0_i, n1_i), 0.16666666666666666f, (0.5f * n0_i)));
}
function code(normAngle, u, n0_i, n1_i) return Float32(fma(Float32(n1_i - n0_i), u, n0_i) + Float32(Float32(Float32(normAngle * normAngle) * u) * fma(fma(Float32(-1.0), n0_i, n1_i), Float32(0.16666666666666666), Float32(Float32(0.5) * n0_i)))) end
\begin{array}{l}
\\
\mathsf{fma}\left(n1\_i - n0\_i, u, n0\_i\right) + \left(\left(normAngle \cdot normAngle\right) \cdot u\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(-1, n0\_i, n1\_i\right), 0.16666666666666666, 0.5 \cdot n0\_i\right)
\end{array}
Initial program 96.1%
Taylor expanded in normAngle around 0
*-commutativeN/A
lower-fma.f32N/A
lift--.f32N/A
+-commutativeN/A
Applied rewrites99.4%
Taylor expanded in u around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites99.5%
Taylor expanded in normAngle around 0
associate-+r+N/A
lower-+.f32N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
lower--.f32N/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
pow2N/A
lift-*.f32N/A
*-commutativeN/A
lower-fma.f32N/A
+-commutativeN/A
lift-fma.f32N/A
lift-*.f3299.5
Applied rewrites99.5%
(FPCore (normAngle u n0_i n1_i)
:precision binary32
(fma
(+
(fma
(fma 0.5 n0_i (* 0.16666666666666666 (fma -1.0 n0_i n1_i)))
(* normAngle normAngle)
(- n0_i))
n1_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 * fmaf(-1.0f, n0_i, n1_i))), (normAngle * normAngle), -n0_i) + n1_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) * fma(Float32(-1.0), n0_i, n1_i))), Float32(normAngle * normAngle), Float32(-n0_i)) + n1_i), u, n0_i) end
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.5, n0\_i, 0.16666666666666666 \cdot \mathsf{fma}\left(-1, n0\_i, n1\_i\right)\right), normAngle \cdot normAngle, -n0\_i\right) + n1\_i, u, n0\_i\right)
\end{array}
Initial program 96.1%
Taylor expanded in normAngle around 0
*-commutativeN/A
lower-fma.f32N/A
lift--.f32N/A
+-commutativeN/A
Applied rewrites99.4%
Taylor expanded in u around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites99.5%
(FPCore (normAngle u n0_i n1_i) :precision binary32 (fma (+ (fma (* 0.16666666666666666 n1_i) (* normAngle normAngle) (- n0_i)) n1_i) u n0_i))
float code(float normAngle, float u, float n0_i, float n1_i) {
return fmaf((fmaf((0.16666666666666666f * n1_i), (normAngle * normAngle), -n0_i) + n1_i), u, n0_i);
}
function code(normAngle, u, n0_i, n1_i) return fma(Float32(fma(Float32(Float32(0.16666666666666666) * n1_i), Float32(normAngle * normAngle), Float32(-n0_i)) + n1_i), u, n0_i) end
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666 \cdot n1\_i, normAngle \cdot normAngle, -n0\_i\right) + n1\_i, u, n0\_i\right)
\end{array}
Initial program 96.1%
Taylor expanded in normAngle around 0
*-commutativeN/A
lower-fma.f32N/A
lift--.f32N/A
+-commutativeN/A
Applied rewrites99.4%
Taylor expanded in u around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites99.5%
Taylor expanded in n0_i around 0
lower-*.f3299.2
Applied rewrites99.2%
(FPCore (normAngle u n0_i n1_i)
:precision binary32
(if (or (<= n0_i -4.999999841327613e-21)
(not (<= n0_i 8.000000156331851e-25)))
(* n0_i (- 1.0 u))
(* n1_i u)))
float code(float normAngle, float u, float n0_i, float n1_i) {
float tmp;
if ((n0_i <= -4.999999841327613e-21f) || !(n0_i <= 8.000000156331851e-25f)) {
tmp = n0_i * (1.0f - u);
} 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.999999841327613e-21)) .or. (.not. (n0_i <= 8.000000156331851e-25))) then
tmp = n0_i * (1.0e0 - u)
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.999999841327613e-21)) || !(n0_i <= Float32(8.000000156331851e-25))) tmp = Float32(n0_i * Float32(Float32(1.0) - u)); 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.999999841327613e-21)) || ~((n0_i <= single(8.000000156331851e-25)))) tmp = n0_i * (single(1.0) - u); else tmp = n1_i * u; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n0\_i \leq -4.999999841327613 \cdot 10^{-21} \lor \neg \left(n0\_i \leq 8.000000156331851 \cdot 10^{-25}\right):\\
\;\;\;\;n0\_i \cdot \left(1 - u\right)\\
\mathbf{else}:\\
\;\;\;\;n1\_i \cdot u\\
\end{array}
\end{array}
if n0_i < -4.99999984e-21 or 8.00000016e-25 < n0_i Initial program 97.8%
Taylor expanded in n0_i around inf
associate-/l*N/A
lower-*.f32N/A
*-commutativeN/A
lower-/.f32N/A
lift-*.f32N/A
lift--.f32N/A
lift-sin.f32N/A
lift-sin.f3279.4
Applied rewrites79.4%
Taylor expanded in normAngle around 0
lift--.f3278.6
Applied rewrites78.6%
if -4.99999984e-21 < n0_i < 8.00000016e-25Initial program 94.0%
Taylor expanded in normAngle around 0
*-commutativeN/A
lower-fma.f32N/A
lift--.f32N/A
lower-*.f3297.5
Applied rewrites97.5%
Taylor expanded in n0_i around 0
lift-*.f3266.3
Applied rewrites66.3%
Final simplification72.9%
(FPCore (normAngle u n0_i n1_i)
:precision binary32
(if (or (<= n0_i -7.99999974612418e-21)
(not (<= n0_i 4.0000000781659255e-24)))
n0_i
(* n1_i u)))
float code(float normAngle, float u, float n0_i, float n1_i) {
float tmp;
if ((n0_i <= -7.99999974612418e-21f) || !(n0_i <= 4.0000000781659255e-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 <= (-7.99999974612418e-21)) .or. (.not. (n0_i <= 4.0000000781659255e-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(-7.99999974612418e-21)) || !(n0_i <= Float32(4.0000000781659255e-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(-7.99999974612418e-21)) || ~((n0_i <= single(4.0000000781659255e-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 -7.99999974612418 \cdot 10^{-21} \lor \neg \left(n0\_i \leq 4.0000000781659255 \cdot 10^{-24}\right):\\
\;\;\;\;n0\_i\\
\mathbf{else}:\\
\;\;\;\;n1\_i \cdot u\\
\end{array}
\end{array}
if n0_i < -7.9999997e-21 or 4.00000008e-24 < n0_i Initial program 97.8%
Taylor expanded in u around 0
Applied rewrites64.1%
if -7.9999997e-21 < n0_i < 4.00000008e-24Initial program 94.2%
Taylor expanded in normAngle around 0
*-commutativeN/A
lower-fma.f32N/A
lift--.f32N/A
lower-*.f3297.6
Applied rewrites97.6%
Taylor expanded in n0_i around 0
lift-*.f3265.9
Applied rewrites65.9%
Final simplification64.9%
(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 96.1%
Taylor expanded in normAngle around 0
*-commutativeN/A
lower-fma.f32N/A
lift--.f32N/A
+-commutativeN/A
Applied rewrites99.4%
Taylor expanded in u around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites99.5%
Taylor expanded in normAngle around 0
lower--.f3298.2
Applied rewrites98.2%
(FPCore (normAngle u n0_i n1_i) :precision binary32 (+ n0_i (* u n1_i)))
float code(float normAngle, float u, float n0_i, float n1_i) {
return n0_i + (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 + (u * n1_i)
end function
function code(normAngle, u, n0_i, n1_i) return Float32(n0_i + Float32(u * n1_i)) end
function tmp = code(normAngle, u, n0_i, n1_i) tmp = n0_i + (u * n1_i); end
\begin{array}{l}
\\
n0\_i + u \cdot n1\_i
\end{array}
Initial program 96.1%
Taylor expanded in normAngle around 0
Applied rewrites97.4%
Taylor expanded in u around 0
Applied rewrites83.8%
(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 96.1%
Taylor expanded in u around 0
Applied rewrites46.9%
herbie shell --seed 2025028
(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)))