| Alternative 1 | |
|---|---|
| Accuracy | 98.6% |
| Cost | 608 |
\[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)
\]
(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)
Initial program 98.0%
Taylor expanded in normAngle around 0 97.8%
Taylor expanded in normAngle around 0 98.6%
Simplified98.6%
[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
\] |
Applied egg-rr98.6%
[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)
\] |
Taylor expanded in u around 0 98.6%
Simplified98.8%
[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)
\] |
Final simplification98.8%
| Alternative 1 | |
|---|---|
| Accuracy | 98.6% |
| Cost | 608 |
| Alternative 2 | |
|---|---|
| Accuracy | 86.1% |
| Cost | 297 |
| Alternative 3 | |
|---|---|
| Accuracy | 86.2% |
| Cost | 297 |
| Alternative 4 | |
|---|---|
| Accuracy | 68.4% |
| Cost | 296 |
| Alternative 5 | |
|---|---|
| Accuracy | 60.0% |
| Cost | 232 |
| Alternative 6 | |
|---|---|
| Accuracy | 98.1% |
| Cost | 224 |
| Alternative 7 | |
|---|---|
| Accuracy | 46.7% |
| Cost | 32 |
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)))