Curve intersection, scale width based on ribbon orientation

Percentage Accurate: 97.2% → 99.2%
Time: 15.6s
Alternatives: 12
Speedup: 45.9×

Specification

?
\[\left(\left(\left(0 \leq normAngle \land normAngle \leq \frac{\pi}{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 12 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.2% accurate, 4.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(normAngle \cdot normAngle, \mathsf{fma}\left(normAngle \cdot normAngle, 0.00205026455026455, 0.019444444444444445\right), 0.16666666666666666\right)\\ t_1 := n1\_i \cdot \left(normAngle \cdot normAngle\right)\\ \mathsf{fma}\left(u, \mathsf{fma}\left(\left(t\_1 \cdot -0.16666666666666666\right) \cdot \left(u \cdot u\right), \mathsf{fma}\left(normAngle \cdot normAngle, t\_0, 1\right), \mathsf{fma}\left(t\_1, t\_0, n1\_i\right) - n0\_i\right), n0\_i\right) \end{array} \end{array} \]
(FPCore (normAngle u n0_i n1_i)
 :precision binary32
 (let* ((t_0
         (fma
          (* normAngle normAngle)
          (fma
           (* normAngle normAngle)
           0.00205026455026455
           0.019444444444444445)
          0.16666666666666666))
        (t_1 (* n1_i (* normAngle normAngle))))
   (fma
    u
    (fma
     (* (* t_1 -0.16666666666666666) (* u u))
     (fma (* normAngle normAngle) t_0 1.0)
     (- (fma t_1 t_0 n1_i) n0_i))
    n0_i)))
float code(float normAngle, float u, float n0_i, float n1_i) {
	float t_0 = fmaf((normAngle * normAngle), fmaf((normAngle * normAngle), 0.00205026455026455f, 0.019444444444444445f), 0.16666666666666666f);
	float t_1 = n1_i * (normAngle * normAngle);
	return fmaf(u, fmaf(((t_1 * -0.16666666666666666f) * (u * u)), fmaf((normAngle * normAngle), t_0, 1.0f), (fmaf(t_1, t_0, n1_i) - n0_i)), n0_i);
}
function code(normAngle, u, n0_i, n1_i)
	t_0 = fma(Float32(normAngle * normAngle), fma(Float32(normAngle * normAngle), Float32(0.00205026455026455), Float32(0.019444444444444445)), Float32(0.16666666666666666))
	t_1 = Float32(n1_i * Float32(normAngle * normAngle))
	return fma(u, fma(Float32(Float32(t_1 * Float32(-0.16666666666666666)) * Float32(u * u)), fma(Float32(normAngle * normAngle), t_0, Float32(1.0)), Float32(fma(t_1, t_0, n1_i) - n0_i)), n0_i)
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(normAngle \cdot normAngle, \mathsf{fma}\left(normAngle \cdot normAngle, 0.00205026455026455, 0.019444444444444445\right), 0.16666666666666666\right)\\
t_1 := n1\_i \cdot \left(normAngle \cdot normAngle\right)\\
\mathsf{fma}\left(u, \mathsf{fma}\left(\left(t\_1 \cdot -0.16666666666666666\right) \cdot \left(u \cdot u\right), \mathsf{fma}\left(normAngle \cdot normAngle, t\_0, 1\right), \mathsf{fma}\left(t\_1, t\_0, n1\_i\right) - n0\_i\right), n0\_i\right)
\end{array}
\end{array}
Derivation
  1. Initial program 96.8%

    \[\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)} + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n1\_i \]
  4. Step-by-step derivation
    1. sub-negN/A

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right)} + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n1\_i \]
    6. neg-lowering-neg.f3297.4

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

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

    \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \color{blue}{\frac{1 + {normAngle}^{2} \cdot \left(\frac{1}{6} + {normAngle}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}\right)\right)}{normAngle}}\right) \cdot n1\_i \]
  7. Step-by-step derivation
    1. /-lowering-/.f32N/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \color{blue}{\frac{1 + {normAngle}^{2} \cdot \left(\frac{1}{6} + {normAngle}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}\right)\right)}{normAngle}}\right) \cdot n1\_i \]
    2. +-commutativeN/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\color{blue}{{normAngle}^{2} \cdot \left(\frac{1}{6} + {normAngle}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}\right)\right) + 1}}{normAngle}\right) \cdot n1\_i \]
    3. accelerator-lowering-fma.f32N/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\color{blue}{\mathsf{fma}\left({normAngle}^{2}, \frac{1}{6} + {normAngle}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}\right), 1\right)}}{normAngle}\right) \cdot n1\_i \]
    4. unpow2N/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(\color{blue}{normAngle \cdot normAngle}, \frac{1}{6} + {normAngle}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}\right), 1\right)}{normAngle}\right) \cdot n1\_i \]
    5. *-lowering-*.f32N/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(\color{blue}{normAngle \cdot normAngle}, \frac{1}{6} + {normAngle}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}\right), 1\right)}{normAngle}\right) \cdot n1\_i \]
    6. +-commutativeN/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(normAngle \cdot normAngle, \color{blue}{{normAngle}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}\right) + \frac{1}{6}}, 1\right)}{normAngle}\right) \cdot n1\_i \]
    7. accelerator-lowering-fma.f32N/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(normAngle \cdot normAngle, \color{blue}{\mathsf{fma}\left({normAngle}^{2}, \frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}, \frac{1}{6}\right)}, 1\right)}{normAngle}\right) \cdot n1\_i \]
    8. unpow2N/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(normAngle \cdot normAngle, \mathsf{fma}\left(\color{blue}{normAngle \cdot normAngle}, \frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}, \frac{1}{6}\right), 1\right)}{normAngle}\right) \cdot n1\_i \]
    9. *-lowering-*.f32N/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(normAngle \cdot normAngle, \mathsf{fma}\left(\color{blue}{normAngle \cdot normAngle}, \frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}, \frac{1}{6}\right), 1\right)}{normAngle}\right) \cdot n1\_i \]
    10. +-commutativeN/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(normAngle \cdot normAngle, \mathsf{fma}\left(normAngle \cdot normAngle, \color{blue}{\frac{31}{15120} \cdot {normAngle}^{2} + \frac{7}{360}}, \frac{1}{6}\right), 1\right)}{normAngle}\right) \cdot n1\_i \]
    11. *-commutativeN/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(normAngle \cdot normAngle, \mathsf{fma}\left(normAngle \cdot normAngle, \color{blue}{{normAngle}^{2} \cdot \frac{31}{15120}} + \frac{7}{360}, \frac{1}{6}\right), 1\right)}{normAngle}\right) \cdot n1\_i \]
    12. accelerator-lowering-fma.f32N/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(normAngle \cdot normAngle, \mathsf{fma}\left(normAngle \cdot normAngle, \color{blue}{\mathsf{fma}\left({normAngle}^{2}, \frac{31}{15120}, \frac{7}{360}\right)}, \frac{1}{6}\right), 1\right)}{normAngle}\right) \cdot n1\_i \]
    13. unpow2N/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(normAngle \cdot normAngle, \mathsf{fma}\left(normAngle \cdot normAngle, \mathsf{fma}\left(\color{blue}{normAngle \cdot normAngle}, \frac{31}{15120}, \frac{7}{360}\right), \frac{1}{6}\right), 1\right)}{normAngle}\right) \cdot n1\_i \]
    14. *-lowering-*.f3297.1

      \[\leadsto \mathsf{fma}\left(n0\_i, -u, n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(normAngle \cdot normAngle, \mathsf{fma}\left(normAngle \cdot normAngle, \mathsf{fma}\left(\color{blue}{normAngle \cdot normAngle}, 0.00205026455026455, 0.019444444444444445\right), 0.16666666666666666\right), 1\right)}{normAngle}\right) \cdot n1\_i \]
  8. Simplified97.1%

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

    \[\leadsto \color{blue}{n0\_i + u \cdot \left(-1 \cdot n0\_i + \left(\frac{-1}{6} \cdot \left(n1\_i \cdot \left({normAngle}^{2} \cdot \left({u}^{2} \cdot \left(1 + {normAngle}^{2} \cdot \left(\frac{1}{6} + {normAngle}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}\right)\right)\right)\right)\right)\right) + n1\_i \cdot \left(1 + {normAngle}^{2} \cdot \left(\frac{1}{6} + {normAngle}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}\right)\right)\right)\right)\right)} \]
  10. Simplified99.3%

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

Alternative 2: 99.1% accurate, 7.2× speedup?

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

\\
\mathsf{fma}\left(u, \mathsf{fma}\left(normAngle \cdot normAngle, \mathsf{fma}\left(n1\_i, \mathsf{fma}\left(-0.16666666666666666, u \cdot u, 0.16666666666666666\right), \left(normAngle \cdot normAngle\right) \cdot \left(n1\_i \cdot \mathsf{fma}\left(u \cdot u, -0.027777777777777776, 0.019444444444444445\right)\right)\right), n1\_i - n0\_i\right), n0\_i\right)
\end{array}
Derivation
  1. Initial program 96.8%

    \[\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)} + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n1\_i \]
  4. Step-by-step derivation
    1. sub-negN/A

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right)} + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n1\_i \]
    6. neg-lowering-neg.f3297.4

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

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

    \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \color{blue}{\frac{1 + {normAngle}^{2} \cdot \left(\frac{1}{6} + {normAngle}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}\right)\right)}{normAngle}}\right) \cdot n1\_i \]
  7. Step-by-step derivation
    1. /-lowering-/.f32N/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \color{blue}{\frac{1 + {normAngle}^{2} \cdot \left(\frac{1}{6} + {normAngle}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}\right)\right)}{normAngle}}\right) \cdot n1\_i \]
    2. +-commutativeN/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\color{blue}{{normAngle}^{2} \cdot \left(\frac{1}{6} + {normAngle}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}\right)\right) + 1}}{normAngle}\right) \cdot n1\_i \]
    3. accelerator-lowering-fma.f32N/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\color{blue}{\mathsf{fma}\left({normAngle}^{2}, \frac{1}{6} + {normAngle}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}\right), 1\right)}}{normAngle}\right) \cdot n1\_i \]
    4. unpow2N/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(\color{blue}{normAngle \cdot normAngle}, \frac{1}{6} + {normAngle}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}\right), 1\right)}{normAngle}\right) \cdot n1\_i \]
    5. *-lowering-*.f32N/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(\color{blue}{normAngle \cdot normAngle}, \frac{1}{6} + {normAngle}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}\right), 1\right)}{normAngle}\right) \cdot n1\_i \]
    6. +-commutativeN/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(normAngle \cdot normAngle, \color{blue}{{normAngle}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}\right) + \frac{1}{6}}, 1\right)}{normAngle}\right) \cdot n1\_i \]
    7. accelerator-lowering-fma.f32N/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(normAngle \cdot normAngle, \color{blue}{\mathsf{fma}\left({normAngle}^{2}, \frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}, \frac{1}{6}\right)}, 1\right)}{normAngle}\right) \cdot n1\_i \]
    8. unpow2N/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(normAngle \cdot normAngle, \mathsf{fma}\left(\color{blue}{normAngle \cdot normAngle}, \frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}, \frac{1}{6}\right), 1\right)}{normAngle}\right) \cdot n1\_i \]
    9. *-lowering-*.f32N/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(normAngle \cdot normAngle, \mathsf{fma}\left(\color{blue}{normAngle \cdot normAngle}, \frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}, \frac{1}{6}\right), 1\right)}{normAngle}\right) \cdot n1\_i \]
    10. +-commutativeN/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(normAngle \cdot normAngle, \mathsf{fma}\left(normAngle \cdot normAngle, \color{blue}{\frac{31}{15120} \cdot {normAngle}^{2} + \frac{7}{360}}, \frac{1}{6}\right), 1\right)}{normAngle}\right) \cdot n1\_i \]
    11. *-commutativeN/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(normAngle \cdot normAngle, \mathsf{fma}\left(normAngle \cdot normAngle, \color{blue}{{normAngle}^{2} \cdot \frac{31}{15120}} + \frac{7}{360}, \frac{1}{6}\right), 1\right)}{normAngle}\right) \cdot n1\_i \]
    12. accelerator-lowering-fma.f32N/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(normAngle \cdot normAngle, \mathsf{fma}\left(normAngle \cdot normAngle, \color{blue}{\mathsf{fma}\left({normAngle}^{2}, \frac{31}{15120}, \frac{7}{360}\right)}, \frac{1}{6}\right), 1\right)}{normAngle}\right) \cdot n1\_i \]
    13. unpow2N/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(normAngle \cdot normAngle, \mathsf{fma}\left(normAngle \cdot normAngle, \mathsf{fma}\left(\color{blue}{normAngle \cdot normAngle}, \frac{31}{15120}, \frac{7}{360}\right), \frac{1}{6}\right), 1\right)}{normAngle}\right) \cdot n1\_i \]
    14. *-lowering-*.f3297.1

      \[\leadsto \mathsf{fma}\left(n0\_i, -u, n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(normAngle \cdot normAngle, \mathsf{fma}\left(normAngle \cdot normAngle, \mathsf{fma}\left(\color{blue}{normAngle \cdot normAngle}, 0.00205026455026455, 0.019444444444444445\right), 0.16666666666666666\right), 1\right)}{normAngle}\right) \cdot n1\_i \]
  8. Simplified97.1%

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

    \[\leadsto \color{blue}{n0\_i + u \cdot \left(-1 \cdot n0\_i + \left(\frac{-1}{6} \cdot \left(n1\_i \cdot \left({normAngle}^{2} \cdot \left({u}^{2} \cdot \left(1 + {normAngle}^{2} \cdot \left(\frac{1}{6} + {normAngle}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}\right)\right)\right)\right)\right)\right) + n1\_i \cdot \left(1 + {normAngle}^{2} \cdot \left(\frac{1}{6} + {normAngle}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}\right)\right)\right)\right)\right)} \]
  10. Simplified99.3%

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

    \[\leadsto \mathsf{fma}\left(u, \color{blue}{\left(n1\_i + {normAngle}^{2} \cdot \left(\frac{-1}{6} \cdot \left(n1\_i \cdot {u}^{2}\right) + \left(\frac{1}{6} \cdot n1\_i + {normAngle}^{2} \cdot \left(\frac{-1}{36} \cdot \left(n1\_i \cdot {u}^{2}\right) + \frac{7}{360} \cdot n1\_i\right)\right)\right)\right) - n0\_i}, n0\_i\right) \]
  12. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \mathsf{fma}\left(u, \color{blue}{\left({normAngle}^{2} \cdot \left(\frac{-1}{6} \cdot \left(n1\_i \cdot {u}^{2}\right) + \left(\frac{1}{6} \cdot n1\_i + {normAngle}^{2} \cdot \left(\frac{-1}{36} \cdot \left(n1\_i \cdot {u}^{2}\right) + \frac{7}{360} \cdot n1\_i\right)\right)\right) + n1\_i\right)} - n0\_i, n0\_i\right) \]
    2. associate--l+N/A

      \[\leadsto \mathsf{fma}\left(u, \color{blue}{{normAngle}^{2} \cdot \left(\frac{-1}{6} \cdot \left(n1\_i \cdot {u}^{2}\right) + \left(\frac{1}{6} \cdot n1\_i + {normAngle}^{2} \cdot \left(\frac{-1}{36} \cdot \left(n1\_i \cdot {u}^{2}\right) + \frac{7}{360} \cdot n1\_i\right)\right)\right) + \left(n1\_i - n0\_i\right)}, n0\_i\right) \]
    3. accelerator-lowering-fma.f32N/A

      \[\leadsto \mathsf{fma}\left(u, \color{blue}{\mathsf{fma}\left({normAngle}^{2}, \frac{-1}{6} \cdot \left(n1\_i \cdot {u}^{2}\right) + \left(\frac{1}{6} \cdot n1\_i + {normAngle}^{2} \cdot \left(\frac{-1}{36} \cdot \left(n1\_i \cdot {u}^{2}\right) + \frac{7}{360} \cdot n1\_i\right)\right), n1\_i - n0\_i\right)}, n0\_i\right) \]
  13. Simplified99.2%

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

Alternative 3: 99.1% accurate, 9.6× speedup?

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

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

    \[\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)} + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n1\_i \]
  4. Step-by-step derivation
    1. sub-negN/A

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right)} + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n1\_i \]
    6. neg-lowering-neg.f3297.4

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

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

    \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \color{blue}{\frac{1 + {normAngle}^{2} \cdot \left(\frac{1}{6} + {normAngle}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}\right)\right)}{normAngle}}\right) \cdot n1\_i \]
  7. Step-by-step derivation
    1. /-lowering-/.f32N/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \color{blue}{\frac{1 + {normAngle}^{2} \cdot \left(\frac{1}{6} + {normAngle}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}\right)\right)}{normAngle}}\right) \cdot n1\_i \]
    2. +-commutativeN/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\color{blue}{{normAngle}^{2} \cdot \left(\frac{1}{6} + {normAngle}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}\right)\right) + 1}}{normAngle}\right) \cdot n1\_i \]
    3. accelerator-lowering-fma.f32N/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\color{blue}{\mathsf{fma}\left({normAngle}^{2}, \frac{1}{6} + {normAngle}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}\right), 1\right)}}{normAngle}\right) \cdot n1\_i \]
    4. unpow2N/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(\color{blue}{normAngle \cdot normAngle}, \frac{1}{6} + {normAngle}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}\right), 1\right)}{normAngle}\right) \cdot n1\_i \]
    5. *-lowering-*.f32N/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(\color{blue}{normAngle \cdot normAngle}, \frac{1}{6} + {normAngle}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}\right), 1\right)}{normAngle}\right) \cdot n1\_i \]
    6. +-commutativeN/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(normAngle \cdot normAngle, \color{blue}{{normAngle}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}\right) + \frac{1}{6}}, 1\right)}{normAngle}\right) \cdot n1\_i \]
    7. accelerator-lowering-fma.f32N/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(normAngle \cdot normAngle, \color{blue}{\mathsf{fma}\left({normAngle}^{2}, \frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}, \frac{1}{6}\right)}, 1\right)}{normAngle}\right) \cdot n1\_i \]
    8. unpow2N/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(normAngle \cdot normAngle, \mathsf{fma}\left(\color{blue}{normAngle \cdot normAngle}, \frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}, \frac{1}{6}\right), 1\right)}{normAngle}\right) \cdot n1\_i \]
    9. *-lowering-*.f32N/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(normAngle \cdot normAngle, \mathsf{fma}\left(\color{blue}{normAngle \cdot normAngle}, \frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}, \frac{1}{6}\right), 1\right)}{normAngle}\right) \cdot n1\_i \]
    10. +-commutativeN/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(normAngle \cdot normAngle, \mathsf{fma}\left(normAngle \cdot normAngle, \color{blue}{\frac{31}{15120} \cdot {normAngle}^{2} + \frac{7}{360}}, \frac{1}{6}\right), 1\right)}{normAngle}\right) \cdot n1\_i \]
    11. *-commutativeN/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(normAngle \cdot normAngle, \mathsf{fma}\left(normAngle \cdot normAngle, \color{blue}{{normAngle}^{2} \cdot \frac{31}{15120}} + \frac{7}{360}, \frac{1}{6}\right), 1\right)}{normAngle}\right) \cdot n1\_i \]
    12. accelerator-lowering-fma.f32N/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(normAngle \cdot normAngle, \mathsf{fma}\left(normAngle \cdot normAngle, \color{blue}{\mathsf{fma}\left({normAngle}^{2}, \frac{31}{15120}, \frac{7}{360}\right)}, \frac{1}{6}\right), 1\right)}{normAngle}\right) \cdot n1\_i \]
    13. unpow2N/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(normAngle \cdot normAngle, \mathsf{fma}\left(normAngle \cdot normAngle, \mathsf{fma}\left(\color{blue}{normAngle \cdot normAngle}, \frac{31}{15120}, \frac{7}{360}\right), \frac{1}{6}\right), 1\right)}{normAngle}\right) \cdot n1\_i \]
    14. *-lowering-*.f3297.1

      \[\leadsto \mathsf{fma}\left(n0\_i, -u, n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(normAngle \cdot normAngle, \mathsf{fma}\left(normAngle \cdot normAngle, \mathsf{fma}\left(\color{blue}{normAngle \cdot normAngle}, 0.00205026455026455, 0.019444444444444445\right), 0.16666666666666666\right), 1\right)}{normAngle}\right) \cdot n1\_i \]
  8. Simplified97.1%

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

    \[\leadsto \color{blue}{n0\_i + u \cdot \left(-1 \cdot n0\_i + n1\_i \cdot \left(1 + {normAngle}^{2} \cdot \left(\frac{1}{6} + {normAngle}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}\right)\right)\right)\right)} \]
  10. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \color{blue}{u \cdot \left(-1 \cdot n0\_i + n1\_i \cdot \left(1 + {normAngle}^{2} \cdot \left(\frac{1}{6} + {normAngle}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}\right)\right)\right)\right) + n0\_i} \]
    2. mul-1-negN/A

      \[\leadsto u \cdot \left(\color{blue}{\left(\mathsf{neg}\left(n0\_i\right)\right)} + n1\_i \cdot \left(1 + {normAngle}^{2} \cdot \left(\frac{1}{6} + {normAngle}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}\right)\right)\right)\right) + n0\_i \]
    3. accelerator-lowering-fma.f32N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(u, \left(\mathsf{neg}\left(n0\_i\right)\right) + n1\_i \cdot \left(1 + {normAngle}^{2} \cdot \left(\frac{1}{6} + {normAngle}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}\right)\right)\right), n0\_i\right)} \]
  11. Simplified99.1%

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

Alternative 4: 98.9% accurate, 10.9× speedup?

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

\\
\mathsf{fma}\left(n1\_i - n0\_i, u, \mathsf{fma}\left(normAngle \cdot normAngle, -0.16666666666666666 \cdot \left(\left(u \cdot n1\_i\right) \cdot \mathsf{fma}\left(u, u, -1\right)\right), n0\_i\right)\right)
\end{array}
Derivation
  1. Initial program 96.8%

    \[\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)} + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n1\_i \]
  4. Step-by-step derivation
    1. sub-negN/A

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right)} + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n1\_i \]
    6. neg-lowering-neg.f3297.4

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

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

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

      \[\leadsto \color{blue}{\left(-1 \cdot \left(n0\_i \cdot u\right) + \left(n1\_i \cdot u + {normAngle}^{2} \cdot \left(\frac{-1}{6} \cdot \left(n1\_i \cdot {u}^{3}\right) - \frac{-1}{6} \cdot \left(n1\_i \cdot u\right)\right)\right)\right) + n0\_i} \]
    2. associate-+r+N/A

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

      \[\leadsto \left(\color{blue}{\left(n1\_i \cdot u + -1 \cdot \left(n0\_i \cdot u\right)\right)} + {normAngle}^{2} \cdot \left(\frac{-1}{6} \cdot \left(n1\_i \cdot {u}^{3}\right) - \frac{-1}{6} \cdot \left(n1\_i \cdot u\right)\right)\right) + n0\_i \]
    4. associate-*r*N/A

      \[\leadsto \left(\left(n1\_i \cdot u + \color{blue}{\left(-1 \cdot n0\_i\right) \cdot u}\right) + {normAngle}^{2} \cdot \left(\frac{-1}{6} \cdot \left(n1\_i \cdot {u}^{3}\right) - \frac{-1}{6} \cdot \left(n1\_i \cdot u\right)\right)\right) + n0\_i \]
    5. distribute-rgt-inN/A

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

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

      \[\leadsto \color{blue}{\left(n1\_i + -1 \cdot n0\_i\right) \cdot u} + \left({normAngle}^{2} \cdot \left(\frac{-1}{6} \cdot \left(n1\_i \cdot {u}^{3}\right) - \frac{-1}{6} \cdot \left(n1\_i \cdot u\right)\right) + n0\_i\right) \]
    8. accelerator-lowering-fma.f32N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(n1\_i + -1 \cdot n0\_i, u, {normAngle}^{2} \cdot \left(\frac{-1}{6} \cdot \left(n1\_i \cdot {u}^{3}\right) - \frac{-1}{6} \cdot \left(n1\_i \cdot u\right)\right) + n0\_i\right)} \]
    9. mul-1-negN/A

      \[\leadsto \mathsf{fma}\left(n1\_i + \color{blue}{\left(\mathsf{neg}\left(n0\_i\right)\right)}, u, {normAngle}^{2} \cdot \left(\frac{-1}{6} \cdot \left(n1\_i \cdot {u}^{3}\right) - \frac{-1}{6} \cdot \left(n1\_i \cdot u\right)\right) + n0\_i\right) \]
    10. unsub-negN/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{n1\_i - n0\_i}, u, {normAngle}^{2} \cdot \left(\frac{-1}{6} \cdot \left(n1\_i \cdot {u}^{3}\right) - \frac{-1}{6} \cdot \left(n1\_i \cdot u\right)\right) + n0\_i\right) \]
    11. --lowering--.f32N/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{n1\_i - n0\_i}, u, {normAngle}^{2} \cdot \left(\frac{-1}{6} \cdot \left(n1\_i \cdot {u}^{3}\right) - \frac{-1}{6} \cdot \left(n1\_i \cdot u\right)\right) + n0\_i\right) \]
    12. accelerator-lowering-fma.f32N/A

      \[\leadsto \mathsf{fma}\left(n1\_i - n0\_i, u, \color{blue}{\mathsf{fma}\left({normAngle}^{2}, \frac{-1}{6} \cdot \left(n1\_i \cdot {u}^{3}\right) - \frac{-1}{6} \cdot \left(n1\_i \cdot u\right), n0\_i\right)}\right) \]
  8. Simplified98.9%

    \[\leadsto \color{blue}{\mathsf{fma}\left(n1\_i - n0\_i, u, \mathsf{fma}\left(normAngle \cdot normAngle, -0.16666666666666666 \cdot \left(\left(n1\_i \cdot u\right) \cdot \mathsf{fma}\left(u, u, -1\right)\right), n0\_i\right)\right)} \]
  9. Final simplification98.9%

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

Alternative 5: 98.9% accurate, 12.4× speedup?

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

\\
\mathsf{fma}\left(u, \mathsf{fma}\left(normAngle, normAngle \cdot \left(n1\_i \cdot \mathsf{fma}\left(-0.16666666666666666, u \cdot u, 0.16666666666666666\right)\right), n1\_i - n0\_i\right), n0\_i\right)
\end{array}
Derivation
  1. Initial program 96.8%

    \[\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)} + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n1\_i \]
  4. Step-by-step derivation
    1. sub-negN/A

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right)} + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n1\_i \]
    6. neg-lowering-neg.f3297.4

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

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

    \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \color{blue}{\frac{1 + {normAngle}^{2} \cdot \left(\frac{1}{6} + {normAngle}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}\right)\right)}{normAngle}}\right) \cdot n1\_i \]
  7. Step-by-step derivation
    1. /-lowering-/.f32N/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \color{blue}{\frac{1 + {normAngle}^{2} \cdot \left(\frac{1}{6} + {normAngle}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}\right)\right)}{normAngle}}\right) \cdot n1\_i \]
    2. +-commutativeN/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\color{blue}{{normAngle}^{2} \cdot \left(\frac{1}{6} + {normAngle}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}\right)\right) + 1}}{normAngle}\right) \cdot n1\_i \]
    3. accelerator-lowering-fma.f32N/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\color{blue}{\mathsf{fma}\left({normAngle}^{2}, \frac{1}{6} + {normAngle}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}\right), 1\right)}}{normAngle}\right) \cdot n1\_i \]
    4. unpow2N/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(\color{blue}{normAngle \cdot normAngle}, \frac{1}{6} + {normAngle}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}\right), 1\right)}{normAngle}\right) \cdot n1\_i \]
    5. *-lowering-*.f32N/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(\color{blue}{normAngle \cdot normAngle}, \frac{1}{6} + {normAngle}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}\right), 1\right)}{normAngle}\right) \cdot n1\_i \]
    6. +-commutativeN/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(normAngle \cdot normAngle, \color{blue}{{normAngle}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}\right) + \frac{1}{6}}, 1\right)}{normAngle}\right) \cdot n1\_i \]
    7. accelerator-lowering-fma.f32N/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(normAngle \cdot normAngle, \color{blue}{\mathsf{fma}\left({normAngle}^{2}, \frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}, \frac{1}{6}\right)}, 1\right)}{normAngle}\right) \cdot n1\_i \]
    8. unpow2N/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(normAngle \cdot normAngle, \mathsf{fma}\left(\color{blue}{normAngle \cdot normAngle}, \frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}, \frac{1}{6}\right), 1\right)}{normAngle}\right) \cdot n1\_i \]
    9. *-lowering-*.f32N/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(normAngle \cdot normAngle, \mathsf{fma}\left(\color{blue}{normAngle \cdot normAngle}, \frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}, \frac{1}{6}\right), 1\right)}{normAngle}\right) \cdot n1\_i \]
    10. +-commutativeN/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(normAngle \cdot normAngle, \mathsf{fma}\left(normAngle \cdot normAngle, \color{blue}{\frac{31}{15120} \cdot {normAngle}^{2} + \frac{7}{360}}, \frac{1}{6}\right), 1\right)}{normAngle}\right) \cdot n1\_i \]
    11. *-commutativeN/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(normAngle \cdot normAngle, \mathsf{fma}\left(normAngle \cdot normAngle, \color{blue}{{normAngle}^{2} \cdot \frac{31}{15120}} + \frac{7}{360}, \frac{1}{6}\right), 1\right)}{normAngle}\right) \cdot n1\_i \]
    12. accelerator-lowering-fma.f32N/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(normAngle \cdot normAngle, \mathsf{fma}\left(normAngle \cdot normAngle, \color{blue}{\mathsf{fma}\left({normAngle}^{2}, \frac{31}{15120}, \frac{7}{360}\right)}, \frac{1}{6}\right), 1\right)}{normAngle}\right) \cdot n1\_i \]
    13. unpow2N/A

      \[\leadsto \mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(normAngle \cdot normAngle, \mathsf{fma}\left(normAngle \cdot normAngle, \mathsf{fma}\left(\color{blue}{normAngle \cdot normAngle}, \frac{31}{15120}, \frac{7}{360}\right), \frac{1}{6}\right), 1\right)}{normAngle}\right) \cdot n1\_i \]
    14. *-lowering-*.f3297.1

      \[\leadsto \mathsf{fma}\left(n0\_i, -u, n0\_i\right) + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{\mathsf{fma}\left(normAngle \cdot normAngle, \mathsf{fma}\left(normAngle \cdot normAngle, \mathsf{fma}\left(\color{blue}{normAngle \cdot normAngle}, 0.00205026455026455, 0.019444444444444445\right), 0.16666666666666666\right), 1\right)}{normAngle}\right) \cdot n1\_i \]
  8. Simplified97.1%

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

    \[\leadsto \color{blue}{n0\_i + u \cdot \left(-1 \cdot n0\_i + \left(\frac{-1}{6} \cdot \left(n1\_i \cdot \left({normAngle}^{2} \cdot \left({u}^{2} \cdot \left(1 + {normAngle}^{2} \cdot \left(\frac{1}{6} + {normAngle}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}\right)\right)\right)\right)\right)\right) + n1\_i \cdot \left(1 + {normAngle}^{2} \cdot \left(\frac{1}{6} + {normAngle}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {normAngle}^{2}\right)\right)\right)\right)\right)} \]
  10. Simplified99.3%

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

    \[\leadsto \mathsf{fma}\left(u, \color{blue}{\left(n1\_i + {normAngle}^{2} \cdot \left(\frac{-1}{6} \cdot \left(n1\_i \cdot {u}^{2}\right) + \frac{1}{6} \cdot n1\_i\right)\right) - n0\_i}, n0\_i\right) \]
  12. Step-by-step derivation
    1. +-commutativeN/A

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

      \[\leadsto \mathsf{fma}\left(u, \color{blue}{{normAngle}^{2} \cdot \left(\frac{-1}{6} \cdot \left(n1\_i \cdot {u}^{2}\right) + \frac{1}{6} \cdot n1\_i\right) + \left(n1\_i - n0\_i\right)}, n0\_i\right) \]
    3. unpow2N/A

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

      \[\leadsto \mathsf{fma}\left(u, \color{blue}{normAngle \cdot \left(normAngle \cdot \left(\frac{-1}{6} \cdot \left(n1\_i \cdot {u}^{2}\right) + \frac{1}{6} \cdot n1\_i\right)\right)} + \left(n1\_i - n0\_i\right), n0\_i\right) \]
    5. accelerator-lowering-fma.f32N/A

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

      \[\leadsto \mathsf{fma}\left(u, \mathsf{fma}\left(normAngle, \color{blue}{normAngle \cdot \left(\frac{-1}{6} \cdot \left(n1\_i \cdot {u}^{2}\right) + \frac{1}{6} \cdot n1\_i\right)}, n1\_i - n0\_i\right), n0\_i\right) \]
    7. associate-*r*N/A

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

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

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

      \[\leadsto \mathsf{fma}\left(u, \mathsf{fma}\left(normAngle, normAngle \cdot \left(n1\_i \cdot \left(\frac{-1}{6} \cdot {u}^{2}\right) + \color{blue}{n1\_i \cdot \frac{1}{6}}\right), n1\_i - n0\_i\right), n0\_i\right) \]
    11. distribute-lft-outN/A

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

      \[\leadsto \mathsf{fma}\left(u, \mathsf{fma}\left(normAngle, normAngle \cdot \color{blue}{\left(n1\_i \cdot \left(\frac{-1}{6} \cdot {u}^{2} + \frac{1}{6}\right)\right)}, n1\_i - n0\_i\right), n0\_i\right) \]
    13. accelerator-lowering-fma.f32N/A

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

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

      \[\leadsto \mathsf{fma}\left(u, \mathsf{fma}\left(normAngle, normAngle \cdot \left(n1\_i \cdot \mathsf{fma}\left(\frac{-1}{6}, \color{blue}{u \cdot u}, \frac{1}{6}\right)\right), n1\_i - n0\_i\right), n0\_i\right) \]
    16. --lowering--.f3298.9

      \[\leadsto \mathsf{fma}\left(u, \mathsf{fma}\left(normAngle, normAngle \cdot \left(n1\_i \cdot \mathsf{fma}\left(-0.16666666666666666, u \cdot u, 0.16666666666666666\right)\right), \color{blue}{n1\_i - n0\_i}\right), n0\_i\right) \]
  13. Simplified98.9%

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

Alternative 6: 99.0% accurate, 14.3× speedup?

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

\\
\mathsf{fma}\left(u, \mathsf{fma}\left(normAngle \cdot normAngle, \mathsf{fma}\left(n0\_i, 0.3333333333333333, n1\_i \cdot 0.16666666666666666\right), n1\_i - n0\_i\right), n0\_i\right)
\end{array}
Derivation
  1. Initial program 96.8%

    \[\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. accelerator-lowering-fma.f32N/A

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

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

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

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

      \[\leadsto \mathsf{fma}\left(u, \color{blue}{\left({normAngle}^{2} \cdot \left(-1 \cdot \left(\frac{-1}{2} \cdot n0\_i - \frac{-1}{6} \cdot n0\_i\right) - \frac{-1}{6} \cdot n1\_i\right) + -1 \cdot n0\_i\right)} + n1\_i, n0\_i\right) \]
    3. associate-+l+N/A

      \[\leadsto \mathsf{fma}\left(u, \color{blue}{{normAngle}^{2} \cdot \left(-1 \cdot \left(\frac{-1}{2} \cdot n0\_i - \frac{-1}{6} \cdot n0\_i\right) - \frac{-1}{6} \cdot n1\_i\right) + \left(-1 \cdot n0\_i + n1\_i\right)}, n0\_i\right) \]
    4. +-commutativeN/A

      \[\leadsto \mathsf{fma}\left(u, {normAngle}^{2} \cdot \left(-1 \cdot \left(\frac{-1}{2} \cdot n0\_i - \frac{-1}{6} \cdot n0\_i\right) - \frac{-1}{6} \cdot n1\_i\right) + \color{blue}{\left(n1\_i + -1 \cdot n0\_i\right)}, n0\_i\right) \]
    5. accelerator-lowering-fma.f32N/A

      \[\leadsto \mathsf{fma}\left(u, \color{blue}{\mathsf{fma}\left({normAngle}^{2}, -1 \cdot \left(\frac{-1}{2} \cdot n0\_i - \frac{-1}{6} \cdot n0\_i\right) - \frac{-1}{6} \cdot n1\_i, n1\_i + -1 \cdot n0\_i\right)}, n0\_i\right) \]
  8. Simplified98.7%

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

Alternative 7: 98.8% accurate, 17.7× speedup?

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

\\
\mathsf{fma}\left(u, \mathsf{fma}\left(n1\_i, \left(normAngle \cdot normAngle\right) \cdot 0.16666666666666666, n1\_i - n0\_i\right), n0\_i\right)
\end{array}
Derivation
  1. Initial program 96.8%

    \[\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)} + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n1\_i \]
  4. Step-by-step derivation
    1. sub-negN/A

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(n0\_i, \mathsf{neg}\left(u\right), n0\_i\right)} + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n1\_i \]
    6. neg-lowering-neg.f3297.4

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

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

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

      \[\leadsto \color{blue}{\left(-1 \cdot \left(n0\_i \cdot u\right) + \left(n1\_i \cdot u + {normAngle}^{2} \cdot \left(\frac{-1}{6} \cdot \left(n1\_i \cdot {u}^{3}\right) - \frac{-1}{6} \cdot \left(n1\_i \cdot u\right)\right)\right)\right) + n0\_i} \]
    2. associate-+r+N/A

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

      \[\leadsto \left(\color{blue}{\left(n1\_i \cdot u + -1 \cdot \left(n0\_i \cdot u\right)\right)} + {normAngle}^{2} \cdot \left(\frac{-1}{6} \cdot \left(n1\_i \cdot {u}^{3}\right) - \frac{-1}{6} \cdot \left(n1\_i \cdot u\right)\right)\right) + n0\_i \]
    4. associate-*r*N/A

      \[\leadsto \left(\left(n1\_i \cdot u + \color{blue}{\left(-1 \cdot n0\_i\right) \cdot u}\right) + {normAngle}^{2} \cdot \left(\frac{-1}{6} \cdot \left(n1\_i \cdot {u}^{3}\right) - \frac{-1}{6} \cdot \left(n1\_i \cdot u\right)\right)\right) + n0\_i \]
    5. distribute-rgt-inN/A

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

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

      \[\leadsto \color{blue}{\left(n1\_i + -1 \cdot n0\_i\right) \cdot u} + \left({normAngle}^{2} \cdot \left(\frac{-1}{6} \cdot \left(n1\_i \cdot {u}^{3}\right) - \frac{-1}{6} \cdot \left(n1\_i \cdot u\right)\right) + n0\_i\right) \]
    8. accelerator-lowering-fma.f32N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(n1\_i + -1 \cdot n0\_i, u, {normAngle}^{2} \cdot \left(\frac{-1}{6} \cdot \left(n1\_i \cdot {u}^{3}\right) - \frac{-1}{6} \cdot \left(n1\_i \cdot u\right)\right) + n0\_i\right)} \]
    9. mul-1-negN/A

      \[\leadsto \mathsf{fma}\left(n1\_i + \color{blue}{\left(\mathsf{neg}\left(n0\_i\right)\right)}, u, {normAngle}^{2} \cdot \left(\frac{-1}{6} \cdot \left(n1\_i \cdot {u}^{3}\right) - \frac{-1}{6} \cdot \left(n1\_i \cdot u\right)\right) + n0\_i\right) \]
    10. unsub-negN/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{n1\_i - n0\_i}, u, {normAngle}^{2} \cdot \left(\frac{-1}{6} \cdot \left(n1\_i \cdot {u}^{3}\right) - \frac{-1}{6} \cdot \left(n1\_i \cdot u\right)\right) + n0\_i\right) \]
    11. --lowering--.f32N/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{n1\_i - n0\_i}, u, {normAngle}^{2} \cdot \left(\frac{-1}{6} \cdot \left(n1\_i \cdot {u}^{3}\right) - \frac{-1}{6} \cdot \left(n1\_i \cdot u\right)\right) + n0\_i\right) \]
    12. accelerator-lowering-fma.f32N/A

      \[\leadsto \mathsf{fma}\left(n1\_i - n0\_i, u, \color{blue}{\mathsf{fma}\left({normAngle}^{2}, \frac{-1}{6} \cdot \left(n1\_i \cdot {u}^{3}\right) - \frac{-1}{6} \cdot \left(n1\_i \cdot u\right), n0\_i\right)}\right) \]
  8. Simplified98.9%

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

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

      \[\leadsto \color{blue}{u \cdot \left(\left(n1\_i + \frac{1}{6} \cdot \left(n1\_i \cdot {normAngle}^{2}\right)\right) - n0\_i\right) + n0\_i} \]
    2. accelerator-lowering-fma.f32N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(u, \left(n1\_i + \frac{1}{6} \cdot \left(n1\_i \cdot {normAngle}^{2}\right)\right) - n0\_i, n0\_i\right)} \]
    3. +-commutativeN/A

      \[\leadsto \mathsf{fma}\left(u, \color{blue}{\left(\frac{1}{6} \cdot \left(n1\_i \cdot {normAngle}^{2}\right) + n1\_i\right)} - n0\_i, n0\_i\right) \]
    4. associate--l+N/A

      \[\leadsto \mathsf{fma}\left(u, \color{blue}{\frac{1}{6} \cdot \left(n1\_i \cdot {normAngle}^{2}\right) + \left(n1\_i - n0\_i\right)}, n0\_i\right) \]
    5. associate-*r*N/A

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

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

      \[\leadsto \mathsf{fma}\left(u, \color{blue}{n1\_i \cdot \left(\frac{1}{6} \cdot {normAngle}^{2}\right)} + \left(n1\_i - n0\_i\right), n0\_i\right) \]
    8. accelerator-lowering-fma.f32N/A

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

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

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

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

      \[\leadsto \mathsf{fma}\left(u, \mathsf{fma}\left(n1\_i, \color{blue}{\left(normAngle \cdot normAngle\right)} \cdot \frac{1}{6}, n1\_i - n0\_i\right), n0\_i\right) \]
    13. --lowering--.f3298.7

      \[\leadsto \mathsf{fma}\left(u, \mathsf{fma}\left(n1\_i, \left(normAngle \cdot normAngle\right) \cdot 0.16666666666666666, \color{blue}{n1\_i - n0\_i}\right), n0\_i\right) \]
  11. Simplified98.7%

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

Alternative 8: 61.3% accurate, 25.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n0\_i \leq -1.999999936531045 \cdot 10^{-20}:\\ \;\;\;\;n0\_i\\ \mathbf{elif}\;n0\_i \leq 2.5000000488537034 \cdot 10^{-26}:\\ \;\;\;\;u \cdot n1\_i\\ \mathbf{else}:\\ \;\;\;\;n0\_i\\ \end{array} \end{array} \]
(FPCore (normAngle u n0_i n1_i)
 :precision binary32
 (if (<= n0_i -1.999999936531045e-20)
   n0_i
   (if (<= n0_i 2.5000000488537034e-26) (* u n1_i) n0_i)))
float code(float normAngle, float u, float n0_i, float n1_i) {
	float tmp;
	if (n0_i <= -1.999999936531045e-20f) {
		tmp = n0_i;
	} else if (n0_i <= 2.5000000488537034e-26f) {
		tmp = u * n1_i;
	} else {
		tmp = 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.999999936531045e-20)) then
        tmp = n0_i
    else if (n0_i <= 2.5000000488537034e-26) then
        tmp = u * n1_i
    else
        tmp = 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.999999936531045e-20))
		tmp = n0_i;
	elseif (n0_i <= Float32(2.5000000488537034e-26))
		tmp = Float32(u * n1_i);
	else
		tmp = 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.999999936531045e-20))
		tmp = n0_i;
	elseif (n0_i <= single(2.5000000488537034e-26))
		tmp = u * n1_i;
	else
		tmp = n0_i;
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;n0\_i \leq -1.999999936531045 \cdot 10^{-20}:\\
\;\;\;\;n0\_i\\

\mathbf{elif}\;n0\_i \leq 2.5000000488537034 \cdot 10^{-26}:\\
\;\;\;\;u \cdot n1\_i\\

\mathbf{else}:\\
\;\;\;\;n0\_i\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if n0_i < -1.99999994e-20 or 2.50000005e-26 < n0_i

    1. Initial program 97.8%

      \[\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} \]
    4. Step-by-step derivation
      1. Simplified59.0%

        \[\leadsto \color{blue}{n0\_i} \]

      if -1.99999994e-20 < n0_i < 2.50000005e-26

      1. Initial program 95.3%

        \[\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) + \left(n1\_i \cdot u + {normAngle}^{2} \cdot \left(\left(\frac{-1}{6} \cdot \left(n0\_i \cdot {\left(1 - u\right)}^{3}\right) + \frac{-1}{6} \cdot \left(n1\_i \cdot {u}^{3}\right)\right) - \left(\frac{-1}{6} \cdot \left(n0\_i \cdot \left(1 - u\right)\right) + \frac{-1}{6} \cdot \left(n1\_i \cdot u\right)\right)\right)\right)} \]
      4. Simplified97.6%

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

        \[\leadsto \mathsf{fma}\left(u, n1\_i, \color{blue}{n0\_i}\right) \]
      6. Step-by-step derivation
        1. Simplified89.3%

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

          \[\leadsto \color{blue}{n1\_i \cdot u} \]
        3. Step-by-step derivation
          1. *-lowering-*.f3270.2

            \[\leadsto \color{blue}{n1\_i \cdot u} \]
        4. Simplified70.2%

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;n0\_i \leq -1.999999936531045 \cdot 10^{-20}:\\ \;\;\;\;n0\_i\\ \mathbf{elif}\;n0\_i \leq 2.5000000488537034 \cdot 10^{-26}:\\ \;\;\;\;u \cdot n1\_i\\ \mathbf{else}:\\ \;\;\;\;n0\_i\\ \end{array} \]
      9. Add Preprocessing

      Alternative 9: 84.3% accurate, 30.5× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n0\_i \leq -5.00000006675716 \cdot 10^{-11}:\\ \;\;\;\;\mathsf{fma}\left(n0\_i, -u, n0\_i\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(u, n1\_i, n0\_i\right)\\ \end{array} \end{array} \]
      (FPCore (normAngle u n0_i n1_i)
       :precision binary32
       (if (<= n0_i -5.00000006675716e-11) (fma n0_i (- u) n0_i) (fma u n1_i n0_i)))
      float code(float normAngle, float u, float n0_i, float n1_i) {
      	float tmp;
      	if (n0_i <= -5.00000006675716e-11f) {
      		tmp = fmaf(n0_i, -u, n0_i);
      	} else {
      		tmp = fmaf(u, n1_i, n0_i);
      	}
      	return tmp;
      }
      
      function code(normAngle, u, n0_i, n1_i)
      	tmp = Float32(0.0)
      	if (n0_i <= Float32(-5.00000006675716e-11))
      		tmp = fma(n0_i, Float32(-u), n0_i);
      	else
      		tmp = fma(u, n1_i, n0_i);
      	end
      	return tmp
      end
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;n0\_i \leq -5.00000006675716 \cdot 10^{-11}:\\
      \;\;\;\;\mathsf{fma}\left(n0\_i, -u, n0\_i\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;\mathsf{fma}\left(u, n1\_i, n0\_i\right)\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if n0_i < -5.00000007e-11

        1. Initial program 98.3%

          \[\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 n0_i around inf

          \[\leadsto \color{blue}{\frac{n0\_i \cdot \sin \left(normAngle \cdot \left(1 - u\right)\right)}{\sin normAngle}} \]
        4. 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}{\sin \left(normAngle \cdot \left(1 - u\right)\right) \cdot \frac{n0\_i}{\sin normAngle}} \]
          3. *-lowering-*.f32N/A

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

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

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

            \[\leadsto \sin \left(normAngle \cdot \color{blue}{\left(\left(\mathsf{neg}\left(u\right)\right) + 1\right)}\right) \cdot \frac{n0\_i}{\sin normAngle} \]
          7. distribute-rgt-inN/A

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

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

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

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

            \[\leadsto \sin \left(u \cdot \left(-1 \cdot normAngle\right) + \color{blue}{normAngle}\right) \cdot \frac{n0\_i}{\sin normAngle} \]
          12. accelerator-lowering-fma.f32N/A

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

            \[\leadsto \sin \left(\mathsf{fma}\left(u, \color{blue}{\mathsf{neg}\left(normAngle\right)}, normAngle\right)\right) \cdot \frac{n0\_i}{\sin normAngle} \]
          14. neg-lowering-neg.f32N/A

            \[\leadsto \sin \left(\mathsf{fma}\left(u, \color{blue}{\mathsf{neg}\left(normAngle\right)}, normAngle\right)\right) \cdot \frac{n0\_i}{\sin normAngle} \]
          15. /-lowering-/.f32N/A

            \[\leadsto \sin \left(\mathsf{fma}\left(u, \mathsf{neg}\left(normAngle\right), normAngle\right)\right) \cdot \color{blue}{\frac{n0\_i}{\sin normAngle}} \]
          16. sin-lowering-sin.f3291.0

            \[\leadsto \sin \left(\mathsf{fma}\left(u, -normAngle, normAngle\right)\right) \cdot \frac{n0\_i}{\color{blue}{\sin normAngle}} \]
        5. Simplified91.0%

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

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(n0\_i, \color{blue}{\mathsf{neg}\left(u\right)}, n0\_i\right) \]
          6. neg-lowering-neg.f3291.6

            \[\leadsto \mathsf{fma}\left(n0\_i, \color{blue}{-u}, n0\_i\right) \]
        8. Simplified91.6%

          \[\leadsto \color{blue}{\mathsf{fma}\left(n0\_i, -u, n0\_i\right)} \]

        if -5.00000007e-11 < n0_i

        1. Initial program 96.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) + \left(n1\_i \cdot u + {normAngle}^{2} \cdot \left(\left(\frac{-1}{6} \cdot \left(n0\_i \cdot {\left(1 - u\right)}^{3}\right) + \frac{-1}{6} \cdot \left(n1\_i \cdot {u}^{3}\right)\right) - \left(\frac{-1}{6} \cdot \left(n0\_i \cdot \left(1 - u\right)\right) + \frac{-1}{6} \cdot \left(n1\_i \cdot u\right)\right)\right)\right)} \]
        4. Simplified98.7%

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

          \[\leadsto \mathsf{fma}\left(u, n1\_i, \color{blue}{n0\_i}\right) \]
        6. Step-by-step derivation
          1. Simplified82.9%

            \[\leadsto \mathsf{fma}\left(u, n1\_i, \color{blue}{n0\_i}\right) \]
        7. Recombined 2 regimes into one program.
        8. Add Preprocessing

        Alternative 10: 98.1% 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 96.8%

          \[\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. accelerator-lowering-fma.f32N/A

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

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

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(\color{blue}{n1\_i - n0\_i}, u, n0\_i\right) \]
          6. --lowering--.f3297.6

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

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

        Alternative 11: 82.0% accurate, 65.6× speedup?

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

          \[\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) + \left(n1\_i \cdot u + {normAngle}^{2} \cdot \left(\left(\frac{-1}{6} \cdot \left(n0\_i \cdot {\left(1 - u\right)}^{3}\right) + \frac{-1}{6} \cdot \left(n1\_i \cdot {u}^{3}\right)\right) - \left(\frac{-1}{6} \cdot \left(n0\_i \cdot \left(1 - u\right)\right) + \frac{-1}{6} \cdot \left(n1\_i \cdot u\right)\right)\right)\right)} \]
        4. Simplified98.8%

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

          \[\leadsto \mathsf{fma}\left(u, n1\_i, \color{blue}{n0\_i}\right) \]
        6. Step-by-step derivation
          1. Simplified79.8%

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

          Alternative 12: 47.1% accurate, 459.0× speedup?

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

            \[\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} \]
          4. Step-by-step derivation
            1. Simplified43.3%

              \[\leadsto \color{blue}{n0\_i} \]
            2. Add Preprocessing

            Reproduce

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