Curve intersection, scale width based on ribbon orientation

Percentage Accurate: 97.3% → 98.9%
Time: 10.2s
Alternatives: 8
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 8 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: 98.9% accurate, 1.3× speedup?

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

\\
n1\_i \cdot \left(\frac{normAngle}{\sin normAngle} \cdot u\right) + \sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot \frac{n0\_i}{\sin normAngle}
\end{array}
Derivation
  1. Initial program 97.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 98.8% 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.4%

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

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

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

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

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

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

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

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

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

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

Alternative 3: 98.7% accurate, 3.5× speedup?

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

\\
\left(\frac{u}{\sin normAngle} \cdot normAngle\right) \cdot n1\_i + \left(1 - u\right) \cdot n0\_i
\end{array}
Derivation
  1. Initial program 97.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 67.9% accurate, 17.0× 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 4.99999991225835 \cdot 10^{-14}:\\ \;\;\;\;\mathsf{fma}\left(u, n1\_i, \left(1 - u\right) \cdot n0\_i\right)\\ \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 4.99999991225835e-14)
     (fma u n1_i (* (- 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 <= 4.99999991225835e-14f) {
		tmp = fmaf(u, n1_i, ((1.0f - u) * n0_i));
	} else {
		tmp = n1_i * u;
	}
	return tmp;
}
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(4.99999991225835e-14))
		tmp = fma(u, n1_i, Float32(Float32(Float32(1.0) - u) * n0_i));
	else
		tmp = Float32(n1_i * u);
	end
	return 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 4.99999991225835 \cdot 10^{-14}:\\
\;\;\;\;\mathsf{fma}\left(u, n1\_i, \left(1 - u\right) \cdot n0\_i\right)\\

\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 4.99999991e-14 < n1_i

    1. Initial program 95.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

          if -1.99999996e-14 < n1_i < 4.99999991e-14

          1. Initial program 98.5%

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(u, n1\_i, \left(1 - u\right) \cdot n0\_i\right) \]
              4. Recombined 2 regimes into one program.
              5. Add Preprocessing

              Alternative 5: 66.3% accurate, 17.0× 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 4.99999991225835 \cdot 10^{-14}:\\ \;\;\;\;\mathsf{fma}\left(n1\_i, u, \left(1 - u\right) \cdot n0\_i\right)\\ \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 4.99999991225835e-14)
                   (fma n1_i u (* (- 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 <= 4.99999991225835e-14f) {
              		tmp = fmaf(n1_i, u, ((1.0f - u) * n0_i));
              	} else {
              		tmp = n1_i * u;
              	}
              	return tmp;
              }
              
              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(4.99999991225835e-14))
              		tmp = fma(n1_i, u, Float32(Float32(Float32(1.0) - u) * n0_i));
              	else
              		tmp = Float32(n1_i * u);
              	end
              	return 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 4.99999991225835 \cdot 10^{-14}:\\
              \;\;\;\;\mathsf{fma}\left(n1\_i, u, \left(1 - u\right) \cdot n0\_i\right)\\
              
              \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 4.99999991e-14 < n1_i

                1. Initial program 95.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

                      if -1.99999996e-14 < n1_i < 4.99999991e-14

                      1. Initial program 98.5%

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

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

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

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

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

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

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

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

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

                              \[\leadsto \mathsf{fma}\left(n1\_i, \color{blue}{u}, n0\_i \cdot \left(1 - u\right)\right) \]
                          3. Recombined 2 regimes into one program.
                          4. Final simplification78.6%

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

                          Alternative 6: 57.5% accurate, 20.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 6.000000233523199 \cdot 10^{-17}:\\ \;\;\;\;\mathsf{fma}\left(n1\_i - n0\_i, u, n0\_i\right)\\ \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 6.000000233523199e-17) (fma (- n1_i n0_i) 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 <= 6.000000233523199e-17f) {
                          		tmp = fmaf((n1_i - n0_i), u, n0_i);
                          	} else {
                          		tmp = n1_i * u;
                          	}
                          	return tmp;
                          }
                          
                          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(6.000000233523199e-17))
                          		tmp = fma(Float32(n1_i - n0_i), u, n0_i);
                          	else
                          		tmp = Float32(n1_i * u);
                          	end
                          	return 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 6.000000233523199 \cdot 10^{-17}:\\
                          \;\;\;\;\mathsf{fma}\left(n1\_i - n0\_i, u, n0\_i\right)\\
                          
                          \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 6.0000002e-17 < n1_i

                            1. Initial program 95.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                  1. Initial program 98.5%

                                    \[\left(\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n0\_i + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n1\_i \]
                                  2. Add Preprocessing
                                  3. Step-by-step derivation
                                    1. lift-*.f32N/A

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

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

                                      \[\leadsto \left(\sin \left(normAngle \cdot \color{blue}{\left(1 - u\right)}\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 \]
                                    4. sub-negN/A

                                      \[\leadsto \left(\sin \left(normAngle \cdot \color{blue}{\left(1 + \left(\mathsf{neg}\left(u\right)\right)\right)}\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 \]
                                    5. +-commutativeN/A

                                      \[\leadsto \left(\sin \left(normAngle \cdot \color{blue}{\left(\left(\mathsf{neg}\left(u\right)\right) + 1\right)}\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 \]
                                    6. distribute-lft-inN/A

                                      \[\leadsto \left(\sin \color{blue}{\left(normAngle \cdot \left(\mathsf{neg}\left(u\right)\right) + normAngle \cdot 1\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 \]
                                    7. *-rgt-identityN/A

                                      \[\leadsto \left(\sin \left(normAngle \cdot \left(\mathsf{neg}\left(u\right)\right) + \color{blue}{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 \]
                                    8. lower-+.f32N/A

                                      \[\leadsto \left(\sin \color{blue}{\left(normAngle \cdot \left(\mathsf{neg}\left(u\right)\right) + 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 \]
                                    9. *-commutativeN/A

                                      \[\leadsto \left(\sin \left(\color{blue}{\left(\mathsf{neg}\left(u\right)\right) \cdot normAngle} + 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 \]
                                    10. lower-*.f32N/A

                                      \[\leadsto \left(\sin \left(\color{blue}{\left(\mathsf{neg}\left(u\right)\right) \cdot normAngle} + 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 \]
                                    11. lower-neg.f3298.5

                                      \[\leadsto \left(\sin \left(\color{blue}{\left(-u\right)} \cdot normAngle + 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 \]
                                  4. Applied rewrites98.5%

                                    \[\leadsto \left(\sin \color{blue}{\left(\left(-u\right) \cdot normAngle + 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 \]
                                  5. Taylor expanded in normAngle around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                Alternative 7: 97.8% accurate, 27.0× speedup?

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

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

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

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

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

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

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

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

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

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

                                  Alternative 8: 38.0% 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.4%

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

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

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

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

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

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

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

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

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

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

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

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

                                          \[\leadsto n1\_i \cdot \color{blue}{u} \]
                                        2. Add Preprocessing

                                        Reproduce

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