Curve intersection, scale width based on ribbon orientation

Percentage Accurate: 97.3% → 99.1%
Time: 11.0s
Alternatives: 9
Speedup: 27.0×

Specification

?
\[\left(\left(\left(0 \leq normAngle \land normAngle \leq \frac{\mathsf{PI}\left(\right)}{2}\right) \land \left(-1 \leq n0\_i \land n0\_i \leq 1\right)\right) \land \left(-1 \leq n1\_i \land n1\_i \leq 1\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq u \land u \leq 1\right)\]
\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{\sin normAngle}\\ \left(\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot t\_0\right) \cdot n0\_i + \left(\sin \left(u \cdot normAngle\right) \cdot t\_0\right) \cdot n1\_i \end{array} \end{array} \]
(FPCore (normAngle u n0_i n1_i)
 :precision binary32
 (let* ((t_0 (/ 1.0 (sin normAngle))))
   (+
    (* (* (sin (* (- 1.0 u) normAngle)) t_0) n0_i)
    (* (* (sin (* u normAngle)) t_0) n1_i))))
float code(float normAngle, float u, float n0_i, float n1_i) {
	float t_0 = 1.0f / sinf(normAngle);
	return ((sinf(((1.0f - u) * normAngle)) * t_0) * n0_i) + ((sinf((u * normAngle)) * t_0) * n1_i);
}
real(4) function code(normangle, u, n0_i, n1_i)
    real(4), intent (in) :: normangle
    real(4), intent (in) :: u
    real(4), intent (in) :: n0_i
    real(4), intent (in) :: n1_i
    real(4) :: t_0
    t_0 = 1.0e0 / sin(normangle)
    code = ((sin(((1.0e0 - u) * normangle)) * t_0) * n0_i) + ((sin((u * normangle)) * t_0) * n1_i)
end function
function code(normAngle, u, n0_i, n1_i)
	t_0 = Float32(Float32(1.0) / sin(normAngle))
	return Float32(Float32(Float32(sin(Float32(Float32(Float32(1.0) - u) * normAngle)) * t_0) * n0_i) + Float32(Float32(sin(Float32(u * normAngle)) * t_0) * n1_i))
end
function tmp = code(normAngle, u, n0_i, n1_i)
	t_0 = single(1.0) / sin(normAngle);
	tmp = ((sin(((single(1.0) - u) * normAngle)) * t_0) * n0_i) + ((sin((u * normAngle)) * t_0) * n1_i);
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{1}{\sin normAngle}\\
\left(\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot t\_0\right) \cdot n0\_i + \left(\sin \left(u \cdot normAngle\right) \cdot t\_0\right) \cdot n1\_i
\end{array}
\end{array}

Sampling outcomes in binary32 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 9 alternatives:

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

Initial Program: 97.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{\sin normAngle}\\ \left(\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot t\_0\right) \cdot n0\_i + \left(\sin \left(u \cdot normAngle\right) \cdot t\_0\right) \cdot n1\_i \end{array} \end{array} \]
(FPCore (normAngle u n0_i n1_i)
 :precision binary32
 (let* ((t_0 (/ 1.0 (sin normAngle))))
   (+
    (* (* (sin (* (- 1.0 u) normAngle)) t_0) n0_i)
    (* (* (sin (* u normAngle)) t_0) n1_i))))
float code(float normAngle, float u, float n0_i, float n1_i) {
	float t_0 = 1.0f / sinf(normAngle);
	return ((sinf(((1.0f - u) * normAngle)) * t_0) * n0_i) + ((sinf((u * normAngle)) * t_0) * n1_i);
}
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.1% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{normAngle}{\sin normAngle} \cdot u\\ n1\_i \cdot t\_0 + n0\_i \cdot \left(1 - t\_0 \cdot \cos normAngle\right) \end{array} \end{array} \]
(FPCore (normAngle u n0_i n1_i)
 :precision binary32
 (let* ((t_0 (* (/ normAngle (sin normAngle)) u)))
   (+ (* n1_i t_0) (* n0_i (- 1.0 (* t_0 (cos normAngle)))))))
float code(float normAngle, float u, float n0_i, float n1_i) {
	float t_0 = (normAngle / sinf(normAngle)) * u;
	return (n1_i * t_0) + (n0_i * (1.0f - (t_0 * cosf(normAngle))));
}
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 = (normangle / sin(normangle)) * u
    code = (n1_i * t_0) + (n0_i * (1.0e0 - (t_0 * cos(normangle))))
end function
function code(normAngle, u, n0_i, n1_i)
	t_0 = Float32(Float32(normAngle / sin(normAngle)) * u)
	return Float32(Float32(n1_i * t_0) + Float32(n0_i * Float32(Float32(1.0) - Float32(t_0 * cos(normAngle)))))
end
function tmp = code(normAngle, u, n0_i, n1_i)
	t_0 = (normAngle / sin(normAngle)) * u;
	tmp = (n1_i * t_0) + (n0_i * (single(1.0) - (t_0 * cos(normAngle))));
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{normAngle}{\sin normAngle} \cdot u\\
n1\_i \cdot t\_0 + n0\_i \cdot \left(1 - t\_0 \cdot \cos normAngle\right)
\end{array}
\end{array}
Derivation
  1. Initial program 97.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(1 - \frac{\left(\cos normAngle \cdot u\right) \cdot normAngle}{\color{blue}{\sin normAngle}}\right) \cdot n0\_i + \left(\frac{normAngle}{\sin normAngle} \cdot u\right) \cdot n1\_i \]
  11. Applied rewrites98.9%

    \[\leadsto \color{blue}{\left(1 - \frac{\left(\cos normAngle \cdot u\right) \cdot normAngle}{\sin normAngle}\right)} \cdot n0\_i + \left(\frac{normAngle}{\sin normAngle} \cdot u\right) \cdot n1\_i \]
  12. Step-by-step derivation
    1. Applied rewrites98.9%

      \[\leadsto \left(1 - \cos normAngle \cdot \color{blue}{\left(\frac{normAngle}{\sin normAngle} \cdot u\right)}\right) \cdot n0\_i + \left(\frac{normAngle}{\sin normAngle} \cdot u\right) \cdot n1\_i \]
    2. Final simplification98.9%

      \[\leadsto n1\_i \cdot \left(\frac{normAngle}{\sin normAngle} \cdot u\right) + n0\_i \cdot \left(1 - \left(\frac{normAngle}{\sin normAngle} \cdot u\right) \cdot \cos normAngle\right) \]
    3. Add Preprocessing

    Alternative 2: 99.1% accurate, 1.8× speedup?

    \[\begin{array}{l} \\ \left(1 - \frac{1}{\frac{\tan normAngle}{normAngle \cdot u}}\right) \cdot n0\_i + n1\_i \cdot \left(\frac{normAngle}{\sin normAngle} \cdot u\right) \end{array} \]
    (FPCore (normAngle u n0_i n1_i)
     :precision binary32
     (+
      (* (- 1.0 (/ 1.0 (/ (tan normAngle) (* normAngle u)))) n0_i)
      (* n1_i (* (/ normAngle (sin normAngle)) u))))
    float code(float normAngle, float u, float n0_i, float n1_i) {
    	return ((1.0f - (1.0f / (tanf(normAngle) / (normAngle * u)))) * n0_i) + (n1_i * ((normAngle / sinf(normAngle)) * u));
    }
    
    real(4) function code(normangle, u, n0_i, n1_i)
        real(4), intent (in) :: normangle
        real(4), intent (in) :: u
        real(4), intent (in) :: n0_i
        real(4), intent (in) :: n1_i
        code = ((1.0e0 - (1.0e0 / (tan(normangle) / (normangle * u)))) * n0_i) + (n1_i * ((normangle / sin(normangle)) * u))
    end function
    
    function code(normAngle, u, n0_i, n1_i)
    	return Float32(Float32(Float32(Float32(1.0) - Float32(Float32(1.0) / Float32(tan(normAngle) / Float32(normAngle * u)))) * n0_i) + Float32(n1_i * Float32(Float32(normAngle / sin(normAngle)) * u)))
    end
    
    function tmp = code(normAngle, u, n0_i, n1_i)
    	tmp = ((single(1.0) - (single(1.0) / (tan(normAngle) / (normAngle * u)))) * n0_i) + (n1_i * ((normAngle / sin(normAngle)) * u));
    end
    
    \begin{array}{l}
    
    \\
    \left(1 - \frac{1}{\frac{\tan normAngle}{normAngle \cdot u}}\right) \cdot n0\_i + n1\_i \cdot \left(\frac{normAngle}{\sin normAngle} \cdot u\right)
    \end{array}
    
    Derivation
    1. Initial program 97.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(1 - \frac{\left(\cos normAngle \cdot u\right) \cdot normAngle}{\color{blue}{\sin normAngle}}\right) \cdot n0\_i + \left(\frac{normAngle}{\sin normAngle} \cdot u\right) \cdot n1\_i \]
    11. Applied rewrites98.9%

      \[\leadsto \color{blue}{\left(1 - \frac{\left(\cos normAngle \cdot u\right) \cdot normAngle}{\sin normAngle}\right)} \cdot n0\_i + \left(\frac{normAngle}{\sin normAngle} \cdot u\right) \cdot n1\_i \]
    12. Step-by-step derivation
      1. Applied rewrites98.9%

        \[\leadsto \color{blue}{\left(1 - \frac{1}{\frac{\tan normAngle}{normAngle \cdot u}}\right) \cdot n0\_i} + \left(\frac{normAngle}{\sin normAngle} \cdot u\right) \cdot n1\_i \]
      2. Final simplification98.9%

        \[\leadsto \left(1 - \frac{1}{\frac{\tan normAngle}{normAngle \cdot u}}\right) \cdot n0\_i + n1\_i \cdot \left(\frac{normAngle}{\sin normAngle} \cdot u\right) \]
      3. Add Preprocessing

      Alternative 3: 98.9% accurate, 3.5× speedup?

      \[\begin{array}{l} \\ \left(1 - u\right) \cdot n0\_i + n1\_i \cdot \left(\frac{normAngle}{\sin normAngle} \cdot u\right) \end{array} \]
      (FPCore (normAngle u n0_i n1_i)
       :precision binary32
       (+ (* (- 1.0 u) n0_i) (* n1_i (* (/ normAngle (sin normAngle)) u))))
      float code(float normAngle, float u, float n0_i, float n1_i) {
      	return ((1.0f - u) * n0_i) + (n1_i * ((normAngle / sinf(normAngle)) * u));
      }
      
      real(4) function code(normangle, u, n0_i, n1_i)
          real(4), intent (in) :: normangle
          real(4), intent (in) :: u
          real(4), intent (in) :: n0_i
          real(4), intent (in) :: n1_i
          code = ((1.0e0 - u) * n0_i) + (n1_i * ((normangle / sin(normangle)) * u))
      end function
      
      function code(normAngle, u, n0_i, n1_i)
      	return Float32(Float32(Float32(Float32(1.0) - u) * n0_i) + Float32(n1_i * Float32(Float32(normAngle / sin(normAngle)) * u)))
      end
      
      function tmp = code(normAngle, u, n0_i, n1_i)
      	tmp = ((single(1.0) - u) * n0_i) + (n1_i * ((normAngle / sin(normAngle)) * u));
      end
      
      \begin{array}{l}
      
      \\
      \left(1 - u\right) \cdot n0\_i + n1\_i \cdot \left(\frac{normAngle}{\sin normAngle} \cdot u\right)
      \end{array}
      
      Derivation
      1. Initial program 97.0%

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

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

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

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

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

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

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

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

        \[\leadsto \left(1 - u\right) \cdot n0\_i + \color{blue}{\left(\frac{normAngle}{\sin normAngle} \cdot u\right)} \cdot n1\_i \]
      9. Final simplification98.7%

        \[\leadsto \left(1 - u\right) \cdot n0\_i + n1\_i \cdot \left(\frac{normAngle}{\sin normAngle} \cdot u\right) \]
      10. Add Preprocessing

      Alternative 4: 86.2% accurate, 17.6× speedup?

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

        1. Initial program 96.2%

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

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

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

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

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

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

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

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

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

            \[\leadsto n1\_i \cdot u + n0\_i \cdot 1 \]
          3. Step-by-step derivation
            1. Applied rewrites86.1%

              \[\leadsto n1\_i \cdot u + n0\_i \cdot 1 \]

            if -2.99999989e-28 < n1_i < 5.00000002e-30

            1. Initial program 98.9%

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto n0\_i - n0\_i \cdot \color{blue}{u} \]
                4. Recombined 2 regimes into one program.
                5. Final simplification88.1%

                  \[\leadsto \begin{array}{l} \mathbf{if}\;n1\_i \leq -2.999999889142609 \cdot 10^{-28}:\\ \;\;\;\;1 \cdot n0\_i + n1\_i \cdot u\\ \mathbf{elif}\;n1\_i \leq 5.000000015855384 \cdot 10^{-30}:\\ \;\;\;\;n0\_i - n0\_i \cdot u\\ \mathbf{else}:\\ \;\;\;\;1 \cdot n0\_i + n1\_i \cdot u\\ \end{array} \]
                6. Add Preprocessing

                Alternative 5: 71.6% accurate, 21.8× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n1\_i \leq -1.99999996490334 \cdot 10^{-14}:\\ \;\;\;\;n1\_i \cdot u\\ \mathbf{elif}\;n1\_i \leq 1.999999967550318 \cdot 10^{-17}:\\ \;\;\;\;n0\_i - n0\_i \cdot u\\ \mathbf{else}:\\ \;\;\;\;n1\_i \cdot u\\ \end{array} \end{array} \]
                (FPCore (normAngle u n0_i n1_i)
                 :precision binary32
                 (if (<= n1_i -1.99999996490334e-14)
                   (* n1_i u)
                   (if (<= n1_i 1.999999967550318e-17) (- n0_i (* n0_i u)) (* n1_i u))))
                float code(float normAngle, float u, float n0_i, float n1_i) {
                	float tmp;
                	if (n1_i <= -1.99999996490334e-14f) {
                		tmp = n1_i * u;
                	} else if (n1_i <= 1.999999967550318e-17f) {
                		tmp = n0_i - (n0_i * u);
                	} else {
                		tmp = n1_i * u;
                	}
                	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 (n1_i <= (-1.99999996490334e-14)) then
                        tmp = n1_i * u
                    else if (n1_i <= 1.999999967550318e-17) then
                        tmp = n0_i - (n0_i * u)
                    else
                        tmp = n1_i * u
                    end if
                    code = tmp
                end function
                
                function code(normAngle, u, n0_i, n1_i)
                	tmp = Float32(0.0)
                	if (n1_i <= Float32(-1.99999996490334e-14))
                		tmp = Float32(n1_i * u);
                	elseif (n1_i <= Float32(1.999999967550318e-17))
                		tmp = Float32(n0_i - Float32(n0_i * u));
                	else
                		tmp = Float32(n1_i * u);
                	end
                	return tmp
                end
                
                function tmp_2 = code(normAngle, u, n0_i, n1_i)
                	tmp = single(0.0);
                	if (n1_i <= single(-1.99999996490334e-14))
                		tmp = n1_i * u;
                	elseif (n1_i <= single(1.999999967550318e-17))
                		tmp = n0_i - (n0_i * u);
                	else
                		tmp = n1_i * u;
                	end
                	tmp_2 = tmp;
                end
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;n1\_i \leq -1.99999996490334 \cdot 10^{-14}:\\
                \;\;\;\;n1\_i \cdot u\\
                
                \mathbf{elif}\;n1\_i \leq 1.999999967550318 \cdot 10^{-17}:\\
                \;\;\;\;n0\_i - n0\_i \cdot u\\
                
                \mathbf{else}:\\
                \;\;\;\;n1\_i \cdot u\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if n1_i < -1.99999996e-14 or 1.99999997e-17 < n1_i

                  1. Initial program 96.2%

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

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

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

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

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

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

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

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

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

                      \[\leadsto u \cdot \color{blue}{n1\_i} \]

                    if -1.99999996e-14 < n1_i < 1.99999997e-17

                    1. Initial program 97.5%

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

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

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

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

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

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

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

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

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

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

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

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

                            \[\leadsto n0\_i - n0\_i \cdot \color{blue}{u} \]
                        4. Recombined 2 regimes into one program.
                        5. Final simplification73.9%

                          \[\leadsto \begin{array}{l} \mathbf{if}\;n1\_i \leq -1.99999996490334 \cdot 10^{-14}:\\ \;\;\;\;n1\_i \cdot u\\ \mathbf{elif}\;n1\_i \leq 1.999999967550318 \cdot 10^{-17}:\\ \;\;\;\;n0\_i - n0\_i \cdot u\\ \mathbf{else}:\\ \;\;\;\;n1\_i \cdot u\\ \end{array} \]
                        6. Add Preprocessing

                        Alternative 6: 71.5% accurate, 21.8× speedup?

                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n1\_i \leq -1.99999996490334 \cdot 10^{-14}:\\ \;\;\;\;n1\_i \cdot u\\ \mathbf{elif}\;n1\_i \leq 1.999999967550318 \cdot 10^{-17}:\\ \;\;\;\;\left(1 - u\right) \cdot n0\_i\\ \mathbf{else}:\\ \;\;\;\;n1\_i \cdot u\\ \end{array} \end{array} \]
                        (FPCore (normAngle u n0_i n1_i)
                         :precision binary32
                         (if (<= n1_i -1.99999996490334e-14)
                           (* n1_i u)
                           (if (<= n1_i 1.999999967550318e-17) (* (- 1.0 u) n0_i) (* n1_i u))))
                        float code(float normAngle, float u, float n0_i, float n1_i) {
                        	float tmp;
                        	if (n1_i <= -1.99999996490334e-14f) {
                        		tmp = n1_i * u;
                        	} else if (n1_i <= 1.999999967550318e-17f) {
                        		tmp = (1.0f - u) * n0_i;
                        	} else {
                        		tmp = n1_i * u;
                        	}
                        	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 (n1_i <= (-1.99999996490334e-14)) then
                                tmp = n1_i * u
                            else if (n1_i <= 1.999999967550318e-17) then
                                tmp = (1.0e0 - u) * n0_i
                            else
                                tmp = n1_i * u
                            end if
                            code = tmp
                        end function
                        
                        function code(normAngle, u, n0_i, n1_i)
                        	tmp = Float32(0.0)
                        	if (n1_i <= Float32(-1.99999996490334e-14))
                        		tmp = Float32(n1_i * u);
                        	elseif (n1_i <= Float32(1.999999967550318e-17))
                        		tmp = Float32(Float32(Float32(1.0) - u) * n0_i);
                        	else
                        		tmp = Float32(n1_i * u);
                        	end
                        	return tmp
                        end
                        
                        function tmp_2 = code(normAngle, u, n0_i, n1_i)
                        	tmp = single(0.0);
                        	if (n1_i <= single(-1.99999996490334e-14))
                        		tmp = n1_i * u;
                        	elseif (n1_i <= single(1.999999967550318e-17))
                        		tmp = (single(1.0) - u) * n0_i;
                        	else
                        		tmp = n1_i * u;
                        	end
                        	tmp_2 = tmp;
                        end
                        
                        \begin{array}{l}
                        
                        \\
                        \begin{array}{l}
                        \mathbf{if}\;n1\_i \leq -1.99999996490334 \cdot 10^{-14}:\\
                        \;\;\;\;n1\_i \cdot u\\
                        
                        \mathbf{elif}\;n1\_i \leq 1.999999967550318 \cdot 10^{-17}:\\
                        \;\;\;\;\left(1 - u\right) \cdot n0\_i\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;n1\_i \cdot u\\
                        
                        
                        \end{array}
                        \end{array}
                        
                        Derivation
                        1. Split input into 2 regimes
                        2. if n1_i < -1.99999996e-14 or 1.99999997e-17 < n1_i

                          1. Initial program 96.2%

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

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

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

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

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

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

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

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

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

                              \[\leadsto u \cdot \color{blue}{n1\_i} \]

                            if -1.99999996e-14 < n1_i < 1.99999997e-17

                            1. Initial program 97.5%

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

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

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

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

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

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

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

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

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

                                \[\leadsto \left(1 - u\right) \cdot \color{blue}{n0\_i} \]
                            8. Recombined 2 regimes into one program.
                            9. Final simplification73.8%

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

                            Alternative 7: 61.5% accurate, 25.4× speedup?

                            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n1\_i \leq -1.99999996490334 \cdot 10^{-14}:\\ \;\;\;\;n1\_i \cdot u\\ \mathbf{elif}\;n1\_i \leq 5.000000229068525 \cdot 10^{-19}:\\ \;\;\;\;1 \cdot n0\_i\\ \mathbf{else}:\\ \;\;\;\;n1\_i \cdot u\\ \end{array} \end{array} \]
                            (FPCore (normAngle u n0_i n1_i)
                             :precision binary32
                             (if (<= n1_i -1.99999996490334e-14)
                               (* n1_i u)
                               (if (<= n1_i 5.000000229068525e-19) (* 1.0 n0_i) (* n1_i u))))
                            float code(float normAngle, float u, float n0_i, float n1_i) {
                            	float tmp;
                            	if (n1_i <= -1.99999996490334e-14f) {
                            		tmp = n1_i * u;
                            	} else if (n1_i <= 5.000000229068525e-19f) {
                            		tmp = 1.0f * n0_i;
                            	} else {
                            		tmp = n1_i * u;
                            	}
                            	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 (n1_i <= (-1.99999996490334e-14)) then
                                    tmp = n1_i * u
                                else if (n1_i <= 5.000000229068525e-19) then
                                    tmp = 1.0e0 * n0_i
                                else
                                    tmp = n1_i * u
                                end if
                                code = tmp
                            end function
                            
                            function code(normAngle, u, n0_i, n1_i)
                            	tmp = Float32(0.0)
                            	if (n1_i <= Float32(-1.99999996490334e-14))
                            		tmp = Float32(n1_i * u);
                            	elseif (n1_i <= Float32(5.000000229068525e-19))
                            		tmp = Float32(Float32(1.0) * n0_i);
                            	else
                            		tmp = Float32(n1_i * u);
                            	end
                            	return tmp
                            end
                            
                            function tmp_2 = code(normAngle, u, n0_i, n1_i)
                            	tmp = single(0.0);
                            	if (n1_i <= single(-1.99999996490334e-14))
                            		tmp = n1_i * u;
                            	elseif (n1_i <= single(5.000000229068525e-19))
                            		tmp = single(1.0) * n0_i;
                            	else
                            		tmp = n1_i * u;
                            	end
                            	tmp_2 = tmp;
                            end
                            
                            \begin{array}{l}
                            
                            \\
                            \begin{array}{l}
                            \mathbf{if}\;n1\_i \leq -1.99999996490334 \cdot 10^{-14}:\\
                            \;\;\;\;n1\_i \cdot u\\
                            
                            \mathbf{elif}\;n1\_i \leq 5.000000229068525 \cdot 10^{-19}:\\
                            \;\;\;\;1 \cdot n0\_i\\
                            
                            \mathbf{else}:\\
                            \;\;\;\;n1\_i \cdot u\\
                            
                            
                            \end{array}
                            \end{array}
                            
                            Derivation
                            1. Split input into 2 regimes
                            2. if n1_i < -1.99999996e-14 or 5.00000023e-19 < n1_i

                              1. Initial program 96.1%

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

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

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

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

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

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

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

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

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

                                  \[\leadsto u \cdot \color{blue}{n1\_i} \]

                                if -1.99999996e-14 < n1_i < 5.00000023e-19

                                1. Initial program 97.7%

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

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

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

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

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

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

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

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

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

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

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

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

                                        \[\leadsto 1 \cdot n0\_i \]
                                    4. Recombined 2 regimes into one program.
                                    5. Final simplification61.9%

                                      \[\leadsto \begin{array}{l} \mathbf{if}\;n1\_i \leq -1.99999996490334 \cdot 10^{-14}:\\ \;\;\;\;n1\_i \cdot u\\ \mathbf{elif}\;n1\_i \leq 5.000000229068525 \cdot 10^{-19}:\\ \;\;\;\;1 \cdot n0\_i\\ \mathbf{else}:\\ \;\;\;\;n1\_i \cdot u\\ \end{array} \]
                                    6. Add Preprocessing

                                    Alternative 8: 98.1% accurate, 27.0× speedup?

                                    \[\begin{array}{l} \\ \left(n0\_i - n0\_i \cdot u\right) + n1\_i \cdot u \end{array} \]
                                    (FPCore (normAngle u n0_i n1_i)
                                     :precision binary32
                                     (+ (- n0_i (* n0_i u)) (* n1_i u)))
                                    float code(float normAngle, float u, float n0_i, float n1_i) {
                                    	return (n0_i - (n0_i * u)) + (n1_i * u);
                                    }
                                    
                                    real(4) function code(normangle, u, n0_i, n1_i)
                                        real(4), intent (in) :: normangle
                                        real(4), intent (in) :: u
                                        real(4), intent (in) :: n0_i
                                        real(4), intent (in) :: n1_i
                                        code = (n0_i - (n0_i * u)) + (n1_i * u)
                                    end function
                                    
                                    function code(normAngle, u, n0_i, n1_i)
                                    	return Float32(Float32(n0_i - Float32(n0_i * u)) + Float32(n1_i * u))
                                    end
                                    
                                    function tmp = code(normAngle, u, n0_i, n1_i)
                                    	tmp = (n0_i - (n0_i * u)) + (n1_i * u);
                                    end
                                    
                                    \begin{array}{l}
                                    
                                    \\
                                    \left(n0\_i - n0\_i \cdot u\right) + n1\_i \cdot u
                                    \end{array}
                                    
                                    Derivation
                                    1. Initial program 97.0%

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

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

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

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

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

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

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

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

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

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

                                          \[\leadsto n1\_i \cdot u + \left(n0\_i - \color{blue}{n0\_i \cdot u}\right) \]
                                        2. Final simplification98.0%

                                          \[\leadsto \left(n0\_i - n0\_i \cdot u\right) + n1\_i \cdot u \]
                                        3. Add Preprocessing

                                        Alternative 9: 38.8% accurate, 76.5× speedup?

                                        \[\begin{array}{l} \\ n1\_i \cdot u \end{array} \]
                                        (FPCore (normAngle u n0_i n1_i) :precision binary32 (* n1_i u))
                                        float code(float normAngle, float u, float n0_i, float n1_i) {
                                        	return n1_i * u;
                                        }
                                        
                                        real(4) function code(normangle, u, n0_i, n1_i)
                                            real(4), intent (in) :: normangle
                                            real(4), intent (in) :: u
                                            real(4), intent (in) :: n0_i
                                            real(4), intent (in) :: n1_i
                                            code = n1_i * u
                                        end function
                                        
                                        function code(normAngle, u, n0_i, n1_i)
                                        	return Float32(n1_i * u)
                                        end
                                        
                                        function tmp = code(normAngle, u, n0_i, n1_i)
                                        	tmp = n1_i * u;
                                        end
                                        
                                        \begin{array}{l}
                                        
                                        \\
                                        n1\_i \cdot u
                                        \end{array}
                                        
                                        Derivation
                                        1. Initial program 97.0%

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

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

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

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

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

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

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

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

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

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

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

                                          Reproduce

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