?

Average Accuracy: 97.1% → 98.9%
Time: 17.4s
Precision: binary32
Cost: 3616

?

\[\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 \]
\[\mathsf{fma}\left(u, \left(normAngle \cdot normAngle\right) \cdot \left(0.16666666666666666 \cdot n1_i\right) + \left(n1_i - n0_i\right), n0_i\right) \]
(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
 (fma
  u
  (+ (* (* normAngle normAngle) (* 0.16666666666666666 n1_i)) (- n1_i n0_i))
  n0_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 fmaf(u, (((normAngle * normAngle) * (0.16666666666666666f * n1_i)) + (n1_i - n0_i)), n0_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)
	return fma(u, Float32(Float32(Float32(normAngle * normAngle) * Float32(Float32(0.16666666666666666) * n1_i)) + Float32(n1_i - n0_i)), n0_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
\mathsf{fma}\left(u, \left(normAngle \cdot normAngle\right) \cdot \left(0.16666666666666666 \cdot n1_i\right) + \left(n1_i - n0_i\right), n0_i\right)

Error?

Derivation?

  1. Initial program 98.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. Taylor expanded in normAngle around 0 97.8%

    \[\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 \]
  3. Taylor expanded in normAngle around 0 98.6%

    \[\leadsto \left(1 - u\right) \cdot n0_i + \color{blue}{\left(\left(-0.16666666666666666 \cdot {u}^{3} - -0.16666666666666666 \cdot u\right) \cdot {normAngle}^{2} + u\right)} \cdot n1_i \]
  4. Simplified98.6%

    \[\leadsto \left(1 - u\right) \cdot n0_i + \color{blue}{\mathsf{fma}\left(-0.16666666666666666 \cdot \left({u}^{3} - u\right), normAngle \cdot normAngle, u\right)} \cdot n1_i \]
    Step-by-step derivation

    [Start]98.6

    \[ \left(1 - u\right) \cdot n0_i + \left(\left(-0.16666666666666666 \cdot {u}^{3} - -0.16666666666666666 \cdot u\right) \cdot {normAngle}^{2} + u\right) \cdot n1_i \]

    fma-def [=>]98.6

    \[ \left(1 - u\right) \cdot n0_i + \color{blue}{\mathsf{fma}\left(-0.16666666666666666 \cdot {u}^{3} - -0.16666666666666666 \cdot u, {normAngle}^{2}, u\right)} \cdot n1_i \]

    distribute-lft-out-- [=>]98.6

    \[ \left(1 - u\right) \cdot n0_i + \mathsf{fma}\left(\color{blue}{-0.16666666666666666 \cdot \left({u}^{3} - u\right)}, {normAngle}^{2}, u\right) \cdot n1_i \]

    unpow2 [=>]98.6

    \[ \left(1 - u\right) \cdot n0_i + \mathsf{fma}\left(-0.16666666666666666 \cdot \left({u}^{3} - u\right), \color{blue}{normAngle \cdot normAngle}, u\right) \cdot n1_i \]
  5. Applied egg-rr98.6%

    \[\leadsto \left(1 - u\right) \cdot n0_i + \color{blue}{\left(\left(\left({u}^{3} - u\right) \cdot \left(-0.16666666666666666 \cdot \left(normAngle \cdot normAngle\right)\right)\right) \cdot n1_i + u \cdot n1_i\right)} \]
    Step-by-step derivation

    [Start]98.6

    \[ \left(1 - u\right) \cdot n0_i + \mathsf{fma}\left(-0.16666666666666666 \cdot \left({u}^{3} - u\right), normAngle \cdot normAngle, u\right) \cdot n1_i \]

    *-commutative [=>]98.6

    \[ \left(1 - u\right) \cdot n0_i + \color{blue}{n1_i \cdot \mathsf{fma}\left(-0.16666666666666666 \cdot \left({u}^{3} - u\right), normAngle \cdot normAngle, u\right)} \]

    fma-udef [=>]98.6

    \[ \left(1 - u\right) \cdot n0_i + n1_i \cdot \color{blue}{\left(\left(-0.16666666666666666 \cdot \left({u}^{3} - u\right)\right) \cdot \left(normAngle \cdot normAngle\right) + u\right)} \]

    distribute-rgt-in [=>]98.6

    \[ \left(1 - u\right) \cdot n0_i + \color{blue}{\left(\left(\left(-0.16666666666666666 \cdot \left({u}^{3} - u\right)\right) \cdot \left(normAngle \cdot normAngle\right)\right) \cdot n1_i + u \cdot n1_i\right)} \]

    *-commutative [=>]98.6

    \[ \left(1 - u\right) \cdot n0_i + \left(\left(\color{blue}{\left(\left({u}^{3} - u\right) \cdot -0.16666666666666666\right)} \cdot \left(normAngle \cdot normAngle\right)\right) \cdot n1_i + u \cdot n1_i\right) \]

    associate-*l* [=>]98.6

    \[ \left(1 - u\right) \cdot n0_i + \left(\color{blue}{\left(\left({u}^{3} - u\right) \cdot \left(-0.16666666666666666 \cdot \left(normAngle \cdot normAngle\right)\right)\right)} \cdot n1_i + u \cdot n1_i\right) \]
  6. Taylor expanded in u around 0 98.6%

    \[\leadsto \color{blue}{u \cdot \left(n1_i + \left(-1 \cdot n0_i + 0.16666666666666666 \cdot \left(n1_i \cdot {normAngle}^{2}\right)\right)\right) + n0_i} \]
  7. Simplified98.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(u, \left(normAngle \cdot normAngle\right) \cdot \left(0.16666666666666666 \cdot n1_i\right) + \left(n1_i - n0_i\right), n0_i\right)} \]
    Step-by-step derivation

    [Start]98.6

    \[ u \cdot \left(n1_i + \left(-1 \cdot n0_i + 0.16666666666666666 \cdot \left(n1_i \cdot {normAngle}^{2}\right)\right)\right) + n0_i \]

    fma-def [=>]98.8

    \[ \color{blue}{\mathsf{fma}\left(u, n1_i + \left(-1 \cdot n0_i + 0.16666666666666666 \cdot \left(n1_i \cdot {normAngle}^{2}\right)\right), n0_i\right)} \]

    associate-+r+ [=>]98.8

    \[ \mathsf{fma}\left(u, \color{blue}{\left(n1_i + -1 \cdot n0_i\right) + 0.16666666666666666 \cdot \left(n1_i \cdot {normAngle}^{2}\right)}, n0_i\right) \]

    +-commutative [=>]98.8

    \[ \mathsf{fma}\left(u, \color{blue}{0.16666666666666666 \cdot \left(n1_i \cdot {normAngle}^{2}\right) + \left(n1_i + -1 \cdot n0_i\right)}, n0_i\right) \]

    associate-*r* [=>]98.8

    \[ \mathsf{fma}\left(u, \color{blue}{\left(0.16666666666666666 \cdot n1_i\right) \cdot {normAngle}^{2}} + \left(n1_i + -1 \cdot n0_i\right), n0_i\right) \]

    *-commutative [=>]98.8

    \[ \mathsf{fma}\left(u, \color{blue}{{normAngle}^{2} \cdot \left(0.16666666666666666 \cdot n1_i\right)} + \left(n1_i + -1 \cdot n0_i\right), n0_i\right) \]

    unpow2 [=>]98.8

    \[ \mathsf{fma}\left(u, \color{blue}{\left(normAngle \cdot normAngle\right)} \cdot \left(0.16666666666666666 \cdot n1_i\right) + \left(n1_i + -1 \cdot n0_i\right), n0_i\right) \]

    mul-1-neg [=>]98.8

    \[ \mathsf{fma}\left(u, \left(normAngle \cdot normAngle\right) \cdot \left(0.16666666666666666 \cdot n1_i\right) + \left(n1_i + \color{blue}{\left(-n0_i\right)}\right), n0_i\right) \]

    unsub-neg [=>]98.8

    \[ \mathsf{fma}\left(u, \left(normAngle \cdot normAngle\right) \cdot \left(0.16666666666666666 \cdot n1_i\right) + \color{blue}{\left(n1_i - n0_i\right)}, n0_i\right) \]
  8. Final simplification98.8%

    \[\leadsto \mathsf{fma}\left(u, \left(normAngle \cdot normAngle\right) \cdot \left(0.16666666666666666 \cdot n1_i\right) + \left(n1_i - n0_i\right), n0_i\right) \]

Alternatives

Alternative 1
Accuracy98.6%
Cost608
\[n0_i \cdot \left(1 - u\right) + \left(n1_i \cdot \left(\left(normAngle \cdot normAngle\right) \cdot \left(u \cdot 0.16666666666666666\right)\right) + u \cdot n1_i\right) \]
Alternative 2
Accuracy86.1%
Cost297
\[\begin{array}{l} \mathbf{if}\;n1_i \leq -5.000000015855384 \cdot 10^{-30} \lor \neg \left(n1_i \leq 5.000000015855384 \cdot 10^{-29}\right):\\ \;\;\;\;n0_i + u \cdot n1_i\\ \mathbf{else}:\\ \;\;\;\;n0_i \cdot \left(1 - u\right)\\ \end{array} \]
Alternative 3
Accuracy86.2%
Cost297
\[\begin{array}{l} \mathbf{if}\;n1_i \leq -5.000000015855384 \cdot 10^{-30} \lor \neg \left(n1_i \leq 5.000000015855384 \cdot 10^{-29}\right):\\ \;\;\;\;n0_i + u \cdot n1_i\\ \mathbf{else}:\\ \;\;\;\;n0_i - u \cdot n0_i\\ \end{array} \]
Alternative 4
Accuracy68.4%
Cost296
\[\begin{array}{l} \mathbf{if}\;n1_i \leq -4.0000000467443897 \cdot 10^{-7}:\\ \;\;\;\;u \cdot n1_i\\ \mathbf{elif}\;n1_i \leq 1.99999996490334 \cdot 10^{-13}:\\ \;\;\;\;n0_i \cdot \left(1 - u\right)\\ \mathbf{else}:\\ \;\;\;\;u \cdot n1_i\\ \end{array} \]
Alternative 5
Accuracy60.0%
Cost232
\[\begin{array}{l} \mathbf{if}\;n1_i \leq -1.000000045813705 \cdot 10^{-18}:\\ \;\;\;\;u \cdot n1_i\\ \mathbf{elif}\;n1_i \leq 1.99999996490334 \cdot 10^{-13}:\\ \;\;\;\;n0_i\\ \mathbf{else}:\\ \;\;\;\;u \cdot n1_i\\ \end{array} \]
Alternative 6
Accuracy98.1%
Cost224
\[n0_i + u \cdot \left(n1_i - n0_i\right) \]
Alternative 7
Accuracy46.7%
Cost32
\[n0_i \]

Error

Reproduce?

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