Curve intersection, scale width based on ribbon orientation

Percentage Accurate: 97.0% → 99.2%
Time: 11.3s
Alternatives: 7
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);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(4) function code(normangle, u, n0_i, n1_i)
use fmin_fmax_functions
    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 7 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.0% 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);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(4) function code(normangle, u, n0_i, n1_i)
use fmin_fmax_functions
    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: 99.2% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \left(n0\_i - \left(\left(\cos normAngle \cdot u\right) \cdot normAngle\right) \cdot \frac{n0\_i}{\sin normAngle}\right) + \left(\frac{normAngle}{\sin normAngle} \cdot u\right) \cdot n1\_i \end{array} \]
(FPCore (normAngle u n0_i n1_i)
 :precision binary32
 (+
  (- n0_i (* (* (* (cos normAngle) u) normAngle) (/ n0_i (sin normAngle))))
  (* (* (/ normAngle (sin normAngle)) u) n1_i)))
float code(float normAngle, float u, float n0_i, float n1_i) {
	return (n0_i - (((cosf(normAngle) * u) * normAngle) * (n0_i / sinf(normAngle)))) + (((normAngle / sinf(normAngle)) * u) * n1_i);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(4) function code(normangle, u, n0_i, n1_i)
use fmin_fmax_functions
    real(4), intent (in) :: normangle
    real(4), intent (in) :: u
    real(4), intent (in) :: n0_i
    real(4), intent (in) :: n1_i
    code = (n0_i - (((cos(normangle) * u) * normangle) * (n0_i / sin(normangle)))) + (((normangle / sin(normangle)) * u) * n1_i)
end function
function code(normAngle, u, n0_i, n1_i)
	return Float32(Float32(n0_i - Float32(Float32(Float32(cos(normAngle) * u) * normAngle) * Float32(n0_i / sin(normAngle)))) + Float32(Float32(Float32(normAngle / sin(normAngle)) * u) * n1_i))
end
function tmp = code(normAngle, u, n0_i, n1_i)
	tmp = (n0_i - (((cos(normAngle) * u) * normAngle) * (n0_i / sin(normAngle)))) + (((normAngle / sin(normAngle)) * u) * n1_i);
end
\begin{array}{l}

\\
\left(n0\_i - \left(\left(\cos normAngle \cdot u\right) \cdot normAngle\right) \cdot \frac{n0\_i}{\sin normAngle}\right) + \left(\frac{normAngle}{\sin normAngle} \cdot u\right) \cdot n1\_i
\end{array}
Derivation
  1. Initial program 95.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. 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.7

      \[\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.7%

    \[\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. 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 \]
    3. associate-*l*N/A

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

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

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

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

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

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

      \[\leadsto \left(n0\_i \cdot \frac{1}{\sin normAngle}\right) \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.8%

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

    \[\leadsto \color{blue}{\left(n0\_i + -1 \cdot \frac{n0\_i \cdot \left(normAngle \cdot \left(u \cdot \cos normAngle\right)\right)}{\sin normAngle}\right)} + \left(\frac{normAngle}{\sin normAngle} \cdot u\right) \cdot n1\_i \]
  9. Step-by-step derivation
    1. fp-cancel-sign-sub-invN/A

      \[\leadsto \color{blue}{\left(n0\_i - \left(\mathsf{neg}\left(-1\right)\right) \cdot \frac{n0\_i \cdot \left(normAngle \cdot \left(u \cdot \cos normAngle\right)\right)}{\sin normAngle}\right)} + \left(\frac{normAngle}{\sin normAngle} \cdot u\right) \cdot n1\_i \]
    2. metadata-evalN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\left(n0\_i - \left(\left(\cos normAngle \cdot u\right) \cdot normAngle\right) \cdot \frac{n0\_i}{\sin normAngle}\right)} + \left(\frac{normAngle}{\sin normAngle} \cdot u\right) \cdot n1\_i \]
  11. Add Preprocessing

Alternative 2: 98.8% accurate, 3.5× speedup?

\[\begin{array}{l} \\ \left(1 - u\right) \cdot n0\_i + \left(\frac{normAngle}{\sin normAngle} \cdot u\right) \cdot n1\_i \end{array} \]
(FPCore (normAngle u n0_i n1_i)
 :precision binary32
 (+ (* (- 1.0 u) n0_i) (* (* (/ normAngle (sin normAngle)) u) n1_i)))
float code(float normAngle, float u, float n0_i, float n1_i) {
	return ((1.0f - u) * n0_i) + (((normAngle / sinf(normAngle)) * u) * n1_i);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(4) function code(normangle, u, n0_i, n1_i)
use fmin_fmax_functions
    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) + (((normangle / sin(normangle)) * u) * n1_i)
end function
function code(normAngle, u, n0_i, n1_i)
	return Float32(Float32(Float32(Float32(1.0) - u) * n0_i) + Float32(Float32(Float32(normAngle / sin(normAngle)) * u) * n1_i))
end
function tmp = code(normAngle, u, n0_i, n1_i)
	tmp = ((single(1.0) - u) * n0_i) + (((normAngle / sin(normAngle)) * u) * n1_i);
end
\begin{array}{l}

\\
\left(1 - u\right) \cdot n0\_i + \left(\frac{normAngle}{\sin normAngle} \cdot u\right) \cdot n1\_i
\end{array}
Derivation
  1. Initial program 95.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. 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.7

      \[\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.7%

    \[\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.7

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

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

Alternative 3: 70.6% accurate, 21.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n0\_i \leq -4.499999841417633 \cdot 10^{-25} \lor \neg \left(n0\_i \leq 4.999999999099794 \cdot 10^{-24}\right):\\ \;\;\;\;n0\_i - u \cdot n0\_i\\ \mathbf{else}:\\ \;\;\;\;n1\_i \cdot u\\ \end{array} \end{array} \]
(FPCore (normAngle u n0_i n1_i)
 :precision binary32
 (if (or (<= n0_i -4.499999841417633e-25)
         (not (<= n0_i 4.999999999099794e-24)))
   (- n0_i (* u n0_i))
   (* n1_i u)))
float code(float normAngle, float u, float n0_i, float n1_i) {
	float tmp;
	if ((n0_i <= -4.499999841417633e-25f) || !(n0_i <= 4.999999999099794e-24f)) {
		tmp = n0_i - (u * n0_i);
	} else {
		tmp = n1_i * u;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(4) function code(normangle, u, n0_i, n1_i)
use fmin_fmax_functions
    real(4), intent (in) :: normangle
    real(4), intent (in) :: u
    real(4), intent (in) :: n0_i
    real(4), intent (in) :: n1_i
    real(4) :: tmp
    if ((n0_i <= (-4.499999841417633e-25)) .or. (.not. (n0_i <= 4.999999999099794e-24))) then
        tmp = n0_i - (u * n0_i)
    else
        tmp = n1_i * u
    end if
    code = tmp
end function
function code(normAngle, u, n0_i, n1_i)
	tmp = Float32(0.0)
	if ((n0_i <= Float32(-4.499999841417633e-25)) || !(n0_i <= Float32(4.999999999099794e-24)))
		tmp = Float32(n0_i - Float32(u * n0_i));
	else
		tmp = Float32(n1_i * u);
	end
	return tmp
end
function tmp_2 = code(normAngle, u, n0_i, n1_i)
	tmp = single(0.0);
	if ((n0_i <= single(-4.499999841417633e-25)) || ~((n0_i <= single(4.999999999099794e-24))))
		tmp = n0_i - (u * n0_i);
	else
		tmp = n1_i * u;
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;n0\_i \leq -4.499999841417633 \cdot 10^{-25} \lor \neg \left(n0\_i \leq 4.999999999099794 \cdot 10^{-24}\right):\\
\;\;\;\;n0\_i - u \cdot n0\_i\\

\mathbf{else}:\\
\;\;\;\;n1\_i \cdot u\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if n0_i < -4.49999984e-25 or 5e-24 < n0_i

    1. Initial program 97.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. 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-*.f3219.8

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

      \[\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 + \left(-1 \cdot n0\_i + \frac{n0\_i}{u}\right)\right)} \]
    7. Step-by-step derivation
      1. Applied rewrites97.3%

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

        \[\leadsto u \cdot \left(\frac{n0\_i}{u} - \color{blue}{n0\_i}\right) \]
      3. Step-by-step derivation
        1. Applied rewrites76.0%

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

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

            \[\leadsto n0\_i - u \cdot n0\_i \]

          if -4.49999984e-25 < n0_i < 5e-24

          1. Initial program 93.2%

            \[\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 n0_i around 0

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

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

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

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

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

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

              \[\leadsto \sin \left(normAngle \cdot u\right) \cdot \color{blue}{\frac{n1\_i}{\sin normAngle}} \]
            7. lower-sin.f3269.1

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

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

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

              \[\leadsto n1\_i \cdot \color{blue}{u} \]
          8. Recombined 2 regimes into one program.
          9. Final simplification75.1%

            \[\leadsto \begin{array}{l} \mathbf{if}\;n0\_i \leq -4.499999841417633 \cdot 10^{-25} \lor \neg \left(n0\_i \leq 4.999999999099794 \cdot 10^{-24}\right):\\ \;\;\;\;n0\_i - u \cdot n0\_i\\ \mathbf{else}:\\ \;\;\;\;n1\_i \cdot u\\ \end{array} \]
          10. Add Preprocessing

          Alternative 4: 61.0% accurate, 25.4× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n0\_i \leq -2.9999999047965676 \cdot 10^{-22} \lor \neg \left(n0\_i \leq 4.999999999099794 \cdot 10^{-24}\right):\\ \;\;\;\;n0\_i\\ \mathbf{else}:\\ \;\;\;\;n1\_i \cdot u\\ \end{array} \end{array} \]
          (FPCore (normAngle u n0_i n1_i)
           :precision binary32
           (if (or (<= n0_i -2.9999999047965676e-22)
                   (not (<= n0_i 4.999999999099794e-24)))
             n0_i
             (* n1_i u)))
          float code(float normAngle, float u, float n0_i, float n1_i) {
          	float tmp;
          	if ((n0_i <= -2.9999999047965676e-22f) || !(n0_i <= 4.999999999099794e-24f)) {
          		tmp = n0_i;
          	} else {
          		tmp = n1_i * u;
          	}
          	return tmp;
          }
          
          module fmin_fmax_functions
              implicit none
              private
              public fmax
              public fmin
          
              interface fmax
                  module procedure fmax88
                  module procedure fmax44
                  module procedure fmax84
                  module procedure fmax48
              end interface
              interface fmin
                  module procedure fmin88
                  module procedure fmin44
                  module procedure fmin84
                  module procedure fmin48
              end interface
          contains
              real(8) function fmax88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(4) function fmax44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(8) function fmax84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmax48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
              end function
              real(8) function fmin88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(4) function fmin44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(8) function fmin84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmin48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
              end function
          end module
          
          real(4) function code(normangle, u, n0_i, n1_i)
          use fmin_fmax_functions
              real(4), intent (in) :: normangle
              real(4), intent (in) :: u
              real(4), intent (in) :: n0_i
              real(4), intent (in) :: n1_i
              real(4) :: tmp
              if ((n0_i <= (-2.9999999047965676e-22)) .or. (.not. (n0_i <= 4.999999999099794e-24))) then
                  tmp = n0_i
              else
                  tmp = n1_i * u
              end if
              code = tmp
          end function
          
          function code(normAngle, u, n0_i, n1_i)
          	tmp = Float32(0.0)
          	if ((n0_i <= Float32(-2.9999999047965676e-22)) || !(n0_i <= Float32(4.999999999099794e-24)))
          		tmp = n0_i;
          	else
          		tmp = Float32(n1_i * u);
          	end
          	return tmp
          end
          
          function tmp_2 = code(normAngle, u, n0_i, n1_i)
          	tmp = single(0.0);
          	if ((n0_i <= single(-2.9999999047965676e-22)) || ~((n0_i <= single(4.999999999099794e-24))))
          		tmp = n0_i;
          	else
          		tmp = n1_i * u;
          	end
          	tmp_2 = tmp;
          end
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;n0\_i \leq -2.9999999047965676 \cdot 10^{-22} \lor \neg \left(n0\_i \leq 4.999999999099794 \cdot 10^{-24}\right):\\
          \;\;\;\;n0\_i\\
          
          \mathbf{else}:\\
          \;\;\;\;n1\_i \cdot u\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if n0_i < -2.9999999e-22 or 5e-24 < n0_i

            1. Initial program 98.3%

              \[\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}{\left(1 - u\right)} \cdot n0\_i + \left(\sin \left(u \cdot normAngle\right) \cdot \frac{1}{\sin normAngle}\right) \cdot n1\_i \]
            4. Step-by-step derivation
              1. lower--.f3297.4

                \[\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 \]
            5. Applied rewrites97.4%

              \[\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 \]
            6. Step-by-step derivation
              1. lift-*.f32N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \left(1 - u\right) \cdot n0\_i + \frac{\sin \left(\mathsf{fma}\left(normAngle, u, \mathsf{PI}\left(\right)\right)\right)}{\mathsf{neg}\left(\color{blue}{\sin normAngle}\right)} \cdot n1\_i \]
              15. sin-neg-revN/A

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

                \[\leadsto \left(1 - u\right) \cdot n0\_i + \frac{\sin \left(\mathsf{fma}\left(normAngle, u, \mathsf{PI}\left(\right)\right)\right)}{\color{blue}{\sin \left(\mathsf{neg}\left(normAngle\right)\right)}} \cdot n1\_i \]
              17. lower-neg.f3237.6

                \[\leadsto \left(1 - u\right) \cdot n0\_i + \frac{\sin \left(\mathsf{fma}\left(normAngle, u, \mathsf{PI}\left(\right)\right)\right)}{\sin \color{blue}{\left(-normAngle\right)}} \cdot n1\_i \]
            7. Applied rewrites37.5%

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

              \[\leadsto \color{blue}{n0\_i + \frac{n1\_i \cdot \sin \mathsf{PI}\left(\right)}{\sin \left(\mathsf{neg}\left(normAngle\right)\right)}} \]
            9. Step-by-step derivation
              1. associate-/l*N/A

                \[\leadsto n0\_i + \color{blue}{n1\_i \cdot \frac{\sin \mathsf{PI}\left(\right)}{\sin \left(\mathsf{neg}\left(normAngle\right)\right)}} \]
              2. fp-cancel-sign-sub-invN/A

                \[\leadsto \color{blue}{n0\_i - \left(\mathsf{neg}\left(n1\_i\right)\right) \cdot \frac{\sin \mathsf{PI}\left(\right)}{\sin \left(\mathsf{neg}\left(normAngle\right)\right)}} \]
              3. mul-1-negN/A

                \[\leadsto n0\_i - \color{blue}{\left(-1 \cdot n1\_i\right)} \cdot \frac{\sin \mathsf{PI}\left(\right)}{\sin \left(\mathsf{neg}\left(normAngle\right)\right)} \]
              4. sin-PIN/A

                \[\leadsto n0\_i - \left(-1 \cdot n1\_i\right) \cdot \frac{\color{blue}{0}}{\sin \left(\mathsf{neg}\left(normAngle\right)\right)} \]
              5. div0N/A

                \[\leadsto n0\_i - \left(-1 \cdot n1\_i\right) \cdot \color{blue}{0} \]
              6. mul0-rgtN/A

                \[\leadsto n0\_i - \color{blue}{0} \]
              7. sin-PIN/A

                \[\leadsto n0\_i - \color{blue}{\sin \mathsf{PI}\left(\right)} \]
              8. lower--.f32N/A

                \[\leadsto \color{blue}{n0\_i - \sin \mathsf{PI}\left(\right)} \]
              9. sin-PI60.0

                \[\leadsto n0\_i - \color{blue}{0} \]
            10. Applied rewrites60.0%

              \[\leadsto \color{blue}{n0\_i - 0} \]

            if -2.9999999e-22 < n0_i < 5e-24

            1. Initial program 93.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. Add Preprocessing
            3. Taylor expanded in n0_i around 0

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

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

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

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

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

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

                \[\leadsto \sin \left(normAngle \cdot u\right) \cdot \color{blue}{\frac{n1\_i}{\sin normAngle}} \]
              7. lower-sin.f3266.8

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

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

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

                \[\leadsto n1\_i \cdot \color{blue}{u} \]
            8. Recombined 2 regimes into one program.
            9. Final simplification64.6%

              \[\leadsto \begin{array}{l} \mathbf{if}\;n0\_i \leq -2.9999999047965676 \cdot 10^{-22} \lor \neg \left(n0\_i \leq 4.999999999099794 \cdot 10^{-24}\right):\\ \;\;\;\;n0\_i\\ \mathbf{else}:\\ \;\;\;\;n1\_i \cdot u\\ \end{array} \]
            10. Add Preprocessing

            Alternative 5: 97.8% accurate, 27.0× speedup?

            \[\begin{array}{l} \\ n1\_i \cdot u + n0\_i \cdot \left(1 - u\right) \end{array} \]
            (FPCore (normAngle u n0_i n1_i)
             :precision binary32
             (+ (* n1_i u) (* n0_i (- 1.0 u))))
            float code(float normAngle, float u, float n0_i, float n1_i) {
            	return (n1_i * u) + (n0_i * (1.0f - u));
            }
            
            module fmin_fmax_functions
                implicit none
                private
                public fmax
                public fmin
            
                interface fmax
                    module procedure fmax88
                    module procedure fmax44
                    module procedure fmax84
                    module procedure fmax48
                end interface
                interface fmin
                    module procedure fmin88
                    module procedure fmin44
                    module procedure fmin84
                    module procedure fmin48
                end interface
            contains
                real(8) function fmax88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(4) function fmax44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(8) function fmax84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmax48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                end function
                real(8) function fmin88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(4) function fmin44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(8) function fmin84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmin48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                end function
            end module
            
            real(4) function code(normangle, u, n0_i, n1_i)
            use fmin_fmax_functions
                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) + (n0_i * (1.0e0 - u))
            end function
            
            function code(normAngle, u, n0_i, n1_i)
            	return Float32(Float32(n1_i * u) + Float32(n0_i * Float32(Float32(1.0) - u)))
            end
            
            function tmp = code(normAngle, u, n0_i, n1_i)
            	tmp = (n1_i * u) + (n0_i * (single(1.0) - u));
            end
            
            \begin{array}{l}
            
            \\
            n1\_i \cdot u + n0\_i \cdot \left(1 - u\right)
            \end{array}
            
            Derivation
            1. Initial program 95.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. 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-*.f3241.3

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

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

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

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

              Alternative 6: 47.3% accurate, 459.0× speedup?

              \[\begin{array}{l} \\ n0\_i \end{array} \]
              (FPCore (normAngle u n0_i n1_i) :precision binary32 n0_i)
              float code(float normAngle, float u, float n0_i, float n1_i) {
              	return n0_i;
              }
              
              module fmin_fmax_functions
                  implicit none
                  private
                  public fmax
                  public fmin
              
                  interface fmax
                      module procedure fmax88
                      module procedure fmax44
                      module procedure fmax84
                      module procedure fmax48
                  end interface
                  interface fmin
                      module procedure fmin88
                      module procedure fmin44
                      module procedure fmin84
                      module procedure fmin48
                  end interface
              contains
                  real(8) function fmax88(x, y) result (res)
                      real(8), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                  end function
                  real(4) function fmax44(x, y) result (res)
                      real(4), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                  end function
                  real(8) function fmax84(x, y) result(res)
                      real(8), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                  end function
                  real(8) function fmax48(x, y) result(res)
                      real(4), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                  end function
                  real(8) function fmin88(x, y) result (res)
                      real(8), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                  end function
                  real(4) function fmin44(x, y) result (res)
                      real(4), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                  end function
                  real(8) function fmin84(x, y) result(res)
                      real(8), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                  end function
                  real(8) function fmin48(x, y) result(res)
                      real(4), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                  end function
              end module
              
              real(4) function code(normangle, u, n0_i, n1_i)
              use fmin_fmax_functions
                  real(4), intent (in) :: normangle
                  real(4), intent (in) :: u
                  real(4), intent (in) :: n0_i
                  real(4), intent (in) :: n1_i
                  code = n0_i
              end function
              
              function code(normAngle, u, n0_i, n1_i)
              	return n0_i
              end
              
              function tmp = code(normAngle, u, n0_i, n1_i)
              	tmp = n0_i;
              end
              
              \begin{array}{l}
              
              \\
              n0\_i
              \end{array}
              
              Derivation
              1. Initial program 95.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. Add Preprocessing
              3. Taylor expanded in normAngle around 0

                \[\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 \]
              4. Step-by-step derivation
                1. lower--.f3295.4

                  \[\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 \]
              5. Applied rewrites95.4%

                \[\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 \]
              6. Step-by-step derivation
                1. lift-*.f32N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \left(1 - u\right) \cdot n0\_i + \frac{\sin \left(\mathsf{fma}\left(normAngle, u, \mathsf{PI}\left(\right)\right)\right)}{\mathsf{neg}\left(\color{blue}{\sin normAngle}\right)} \cdot n1\_i \]
                15. sin-neg-revN/A

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

                  \[\leadsto \left(1 - u\right) \cdot n0\_i + \frac{\sin \left(\mathsf{fma}\left(normAngle, u, \mathsf{PI}\left(\right)\right)\right)}{\color{blue}{\sin \left(\mathsf{neg}\left(normAngle\right)\right)}} \cdot n1\_i \]
                17. lower-neg.f3227.1

                  \[\leadsto \left(1 - u\right) \cdot n0\_i + \frac{\sin \left(\mathsf{fma}\left(normAngle, u, \mathsf{PI}\left(\right)\right)\right)}{\sin \color{blue}{\left(-normAngle\right)}} \cdot n1\_i \]
              7. Applied rewrites27.0%

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

                \[\leadsto \color{blue}{n0\_i + \frac{n1\_i \cdot \sin \mathsf{PI}\left(\right)}{\sin \left(\mathsf{neg}\left(normAngle\right)\right)}} \]
              9. Step-by-step derivation
                1. associate-/l*N/A

                  \[\leadsto n0\_i + \color{blue}{n1\_i \cdot \frac{\sin \mathsf{PI}\left(\right)}{\sin \left(\mathsf{neg}\left(normAngle\right)\right)}} \]
                2. fp-cancel-sign-sub-invN/A

                  \[\leadsto \color{blue}{n0\_i - \left(\mathsf{neg}\left(n1\_i\right)\right) \cdot \frac{\sin \mathsf{PI}\left(\right)}{\sin \left(\mathsf{neg}\left(normAngle\right)\right)}} \]
                3. mul-1-negN/A

                  \[\leadsto n0\_i - \color{blue}{\left(-1 \cdot n1\_i\right)} \cdot \frac{\sin \mathsf{PI}\left(\right)}{\sin \left(\mathsf{neg}\left(normAngle\right)\right)} \]
                4. sin-PIN/A

                  \[\leadsto n0\_i - \left(-1 \cdot n1\_i\right) \cdot \frac{\color{blue}{0}}{\sin \left(\mathsf{neg}\left(normAngle\right)\right)} \]
                5. div0N/A

                  \[\leadsto n0\_i - \left(-1 \cdot n1\_i\right) \cdot \color{blue}{0} \]
                6. mul0-rgtN/A

                  \[\leadsto n0\_i - \color{blue}{0} \]
                7. sin-PIN/A

                  \[\leadsto n0\_i - \color{blue}{\sin \mathsf{PI}\left(\right)} \]
                8. lower--.f32N/A

                  \[\leadsto \color{blue}{n0\_i - \sin \mathsf{PI}\left(\right)} \]
                9. sin-PI43.7

                  \[\leadsto n0\_i - \color{blue}{0} \]
              10. Applied rewrites43.7%

                \[\leadsto \color{blue}{n0\_i - 0} \]
              11. Final simplification43.7%

                \[\leadsto n0\_i \]
              12. Add Preprocessing

              Alternative 7: 9.0% accurate, 459.0× speedup?

              \[\begin{array}{l} \\ 0 \end{array} \]
              (FPCore (normAngle u n0_i n1_i) :precision binary32 0.0)
              float code(float normAngle, float u, float n0_i, float n1_i) {
              	return 0.0f;
              }
              
              module fmin_fmax_functions
                  implicit none
                  private
                  public fmax
                  public fmin
              
                  interface fmax
                      module procedure fmax88
                      module procedure fmax44
                      module procedure fmax84
                      module procedure fmax48
                  end interface
                  interface fmin
                      module procedure fmin88
                      module procedure fmin44
                      module procedure fmin84
                      module procedure fmin48
                  end interface
              contains
                  real(8) function fmax88(x, y) result (res)
                      real(8), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                  end function
                  real(4) function fmax44(x, y) result (res)
                      real(4), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                  end function
                  real(8) function fmax84(x, y) result(res)
                      real(8), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                  end function
                  real(8) function fmax48(x, y) result(res)
                      real(4), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                  end function
                  real(8) function fmin88(x, y) result (res)
                      real(8), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                  end function
                  real(4) function fmin44(x, y) result (res)
                      real(4), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                  end function
                  real(8) function fmin84(x, y) result(res)
                      real(8), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                  end function
                  real(8) function fmin48(x, y) result(res)
                      real(4), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                  end function
              end module
              
              real(4) function code(normangle, u, n0_i, n1_i)
              use fmin_fmax_functions
                  real(4), intent (in) :: normangle
                  real(4), intent (in) :: u
                  real(4), intent (in) :: n0_i
                  real(4), intent (in) :: n1_i
                  code = 0.0e0
              end function
              
              function code(normAngle, u, n0_i, n1_i)
              	return Float32(0.0)
              end
              
              function tmp = code(normAngle, u, n0_i, n1_i)
              	tmp = single(0.0);
              end
              
              \begin{array}{l}
              
              \\
              0
              \end{array}
              
              Derivation
              1. Initial program 95.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. Add Preprocessing
              3. Taylor expanded in normAngle around 0

                \[\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 \]
              4. Step-by-step derivation
                1. lower--.f3295.4

                  \[\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 \]
              5. Applied rewrites95.4%

                \[\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 \]
              6. Step-by-step derivation
                1. lift-*.f32N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \left(1 - u\right) \cdot n0\_i + \frac{\sin \left(\mathsf{fma}\left(normAngle, u, \mathsf{PI}\left(\right)\right)\right)}{\mathsf{neg}\left(\color{blue}{\sin normAngle}\right)} \cdot n1\_i \]
                15. sin-neg-revN/A

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

                  \[\leadsto \left(1 - u\right) \cdot n0\_i + \frac{\sin \left(\mathsf{fma}\left(normAngle, u, \mathsf{PI}\left(\right)\right)\right)}{\color{blue}{\sin \left(\mathsf{neg}\left(normAngle\right)\right)}} \cdot n1\_i \]
                17. lower-neg.f3227.2

                  \[\leadsto \left(1 - u\right) \cdot n0\_i + \frac{\sin \left(\mathsf{fma}\left(normAngle, u, \mathsf{PI}\left(\right)\right)\right)}{\sin \color{blue}{\left(-normAngle\right)}} \cdot n1\_i \]
              7. Applied rewrites26.9%

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

                \[\leadsto \color{blue}{-1 \cdot \frac{n1\_i \cdot \sin \mathsf{PI}\left(\right)}{normAngle}} \]
              9. Step-by-step derivation
                1. mul-1-negN/A

                  \[\leadsto \color{blue}{\mathsf{neg}\left(\frac{n1\_i \cdot \sin \mathsf{PI}\left(\right)}{normAngle}\right)} \]
                2. associate-/l*N/A

                  \[\leadsto \mathsf{neg}\left(\color{blue}{n1\_i \cdot \frac{\sin \mathsf{PI}\left(\right)}{normAngle}}\right) \]
                3. distribute-rgt-neg-inN/A

                  \[\leadsto \color{blue}{n1\_i \cdot \left(\mathsf{neg}\left(\frac{\sin \mathsf{PI}\left(\right)}{normAngle}\right)\right)} \]
                4. distribute-neg-fracN/A

                  \[\leadsto n1\_i \cdot \color{blue}{\frac{\mathsf{neg}\left(\sin \mathsf{PI}\left(\right)\right)}{normAngle}} \]
                5. sin-PIN/A

                  \[\leadsto n1\_i \cdot \frac{\mathsf{neg}\left(\color{blue}{0}\right)}{normAngle} \]
                6. metadata-evalN/A

                  \[\leadsto n1\_i \cdot \frac{\color{blue}{0}}{normAngle} \]
                7. div0N/A

                  \[\leadsto n1\_i \cdot \color{blue}{0} \]
                8. mul0-rgt9.0

                  \[\leadsto \color{blue}{0} \]
              10. Applied rewrites9.0%

                \[\leadsto \color{blue}{0} \]
              11. Add Preprocessing

              Reproduce

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