Curve intersection, scale width based on ribbon orientation

Percentage Accurate: 97.3% → 99.4%
Time: 12.7s
Alternatives: 9
Speedup: 45.9×

Specification

?
\[\left(\left(\left(0 \leq normAngle \land normAngle \leq \frac{\mathsf{PI}\left(\right)}{2}\right) \land \left(-1 \leq n0\_i \land n0\_i \leq 1\right)\right) \land \left(-1 \leq n1\_i \land n1\_i \leq 1\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq u \land u \leq 1\right)\]
\[\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
 (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:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 9 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 97.3% accurate, 1.0× speedup?

\[\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
 (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}

Alternative 1: 99.4% accurate, 5.7× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889 \cdot n0\_i - -0.00205026455026455 \cdot n1\_i, normAngle \cdot normAngle, \mathsf{fma}\left(0.022222222222222223, n0\_i, 0.019444444444444445 \cdot n1\_i\right)\right), normAngle \cdot normAngle, \mathsf{fma}\left(0.5, n0\_i, 0.16666666666666666 \cdot \left(n1\_i - n0\_i\right)\right)\right), normAngle \cdot normAngle, n1\_i - n0\_i\right), u, n0\_i\right) \end{array} \]
(FPCore (normAngle u n0_i n1_i)
 :precision binary32
 (fma
  (fma
   (fma
    (fma
     (- (* 0.001388888888888889 n0_i) (* -0.00205026455026455 n1_i))
     (* normAngle normAngle)
     (fma 0.022222222222222223 n0_i (* 0.019444444444444445 n1_i)))
    (* normAngle normAngle)
    (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(fmaf(((0.001388888888888889f * n0_i) - (-0.00205026455026455f * n1_i)), (normAngle * normAngle), fmaf(0.022222222222222223f, n0_i, (0.019444444444444445f * n1_i))), (normAngle * normAngle), 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(fma(fma(fma(Float32(Float32(Float32(0.001388888888888889) * n0_i) - Float32(Float32(-0.00205026455026455) * n1_i)), Float32(normAngle * normAngle), fma(Float32(0.022222222222222223), n0_i, Float32(Float32(0.019444444444444445) * n1_i))), Float32(normAngle * normAngle), fma(Float32(0.5), n0_i, Float32(Float32(0.16666666666666666) * Float32(n1_i - n0_i)))), Float32(normAngle * normAngle), Float32(n1_i - n0_i)), u, n0_i)
end
\begin{array}{l}

\\
\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889 \cdot n0\_i - -0.00205026455026455 \cdot n1\_i, normAngle \cdot normAngle, \mathsf{fma}\left(0.022222222222222223, n0\_i, 0.019444444444444445 \cdot n1\_i\right)\right), normAngle \cdot normAngle, \mathsf{fma}\left(0.5, n0\_i, 0.16666666666666666 \cdot \left(n1\_i - n0\_i\right)\right)\right), normAngle \cdot normAngle, n1\_i - n0\_i\right), u, n0\_i\right)
\end{array}
Derivation
  1. Initial program 97.2%

    \[\left(\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n0\_i + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n1\_i \]
  2. Add Preprocessing
  3. Taylor expanded in u around 0

    \[\leadsto \color{blue}{n0\_i + u \cdot \left(-1 \cdot \frac{n0\_i \cdot \left(normAngle \cdot \cos normAngle\right)}{\sin normAngle} + \frac{n1\_i \cdot normAngle}{\sin normAngle}\right)} \]
  4. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \color{blue}{u \cdot \left(-1 \cdot \frac{n0\_i \cdot \left(normAngle \cdot \cos normAngle\right)}{\sin normAngle} + \frac{n1\_i \cdot normAngle}{\sin normAngle}\right) + n0\_i} \]
    2. *-commutativeN/A

      \[\leadsto \color{blue}{\left(-1 \cdot \frac{n0\_i \cdot \left(normAngle \cdot \cos normAngle\right)}{\sin normAngle} + \frac{n1\_i \cdot normAngle}{\sin normAngle}\right) \cdot u} + n0\_i \]
    3. lower-fma.f32N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(-1 \cdot \frac{n0\_i \cdot \left(normAngle \cdot \cos normAngle\right)}{\sin normAngle} + \frac{n1\_i \cdot normAngle}{\sin normAngle}, u, n0\_i\right)} \]
  5. Applied rewrites89.7%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{n1\_i \cdot normAngle - \left(\cos normAngle \cdot normAngle\right) \cdot n0\_i}{\sin normAngle}, u, n0\_i\right)} \]
  6. Taylor expanded in normAngle around 0

    \[\leadsto \mathsf{fma}\left(\left(n1\_i + {normAngle}^{2} \cdot \left(\left(\frac{1}{2} \cdot n0\_i + {normAngle}^{2} \cdot \left(\left(\frac{-1}{24} \cdot n0\_i + {normAngle}^{2} \cdot \left(\frac{1}{720} \cdot n0\_i - \left(\frac{-1}{6} \cdot \left(\frac{-1}{24} \cdot n0\_i - \left(\frac{-1}{6} \cdot \left(\frac{1}{2} \cdot n0\_i - \frac{-1}{6} \cdot \left(n1\_i - n0\_i\right)\right) + \frac{1}{120} \cdot \left(n1\_i - n0\_i\right)\right)\right) + \left(\frac{-1}{5040} \cdot \left(n1\_i - n0\_i\right) + \frac{1}{120} \cdot \left(\frac{1}{2} \cdot n0\_i - \frac{-1}{6} \cdot \left(n1\_i - n0\_i\right)\right)\right)\right)\right)\right) - \left(\frac{-1}{6} \cdot \left(\frac{1}{2} \cdot n0\_i - \frac{-1}{6} \cdot \left(n1\_i - n0\_i\right)\right) + \frac{1}{120} \cdot \left(n1\_i - n0\_i\right)\right)\right)\right) - \frac{-1}{6} \cdot \left(n1\_i - n0\_i\right)\right)\right) - n0\_i, u, n0\_i\right) \]
  7. Applied rewrites99.6%

    \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889 \cdot n0\_i - \mathsf{fma}\left(-0.041666666666666664 \cdot n0\_i - \mathsf{fma}\left(\mathsf{fma}\left(0.5, n0\_i, 0.16666666666666666 \cdot \left(n1\_i - n0\_i\right)\right), -0.16666666666666666, \left(n1\_i - n0\_i\right) \cdot 0.008333333333333333\right), -0.16666666666666666, \mathsf{fma}\left(\mathsf{fma}\left(0.5, n0\_i, 0.16666666666666666 \cdot \left(n1\_i - n0\_i\right)\right), 0.008333333333333333, \left(n1\_i - n0\_i\right) \cdot -0.0001984126984126984\right)\right), normAngle \cdot normAngle, -0.041666666666666664 \cdot n0\_i - \mathsf{fma}\left(\mathsf{fma}\left(0.5, n0\_i, 0.16666666666666666 \cdot \left(n1\_i - n0\_i\right)\right), -0.16666666666666666, \left(n1\_i - n0\_i\right) \cdot 0.008333333333333333\right)\right), normAngle \cdot normAngle, \mathsf{fma}\left(0.5, n0\_i, 0.16666666666666666 \cdot \left(n1\_i - n0\_i\right)\right)\right), normAngle \cdot normAngle, n1\_i - n0\_i\right), u, n0\_i\right) \]
  8. Taylor expanded in n1_i around inf

    \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{720} \cdot n0\_i - \frac{-31}{15120} \cdot n1\_i, normAngle \cdot normAngle, \frac{-1}{24} \cdot n0\_i - \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2}, n0\_i, \frac{1}{6} \cdot \left(n1\_i - n0\_i\right)\right), \frac{-1}{6}, \left(n1\_i - n0\_i\right) \cdot \frac{1}{120}\right)\right), normAngle \cdot normAngle, \mathsf{fma}\left(\frac{1}{2}, n0\_i, \frac{1}{6} \cdot \left(n1\_i - n0\_i\right)\right)\right), normAngle \cdot normAngle, n1\_i - n0\_i\right), u, n0\_i\right) \]
  9. Step-by-step derivation
    1. Applied rewrites99.6%

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889 \cdot n0\_i - -0.00205026455026455 \cdot n1\_i, normAngle \cdot normAngle, -0.041666666666666664 \cdot n0\_i - \mathsf{fma}\left(\mathsf{fma}\left(0.5, n0\_i, 0.16666666666666666 \cdot \left(n1\_i - n0\_i\right)\right), -0.16666666666666666, \left(n1\_i - n0\_i\right) \cdot 0.008333333333333333\right)\right), normAngle \cdot normAngle, \mathsf{fma}\left(0.5, n0\_i, 0.16666666666666666 \cdot \left(n1\_i - n0\_i\right)\right)\right), normAngle \cdot normAngle, n1\_i - n0\_i\right), u, n0\_i\right) \]
    2. Taylor expanded in n0_i around 0

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{720} \cdot n0\_i - \frac{-31}{15120} \cdot n1\_i, normAngle \cdot normAngle, \frac{1}{45} \cdot n0\_i - \left(\frac{-1}{36} \cdot n1\_i + \frac{1}{120} \cdot n1\_i\right)\right), normAngle \cdot normAngle, \mathsf{fma}\left(\frac{1}{2}, n0\_i, \frac{1}{6} \cdot \left(n1\_i - n0\_i\right)\right)\right), normAngle \cdot normAngle, n1\_i - n0\_i\right), u, n0\_i\right) \]
    3. Step-by-step derivation
      1. Applied rewrites99.6%

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889 \cdot n0\_i - -0.00205026455026455 \cdot n1\_i, normAngle \cdot normAngle, \mathsf{fma}\left(0.022222222222222223, n0\_i, 0.019444444444444445 \cdot n1\_i\right)\right), normAngle \cdot normAngle, \mathsf{fma}\left(0.5, n0\_i, 0.16666666666666666 \cdot \left(n1\_i - n0\_i\right)\right)\right), normAngle \cdot normAngle, n1\_i - n0\_i\right), u, n0\_i\right) \]
      2. Add Preprocessing

      Alternative 2: 99.4% accurate, 6.1× speedup?

      \[\begin{array}{l} \\ \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889 \cdot n0\_i - -0.00205026455026455 \cdot n1\_i, normAngle \cdot normAngle, 0.019444444444444445 \cdot n1\_i\right), normAngle \cdot normAngle, \mathsf{fma}\left(0.5, n0\_i, 0.16666666666666666 \cdot \left(n1\_i - n0\_i\right)\right)\right), normAngle \cdot normAngle, n1\_i - n0\_i\right), u, n0\_i\right) \end{array} \]
      (FPCore (normAngle u n0_i n1_i)
       :precision binary32
       (fma
        (fma
         (fma
          (fma
           (- (* 0.001388888888888889 n0_i) (* -0.00205026455026455 n1_i))
           (* normAngle normAngle)
           (* 0.019444444444444445 n1_i))
          (* normAngle normAngle)
          (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(fmaf(((0.001388888888888889f * n0_i) - (-0.00205026455026455f * n1_i)), (normAngle * normAngle), (0.019444444444444445f * n1_i)), (normAngle * normAngle), 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(fma(fma(fma(Float32(Float32(Float32(0.001388888888888889) * n0_i) - Float32(Float32(-0.00205026455026455) * n1_i)), Float32(normAngle * normAngle), Float32(Float32(0.019444444444444445) * n1_i)), Float32(normAngle * normAngle), fma(Float32(0.5), n0_i, Float32(Float32(0.16666666666666666) * Float32(n1_i - n0_i)))), Float32(normAngle * normAngle), Float32(n1_i - n0_i)), u, n0_i)
      end
      
      \begin{array}{l}
      
      \\
      \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889 \cdot n0\_i - -0.00205026455026455 \cdot n1\_i, normAngle \cdot normAngle, 0.019444444444444445 \cdot n1\_i\right), normAngle \cdot normAngle, \mathsf{fma}\left(0.5, n0\_i, 0.16666666666666666 \cdot \left(n1\_i - n0\_i\right)\right)\right), normAngle \cdot normAngle, n1\_i - n0\_i\right), u, n0\_i\right)
      \end{array}
      
      Derivation
      1. Initial program 97.2%

        \[\left(\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n0\_i + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n1\_i \]
      2. Add Preprocessing
      3. Taylor expanded in u around 0

        \[\leadsto \color{blue}{n0\_i + u \cdot \left(-1 \cdot \frac{n0\_i \cdot \left(normAngle \cdot \cos normAngle\right)}{\sin normAngle} + \frac{n1\_i \cdot normAngle}{\sin normAngle}\right)} \]
      4. Step-by-step derivation
        1. +-commutativeN/A

          \[\leadsto \color{blue}{u \cdot \left(-1 \cdot \frac{n0\_i \cdot \left(normAngle \cdot \cos normAngle\right)}{\sin normAngle} + \frac{n1\_i \cdot normAngle}{\sin normAngle}\right) + n0\_i} \]
        2. *-commutativeN/A

          \[\leadsto \color{blue}{\left(-1 \cdot \frac{n0\_i \cdot \left(normAngle \cdot \cos normAngle\right)}{\sin normAngle} + \frac{n1\_i \cdot normAngle}{\sin normAngle}\right) \cdot u} + n0\_i \]
        3. lower-fma.f32N/A

          \[\leadsto \color{blue}{\mathsf{fma}\left(-1 \cdot \frac{n0\_i \cdot \left(normAngle \cdot \cos normAngle\right)}{\sin normAngle} + \frac{n1\_i \cdot normAngle}{\sin normAngle}, u, n0\_i\right)} \]
      5. Applied rewrites89.7%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{n1\_i \cdot normAngle - \left(\cos normAngle \cdot normAngle\right) \cdot n0\_i}{\sin normAngle}, u, n0\_i\right)} \]
      6. Taylor expanded in normAngle around 0

        \[\leadsto \mathsf{fma}\left(\left(n1\_i + {normAngle}^{2} \cdot \left(\left(\frac{1}{2} \cdot n0\_i + {normAngle}^{2} \cdot \left(\left(\frac{-1}{24} \cdot n0\_i + {normAngle}^{2} \cdot \left(\frac{1}{720} \cdot n0\_i - \left(\frac{-1}{6} \cdot \left(\frac{-1}{24} \cdot n0\_i - \left(\frac{-1}{6} \cdot \left(\frac{1}{2} \cdot n0\_i - \frac{-1}{6} \cdot \left(n1\_i - n0\_i\right)\right) + \frac{1}{120} \cdot \left(n1\_i - n0\_i\right)\right)\right) + \left(\frac{-1}{5040} \cdot \left(n1\_i - n0\_i\right) + \frac{1}{120} \cdot \left(\frac{1}{2} \cdot n0\_i - \frac{-1}{6} \cdot \left(n1\_i - n0\_i\right)\right)\right)\right)\right)\right) - \left(\frac{-1}{6} \cdot \left(\frac{1}{2} \cdot n0\_i - \frac{-1}{6} \cdot \left(n1\_i - n0\_i\right)\right) + \frac{1}{120} \cdot \left(n1\_i - n0\_i\right)\right)\right)\right) - \frac{-1}{6} \cdot \left(n1\_i - n0\_i\right)\right)\right) - n0\_i, u, n0\_i\right) \]
      7. Applied rewrites99.6%

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889 \cdot n0\_i - \mathsf{fma}\left(-0.041666666666666664 \cdot n0\_i - \mathsf{fma}\left(\mathsf{fma}\left(0.5, n0\_i, 0.16666666666666666 \cdot \left(n1\_i - n0\_i\right)\right), -0.16666666666666666, \left(n1\_i - n0\_i\right) \cdot 0.008333333333333333\right), -0.16666666666666666, \mathsf{fma}\left(\mathsf{fma}\left(0.5, n0\_i, 0.16666666666666666 \cdot \left(n1\_i - n0\_i\right)\right), 0.008333333333333333, \left(n1\_i - n0\_i\right) \cdot -0.0001984126984126984\right)\right), normAngle \cdot normAngle, -0.041666666666666664 \cdot n0\_i - \mathsf{fma}\left(\mathsf{fma}\left(0.5, n0\_i, 0.16666666666666666 \cdot \left(n1\_i - n0\_i\right)\right), -0.16666666666666666, \left(n1\_i - n0\_i\right) \cdot 0.008333333333333333\right)\right), normAngle \cdot normAngle, \mathsf{fma}\left(0.5, n0\_i, 0.16666666666666666 \cdot \left(n1\_i - n0\_i\right)\right)\right), normAngle \cdot normAngle, n1\_i - n0\_i\right), u, n0\_i\right) \]
      8. Taylor expanded in n1_i around inf

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{720} \cdot n0\_i - \frac{-31}{15120} \cdot n1\_i, normAngle \cdot normAngle, \frac{-1}{24} \cdot n0\_i - \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2}, n0\_i, \frac{1}{6} \cdot \left(n1\_i - n0\_i\right)\right), \frac{-1}{6}, \left(n1\_i - n0\_i\right) \cdot \frac{1}{120}\right)\right), normAngle \cdot normAngle, \mathsf{fma}\left(\frac{1}{2}, n0\_i, \frac{1}{6} \cdot \left(n1\_i - n0\_i\right)\right)\right), normAngle \cdot normAngle, n1\_i - n0\_i\right), u, n0\_i\right) \]
      9. Step-by-step derivation
        1. Applied rewrites99.6%

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889 \cdot n0\_i - -0.00205026455026455 \cdot n1\_i, normAngle \cdot normAngle, -0.041666666666666664 \cdot n0\_i - \mathsf{fma}\left(\mathsf{fma}\left(0.5, n0\_i, 0.16666666666666666 \cdot \left(n1\_i - n0\_i\right)\right), -0.16666666666666666, \left(n1\_i - n0\_i\right) \cdot 0.008333333333333333\right)\right), normAngle \cdot normAngle, \mathsf{fma}\left(0.5, n0\_i, 0.16666666666666666 \cdot \left(n1\_i - n0\_i\right)\right)\right), normAngle \cdot normAngle, n1\_i - n0\_i\right), u, n0\_i\right) \]
        2. Taylor expanded in n0_i around 0

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{720} \cdot n0\_i - \frac{-31}{15120} \cdot n1\_i, normAngle \cdot normAngle, -1 \cdot \left(\frac{-1}{36} \cdot n1\_i + \frac{1}{120} \cdot n1\_i\right)\right), normAngle \cdot normAngle, \mathsf{fma}\left(\frac{1}{2}, n0\_i, \frac{1}{6} \cdot \left(n1\_i - n0\_i\right)\right)\right), normAngle \cdot normAngle, n1\_i - n0\_i\right), u, n0\_i\right) \]
        3. Step-by-step derivation
          1. Applied rewrites99.6%

            \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889 \cdot n0\_i - -0.00205026455026455 \cdot n1\_i, normAngle \cdot normAngle, 0.019444444444444445 \cdot n1\_i\right), normAngle \cdot normAngle, \mathsf{fma}\left(0.5, n0\_i, 0.16666666666666666 \cdot \left(n1\_i - n0\_i\right)\right)\right), normAngle \cdot normAngle, n1\_i - n0\_i\right), u, n0\_i\right) \]
          2. Add Preprocessing

          Alternative 3: 99.3% accurate, 9.0× speedup?

          \[\begin{array}{l} \\ \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.019444444444444445 \cdot n1\_i, normAngle \cdot normAngle, \mathsf{fma}\left(0.5, n0\_i, 0.16666666666666666 \cdot \left(n1\_i - n0\_i\right)\right)\right), normAngle \cdot normAngle, n1\_i - n0\_i\right), u, n0\_i\right) \end{array} \]
          (FPCore (normAngle u n0_i n1_i)
           :precision binary32
           (fma
            (fma
             (fma
              (* 0.019444444444444445 n1_i)
              (* normAngle normAngle)
              (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.019444444444444445f * n1_i), (normAngle * normAngle), 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(fma(fma(Float32(Float32(0.019444444444444445) * n1_i), Float32(normAngle * normAngle), fma(Float32(0.5), n0_i, Float32(Float32(0.16666666666666666) * Float32(n1_i - n0_i)))), Float32(normAngle * normAngle), Float32(n1_i - n0_i)), u, n0_i)
          end
          
          \begin{array}{l}
          
          \\
          \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.019444444444444445 \cdot n1\_i, normAngle \cdot normAngle, \mathsf{fma}\left(0.5, n0\_i, 0.16666666666666666 \cdot \left(n1\_i - n0\_i\right)\right)\right), normAngle \cdot normAngle, n1\_i - n0\_i\right), u, n0\_i\right)
          \end{array}
          
          Derivation
          1. Initial program 97.2%

            \[\left(\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n0\_i + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n1\_i \]
          2. Add Preprocessing
          3. Taylor expanded in u around 0

            \[\leadsto \color{blue}{n0\_i + u \cdot \left(-1 \cdot \frac{n0\_i \cdot \left(normAngle \cdot \cos normAngle\right)}{\sin normAngle} + \frac{n1\_i \cdot normAngle}{\sin normAngle}\right)} \]
          4. Step-by-step derivation
            1. +-commutativeN/A

              \[\leadsto \color{blue}{u \cdot \left(-1 \cdot \frac{n0\_i \cdot \left(normAngle \cdot \cos normAngle\right)}{\sin normAngle} + \frac{n1\_i \cdot normAngle}{\sin normAngle}\right) + n0\_i} \]
            2. *-commutativeN/A

              \[\leadsto \color{blue}{\left(-1 \cdot \frac{n0\_i \cdot \left(normAngle \cdot \cos normAngle\right)}{\sin normAngle} + \frac{n1\_i \cdot normAngle}{\sin normAngle}\right) \cdot u} + n0\_i \]
            3. lower-fma.f32N/A

              \[\leadsto \color{blue}{\mathsf{fma}\left(-1 \cdot \frac{n0\_i \cdot \left(normAngle \cdot \cos normAngle\right)}{\sin normAngle} + \frac{n1\_i \cdot normAngle}{\sin normAngle}, u, n0\_i\right)} \]
          5. Applied rewrites89.7%

            \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{n1\_i \cdot normAngle - \left(\cos normAngle \cdot normAngle\right) \cdot n0\_i}{\sin normAngle}, u, n0\_i\right)} \]
          6. Taylor expanded in normAngle around 0

            \[\leadsto \mathsf{fma}\left(\left(n1\_i + {normAngle}^{2} \cdot \left(\left(\frac{1}{2} \cdot n0\_i + {normAngle}^{2} \cdot \left(\frac{-1}{24} \cdot n0\_i - \left(\frac{-1}{6} \cdot \left(\frac{1}{2} \cdot n0\_i - \frac{-1}{6} \cdot \left(n1\_i - n0\_i\right)\right) + \frac{1}{120} \cdot \left(n1\_i - n0\_i\right)\right)\right)\right) - \frac{-1}{6} \cdot \left(n1\_i - n0\_i\right)\right)\right) - n0\_i, u, n0\_i\right) \]
          7. Step-by-step derivation
            1. Applied rewrites99.5%

              \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.041666666666666664 \cdot n0\_i - \mathsf{fma}\left(\mathsf{fma}\left(0.5, n0\_i, 0.16666666666666666 \cdot \left(n1\_i - n0\_i\right)\right), -0.16666666666666666, \left(n1\_i - n0\_i\right) \cdot 0.008333333333333333\right), normAngle \cdot normAngle, \mathsf{fma}\left(0.5, n0\_i, 0.16666666666666666 \cdot \left(n1\_i - n0\_i\right)\right)\right), normAngle \cdot normAngle, n1\_i - n0\_i\right), u, n0\_i\right) \]
            2. Taylor expanded in n0_i around 0

              \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-1 \cdot \left(\frac{-1}{36} \cdot n1\_i + \frac{1}{120} \cdot n1\_i\right), normAngle \cdot normAngle, \mathsf{fma}\left(\frac{1}{2}, n0\_i, \frac{1}{6} \cdot \left(n1\_i - n0\_i\right)\right)\right), normAngle \cdot normAngle, n1\_i - n0\_i\right), u, n0\_i\right) \]
            3. Step-by-step derivation
              1. Applied rewrites99.5%

                \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.019444444444444445 \cdot n1\_i, normAngle \cdot normAngle, \mathsf{fma}\left(0.5, n0\_i, 0.16666666666666666 \cdot \left(n1\_i - n0\_i\right)\right)\right), normAngle \cdot normAngle, n1\_i - n0\_i\right), u, n0\_i\right) \]
              2. Add Preprocessing

              Alternative 4: 99.1% accurate, 10.2× speedup?

              \[\begin{array}{l} \\ \mathsf{fma}\left(\mathsf{fma}\left(0.5 \cdot u, n0\_i, \left(0.16666666666666666 \cdot \left(n1\_i - n0\_i\right)\right) \cdot u\right), normAngle \cdot normAngle, \mathsf{fma}\left(n1\_i - n0\_i, u, n0\_i\right)\right) \end{array} \]
              (FPCore (normAngle u n0_i n1_i)
               :precision binary32
               (fma
                (fma (* 0.5 u) n0_i (* (* 0.16666666666666666 (- n1_i n0_i)) u))
                (* normAngle normAngle)
                (fma (- n1_i n0_i) u n0_i)))
              float code(float normAngle, float u, float n0_i, float n1_i) {
              	return fmaf(fmaf((0.5f * u), n0_i, ((0.16666666666666666f * (n1_i - n0_i)) * u)), (normAngle * normAngle), fmaf((n1_i - n0_i), u, n0_i));
              }
              
              function code(normAngle, u, n0_i, n1_i)
              	return fma(fma(Float32(Float32(0.5) * u), n0_i, Float32(Float32(Float32(0.16666666666666666) * Float32(n1_i - n0_i)) * u)), Float32(normAngle * normAngle), fma(Float32(n1_i - n0_i), u, n0_i))
              end
              
              \begin{array}{l}
              
              \\
              \mathsf{fma}\left(\mathsf{fma}\left(0.5 \cdot u, n0\_i, \left(0.16666666666666666 \cdot \left(n1\_i - n0\_i\right)\right) \cdot u\right), normAngle \cdot normAngle, \mathsf{fma}\left(n1\_i - n0\_i, u, n0\_i\right)\right)
              \end{array}
              
              Derivation
              1. Initial program 97.2%

                \[\left(\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n0\_i + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n1\_i \]
              2. Add Preprocessing
              3. Taylor expanded in u around 0

                \[\leadsto \color{blue}{n0\_i + u \cdot \left(-1 \cdot \frac{n0\_i \cdot \left(normAngle \cdot \cos normAngle\right)}{\sin normAngle} + \frac{n1\_i \cdot normAngle}{\sin normAngle}\right)} \]
              4. Step-by-step derivation
                1. +-commutativeN/A

                  \[\leadsto \color{blue}{u \cdot \left(-1 \cdot \frac{n0\_i \cdot \left(normAngle \cdot \cos normAngle\right)}{\sin normAngle} + \frac{n1\_i \cdot normAngle}{\sin normAngle}\right) + n0\_i} \]
                2. *-commutativeN/A

                  \[\leadsto \color{blue}{\left(-1 \cdot \frac{n0\_i \cdot \left(normAngle \cdot \cos normAngle\right)}{\sin normAngle} + \frac{n1\_i \cdot normAngle}{\sin normAngle}\right) \cdot u} + n0\_i \]
                3. lower-fma.f32N/A

                  \[\leadsto \color{blue}{\mathsf{fma}\left(-1 \cdot \frac{n0\_i \cdot \left(normAngle \cdot \cos normAngle\right)}{\sin normAngle} + \frac{n1\_i \cdot normAngle}{\sin normAngle}, u, n0\_i\right)} \]
              5. Applied rewrites89.7%

                \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{n1\_i \cdot normAngle - \left(\cos normAngle \cdot normAngle\right) \cdot n0\_i}{\sin normAngle}, u, n0\_i\right)} \]
              6. Taylor expanded in normAngle around 0

                \[\leadsto n0\_i + \color{blue}{\left(u \cdot \left(n1\_i - n0\_i\right) + {normAngle}^{2} \cdot \left(\frac{1}{2} \cdot \left(n0\_i \cdot u\right) - \frac{-1}{6} \cdot \left(u \cdot \left(n1\_i - n0\_i\right)\right)\right)\right)} \]
              7. Step-by-step derivation
                1. Applied rewrites99.2%

                  \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(0.5 \cdot u, n0\_i, \left(0.16666666666666666 \cdot \left(n1\_i - n0\_i\right)\right) \cdot u\right), \color{blue}{normAngle \cdot normAngle}, \mathsf{fma}\left(n1\_i - n0\_i, u, n0\_i\right)\right) \]
                2. Add Preprocessing

                Alternative 5: 99.1% accurate, 13.1× speedup?

                \[\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 - n0\_i\right), u, n0\_i\right) \end{array} \]
                (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(fma(fma(Float32(0.5), n0_i, Float32(Float32(0.16666666666666666) * Float32(n1_i - n0_i))), Float32(normAngle * normAngle), Float32(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 - n0\_i\right), u, n0\_i\right)
                \end{array}
                
                Derivation
                1. Initial program 97.2%

                  \[\left(\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n0\_i + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n1\_i \]
                2. Add Preprocessing
                3. Taylor expanded in u around 0

                  \[\leadsto \color{blue}{n0\_i + u \cdot \left(-1 \cdot \frac{n0\_i \cdot \left(normAngle \cdot \cos normAngle\right)}{\sin normAngle} + \frac{n1\_i \cdot normAngle}{\sin normAngle}\right)} \]
                4. Step-by-step derivation
                  1. +-commutativeN/A

                    \[\leadsto \color{blue}{u \cdot \left(-1 \cdot \frac{n0\_i \cdot \left(normAngle \cdot \cos normAngle\right)}{\sin normAngle} + \frac{n1\_i \cdot normAngle}{\sin normAngle}\right) + n0\_i} \]
                  2. *-commutativeN/A

                    \[\leadsto \color{blue}{\left(-1 \cdot \frac{n0\_i \cdot \left(normAngle \cdot \cos normAngle\right)}{\sin normAngle} + \frac{n1\_i \cdot normAngle}{\sin normAngle}\right) \cdot u} + n0\_i \]
                  3. lower-fma.f32N/A

                    \[\leadsto \color{blue}{\mathsf{fma}\left(-1 \cdot \frac{n0\_i \cdot \left(normAngle \cdot \cos normAngle\right)}{\sin normAngle} + \frac{n1\_i \cdot normAngle}{\sin normAngle}, u, n0\_i\right)} \]
                5. Applied rewrites89.7%

                  \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{n1\_i \cdot normAngle - \left(\cos normAngle \cdot normAngle\right) \cdot n0\_i}{\sin normAngle}, u, n0\_i\right)} \]
                6. Taylor expanded in normAngle around 0

                  \[\leadsto \mathsf{fma}\left(\left(n1\_i + {normAngle}^{2} \cdot \left(\frac{1}{2} \cdot n0\_i - \frac{-1}{6} \cdot \left(n1\_i - n0\_i\right)\right)\right) - n0\_i, u, n0\_i\right) \]
                7. Step-by-step derivation
                  1. Applied rewrites99.2%

                    \[\leadsto \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 - n0\_i\right), u, n0\_i\right) \]
                  2. Add Preprocessing

                  Alternative 6: 70.7% accurate, 21.8× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n0\_i \leq -3.999999954906409 \cdot 10^{-26} \lor \neg \left(n0\_i \leq 4.9999998413276127 \cdot 10^{-20}\right):\\ \;\;\;\;\left(1 - u\right) \cdot n0\_i\\ \mathbf{else}:\\ \;\;\;\;u \cdot n1\_i\\ \end{array} \end{array} \]
                  (FPCore (normAngle u n0_i n1_i)
                   :precision binary32
                   (if (or (<= n0_i -3.999999954906409e-26)
                           (not (<= n0_i 4.9999998413276127e-20)))
                     (* (- 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 <= -3.999999954906409e-26f) || !(n0_i <= 4.9999998413276127e-20f)) {
                  		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 <= (-3.999999954906409e-26)) .or. (.not. (n0_i <= 4.9999998413276127e-20))) 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(-3.999999954906409e-26)) || !(n0_i <= Float32(4.9999998413276127e-20)))
                  		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(-3.999999954906409e-26)) || ~((n0_i <= single(4.9999998413276127e-20))))
                  		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 -3.999999954906409 \cdot 10^{-26} \lor \neg \left(n0\_i \leq 4.9999998413276127 \cdot 10^{-20}\right):\\
                  \;\;\;\;\left(1 - u\right) \cdot n0\_i\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;u \cdot n1\_i\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if n0_i < -3.99999995e-26 or 4.99999984e-20 < n0_i

                    1. Initial program 98.6%

                      \[\left(\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n0\_i + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n1\_i \]
                    2. Add Preprocessing
                    3. Taylor expanded in normAngle around 0

                      \[\leadsto \color{blue}{n0\_i \cdot \left(1 - u\right) + n1\_i \cdot u} \]
                    4. Step-by-step derivation
                      1. *-commutativeN/A

                        \[\leadsto \color{blue}{\left(1 - u\right) \cdot n0\_i} + n1\_i \cdot u \]
                      2. lower-fma.f32N/A

                        \[\leadsto \color{blue}{\mathsf{fma}\left(1 - u, n0\_i, n1\_i \cdot u\right)} \]
                      3. lower--.f32N/A

                        \[\leadsto \mathsf{fma}\left(\color{blue}{1 - u}, n0\_i, n1\_i \cdot u\right) \]
                      4. lower-*.f3298.2

                        \[\leadsto \mathsf{fma}\left(1 - u, n0\_i, \color{blue}{n1\_i \cdot u}\right) \]
                    5. Applied rewrites98.2%

                      \[\leadsto \color{blue}{\mathsf{fma}\left(1 - u, n0\_i, n1\_i \cdot u\right)} \]
                    6. Taylor expanded in u around inf

                      \[\leadsto u \cdot \color{blue}{\left(n1\_i + -1 \cdot n0\_i\right)} \]
                    7. Step-by-step derivation
                      1. Applied rewrites16.3%

                        \[\leadsto \left(n1\_i - n0\_i\right) \cdot \color{blue}{u} \]
                      2. Taylor expanded in n0_i around inf

                        \[\leadsto n0\_i \cdot \color{blue}{\left(1 - u\right)} \]
                      3. Step-by-step derivation
                        1. Applied rewrites78.6%

                          \[\leadsto \left(1 - u\right) \cdot \color{blue}{n0\_i} \]

                        if -3.99999995e-26 < n0_i < 4.99999984e-20

                        1. Initial program 95.2%

                          \[\left(\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n0\_i + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n1\_i \]
                        2. Add Preprocessing
                        3. Taylor expanded in normAngle around 0

                          \[\leadsto \color{blue}{n0\_i \cdot \left(1 - u\right) + n1\_i \cdot u} \]
                        4. Step-by-step derivation
                          1. *-commutativeN/A

                            \[\leadsto \color{blue}{\left(1 - u\right) \cdot n0\_i} + n1\_i \cdot u \]
                          2. lower-fma.f32N/A

                            \[\leadsto \color{blue}{\mathsf{fma}\left(1 - u, n0\_i, n1\_i \cdot u\right)} \]
                          3. lower--.f32N/A

                            \[\leadsto \mathsf{fma}\left(\color{blue}{1 - u}, n0\_i, n1\_i \cdot u\right) \]
                          4. lower-*.f3297.5

                            \[\leadsto \mathsf{fma}\left(1 - u, n0\_i, \color{blue}{n1\_i \cdot u}\right) \]
                        5. Applied rewrites97.5%

                          \[\leadsto \color{blue}{\mathsf{fma}\left(1 - u, n0\_i, n1\_i \cdot u\right)} \]
                        6. Taylor expanded in u around inf

                          \[\leadsto u \cdot \color{blue}{\left(n1\_i + -1 \cdot n0\_i\right)} \]
                        7. Step-by-step derivation
                          1. Applied rewrites69.8%

                            \[\leadsto \left(n1\_i - n0\_i\right) \cdot \color{blue}{u} \]
                          2. Taylor expanded in n0_i around inf

                            \[\leadsto \left(-1 \cdot n0\_i\right) \cdot u \]
                          3. Step-by-step derivation
                            1. Applied rewrites10.0%

                              \[\leadsto \left(-n0\_i\right) \cdot u \]
                            2. Taylor expanded in n0_i around 0

                              \[\leadsto n1\_i \cdot \color{blue}{u} \]
                            3. Step-by-step derivation
                              1. Applied rewrites70.4%

                                \[\leadsto u \cdot \color{blue}{n1\_i} \]
                            4. Recombined 2 regimes into one program.
                            5. Final simplification75.3%

                              \[\leadsto \begin{array}{l} \mathbf{if}\;n0\_i \leq -3.999999954906409 \cdot 10^{-26} \lor \neg \left(n0\_i \leq 4.9999998413276127 \cdot 10^{-20}\right):\\ \;\;\;\;\left(1 - u\right) \cdot n0\_i\\ \mathbf{else}:\\ \;\;\;\;u \cdot n1\_i\\ \end{array} \]
                            6. Add Preprocessing

                            Alternative 7: 61.0% accurate, 25.4× speedup?

                            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n0\_i \leq -4.999999841327613 \cdot 10^{-22} \lor \neg \left(n0\_i \leq 4.9999998413276127 \cdot 10^{-20}\right):\\ \;\;\;\;1 \cdot n0\_i\\ \mathbf{else}:\\ \;\;\;\;u \cdot n1\_i\\ \end{array} \end{array} \]
                            (FPCore (normAngle u n0_i n1_i)
                             :precision binary32
                             (if (or (<= n0_i -4.999999841327613e-22)
                                     (not (<= n0_i 4.9999998413276127e-20)))
                               (* 1.0 n0_i)
                               (* u n1_i)))
                            float code(float normAngle, float u, float n0_i, float n1_i) {
                            	float tmp;
                            	if ((n0_i <= -4.999999841327613e-22f) || !(n0_i <= 4.9999998413276127e-20f)) {
                            		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 <= (-4.999999841327613e-22)) .or. (.not. (n0_i <= 4.9999998413276127e-20))) 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(-4.999999841327613e-22)) || !(n0_i <= Float32(4.9999998413276127e-20)))
                            		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(-4.999999841327613e-22)) || ~((n0_i <= single(4.9999998413276127e-20))))
                            		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 -4.999999841327613 \cdot 10^{-22} \lor \neg \left(n0\_i \leq 4.9999998413276127 \cdot 10^{-20}\right):\\
                            \;\;\;\;1 \cdot n0\_i\\
                            
                            \mathbf{else}:\\
                            \;\;\;\;u \cdot n1\_i\\
                            
                            
                            \end{array}
                            \end{array}
                            
                            Derivation
                            1. Split input into 2 regimes
                            2. if n0_i < -4.9999998e-22 or 4.99999984e-20 < n0_i

                              1. Initial program 98.5%

                                \[\left(\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n0\_i + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n1\_i \]
                              2. Add Preprocessing
                              3. Taylor expanded in normAngle around 0

                                \[\leadsto \color{blue}{n0\_i \cdot \left(1 - u\right) + n1\_i \cdot u} \]
                              4. Step-by-step derivation
                                1. *-commutativeN/A

                                  \[\leadsto \color{blue}{\left(1 - u\right) \cdot n0\_i} + n1\_i \cdot u \]
                                2. lower-fma.f32N/A

                                  \[\leadsto \color{blue}{\mathsf{fma}\left(1 - u, n0\_i, n1\_i \cdot u\right)} \]
                                3. lower--.f32N/A

                                  \[\leadsto \mathsf{fma}\left(\color{blue}{1 - u}, n0\_i, n1\_i \cdot u\right) \]
                                4. lower-*.f3298.1

                                  \[\leadsto \mathsf{fma}\left(1 - u, n0\_i, \color{blue}{n1\_i \cdot u}\right) \]
                              5. Applied rewrites98.1%

                                \[\leadsto \color{blue}{\mathsf{fma}\left(1 - u, n0\_i, n1\_i \cdot u\right)} \]
                              6. Taylor expanded in u around inf

                                \[\leadsto u \cdot \color{blue}{\left(n1\_i + \left(-1 \cdot n0\_i + \frac{n0\_i}{u}\right)\right)} \]
                              7. Step-by-step derivation
                                1. Applied rewrites97.7%

                                  \[\leadsto \left(n1\_i - \left(n0\_i - \frac{n0\_i}{u}\right)\right) \cdot \color{blue}{u} \]
                                2. Taylor expanded in n0_i around inf

                                  \[\leadsto n0\_i \cdot \left(u \cdot \left(\frac{1}{u} - 1\right) + \color{blue}{\frac{n1\_i \cdot u}{n0\_i}}\right) \]
                                3. Step-by-step derivation
                                  1. Applied rewrites97.7%

                                    \[\leadsto \mathsf{fma}\left(\frac{1}{u} - 1, u, \frac{u \cdot n1\_i}{n0\_i}\right) \cdot n0\_i \]
                                  2. Taylor expanded in u around 0

                                    \[\leadsto 1 \cdot n0\_i \]
                                  3. Step-by-step derivation
                                    1. Applied rewrites64.6%

                                      \[\leadsto 1 \cdot n0\_i \]

                                    if -4.9999998e-22 < n0_i < 4.99999984e-20

                                    1. Initial program 95.7%

                                      \[\left(\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n0\_i + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n1\_i \]
                                    2. Add Preprocessing
                                    3. Taylor expanded in normAngle around 0

                                      \[\leadsto \color{blue}{n0\_i \cdot \left(1 - u\right) + n1\_i \cdot u} \]
                                    4. Step-by-step derivation
                                      1. *-commutativeN/A

                                        \[\leadsto \color{blue}{\left(1 - u\right) \cdot n0\_i} + n1\_i \cdot u \]
                                      2. lower-fma.f32N/A

                                        \[\leadsto \color{blue}{\mathsf{fma}\left(1 - u, n0\_i, n1\_i \cdot u\right)} \]
                                      3. lower--.f32N/A

                                        \[\leadsto \mathsf{fma}\left(\color{blue}{1 - u}, n0\_i, n1\_i \cdot u\right) \]
                                      4. lower-*.f3297.8

                                        \[\leadsto \mathsf{fma}\left(1 - u, n0\_i, \color{blue}{n1\_i \cdot u}\right) \]
                                    5. Applied rewrites97.8%

                                      \[\leadsto \color{blue}{\mathsf{fma}\left(1 - u, n0\_i, n1\_i \cdot u\right)} \]
                                    6. Taylor expanded in u around inf

                                      \[\leadsto u \cdot \color{blue}{\left(n1\_i + -1 \cdot n0\_i\right)} \]
                                    7. Step-by-step derivation
                                      1. Applied rewrites67.0%

                                        \[\leadsto \left(n1\_i - n0\_i\right) \cdot \color{blue}{u} \]
                                      2. Taylor expanded in n0_i around inf

                                        \[\leadsto \left(-1 \cdot n0\_i\right) \cdot u \]
                                      3. Step-by-step derivation
                                        1. Applied rewrites9.8%

                                          \[\leadsto \left(-n0\_i\right) \cdot u \]
                                        2. Taylor expanded in n0_i around 0

                                          \[\leadsto n1\_i \cdot \color{blue}{u} \]
                                        3. Step-by-step derivation
                                          1. Applied rewrites67.6%

                                            \[\leadsto u \cdot \color{blue}{n1\_i} \]
                                        4. Recombined 2 regimes into one program.
                                        5. Final simplification66.0%

                                          \[\leadsto \begin{array}{l} \mathbf{if}\;n0\_i \leq -4.999999841327613 \cdot 10^{-22} \lor \neg \left(n0\_i \leq 4.9999998413276127 \cdot 10^{-20}\right):\\ \;\;\;\;1 \cdot n0\_i\\ \mathbf{else}:\\ \;\;\;\;u \cdot n1\_i\\ \end{array} \]
                                        6. Add Preprocessing

                                        Alternative 8: 98.3% accurate, 45.9× speedup?

                                        \[\begin{array}{l} \\ \mathsf{fma}\left(n1\_i - n0\_i, u, n0\_i\right) \end{array} \]
                                        (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}
                                        
                                        Derivation
                                        1. Initial program 97.2%

                                          \[\left(\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n0\_i + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n1\_i \]
                                        2. Add Preprocessing
                                        3. Taylor expanded in u around 0

                                          \[\leadsto \color{blue}{n0\_i + u \cdot \left(-1 \cdot \frac{n0\_i \cdot \left(normAngle \cdot \cos normAngle\right)}{\sin normAngle} + \frac{n1\_i \cdot normAngle}{\sin normAngle}\right)} \]
                                        4. Step-by-step derivation
                                          1. +-commutativeN/A

                                            \[\leadsto \color{blue}{u \cdot \left(-1 \cdot \frac{n0\_i \cdot \left(normAngle \cdot \cos normAngle\right)}{\sin normAngle} + \frac{n1\_i \cdot normAngle}{\sin normAngle}\right) + n0\_i} \]
                                          2. *-commutativeN/A

                                            \[\leadsto \color{blue}{\left(-1 \cdot \frac{n0\_i \cdot \left(normAngle \cdot \cos normAngle\right)}{\sin normAngle} + \frac{n1\_i \cdot normAngle}{\sin normAngle}\right) \cdot u} + n0\_i \]
                                          3. lower-fma.f32N/A

                                            \[\leadsto \color{blue}{\mathsf{fma}\left(-1 \cdot \frac{n0\_i \cdot \left(normAngle \cdot \cos normAngle\right)}{\sin normAngle} + \frac{n1\_i \cdot normAngle}{\sin normAngle}, u, n0\_i\right)} \]
                                        5. Applied rewrites89.7%

                                          \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{n1\_i \cdot normAngle - \left(\cos normAngle \cdot normAngle\right) \cdot n0\_i}{\sin normAngle}, u, n0\_i\right)} \]
                                        6. Taylor expanded in normAngle around 0

                                          \[\leadsto \mathsf{fma}\left(n1\_i - n0\_i, u, n0\_i\right) \]
                                        7. Step-by-step derivation
                                          1. Applied rewrites98.3%

                                            \[\leadsto \mathsf{fma}\left(n1\_i - n0\_i, u, n0\_i\right) \]
                                          2. Add Preprocessing

                                          Alternative 9: 47.0% accurate, 76.5× speedup?

                                          \[\begin{array}{l} \\ 1 \cdot n0\_i \end{array} \]
                                          (FPCore (normAngle u n0_i n1_i) :precision binary32 (* 1.0 n0_i))
                                          float code(float normAngle, float u, float n0_i, float n1_i) {
                                          	return 1.0f * 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 = 1.0e0 * n0_i
                                          end function
                                          
                                          function code(normAngle, u, n0_i, n1_i)
                                          	return Float32(Float32(1.0) * n0_i)
                                          end
                                          
                                          function tmp = code(normAngle, u, n0_i, n1_i)
                                          	tmp = single(1.0) * n0_i;
                                          end
                                          
                                          \begin{array}{l}
                                          
                                          \\
                                          1 \cdot n0\_i
                                          \end{array}
                                          
                                          Derivation
                                          1. Initial program 97.2%

                                            \[\left(\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n0\_i + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n1\_i \]
                                          2. Add Preprocessing
                                          3. Taylor expanded in normAngle around 0

                                            \[\leadsto \color{blue}{n0\_i \cdot \left(1 - u\right) + n1\_i \cdot u} \]
                                          4. Step-by-step derivation
                                            1. *-commutativeN/A

                                              \[\leadsto \color{blue}{\left(1 - u\right) \cdot n0\_i} + n1\_i \cdot u \]
                                            2. lower-fma.f32N/A

                                              \[\leadsto \color{blue}{\mathsf{fma}\left(1 - u, n0\_i, n1\_i \cdot u\right)} \]
                                            3. lower--.f32N/A

                                              \[\leadsto \mathsf{fma}\left(\color{blue}{1 - u}, n0\_i, n1\_i \cdot u\right) \]
                                            4. lower-*.f3298.0

                                              \[\leadsto \mathsf{fma}\left(1 - u, n0\_i, \color{blue}{n1\_i \cdot u}\right) \]
                                          5. Applied rewrites98.0%

                                            \[\leadsto \color{blue}{\mathsf{fma}\left(1 - u, n0\_i, n1\_i \cdot u\right)} \]
                                          6. Taylor expanded in u around inf

                                            \[\leadsto u \cdot \color{blue}{\left(n1\_i + \left(-1 \cdot n0\_i + \frac{n0\_i}{u}\right)\right)} \]
                                          7. Step-by-step derivation
                                            1. Applied rewrites97.6%

                                              \[\leadsto \left(n1\_i - \left(n0\_i - \frac{n0\_i}{u}\right)\right) \cdot \color{blue}{u} \]
                                            2. Taylor expanded in n0_i around inf

                                              \[\leadsto n0\_i \cdot \left(u \cdot \left(\frac{1}{u} - 1\right) + \color{blue}{\frac{n1\_i \cdot u}{n0\_i}}\right) \]
                                            3. Step-by-step derivation
                                              1. Applied rewrites97.7%

                                                \[\leadsto \mathsf{fma}\left(\frac{1}{u} - 1, u, \frac{u \cdot n1\_i}{n0\_i}\right) \cdot n0\_i \]
                                              2. Taylor expanded in u around 0

                                                \[\leadsto 1 \cdot n0\_i \]
                                              3. Step-by-step derivation
                                                1. Applied rewrites46.4%

                                                  \[\leadsto 1 \cdot n0\_i \]
                                                2. Add Preprocessing

                                                Reproduce

                                                ?
                                                herbie shell --seed 2024358 
                                                (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)))