Average Error: 0.8 → 0.3
Time: 10.7s
Precision: binary32
\[\left(\left(\left(0 \leq normAngle \land normAngle \leq \frac{\pi}{2}\right) \land \left(-1 \leq n0_i \land n0_i \leq 1\right)\right) \land \left(-1 \leq n1_i \land n1_i \leq 1\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq u \land u \leq 1\right)\]
\[\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 \]
\[\begin{array}{l} t_0 := {u}^{3} - u\\ t_1 := \mathsf{fma}\left(0.008333333333333333, {u}^{5} - u, -0.027777777777777776 \cdot t_0\right)\\ \left(\mathsf{fma}\left(-0.5, \left(u \cdot normAngle\right) \cdot \left(u \cdot normAngle\right), 1\right) - u \cdot \frac{\cos normAngle}{\frac{\sin normAngle}{normAngle}}\right) \cdot n0_i + \mathsf{fma}\left(-0.0001984126984126984 \cdot {u}^{7} - \mathsf{fma}\left(u, -0.0001984126984126984, \mathsf{fma}\left(-0.16666666666666666, t_1, t_0 \cdot -0.001388888888888889\right)\right), {normAngle}^{6}, \mathsf{fma}\left(t_1, {normAngle}^{4}, \mathsf{fma}\left(-0.16666666666666666, t_0 \cdot \left(normAngle \cdot normAngle\right), u\right)\right)\right) \cdot n1_i \end{array} \]
(FPCore (normAngle u n0_i n1_i)
 :precision binary32
 (+
  (* (* (sin (* (- 1.0 u) normAngle)) (/ 1.0 (sin normAngle))) n0_i)
  (* (* (sin (* u normAngle)) (/ 1.0 (sin normAngle))) n1_i)))
(FPCore (normAngle u n0_i n1_i)
 :precision binary32
 (let* ((t_0 (- (pow u 3.0) u))
        (t_1
         (fma
          0.008333333333333333
          (- (pow u 5.0) u)
          (* -0.027777777777777776 t_0))))
   (+
    (*
     (-
      (fma -0.5 (* (* u normAngle) (* u normAngle)) 1.0)
      (* u (/ (cos normAngle) (/ (sin normAngle) normAngle))))
     n0_i)
    (*
     (fma
      (-
       (* -0.0001984126984126984 (pow u 7.0))
       (fma
        u
        -0.0001984126984126984
        (fma -0.16666666666666666 t_1 (* t_0 -0.001388888888888889))))
      (pow normAngle 6.0)
      (fma
       t_1
       (pow normAngle 4.0)
       (fma -0.16666666666666666 (* t_0 (* normAngle normAngle)) u)))
     n1_i))))
float code(float normAngle, float u, float n0_i, float n1_i) {
	return ((sinf(((1.0f - u) * normAngle)) * (1.0f / sinf(normAngle))) * n0_i) + ((sinf((u * normAngle)) * (1.0f / sinf(normAngle))) * n1_i);
}
float code(float normAngle, float u, float n0_i, float n1_i) {
	float t_0 = powf(u, 3.0f) - u;
	float t_1 = fmaf(0.008333333333333333f, (powf(u, 5.0f) - u), (-0.027777777777777776f * t_0));
	return ((fmaf(-0.5f, ((u * normAngle) * (u * normAngle)), 1.0f) - (u * (cosf(normAngle) / (sinf(normAngle) / normAngle)))) * n0_i) + (fmaf(((-0.0001984126984126984f * powf(u, 7.0f)) - fmaf(u, -0.0001984126984126984f, fmaf(-0.16666666666666666f, t_1, (t_0 * -0.001388888888888889f)))), powf(normAngle, 6.0f), fmaf(t_1, powf(normAngle, 4.0f), fmaf(-0.16666666666666666f, (t_0 * (normAngle * normAngle)), u))) * n1_i);
}
function code(normAngle, u, n0_i, n1_i)
	return Float32(Float32(Float32(sin(Float32(Float32(Float32(1.0) - u) * normAngle)) * Float32(Float32(1.0) / sin(normAngle))) * n0_i) + Float32(Float32(sin(Float32(u * normAngle)) * Float32(Float32(1.0) / sin(normAngle))) * n1_i))
end
function code(normAngle, u, n0_i, n1_i)
	t_0 = Float32((u ^ Float32(3.0)) - u)
	t_1 = fma(Float32(0.008333333333333333), Float32((u ^ Float32(5.0)) - u), Float32(Float32(-0.027777777777777776) * t_0))
	return Float32(Float32(Float32(fma(Float32(-0.5), Float32(Float32(u * normAngle) * Float32(u * normAngle)), Float32(1.0)) - Float32(u * Float32(cos(normAngle) / Float32(sin(normAngle) / normAngle)))) * n0_i) + Float32(fma(Float32(Float32(Float32(-0.0001984126984126984) * (u ^ Float32(7.0))) - fma(u, Float32(-0.0001984126984126984), fma(Float32(-0.16666666666666666), t_1, Float32(t_0 * Float32(-0.001388888888888889))))), (normAngle ^ Float32(6.0)), fma(t_1, (normAngle ^ Float32(4.0)), fma(Float32(-0.16666666666666666), Float32(t_0 * Float32(normAngle * normAngle)), u))) * n1_i))
end
\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
\begin{array}{l}
t_0 := {u}^{3} - u\\
t_1 := \mathsf{fma}\left(0.008333333333333333, {u}^{5} - u, -0.027777777777777776 \cdot t_0\right)\\
\left(\mathsf{fma}\left(-0.5, \left(u \cdot normAngle\right) \cdot \left(u \cdot normAngle\right), 1\right) - u \cdot \frac{\cos normAngle}{\frac{\sin normAngle}{normAngle}}\right) \cdot n0_i + \mathsf{fma}\left(-0.0001984126984126984 \cdot {u}^{7} - \mathsf{fma}\left(u, -0.0001984126984126984, \mathsf{fma}\left(-0.16666666666666666, t_1, t_0 \cdot -0.001388888888888889\right)\right), {normAngle}^{6}, \mathsf{fma}\left(t_1, {normAngle}^{4}, \mathsf{fma}\left(-0.16666666666666666, t_0 \cdot \left(normAngle \cdot normAngle\right), u\right)\right)\right) \cdot n1_i
\end{array}

Error

Derivation

  1. Initial program 0.8

    \[\left(\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n0_i + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n1_i \]
  2. Taylor expanded in normAngle around 0 0.4

    \[\leadsto \left(\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n0_i + \color{blue}{\left(\left(-0.0001984126984126984 \cdot {u}^{7} - \left(0.008333333333333333 \cdot \left(-0.16666666666666666 \cdot {u}^{3} - -0.16666666666666666 \cdot u\right) + \left(-0.0001984126984126984 \cdot u + -0.16666666666666666 \cdot \left(0.008333333333333333 \cdot {u}^{5} - \left(0.008333333333333333 \cdot u + -0.16666666666666666 \cdot \left(-0.16666666666666666 \cdot {u}^{3} - -0.16666666666666666 \cdot u\right)\right)\right)\right)\right)\right) \cdot {normAngle}^{6} + \left(\left(0.008333333333333333 \cdot {u}^{5} - \left(0.008333333333333333 \cdot u + -0.16666666666666666 \cdot \left(-0.16666666666666666 \cdot {u}^{3} - -0.16666666666666666 \cdot u\right)\right)\right) \cdot {normAngle}^{4} + \left(\left(-0.16666666666666666 \cdot {u}^{3} - -0.16666666666666666 \cdot u\right) \cdot {normAngle}^{2} + u\right)\right)\right)} \cdot n1_i \]
  3. Simplified0.4

    \[\leadsto \left(\sin \left(\left(1 - u\right) \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n0_i + \color{blue}{\mathsf{fma}\left(-0.0001984126984126984 \cdot {u}^{7} - \mathsf{fma}\left(u, -0.0001984126984126984, \mathsf{fma}\left(-0.16666666666666666, \mathsf{fma}\left(0.008333333333333333, {u}^{5} - u, -0.027777777777777776 \cdot \left({u}^{3} - u\right)\right), \left({u}^{3} - u\right) \cdot -0.001388888888888889\right)\right), {normAngle}^{6}, \mathsf{fma}\left(\mathsf{fma}\left(0.008333333333333333, {u}^{5} - u, -0.027777777777777776 \cdot \left({u}^{3} - u\right)\right), {normAngle}^{4}, \mathsf{fma}\left(-0.16666666666666666, \left(normAngle \cdot normAngle\right) \cdot \left({u}^{3} - u\right), u\right)\right)\right)} \cdot n1_i \]
  4. Taylor expanded in u around 0 0.3

    \[\leadsto \color{blue}{\left(1 + \left(-1 \cdot \frac{\cos normAngle \cdot \left(u \cdot normAngle\right)}{\sin normAngle} + -0.5 \cdot \left({u}^{2} \cdot {normAngle}^{2}\right)\right)\right)} \cdot n0_i + \mathsf{fma}\left(-0.0001984126984126984 \cdot {u}^{7} - \mathsf{fma}\left(u, -0.0001984126984126984, \mathsf{fma}\left(-0.16666666666666666, \mathsf{fma}\left(0.008333333333333333, {u}^{5} - u, -0.027777777777777776 \cdot \left({u}^{3} - u\right)\right), \left({u}^{3} - u\right) \cdot -0.001388888888888889\right)\right), {normAngle}^{6}, \mathsf{fma}\left(\mathsf{fma}\left(0.008333333333333333, {u}^{5} - u, -0.027777777777777776 \cdot \left({u}^{3} - u\right)\right), {normAngle}^{4}, \mathsf{fma}\left(-0.16666666666666666, \left(normAngle \cdot normAngle\right) \cdot \left({u}^{3} - u\right), u\right)\right)\right) \cdot n1_i \]
  5. Simplified0.3

    \[\leadsto \color{blue}{\left(\mathsf{fma}\left(-0.5, \left(u \cdot normAngle\right) \cdot \left(u \cdot normAngle\right), 1\right) - \frac{\cos normAngle}{\frac{\sin normAngle}{normAngle}} \cdot u\right)} \cdot n0_i + \mathsf{fma}\left(-0.0001984126984126984 \cdot {u}^{7} - \mathsf{fma}\left(u, -0.0001984126984126984, \mathsf{fma}\left(-0.16666666666666666, \mathsf{fma}\left(0.008333333333333333, {u}^{5} - u, -0.027777777777777776 \cdot \left({u}^{3} - u\right)\right), \left({u}^{3} - u\right) \cdot -0.001388888888888889\right)\right), {normAngle}^{6}, \mathsf{fma}\left(\mathsf{fma}\left(0.008333333333333333, {u}^{5} - u, -0.027777777777777776 \cdot \left({u}^{3} - u\right)\right), {normAngle}^{4}, \mathsf{fma}\left(-0.16666666666666666, \left(normAngle \cdot normAngle\right) \cdot \left({u}^{3} - u\right), u\right)\right)\right) \cdot n1_i \]
  6. Final simplification0.3

    \[\leadsto \left(\mathsf{fma}\left(-0.5, \left(u \cdot normAngle\right) \cdot \left(u \cdot normAngle\right), 1\right) - u \cdot \frac{\cos normAngle}{\frac{\sin normAngle}{normAngle}}\right) \cdot n0_i + \mathsf{fma}\left(-0.0001984126984126984 \cdot {u}^{7} - \mathsf{fma}\left(u, -0.0001984126984126984, \mathsf{fma}\left(-0.16666666666666666, \mathsf{fma}\left(0.008333333333333333, {u}^{5} - u, -0.027777777777777776 \cdot \left({u}^{3} - u\right)\right), \left({u}^{3} - u\right) \cdot -0.001388888888888889\right)\right), {normAngle}^{6}, \mathsf{fma}\left(\mathsf{fma}\left(0.008333333333333333, {u}^{5} - u, -0.027777777777777776 \cdot \left({u}^{3} - u\right)\right), {normAngle}^{4}, \mathsf{fma}\left(-0.16666666666666666, \left({u}^{3} - u\right) \cdot \left(normAngle \cdot normAngle\right), u\right)\right)\right) \cdot n1_i \]

Reproduce

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