Average Error: 0.9 → 0.3
Time: 10.2s
Precision: binary32
\[0 \leq normAngle \land normAngle \leq \frac{\pi}{2} \land -1 \leq n0_i \land n0_i \leq 1 \land -1 \leq n1_i \land n1_i \leq 1 \land 2.328306437 \cdot 10^{-10} \leq u \land u \leq 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 \]
\[\left(1 + \left(\left(normAngle \cdot normAngle\right) \cdot \left(u \cdot 0.3333333333333333 + 0.16666666666666666 \cdot {u}^{3}\right) - \left(u + 0.5 \cdot \left(\left(normAngle \cdot u\right) \cdot \left(normAngle \cdot u\right)\right)\right)\right)\right) \cdot n0_i + \left(\left(\left(u + {normAngle}^{4} \cdot \left(0.008333333333333333 \cdot {u}^{5} + u \cdot 0.019444444444444445\right)\right) + \left(\left(normAngle \cdot normAngle\right) \cdot 0.16666666666666666\right) \cdot \left(u - {u}^{3}\right)\right) + {normAngle}^{4} \cdot \left({u}^{3} \cdot -0.027777777777777776\right)\right) \cdot n1_i \]
\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
\left(1 + \left(\left(normAngle \cdot normAngle\right) \cdot \left(u \cdot 0.3333333333333333 + 0.16666666666666666 \cdot {u}^{3}\right) - \left(u + 0.5 \cdot \left(\left(normAngle \cdot u\right) \cdot \left(normAngle \cdot u\right)\right)\right)\right)\right) \cdot n0_i + \left(\left(\left(u + {normAngle}^{4} \cdot \left(0.008333333333333333 \cdot {u}^{5} + u \cdot 0.019444444444444445\right)\right) + \left(\left(normAngle \cdot normAngle\right) \cdot 0.16666666666666666\right) \cdot \left(u - {u}^{3}\right)\right) + {normAngle}^{4} \cdot \left({u}^{3} \cdot -0.027777777777777776\right)\right) \cdot n1_i
(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
 (+
  (*
   (+
    1.0
    (-
     (*
      (* normAngle normAngle)
      (+ (* u 0.3333333333333333) (* 0.16666666666666666 (pow u 3.0))))
     (+ u (* 0.5 (* (* normAngle u) (* normAngle u))))))
   n0_i)
  (*
   (+
    (+
     (+
      u
      (*
       (pow normAngle 4.0)
       (+ (* 0.008333333333333333 (pow u 5.0)) (* u 0.019444444444444445))))
     (* (* (* normAngle normAngle) 0.16666666666666666) (- u (pow u 3.0))))
    (* (pow normAngle 4.0) (* (pow u 3.0) -0.027777777777777776)))
   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) {
	return ((1.0f + (((normAngle * normAngle) * ((u * 0.3333333333333333f) + (0.16666666666666666f * powf(u, 3.0f)))) - (u + (0.5f * ((normAngle * u) * (normAngle * u)))))) * n0_i) + ((((u + (powf(normAngle, 4.0f) * ((0.008333333333333333f * powf(u, 5.0f)) + (u * 0.019444444444444445f)))) + (((normAngle * normAngle) * 0.16666666666666666f) * (u - powf(u, 3.0f)))) + (powf(normAngle, 4.0f) * (powf(u, 3.0f) * -0.027777777777777776f))) * n1_i);
}

Error

Bits error versus normAngle

Bits error versus u

Bits error versus n0_i

Bits error versus n1_i

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 0.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. Taylor expanded 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.16666666666666666 \cdot \left(u \cdot {normAngle}^{2}\right) + \left(0.008333333333333333 \cdot \left({u}^{5} \cdot {normAngle}^{4}\right) + \left(0.019444444444444445 \cdot \left(u \cdot {normAngle}^{4}\right) + u\right)\right)\right) - \left(0.16666666666666666 \cdot \left({u}^{3} \cdot {normAngle}^{2}\right) + 0.027777777777777776 \cdot \left({u}^{3} \cdot {normAngle}^{4}\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}{\left(\left(\left(u + {normAngle}^{4} \cdot \left(0.008333333333333333 \cdot {u}^{5} + u \cdot 0.019444444444444445\right)\right) + \left(\left(normAngle \cdot normAngle\right) \cdot 0.16666666666666666\right) \cdot \left(u - {u}^{3}\right)\right) + {normAngle}^{4} \cdot \left({u}^{3} \cdot -0.027777777777777776\right)\right)} \cdot n1_i \]
  4. Taylor expanded around 0 0.3

    \[\leadsto \color{blue}{\left(\left(0.3333333333333333 \cdot \left(u \cdot {normAngle}^{2}\right) + \left(1 + 0.16666666666666666 \cdot \left({u}^{3} \cdot {normAngle}^{2}\right)\right)\right) - \left(0.5 \cdot \left({u}^{2} \cdot {normAngle}^{2}\right) + u\right)\right)} \cdot n0_i + \left(\left(\left(u + {normAngle}^{4} \cdot \left(0.008333333333333333 \cdot {u}^{5} + u \cdot 0.019444444444444445\right)\right) + \left(\left(normAngle \cdot normAngle\right) \cdot 0.16666666666666666\right) \cdot \left(u - {u}^{3}\right)\right) + {normAngle}^{4} \cdot \left({u}^{3} \cdot -0.027777777777777776\right)\right) \cdot n1_i \]
  5. Simplified0.3

    \[\leadsto \color{blue}{\left(1 + \left(\left(normAngle \cdot normAngle\right) \cdot \left(u \cdot 0.3333333333333333 + 0.16666666666666666 \cdot {u}^{3}\right) - \left(u + 0.5 \cdot \left(\left(normAngle \cdot u\right) \cdot \left(normAngle \cdot u\right)\right)\right)\right)\right)} \cdot n0_i + \left(\left(\left(u + {normAngle}^{4} \cdot \left(0.008333333333333333 \cdot {u}^{5} + u \cdot 0.019444444444444445\right)\right) + \left(\left(normAngle \cdot normAngle\right) \cdot 0.16666666666666666\right) \cdot \left(u - {u}^{3}\right)\right) + {normAngle}^{4} \cdot \left({u}^{3} \cdot -0.027777777777777776\right)\right) \cdot n1_i \]
  6. Final simplification0.3

    \[\leadsto \left(1 + \left(\left(normAngle \cdot normAngle\right) \cdot \left(u \cdot 0.3333333333333333 + 0.16666666666666666 \cdot {u}^{3}\right) - \left(u + 0.5 \cdot \left(\left(normAngle \cdot u\right) \cdot \left(normAngle \cdot u\right)\right)\right)\right)\right) \cdot n0_i + \left(\left(\left(u + {normAngle}^{4} \cdot \left(0.008333333333333333 \cdot {u}^{5} + u \cdot 0.019444444444444445\right)\right) + \left(\left(normAngle \cdot normAngle\right) \cdot 0.16666666666666666\right) \cdot \left(u - {u}^{3}\right)\right) + {normAngle}^{4} \cdot \left({u}^{3} \cdot -0.027777777777777776\right)\right) \cdot n1_i \]

Reproduce

herbie shell --seed 2021198 
(FPCore (normAngle u n0_i n1_i)
  :name "Curve intersection, scale width based on ribbon orientation"
  :precision binary32
  :pre (and (<= 0.0 normAngle (/ PI 2.0)) (<= -1.0 n0_i 1.0) (<= -1.0 n1_i 1.0) (<= 2.328306437e-10 u 1.0))
  (+ (* (* (sin (* (- 1.0 u) normAngle)) (/ 1.0 (sin normAngle))) n0_i) (* (* (sin (* u normAngle)) (/ 1.0 (sin normAngle))) n1_i)))