Curve intersection, scale width based on ribbon orientation

Percentage Accurate: 97.2% → 99.4%
Time: 12.3s
Alternatives: 11
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);
}
real(4) function code(normangle, u, n0_i, n1_i)
    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 11 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.2% 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);
}
real(4) function code(normangle, u, n0_i, n1_i)
    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, 3.0× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\mathsf{fma}\left(\frac{normAngle}{\sin normAngle}, n1\_i, -\mathsf{fma}\left(\mathsf{fma}\left(-0.022222222222222223, normAngle \cdot normAngle, -0.3333333333333333\right) \cdot n0\_i, normAngle \cdot normAngle, n0\_i\right)\right), u, n0\_i\right) \end{array} \]
(FPCore (normAngle u n0_i n1_i)
 :precision binary32
 (fma
  (fma
   (/ normAngle (sin normAngle))
   n1_i
   (-
    (fma
     (*
      (fma -0.022222222222222223 (* normAngle normAngle) -0.3333333333333333)
      n0_i)
     (* normAngle normAngle)
     n0_i)))
  u
  n0_i))
float code(float normAngle, float u, float n0_i, float n1_i) {
	return fmaf(fmaf((normAngle / sinf(normAngle)), n1_i, -fmaf((fmaf(-0.022222222222222223f, (normAngle * normAngle), -0.3333333333333333f) * n0_i), (normAngle * normAngle), n0_i)), u, n0_i);
}
function code(normAngle, u, n0_i, n1_i)
	return fma(fma(Float32(normAngle / sin(normAngle)), n1_i, Float32(-fma(Float32(fma(Float32(-0.022222222222222223), Float32(normAngle * normAngle), Float32(-0.3333333333333333)) * n0_i), Float32(normAngle * normAngle), n0_i))), u, n0_i)
end
\begin{array}{l}

\\
\mathsf{fma}\left(\mathsf{fma}\left(\frac{normAngle}{\sin normAngle}, n1\_i, -\mathsf{fma}\left(\mathsf{fma}\left(-0.022222222222222223, normAngle \cdot normAngle, -0.3333333333333333\right) \cdot n0\_i, normAngle \cdot normAngle, n0\_i\right)\right), u, n0\_i\right)
\end{array}
Derivation
  1. Initial program 98.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 rewrites99.3%

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

    \[\leadsto \mathsf{fma}\left(\frac{normAngle}{\sin normAngle} \cdot n1\_i - \left(n0\_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 n0\_i\right) + \frac{1}{120} \cdot n0\_i\right)\right)\right) - \frac{-1}{6} \cdot n0\_i\right)\right), u, n0\_i\right) \]
  7. Step-by-step derivation
    1. Applied rewrites99.3%

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

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

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

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{normAngle}{\sin normAngle}, n1\_i, -\mathsf{fma}\left(\mathsf{fma}\left(-0.022222222222222223, normAngle \cdot normAngle, -0.3333333333333333\right) \cdot n0\_i, normAngle \cdot normAngle, n0\_i\right)\right), u, n0\_i\right) \]
        2. Add Preprocessing

        Alternative 2: 99.4% accurate, 3.0× speedup?

        \[\begin{array}{l} \\ \mathsf{fma}\left(\frac{normAngle}{\sin normAngle} \cdot n1\_i - \mathsf{fma}\left(\mathsf{fma}\left(normAngle \cdot normAngle, -0.022222222222222223, -0.3333333333333333\right) \cdot n0\_i, normAngle \cdot normAngle, n0\_i\right), u, n0\_i\right) \end{array} \]
        (FPCore (normAngle u n0_i n1_i)
         :precision binary32
         (fma
          (-
           (* (/ normAngle (sin normAngle)) n1_i)
           (fma
            (*
             (fma (* normAngle normAngle) -0.022222222222222223 -0.3333333333333333)
             n0_i)
            (* normAngle normAngle)
            n0_i))
          u
          n0_i))
        float code(float normAngle, float u, float n0_i, float n1_i) {
        	return fmaf((((normAngle / sinf(normAngle)) * n1_i) - fmaf((fmaf((normAngle * normAngle), -0.022222222222222223f, -0.3333333333333333f) * n0_i), (normAngle * normAngle), n0_i)), u, n0_i);
        }
        
        function code(normAngle, u, n0_i, n1_i)
        	return fma(Float32(Float32(Float32(normAngle / sin(normAngle)) * n1_i) - fma(Float32(fma(Float32(normAngle * normAngle), Float32(-0.022222222222222223), Float32(-0.3333333333333333)) * n0_i), Float32(normAngle * normAngle), n0_i)), u, n0_i)
        end
        
        \begin{array}{l}
        
        \\
        \mathsf{fma}\left(\frac{normAngle}{\sin normAngle} \cdot n1\_i - \mathsf{fma}\left(\mathsf{fma}\left(normAngle \cdot normAngle, -0.022222222222222223, -0.3333333333333333\right) \cdot n0\_i, normAngle \cdot normAngle, n0\_i\right), u, n0\_i\right)
        \end{array}
        
        Derivation
        1. Initial program 98.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 rewrites99.3%

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

          \[\leadsto \mathsf{fma}\left(\frac{normAngle}{\sin normAngle} \cdot n1\_i - \left(n0\_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 n0\_i\right) + \frac{1}{120} \cdot n0\_i\right)\right)\right) - \frac{-1}{6} \cdot n0\_i\right)\right), u, n0\_i\right) \]
        7. Step-by-step derivation
          1. Applied rewrites99.3%

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

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

              \[\leadsto \mathsf{fma}\left(\frac{normAngle}{\sin normAngle} \cdot n1\_i - \mathsf{fma}\left(\mathsf{fma}\left(normAngle \cdot normAngle, -0.022222222222222223, -0.3333333333333333\right) \cdot n0\_i, normAngle \cdot normAngle, n0\_i\right), u, n0\_i\right) \]
            2. Add Preprocessing

            Alternative 3: 99.4% accurate, 3.2× speedup?

            \[\begin{array}{l} \\ \mathsf{fma}\left(\frac{normAngle}{\sin normAngle} \cdot n1\_i - \mathsf{fma}\left(-0.3333333333333333 \cdot n0\_i, normAngle \cdot normAngle, n0\_i\right), u, n0\_i\right) \end{array} \]
            (FPCore (normAngle u n0_i n1_i)
             :precision binary32
             (fma
              (-
               (* (/ normAngle (sin normAngle)) n1_i)
               (fma (* -0.3333333333333333 n0_i) (* normAngle normAngle) n0_i))
              u
              n0_i))
            float code(float normAngle, float u, float n0_i, float n1_i) {
            	return fmaf((((normAngle / sinf(normAngle)) * n1_i) - fmaf((-0.3333333333333333f * n0_i), (normAngle * normAngle), n0_i)), u, n0_i);
            }
            
            function code(normAngle, u, n0_i, n1_i)
            	return fma(Float32(Float32(Float32(normAngle / sin(normAngle)) * n1_i) - fma(Float32(Float32(-0.3333333333333333) * n0_i), Float32(normAngle * normAngle), n0_i)), u, n0_i)
            end
            
            \begin{array}{l}
            
            \\
            \mathsf{fma}\left(\frac{normAngle}{\sin normAngle} \cdot n1\_i - \mathsf{fma}\left(-0.3333333333333333 \cdot n0\_i, normAngle \cdot normAngle, n0\_i\right), u, n0\_i\right)
            \end{array}
            
            Derivation
            1. Initial program 98.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 rewrites99.3%

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

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

                \[\leadsto \mathsf{fma}\left(\frac{normAngle}{\sin normAngle} \cdot n1\_i - \mathsf{fma}\left(n0\_i \cdot -0.3333333333333333, normAngle \cdot normAngle, n0\_i\right), u, n0\_i\right) \]
              2. Final simplification99.3%

                \[\leadsto \mathsf{fma}\left(\frac{normAngle}{\sin normAngle} \cdot n1\_i - \mathsf{fma}\left(-0.3333333333333333 \cdot n0\_i, normAngle \cdot normAngle, n0\_i\right), u, n0\_i\right) \]
              3. Add Preprocessing

              Alternative 4: 99.3% accurate, 4.9× speedup?

              \[\begin{array}{l} \\ \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\left(-normAngle\right) \cdot normAngle, \mathsf{fma}\left(n1\_i, 0.0011904761904761906, -0.0032407407407407406 \cdot n1\_i\right), 0.019444444444444445 \cdot n1\_i\right), normAngle \cdot normAngle, 0.16666666666666666 \cdot n1\_i\right), normAngle \cdot normAngle, n1\_i\right) - \mathsf{fma}\left(\mathsf{fma}\left(normAngle \cdot normAngle, -0.022222222222222223, -0.3333333333333333\right) \cdot n0\_i, normAngle \cdot normAngle, n0\_i\right), u, n0\_i\right) \end{array} \]
              (FPCore (normAngle u n0_i n1_i)
               :precision binary32
               (fma
                (-
                 (fma
                  (fma
                   (fma
                    (* (- normAngle) normAngle)
                    (fma n1_i 0.0011904761904761906 (* -0.0032407407407407406 n1_i))
                    (* 0.019444444444444445 n1_i))
                   (* normAngle normAngle)
                   (* 0.16666666666666666 n1_i))
                  (* normAngle normAngle)
                  n1_i)
                 (fma
                  (*
                   (fma (* normAngle normAngle) -0.022222222222222223 -0.3333333333333333)
                   n0_i)
                  (* normAngle normAngle)
                  n0_i))
                u
                n0_i))
              float code(float normAngle, float u, float n0_i, float n1_i) {
              	return fmaf((fmaf(fmaf(fmaf((-normAngle * normAngle), fmaf(n1_i, 0.0011904761904761906f, (-0.0032407407407407406f * n1_i)), (0.019444444444444445f * n1_i)), (normAngle * normAngle), (0.16666666666666666f * n1_i)), (normAngle * normAngle), n1_i) - fmaf((fmaf((normAngle * normAngle), -0.022222222222222223f, -0.3333333333333333f) * n0_i), (normAngle * normAngle), n0_i)), u, n0_i);
              }
              
              function code(normAngle, u, n0_i, n1_i)
              	return fma(Float32(fma(fma(fma(Float32(Float32(-normAngle) * normAngle), fma(n1_i, Float32(0.0011904761904761906), Float32(Float32(-0.0032407407407407406) * n1_i)), Float32(Float32(0.019444444444444445) * n1_i)), Float32(normAngle * normAngle), Float32(Float32(0.16666666666666666) * n1_i)), Float32(normAngle * normAngle), n1_i) - fma(Float32(fma(Float32(normAngle * normAngle), Float32(-0.022222222222222223), Float32(-0.3333333333333333)) * n0_i), Float32(normAngle * normAngle), n0_i)), u, n0_i)
              end
              
              \begin{array}{l}
              
              \\
              \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\left(-normAngle\right) \cdot normAngle, \mathsf{fma}\left(n1\_i, 0.0011904761904761906, -0.0032407407407407406 \cdot n1\_i\right), 0.019444444444444445 \cdot n1\_i\right), normAngle \cdot normAngle, 0.16666666666666666 \cdot n1\_i\right), normAngle \cdot normAngle, n1\_i\right) - \mathsf{fma}\left(\mathsf{fma}\left(normAngle \cdot normAngle, -0.022222222222222223, -0.3333333333333333\right) \cdot n0\_i, normAngle \cdot normAngle, n0\_i\right), u, n0\_i\right)
              \end{array}
              
              Derivation
              1. Initial program 98.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 rewrites99.3%

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

                \[\leadsto \mathsf{fma}\left(\frac{normAngle}{\sin normAngle} \cdot n1\_i - \left(n0\_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 n0\_i\right) + \frac{1}{120} \cdot n0\_i\right)\right)\right) - \frac{-1}{6} \cdot n0\_i\right)\right), u, n0\_i\right) \]
              7. Step-by-step derivation
                1. Applied rewrites99.3%

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

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

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

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

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

                    Alternative 5: 99.2% accurate, 6.6× speedup?

                    \[\begin{array}{l} \\ \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.041666666666666664, n0\_i, \mathsf{fma}\left(0.019444444444444445, n1\_i, 0.06388888888888888 \cdot n0\_i\right)\right) \cdot u, normAngle \cdot normAngle, \mathsf{fma}\left(0.3333333333333333, n0\_i, 0.16666666666666666 \cdot n1\_i\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
                       (*
                        (fma
                         -0.041666666666666664
                         n0_i
                         (fma 0.019444444444444445 n1_i (* 0.06388888888888888 n0_i)))
                        u)
                       (* normAngle normAngle)
                       (* (fma 0.3333333333333333 n0_i (* 0.16666666666666666 n1_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((fmaf(-0.041666666666666664f, n0_i, fmaf(0.019444444444444445f, n1_i, (0.06388888888888888f * n0_i))) * u), (normAngle * normAngle), (fmaf(0.3333333333333333f, n0_i, (0.16666666666666666f * n1_i)) * u)), (normAngle * normAngle), fmaf((n1_i - n0_i), u, n0_i));
                    }
                    
                    function code(normAngle, u, n0_i, n1_i)
                    	return fma(fma(Float32(fma(Float32(-0.041666666666666664), n0_i, fma(Float32(0.019444444444444445), n1_i, Float32(Float32(0.06388888888888888) * n0_i))) * u), Float32(normAngle * normAngle), Float32(fma(Float32(0.3333333333333333), n0_i, Float32(Float32(0.16666666666666666) * n1_i)) * u)), Float32(normAngle * normAngle), fma(Float32(n1_i - n0_i), u, n0_i))
                    end
                    
                    \begin{array}{l}
                    
                    \\
                    \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.041666666666666664, n0\_i, \mathsf{fma}\left(0.019444444444444445, n1\_i, 0.06388888888888888 \cdot n0\_i\right)\right) \cdot u, normAngle \cdot normAngle, \mathsf{fma}\left(0.3333333333333333, n0\_i, 0.16666666666666666 \cdot n1\_i\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 98.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 rewrites99.3%

                      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{normAngle}{\sin normAngle} \cdot n1\_i - \left(\cos normAngle \cdot normAngle\right) \cdot \frac{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}{6} \cdot n0\_i + {normAngle}^{2} \cdot \left(\left(\frac{-1}{6} \cdot \left(\frac{-1}{2} \cdot n0\_i - \frac{-1}{6} \cdot n0\_i\right) + \frac{1}{120} \cdot n0\_i\right) - \left(\frac{-1}{36} \cdot n1\_i + \left(\frac{1}{120} \cdot n1\_i + \frac{1}{24} \cdot n0\_i\right)\right)\right)\right) - \left(\frac{-1}{2} \cdot n0\_i + \frac{-1}{6} \cdot n1\_i\right)\right)\right) - n0\_i, u, n0\_i\right) \]
                    7. Applied rewrites99.2%

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

                      \[\leadsto n0\_i + \color{blue}{\left(u \cdot \left(n1\_i - n0\_i\right) + {normAngle}^{2} \cdot \left(u \cdot \left(\frac{-1}{6} \cdot n0\_i - \left(\frac{-1}{2} \cdot n0\_i + \frac{-1}{6} \cdot n1\_i\right)\right) + {normAngle}^{2} \cdot \left(u \cdot \left(\left(\frac{-1}{6} \cdot \left(\frac{-1}{2} \cdot n0\_i - \frac{-1}{6} \cdot n0\_i\right) + \frac{1}{120} \cdot n0\_i\right) - \left(\frac{-1}{36} \cdot n1\_i + \left(\frac{1}{120} \cdot n1\_i + \frac{1}{24} \cdot n0\_i\right)\right)\right)\right)\right)\right)} \]
                    9. Applied rewrites99.2%

                      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.041666666666666664, n0\_i, \mathsf{fma}\left(0.019444444444444445, n1\_i, 0.06388888888888888 \cdot n0\_i\right)\right) \cdot u, normAngle \cdot normAngle, \mathsf{fma}\left(0.3333333333333333, n0\_i, 0.16666666666666666 \cdot n1\_i\right) \cdot u\right), \color{blue}{normAngle \cdot normAngle}, \mathsf{fma}\left(n1\_i - n0\_i, u, n0\_i\right)\right) \]
                    10. Add Preprocessing

                    Alternative 6: 99.2% accurate, 9.6× speedup?

                    \[\begin{array}{l} \\ \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.019444444444444445 \cdot n1\_i, normAngle \cdot normAngle, \mathsf{fma}\left(n0\_i, 0.3333333333333333, 0.16666666666666666 \cdot n1\_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.019444444444444445 n1_i)
                        (* normAngle normAngle)
                        (fma n0_i 0.3333333333333333 (* 0.16666666666666666 n1_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(n0_i, 0.3333333333333333f, (0.16666666666666666f * n1_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(n0_i, Float32(0.3333333333333333), Float32(Float32(0.16666666666666666) * n1_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(n0\_i, 0.3333333333333333, 0.16666666666666666 \cdot n1\_i\right)\right), normAngle \cdot normAngle, n1\_i - n0\_i\right), u, n0\_i\right)
                    \end{array}
                    
                    Derivation
                    1. Initial program 98.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 rewrites99.3%

                      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{normAngle}{\sin normAngle} \cdot n1\_i - \left(\cos normAngle \cdot normAngle\right) \cdot \frac{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}{6} \cdot n0\_i + {normAngle}^{2} \cdot \left(\left(\frac{-1}{6} \cdot \left(\frac{-1}{2} \cdot n0\_i - \frac{-1}{6} \cdot n0\_i\right) + \frac{1}{120} \cdot n0\_i\right) - \left(\frac{-1}{36} \cdot n1\_i + \left(\frac{1}{120} \cdot n1\_i + \frac{1}{24} \cdot n0\_i\right)\right)\right)\right) - \left(\frac{-1}{2} \cdot n0\_i + \frac{-1}{6} \cdot n1\_i\right)\right)\right) - n0\_i, u, n0\_i\right) \]
                    7. Applied rewrites99.2%

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

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

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

                      Alternative 7: 99.1% accurate, 14.3× speedup?

                      \[\begin{array}{l} \\ \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(n0\_i, 0.3333333333333333, 0.16666666666666666 \cdot n1\_i\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 n0_i 0.3333333333333333 (* 0.16666666666666666 n1_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(n0_i, 0.3333333333333333f, (0.16666666666666666f * n1_i)), (normAngle * normAngle), (n1_i - n0_i)), u, n0_i);
                      }
                      
                      function code(normAngle, u, n0_i, n1_i)
                      	return fma(fma(fma(n0_i, Float32(0.3333333333333333), Float32(Float32(0.16666666666666666) * n1_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(n0\_i, 0.3333333333333333, 0.16666666666666666 \cdot n1\_i\right), normAngle \cdot normAngle, n1\_i - n0\_i\right), u, n0\_i\right)
                      \end{array}
                      
                      Derivation
                      1. Initial program 98.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 rewrites99.3%

                        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{normAngle}{\sin normAngle} \cdot n1\_i - \left(\cos normAngle \cdot normAngle\right) \cdot \frac{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}{6} \cdot n0\_i - \left(\frac{-1}{2} \cdot n0\_i + \frac{-1}{6} \cdot n1\_i\right)\right)\right) - n0\_i, u, n0\_i\right) \]
                      7. Step-by-step derivation
                        1. Applied rewrites99.0%

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

                        Alternative 8: 70.1% accurate, 21.8× speedup?

                        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(1 - u\right) \cdot n0\_i\\ \mathbf{if}\;n0\_i \leq -1.9999999774532045 \cdot 10^{-26}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;n0\_i \leq 5.000000015855384 \cdot 10^{-31}:\\ \;\;\;\;n1\_i \cdot u\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                        (FPCore (normAngle u n0_i n1_i)
                         :precision binary32
                         (let* ((t_0 (* (- 1.0 u) n0_i)))
                           (if (<= n0_i -1.9999999774532045e-26)
                             t_0
                             (if (<= n0_i 5.000000015855384e-31) (* n1_i u) t_0))))
                        float code(float normAngle, float u, float n0_i, float n1_i) {
                        	float t_0 = (1.0f - u) * n0_i;
                        	float tmp;
                        	if (n0_i <= -1.9999999774532045e-26f) {
                        		tmp = t_0;
                        	} else if (n0_i <= 5.000000015855384e-31f) {
                        		tmp = n1_i * u;
                        	} else {
                        		tmp = t_0;
                        	}
                        	return tmp;
                        }
                        
                        real(4) function code(normangle, u, n0_i, n1_i)
                            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
                            real(4) :: tmp
                            t_0 = (1.0e0 - u) * n0_i
                            if (n0_i <= (-1.9999999774532045e-26)) then
                                tmp = t_0
                            else if (n0_i <= 5.000000015855384e-31) then
                                tmp = n1_i * u
                            else
                                tmp = t_0
                            end if
                            code = tmp
                        end function
                        
                        function code(normAngle, u, n0_i, n1_i)
                        	t_0 = Float32(Float32(Float32(1.0) - u) * n0_i)
                        	tmp = Float32(0.0)
                        	if (n0_i <= Float32(-1.9999999774532045e-26))
                        		tmp = t_0;
                        	elseif (n0_i <= Float32(5.000000015855384e-31))
                        		tmp = Float32(n1_i * u);
                        	else
                        		tmp = t_0;
                        	end
                        	return tmp
                        end
                        
                        function tmp_2 = code(normAngle, u, n0_i, n1_i)
                        	t_0 = (single(1.0) - u) * n0_i;
                        	tmp = single(0.0);
                        	if (n0_i <= single(-1.9999999774532045e-26))
                        		tmp = t_0;
                        	elseif (n0_i <= single(5.000000015855384e-31))
                        		tmp = n1_i * u;
                        	else
                        		tmp = t_0;
                        	end
                        	tmp_2 = tmp;
                        end
                        
                        \begin{array}{l}
                        
                        \\
                        \begin{array}{l}
                        t_0 := \left(1 - u\right) \cdot n0\_i\\
                        \mathbf{if}\;n0\_i \leq -1.9999999774532045 \cdot 10^{-26}:\\
                        \;\;\;\;t\_0\\
                        
                        \mathbf{elif}\;n0\_i \leq 5.000000015855384 \cdot 10^{-31}:\\
                        \;\;\;\;n1\_i \cdot u\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;t\_0\\
                        
                        
                        \end{array}
                        \end{array}
                        
                        Derivation
                        1. Split input into 2 regimes
                        2. if n0_i < -1.99999998e-26 or 5e-31 < n0_i

                          1. Initial program 98.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. *-commutativeN/A

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

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

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

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

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

                            if -1.99999998e-26 < n0_i < 5e-31

                            1. Initial program 98.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. *-commutativeN/A

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

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

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

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

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

                              \[\leadsto \begin{array}{l} \mathbf{if}\;n0\_i \leq -1.9999999774532045 \cdot 10^{-26}:\\ \;\;\;\;\left(1 - u\right) \cdot n0\_i\\ \mathbf{elif}\;n0\_i \leq 5.000000015855384 \cdot 10^{-31}:\\ \;\;\;\;n1\_i \cdot u\\ \mathbf{else}:\\ \;\;\;\;\left(1 - u\right) \cdot n0\_i\\ \end{array} \]
                            10. Add Preprocessing

                            Alternative 9: 59.1% accurate, 25.4× speedup?

                            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n0\_i \leq -1.9999999774532045 \cdot 10^{-26}:\\ \;\;\;\;1 \cdot n0\_i\\ \mathbf{elif}\;n0\_i \leq 5.000000015855384 \cdot 10^{-31}:\\ \;\;\;\;n1\_i \cdot u\\ \mathbf{else}:\\ \;\;\;\;1 \cdot n0\_i\\ \end{array} \end{array} \]
                            (FPCore (normAngle u n0_i n1_i)
                             :precision binary32
                             (if (<= n0_i -1.9999999774532045e-26)
                               (* 1.0 n0_i)
                               (if (<= n0_i 5.000000015855384e-31) (* n1_i u) (* 1.0 n0_i))))
                            float code(float normAngle, float u, float n0_i, float n1_i) {
                            	float tmp;
                            	if (n0_i <= -1.9999999774532045e-26f) {
                            		tmp = 1.0f * n0_i;
                            	} else if (n0_i <= 5.000000015855384e-31f) {
                            		tmp = n1_i * u;
                            	} else {
                            		tmp = 1.0f * n0_i;
                            	}
                            	return tmp;
                            }
                            
                            real(4) function code(normangle, u, n0_i, n1_i)
                                real(4), intent (in) :: normangle
                                real(4), intent (in) :: u
                                real(4), intent (in) :: n0_i
                                real(4), intent (in) :: n1_i
                                real(4) :: tmp
                                if (n0_i <= (-1.9999999774532045e-26)) then
                                    tmp = 1.0e0 * n0_i
                                else if (n0_i <= 5.000000015855384e-31) then
                                    tmp = n1_i * u
                                else
                                    tmp = 1.0e0 * n0_i
                                end if
                                code = tmp
                            end function
                            
                            function code(normAngle, u, n0_i, n1_i)
                            	tmp = Float32(0.0)
                            	if (n0_i <= Float32(-1.9999999774532045e-26))
                            		tmp = Float32(Float32(1.0) * n0_i);
                            	elseif (n0_i <= Float32(5.000000015855384e-31))
                            		tmp = Float32(n1_i * u);
                            	else
                            		tmp = Float32(Float32(1.0) * n0_i);
                            	end
                            	return tmp
                            end
                            
                            function tmp_2 = code(normAngle, u, n0_i, n1_i)
                            	tmp = single(0.0);
                            	if (n0_i <= single(-1.9999999774532045e-26))
                            		tmp = single(1.0) * n0_i;
                            	elseif (n0_i <= single(5.000000015855384e-31))
                            		tmp = n1_i * u;
                            	else
                            		tmp = single(1.0) * n0_i;
                            	end
                            	tmp_2 = tmp;
                            end
                            
                            \begin{array}{l}
                            
                            \\
                            \begin{array}{l}
                            \mathbf{if}\;n0\_i \leq -1.9999999774532045 \cdot 10^{-26}:\\
                            \;\;\;\;1 \cdot n0\_i\\
                            
                            \mathbf{elif}\;n0\_i \leq 5.000000015855384 \cdot 10^{-31}:\\
                            \;\;\;\;n1\_i \cdot u\\
                            
                            \mathbf{else}:\\
                            \;\;\;\;1 \cdot n0\_i\\
                            
                            
                            \end{array}
                            \end{array}
                            
                            Derivation
                            1. Split input into 2 regimes
                            2. if n0_i < -1.99999998e-26 or 5e-31 < n0_i

                              1. Initial program 98.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. Step-by-step derivation
                                1. lift-+.f32N/A

                                  \[\leadsto \color{blue}{\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. +-commutativeN/A

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

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

                                  \[\leadsto \color{blue}{\mathsf{fma}\left(\sin \left(u \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}, n1\_i, \left(\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n0\_i\right)} \]
                                5. lift-*.f32N/A

                                  \[\leadsto \mathsf{fma}\left(\color{blue}{\sin \left(u \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}}, n1\_i, \left(\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n0\_i\right) \]
                                6. lift-/.f32N/A

                                  \[\leadsto \mathsf{fma}\left(\sin \left(u \cdot normAngle\right) \cdot \color{blue}{\frac{1}{\sin normAngle}}, n1\_i, \left(\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n0\_i\right) \]
                                7. un-div-invN/A

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

                                  \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{\sin \left(u \cdot normAngle\right)}{\sin normAngle}}, n1\_i, \left(\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n0\_i\right) \]
                                9. lift-*.f32N/A

                                  \[\leadsto \mathsf{fma}\left(\frac{\sin \color{blue}{\left(u \cdot normAngle\right)}}{\sin normAngle}, n1\_i, \left(\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n0\_i\right) \]
                                10. *-commutativeN/A

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

                                  \[\leadsto \mathsf{fma}\left(\frac{\sin \color{blue}{\left(normAngle \cdot u\right)}}{\sin normAngle}, n1\_i, \left(\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n0\_i\right) \]
                                12. lift-*.f32N/A

                                  \[\leadsto \mathsf{fma}\left(\frac{\sin \left(normAngle \cdot u\right)}{\sin normAngle}, n1\_i, \color{blue}{\left(\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n0\_i}\right) \]
                                13. lift-*.f32N/A

                                  \[\leadsto \mathsf{fma}\left(\frac{\sin \left(normAngle \cdot u\right)}{\sin normAngle}, n1\_i, \color{blue}{\left(\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right)} \cdot n0\_i\right) \]
                                14. associate-*l*N/A

                                  \[\leadsto \mathsf{fma}\left(\frac{\sin \left(normAngle \cdot u\right)}{\sin normAngle}, n1\_i, \color{blue}{\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot \left(\frac{1}{\sin normAngle} \cdot n0\_i\right)}\right) \]
                                15. *-commutativeN/A

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

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

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

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

                                  \[\leadsto \frac{\color{blue}{\sin \left(normAngle \cdot \left(1 - u\right)\right) \cdot n0\_i}}{\sin normAngle} \]
                                2. associate-*l/N/A

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

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

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

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

                                  \[\leadsto \frac{\sin \color{blue}{\left(\left(1 - u\right) \cdot normAngle\right)}}{\sin normAngle} \cdot n0\_i \]
                                7. lower-*.f32N/A

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

                                  \[\leadsto \frac{\sin \left(\color{blue}{\left(1 - u\right)} \cdot normAngle\right)}{\sin normAngle} \cdot n0\_i \]
                                9. lower-sin.f3277.3

                                  \[\leadsto \frac{\sin \left(\left(1 - u\right) \cdot normAngle\right)}{\color{blue}{\sin normAngle}} \cdot n0\_i \]
                              7. Applied rewrites77.3%

                                \[\leadsto \color{blue}{\frac{\sin \left(\left(1 - u\right) \cdot normAngle\right)}{\sin normAngle} \cdot n0\_i} \]
                              8. Taylor expanded in u around 0

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

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

                                if -1.99999998e-26 < n0_i < 5e-31

                                1. Initial program 98.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. *-commutativeN/A

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

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

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

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

                                    \[\leadsto u \cdot \color{blue}{n1\_i} \]
                                8. Recombined 2 regimes into one program.
                                9. Final simplification63.0%

                                  \[\leadsto \begin{array}{l} \mathbf{if}\;n0\_i \leq -1.9999999774532045 \cdot 10^{-26}:\\ \;\;\;\;1 \cdot n0\_i\\ \mathbf{elif}\;n0\_i \leq 5.000000015855384 \cdot 10^{-31}:\\ \;\;\;\;n1\_i \cdot u\\ \mathbf{else}:\\ \;\;\;\;1 \cdot n0\_i\\ \end{array} \]
                                10. Add Preprocessing

                                Alternative 10: 98.2% 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 98.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. Step-by-step derivation
                                  1. lift-+.f32N/A

                                    \[\leadsto \color{blue}{\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. +-commutativeN/A

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

                                    \[\leadsto \color{blue}{\left(\sin \left(u \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n1\_i} + \left(\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n0\_i \]
                                  4. lower-fma.f3298.2

                                    \[\leadsto \color{blue}{\mathsf{fma}\left(\sin \left(u \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}, n1\_i, \left(\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n0\_i\right)} \]
                                  5. lift-*.f32N/A

                                    \[\leadsto \mathsf{fma}\left(\color{blue}{\sin \left(u \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}}, n1\_i, \left(\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n0\_i\right) \]
                                  6. lift-/.f32N/A

                                    \[\leadsto \mathsf{fma}\left(\sin \left(u \cdot normAngle\right) \cdot \color{blue}{\frac{1}{\sin normAngle}}, n1\_i, \left(\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n0\_i\right) \]
                                  7. un-div-invN/A

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

                                    \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{\sin \left(u \cdot normAngle\right)}{\sin normAngle}}, n1\_i, \left(\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n0\_i\right) \]
                                  9. lift-*.f32N/A

                                    \[\leadsto \mathsf{fma}\left(\frac{\sin \color{blue}{\left(u \cdot normAngle\right)}}{\sin normAngle}, n1\_i, \left(\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n0\_i\right) \]
                                  10. *-commutativeN/A

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

                                    \[\leadsto \mathsf{fma}\left(\frac{\sin \color{blue}{\left(normAngle \cdot u\right)}}{\sin normAngle}, n1\_i, \left(\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n0\_i\right) \]
                                  12. lift-*.f32N/A

                                    \[\leadsto \mathsf{fma}\left(\frac{\sin \left(normAngle \cdot u\right)}{\sin normAngle}, n1\_i, \color{blue}{\left(\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n0\_i}\right) \]
                                  13. lift-*.f32N/A

                                    \[\leadsto \mathsf{fma}\left(\frac{\sin \left(normAngle \cdot u\right)}{\sin normAngle}, n1\_i, \color{blue}{\left(\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right)} \cdot n0\_i\right) \]
                                  14. associate-*l*N/A

                                    \[\leadsto \mathsf{fma}\left(\frac{\sin \left(normAngle \cdot u\right)}{\sin normAngle}, n1\_i, \color{blue}{\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot \left(\frac{1}{\sin normAngle} \cdot n0\_i\right)}\right) \]
                                  15. *-commutativeN/A

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

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

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

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

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

                                    \[\leadsto n1\_i \cdot u + n0\_i \cdot \color{blue}{\left(1 + \left(\mathsf{neg}\left(u\right)\right)\right)} \]
                                  3. +-commutativeN/A

                                    \[\leadsto n1\_i \cdot u + n0\_i \cdot \color{blue}{\left(\left(\mathsf{neg}\left(u\right)\right) + 1\right)} \]
                                  4. distribute-lft-inN/A

                                    \[\leadsto n1\_i \cdot u + \color{blue}{\left(n0\_i \cdot \left(\mathsf{neg}\left(u\right)\right) + n0\_i \cdot 1\right)} \]
                                  5. mul-1-negN/A

                                    \[\leadsto n1\_i \cdot u + \left(n0\_i \cdot \color{blue}{\left(-1 \cdot u\right)} + n0\_i \cdot 1\right) \]
                                  6. associate-*l*N/A

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

                                    \[\leadsto n1\_i \cdot u + \left(\color{blue}{\left(-1 \cdot n0\_i\right)} \cdot u + n0\_i \cdot 1\right) \]
                                  8. mul-1-negN/A

                                    \[\leadsto n1\_i \cdot u + \left(\color{blue}{\left(\mathsf{neg}\left(n0\_i\right)\right)} \cdot u + n0\_i \cdot 1\right) \]
                                  9. *-rgt-identityN/A

                                    \[\leadsto n1\_i \cdot u + \left(\left(\mathsf{neg}\left(n0\_i\right)\right) \cdot u + \color{blue}{n0\_i}\right) \]
                                  10. associate-+l+N/A

                                    \[\leadsto \color{blue}{\left(n1\_i \cdot u + \left(\mathsf{neg}\left(n0\_i\right)\right) \cdot u\right) + n0\_i} \]
                                  11. distribute-rgt-inN/A

                                    \[\leadsto \color{blue}{u \cdot \left(n1\_i + \left(\mathsf{neg}\left(n0\_i\right)\right)\right)} + n0\_i \]
                                  12. sub-negN/A

                                    \[\leadsto u \cdot \color{blue}{\left(n1\_i - n0\_i\right)} + n0\_i \]
                                  13. *-commutativeN/A

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

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

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

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

                                Alternative 11: 38.1% accurate, 76.5× speedup?

                                \[\begin{array}{l} \\ n1\_i \cdot u \end{array} \]
                                (FPCore (normAngle u n0_i n1_i) :precision binary32 (* n1_i u))
                                float code(float normAngle, float u, float n0_i, float n1_i) {
                                	return n1_i * u;
                                }
                                
                                real(4) function code(normangle, u, n0_i, n1_i)
                                    real(4), intent (in) :: normangle
                                    real(4), intent (in) :: u
                                    real(4), intent (in) :: n0_i
                                    real(4), intent (in) :: n1_i
                                    code = n1_i * u
                                end function
                                
                                function code(normAngle, u, n0_i, n1_i)
                                	return Float32(n1_i * u)
                                end
                                
                                function tmp = code(normAngle, u, n0_i, n1_i)
                                	tmp = n1_i * u;
                                end
                                
                                \begin{array}{l}
                                
                                \\
                                n1\_i \cdot u
                                \end{array}
                                
                                Derivation
                                1. Initial program 98.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. *-commutativeN/A

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

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

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

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

                                    \[\leadsto u \cdot \color{blue}{n1\_i} \]
                                  2. Final simplification34.1%

                                    \[\leadsto n1\_i \cdot u \]
                                  3. Add Preprocessing

                                  Reproduce

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