HairBSDF, Mp, upper

Percentage Accurate: 98.6% → 98.8%
Time: 12.8s
Alternatives: 15
Speedup: 1.8×

Specification

?
\[\left(\left(\left(\left(\left(-1 \leq cosTheta\_i \land cosTheta\_i \leq 1\right) \land \left(-1 \leq cosTheta\_O \land cosTheta\_O \leq 1\right)\right) \land \left(-1 \leq sinTheta\_i \land sinTheta\_i \leq 1\right)\right) \land \left(-1 \leq sinTheta\_O \land sinTheta\_O \leq 1\right)\right) \land 0.1 < v\right) \land v \leq 1.5707964\]
\[\begin{array}{l} \\ \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \end{array} \]
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
 :precision binary32
 (/
  (* (exp (- (/ (* sinTheta_i sinTheta_O) v))) (/ (* cosTheta_i cosTheta_O) v))
  (* (* (sinh (/ 1.0 v)) 2.0) v)))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
	return (expf(-((sinTheta_i * sinTheta_O) / v)) * ((cosTheta_i * cosTheta_O) / v)) / ((sinhf((1.0f / v)) * 2.0f) * v);
}
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(costheta_i, costheta_o, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
    real(4), intent (in) :: costheta_i
    real(4), intent (in) :: costheta_o
    real(4), intent (in) :: sintheta_i
    real(4), intent (in) :: sintheta_o
    real(4), intent (in) :: v
    code = (exp(-((sintheta_i * sintheta_o) / v)) * ((costheta_i * costheta_o) / v)) / ((sinh((1.0e0 / v)) * 2.0e0) * v)
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
	return Float32(Float32(exp(Float32(-Float32(Float32(sinTheta_i * sinTheta_O) / v))) * Float32(Float32(cosTheta_i * cosTheta_O) / v)) / Float32(Float32(sinh(Float32(Float32(1.0) / v)) * Float32(2.0)) * v))
end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
	tmp = (exp(-((sinTheta_i * sinTheta_O) / v)) * ((cosTheta_i * cosTheta_O) / v)) / ((sinh((single(1.0) / v)) * single(2.0)) * v);
end
\begin{array}{l}

\\
\frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}
\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 15 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: 98.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \end{array} \]
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
 :precision binary32
 (/
  (* (exp (- (/ (* sinTheta_i sinTheta_O) v))) (/ (* cosTheta_i cosTheta_O) v))
  (* (* (sinh (/ 1.0 v)) 2.0) v)))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
	return (expf(-((sinTheta_i * sinTheta_O) / v)) * ((cosTheta_i * cosTheta_O) / v)) / ((sinhf((1.0f / v)) * 2.0f) * v);
}
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(costheta_i, costheta_o, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
    real(4), intent (in) :: costheta_i
    real(4), intent (in) :: costheta_o
    real(4), intent (in) :: sintheta_i
    real(4), intent (in) :: sintheta_o
    real(4), intent (in) :: v
    code = (exp(-((sintheta_i * sintheta_o) / v)) * ((costheta_i * costheta_o) / v)) / ((sinh((1.0e0 / v)) * 2.0e0) * v)
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
	return Float32(Float32(exp(Float32(-Float32(Float32(sinTheta_i * sinTheta_O) / v))) * Float32(Float32(cosTheta_i * cosTheta_O) / v)) / Float32(Float32(sinh(Float32(Float32(1.0) / v)) * Float32(2.0)) * v))
end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
	tmp = (exp(-((sinTheta_i * sinTheta_O) / v)) * ((cosTheta_i * cosTheta_O) / v)) / ((sinh((single(1.0) / v)) * single(2.0)) * v);
end
\begin{array}{l}

\\
\frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}
\end{array}

Alternative 1: 98.8% accurate, 0.7× speedup?

\[\begin{array}{l} cosTheta_i\_m = \left|cosTheta\_i\right| \\ cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right) \\ [cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])\\ \\ cosTheta\_i\_s \cdot \left(\frac{\frac{{\left(e^{sinTheta\_O}\right)}^{\left(\frac{-sinTheta\_i}{v}\right)}}{-2 \cdot v} \cdot \frac{cosTheta\_i\_m}{v}}{\sinh \left(\frac{-1}{v}\right)} \cdot cosTheta\_O\right) \end{array} \]
cosTheta_i\_m = (fabs.f32 cosTheta_i)
cosTheta_i\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_i)
NOTE: cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
(FPCore (cosTheta_i_s cosTheta_i_m cosTheta_O sinTheta_i sinTheta_O v)
 :precision binary32
 (*
  cosTheta_i_s
  (*
   (/
    (*
     (/ (pow (exp sinTheta_O) (/ (- sinTheta_i) v)) (* -2.0 v))
     (/ cosTheta_i_m v))
    (sinh (/ -1.0 v)))
   cosTheta_O)))
cosTheta_i\_m = fabs(cosTheta_i);
cosTheta_i\_s = copysign(1.0, cosTheta_i);
assert(cosTheta_i_m < cosTheta_O && cosTheta_O < sinTheta_i && sinTheta_i < sinTheta_O && sinTheta_O < v);
float code(float cosTheta_i_s, float cosTheta_i_m, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
	return cosTheta_i_s * ((((powf(expf(sinTheta_O), (-sinTheta_i / v)) / (-2.0f * v)) * (cosTheta_i_m / v)) / sinhf((-1.0f / v))) * cosTheta_O);
}
cosTheta_i\_m =     private
cosTheta_i\_s =     private
NOTE: cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
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(costheta_i_s, costheta_i_m, costheta_o, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
    real(4), intent (in) :: costheta_i_s
    real(4), intent (in) :: costheta_i_m
    real(4), intent (in) :: costheta_o
    real(4), intent (in) :: sintheta_i
    real(4), intent (in) :: sintheta_o
    real(4), intent (in) :: v
    code = costheta_i_s * (((((exp(sintheta_o) ** (-sintheta_i / v)) / ((-2.0e0) * v)) * (costheta_i_m / v)) / sinh(((-1.0e0) / v))) * costheta_o)
end function
cosTheta_i\_m = abs(cosTheta_i)
cosTheta_i\_s = copysign(1.0, cosTheta_i)
cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v = sort([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])
function code(cosTheta_i_s, cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v)
	return Float32(cosTheta_i_s * Float32(Float32(Float32(Float32((exp(sinTheta_O) ^ Float32(Float32(-sinTheta_i) / v)) / Float32(Float32(-2.0) * v)) * Float32(cosTheta_i_m / v)) / sinh(Float32(Float32(-1.0) / v))) * cosTheta_O))
end
cosTheta_i\_m = abs(cosTheta_i);
cosTheta_i\_s = sign(cosTheta_i) * abs(1.0);
cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v = num2cell(sort([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])){:}
function tmp = code(cosTheta_i_s, cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v)
	tmp = cosTheta_i_s * (((((exp(sinTheta_O) ^ (-sinTheta_i / v)) / (single(-2.0) * v)) * (cosTheta_i_m / v)) / sinh((single(-1.0) / v))) * cosTheta_O);
end
\begin{array}{l}
cosTheta_i\_m = \left|cosTheta\_i\right|
\\
cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right)
\\
[cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])\\
\\
cosTheta\_i\_s \cdot \left(\frac{\frac{{\left(e^{sinTheta\_O}\right)}^{\left(\frac{-sinTheta\_i}{v}\right)}}{-2 \cdot v} \cdot \frac{cosTheta\_i\_m}{v}}{\sinh \left(\frac{-1}{v}\right)} \cdot cosTheta\_O\right)
\end{array}
Derivation
  1. Initial program 98.5%

    \[\frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-/.f32N/A

      \[\leadsto \color{blue}{\frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}} \]
    2. lift-*.f32N/A

      \[\leadsto \frac{\color{blue}{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
    3. *-commutativeN/A

      \[\leadsto \frac{\color{blue}{\frac{cosTheta\_i \cdot cosTheta\_O}{v} \cdot e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
    4. associate-/l*N/A

      \[\leadsto \color{blue}{\frac{cosTheta\_i \cdot cosTheta\_O}{v} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}} \]
    5. lift-/.f32N/A

      \[\leadsto \color{blue}{\frac{cosTheta\_i \cdot cosTheta\_O}{v}} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
    6. lift-*.f32N/A

      \[\leadsto \frac{\color{blue}{cosTheta\_i \cdot cosTheta\_O}}{v} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
    7. *-commutativeN/A

      \[\leadsto \frac{\color{blue}{cosTheta\_O \cdot cosTheta\_i}}{v} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
    8. associate-/l*N/A

      \[\leadsto \color{blue}{\left(cosTheta\_O \cdot \frac{cosTheta\_i}{v}\right)} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
    9. associate-*l*N/A

      \[\leadsto \color{blue}{cosTheta\_O \cdot \left(\frac{cosTheta\_i}{v} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}\right)} \]
    10. lower-*.f32N/A

      \[\leadsto \color{blue}{cosTheta\_O \cdot \left(\frac{cosTheta\_i}{v} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}\right)} \]
    11. lower-*.f32N/A

      \[\leadsto cosTheta\_O \cdot \color{blue}{\left(\frac{cosTheta\_i}{v} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}\right)} \]
    12. lower-/.f32N/A

      \[\leadsto cosTheta\_O \cdot \left(\color{blue}{\frac{cosTheta\_i}{v}} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}\right) \]
    13. lift-*.f32N/A

      \[\leadsto cosTheta\_O \cdot \left(\frac{cosTheta\_i}{v} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\color{blue}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}}\right) \]
    14. lift-*.f32N/A

      \[\leadsto cosTheta\_O \cdot \left(\frac{cosTheta\_i}{v} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\color{blue}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right)} \cdot v}\right) \]
    15. associate-*l*N/A

      \[\leadsto cosTheta\_O \cdot \left(\frac{cosTheta\_i}{v} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\color{blue}{\sinh \left(\frac{1}{v}\right) \cdot \left(2 \cdot v\right)}}\right) \]
  4. Applied rewrites98.9%

    \[\leadsto \color{blue}{cosTheta\_O \cdot \left(\frac{cosTheta\_i}{v} \cdot \frac{\frac{{\left(e^{sinTheta\_O}\right)}^{\left(\frac{-sinTheta\_i}{v}\right)}}{2 \cdot v}}{\sinh \left(\frac{1}{v}\right)}\right)} \]
  5. Step-by-step derivation
    1. lift-*.f32N/A

      \[\leadsto \color{blue}{cosTheta\_O \cdot \left(\frac{cosTheta\_i}{v} \cdot \frac{\frac{{\left(e^{sinTheta\_O}\right)}^{\left(\frac{-sinTheta\_i}{v}\right)}}{2 \cdot v}}{\sinh \left(\frac{1}{v}\right)}\right)} \]
    2. *-commutativeN/A

      \[\leadsto \color{blue}{\left(\frac{cosTheta\_i}{v} \cdot \frac{\frac{{\left(e^{sinTheta\_O}\right)}^{\left(\frac{-sinTheta\_i}{v}\right)}}{2 \cdot v}}{\sinh \left(\frac{1}{v}\right)}\right) \cdot cosTheta\_O} \]
    3. lower-*.f3298.9

      \[\leadsto \color{blue}{\left(\frac{cosTheta\_i}{v} \cdot \frac{\frac{{\left(e^{sinTheta\_O}\right)}^{\left(\frac{-sinTheta\_i}{v}\right)}}{2 \cdot v}}{\sinh \left(\frac{1}{v}\right)}\right) \cdot cosTheta\_O} \]
  6. Applied rewrites98.9%

    \[\leadsto \color{blue}{\frac{\frac{{\left(e^{sinTheta\_O}\right)}^{\left(\frac{-sinTheta\_i}{v}\right)}}{-2 \cdot v} \cdot \frac{cosTheta\_i}{v}}{\sinh \left(\frac{-1}{v}\right)} \cdot cosTheta\_O} \]
  7. Add Preprocessing

Alternative 2: 98.8% accurate, 0.7× speedup?

\[\begin{array}{l} cosTheta_i\_m = \left|cosTheta\_i\right| \\ cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right) \\ [cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])\\ \\ cosTheta\_i\_s \cdot \left(\frac{cosTheta\_O}{\sinh \left(\frac{1}{v}\right) \cdot v} \cdot \left(\frac{{\left(e^{sinTheta\_i}\right)}^{\left(\frac{-sinTheta\_O}{v}\right)}}{2 \cdot v} \cdot cosTheta\_i\_m\right)\right) \end{array} \]
cosTheta_i\_m = (fabs.f32 cosTheta_i)
cosTheta_i\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_i)
NOTE: cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
(FPCore (cosTheta_i_s cosTheta_i_m cosTheta_O sinTheta_i sinTheta_O v)
 :precision binary32
 (*
  cosTheta_i_s
  (*
   (/ cosTheta_O (* (sinh (/ 1.0 v)) v))
   (*
    (/ (pow (exp sinTheta_i) (/ (- sinTheta_O) v)) (* 2.0 v))
    cosTheta_i_m))))
cosTheta_i\_m = fabs(cosTheta_i);
cosTheta_i\_s = copysign(1.0, cosTheta_i);
assert(cosTheta_i_m < cosTheta_O && cosTheta_O < sinTheta_i && sinTheta_i < sinTheta_O && sinTheta_O < v);
float code(float cosTheta_i_s, float cosTheta_i_m, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
	return cosTheta_i_s * ((cosTheta_O / (sinhf((1.0f / v)) * v)) * ((powf(expf(sinTheta_i), (-sinTheta_O / v)) / (2.0f * v)) * cosTheta_i_m));
}
cosTheta_i\_m =     private
cosTheta_i\_s =     private
NOTE: cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
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(costheta_i_s, costheta_i_m, costheta_o, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
    real(4), intent (in) :: costheta_i_s
    real(4), intent (in) :: costheta_i_m
    real(4), intent (in) :: costheta_o
    real(4), intent (in) :: sintheta_i
    real(4), intent (in) :: sintheta_o
    real(4), intent (in) :: v
    code = costheta_i_s * ((costheta_o / (sinh((1.0e0 / v)) * v)) * (((exp(sintheta_i) ** (-sintheta_o / v)) / (2.0e0 * v)) * costheta_i_m))
end function
cosTheta_i\_m = abs(cosTheta_i)
cosTheta_i\_s = copysign(1.0, cosTheta_i)
cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v = sort([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])
function code(cosTheta_i_s, cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v)
	return Float32(cosTheta_i_s * Float32(Float32(cosTheta_O / Float32(sinh(Float32(Float32(1.0) / v)) * v)) * Float32(Float32((exp(sinTheta_i) ^ Float32(Float32(-sinTheta_O) / v)) / Float32(Float32(2.0) * v)) * cosTheta_i_m)))
end
cosTheta_i\_m = abs(cosTheta_i);
cosTheta_i\_s = sign(cosTheta_i) * abs(1.0);
cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v = num2cell(sort([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])){:}
function tmp = code(cosTheta_i_s, cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v)
	tmp = cosTheta_i_s * ((cosTheta_O / (sinh((single(1.0) / v)) * v)) * (((exp(sinTheta_i) ^ (-sinTheta_O / v)) / (single(2.0) * v)) * cosTheta_i_m));
end
\begin{array}{l}
cosTheta_i\_m = \left|cosTheta\_i\right|
\\
cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right)
\\
[cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])\\
\\
cosTheta\_i\_s \cdot \left(\frac{cosTheta\_O}{\sinh \left(\frac{1}{v}\right) \cdot v} \cdot \left(\frac{{\left(e^{sinTheta\_i}\right)}^{\left(\frac{-sinTheta\_O}{v}\right)}}{2 \cdot v} \cdot cosTheta\_i\_m\right)\right)
\end{array}
Derivation
  1. Initial program 98.5%

    \[\frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-/.f32N/A

      \[\leadsto \color{blue}{\frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}} \]
    2. lift-*.f32N/A

      \[\leadsto \frac{\color{blue}{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
    3. *-commutativeN/A

      \[\leadsto \frac{\color{blue}{\frac{cosTheta\_i \cdot cosTheta\_O}{v} \cdot e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
    4. associate-/l*N/A

      \[\leadsto \color{blue}{\frac{cosTheta\_i \cdot cosTheta\_O}{v} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}} \]
    5. lift-/.f32N/A

      \[\leadsto \color{blue}{\frac{cosTheta\_i \cdot cosTheta\_O}{v}} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
    6. lift-*.f32N/A

      \[\leadsto \frac{\color{blue}{cosTheta\_i \cdot cosTheta\_O}}{v} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
    7. *-commutativeN/A

      \[\leadsto \frac{\color{blue}{cosTheta\_O \cdot cosTheta\_i}}{v} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
    8. associate-/l*N/A

      \[\leadsto \color{blue}{\left(cosTheta\_O \cdot \frac{cosTheta\_i}{v}\right)} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
    9. associate-*l*N/A

      \[\leadsto \color{blue}{cosTheta\_O \cdot \left(\frac{cosTheta\_i}{v} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}\right)} \]
    10. lower-*.f32N/A

      \[\leadsto \color{blue}{cosTheta\_O \cdot \left(\frac{cosTheta\_i}{v} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}\right)} \]
    11. lower-*.f32N/A

      \[\leadsto cosTheta\_O \cdot \color{blue}{\left(\frac{cosTheta\_i}{v} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}\right)} \]
    12. lower-/.f32N/A

      \[\leadsto cosTheta\_O \cdot \left(\color{blue}{\frac{cosTheta\_i}{v}} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}\right) \]
    13. lift-*.f32N/A

      \[\leadsto cosTheta\_O \cdot \left(\frac{cosTheta\_i}{v} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\color{blue}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}}\right) \]
    14. lift-*.f32N/A

      \[\leadsto cosTheta\_O \cdot \left(\frac{cosTheta\_i}{v} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\color{blue}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right)} \cdot v}\right) \]
    15. associate-*l*N/A

      \[\leadsto cosTheta\_O \cdot \left(\frac{cosTheta\_i}{v} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\color{blue}{\sinh \left(\frac{1}{v}\right) \cdot \left(2 \cdot v\right)}}\right) \]
  4. Applied rewrites98.9%

    \[\leadsto \color{blue}{cosTheta\_O \cdot \left(\frac{cosTheta\_i}{v} \cdot \frac{\frac{{\left(e^{sinTheta\_O}\right)}^{\left(\frac{-sinTheta\_i}{v}\right)}}{2 \cdot v}}{\sinh \left(\frac{1}{v}\right)}\right)} \]
  5. Step-by-step derivation
    1. lift-*.f32N/A

      \[\leadsto \color{blue}{cosTheta\_O \cdot \left(\frac{cosTheta\_i}{v} \cdot \frac{\frac{{\left(e^{sinTheta\_O}\right)}^{\left(\frac{-sinTheta\_i}{v}\right)}}{2 \cdot v}}{\sinh \left(\frac{1}{v}\right)}\right)} \]
    2. *-commutativeN/A

      \[\leadsto \color{blue}{\left(\frac{cosTheta\_i}{v} \cdot \frac{\frac{{\left(e^{sinTheta\_O}\right)}^{\left(\frac{-sinTheta\_i}{v}\right)}}{2 \cdot v}}{\sinh \left(\frac{1}{v}\right)}\right) \cdot cosTheta\_O} \]
    3. lower-*.f3298.9

      \[\leadsto \color{blue}{\left(\frac{cosTheta\_i}{v} \cdot \frac{\frac{{\left(e^{sinTheta\_O}\right)}^{\left(\frac{-sinTheta\_i}{v}\right)}}{2 \cdot v}}{\sinh \left(\frac{1}{v}\right)}\right) \cdot cosTheta\_O} \]
  6. Applied rewrites98.9%

    \[\leadsto \color{blue}{\frac{\frac{{\left(e^{sinTheta\_O}\right)}^{\left(\frac{-sinTheta\_i}{v}\right)}}{-2 \cdot v} \cdot \frac{cosTheta\_i}{v}}{\sinh \left(\frac{-1}{v}\right)} \cdot cosTheta\_O} \]
  7. Applied rewrites98.9%

    \[\leadsto \color{blue}{\frac{cosTheta\_O}{\sinh \left(\frac{1}{v}\right) \cdot v} \cdot \left(\frac{{\left(e^{sinTheta\_i}\right)}^{\left(\frac{-sinTheta\_O}{v}\right)}}{2 \cdot v} \cdot cosTheta\_i\right)} \]
  8. Add Preprocessing

Alternative 3: 98.6% accurate, 1.8× speedup?

\[\begin{array}{l} cosTheta_i\_m = \left|cosTheta\_i\right| \\ cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right) \\ [cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])\\ \\ cosTheta\_i\_s \cdot \left(\frac{\frac{-0.5}{v} \cdot \frac{cosTheta\_i\_m}{v}}{\sinh \left(\frac{-1}{v}\right)} \cdot cosTheta\_O\right) \end{array} \]
cosTheta_i\_m = (fabs.f32 cosTheta_i)
cosTheta_i\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_i)
NOTE: cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
(FPCore (cosTheta_i_s cosTheta_i_m cosTheta_O sinTheta_i sinTheta_O v)
 :precision binary32
 (*
  cosTheta_i_s
  (* (/ (* (/ -0.5 v) (/ cosTheta_i_m v)) (sinh (/ -1.0 v))) cosTheta_O)))
cosTheta_i\_m = fabs(cosTheta_i);
cosTheta_i\_s = copysign(1.0, cosTheta_i);
assert(cosTheta_i_m < cosTheta_O && cosTheta_O < sinTheta_i && sinTheta_i < sinTheta_O && sinTheta_O < v);
float code(float cosTheta_i_s, float cosTheta_i_m, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
	return cosTheta_i_s * ((((-0.5f / v) * (cosTheta_i_m / v)) / sinhf((-1.0f / v))) * cosTheta_O);
}
cosTheta_i\_m =     private
cosTheta_i\_s =     private
NOTE: cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
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(costheta_i_s, costheta_i_m, costheta_o, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
    real(4), intent (in) :: costheta_i_s
    real(4), intent (in) :: costheta_i_m
    real(4), intent (in) :: costheta_o
    real(4), intent (in) :: sintheta_i
    real(4), intent (in) :: sintheta_o
    real(4), intent (in) :: v
    code = costheta_i_s * (((((-0.5e0) / v) * (costheta_i_m / v)) / sinh(((-1.0e0) / v))) * costheta_o)
end function
cosTheta_i\_m = abs(cosTheta_i)
cosTheta_i\_s = copysign(1.0, cosTheta_i)
cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v = sort([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])
function code(cosTheta_i_s, cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v)
	return Float32(cosTheta_i_s * Float32(Float32(Float32(Float32(Float32(-0.5) / v) * Float32(cosTheta_i_m / v)) / sinh(Float32(Float32(-1.0) / v))) * cosTheta_O))
end
cosTheta_i\_m = abs(cosTheta_i);
cosTheta_i\_s = sign(cosTheta_i) * abs(1.0);
cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v = num2cell(sort([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])){:}
function tmp = code(cosTheta_i_s, cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v)
	tmp = cosTheta_i_s * ((((single(-0.5) / v) * (cosTheta_i_m / v)) / sinh((single(-1.0) / v))) * cosTheta_O);
end
\begin{array}{l}
cosTheta_i\_m = \left|cosTheta\_i\right|
\\
cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right)
\\
[cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])\\
\\
cosTheta\_i\_s \cdot \left(\frac{\frac{-0.5}{v} \cdot \frac{cosTheta\_i\_m}{v}}{\sinh \left(\frac{-1}{v}\right)} \cdot cosTheta\_O\right)
\end{array}
Derivation
  1. Initial program 98.5%

    \[\frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-/.f32N/A

      \[\leadsto \color{blue}{\frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}} \]
    2. lift-*.f32N/A

      \[\leadsto \frac{\color{blue}{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
    3. *-commutativeN/A

      \[\leadsto \frac{\color{blue}{\frac{cosTheta\_i \cdot cosTheta\_O}{v} \cdot e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
    4. associate-/l*N/A

      \[\leadsto \color{blue}{\frac{cosTheta\_i \cdot cosTheta\_O}{v} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}} \]
    5. lift-/.f32N/A

      \[\leadsto \color{blue}{\frac{cosTheta\_i \cdot cosTheta\_O}{v}} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
    6. lift-*.f32N/A

      \[\leadsto \frac{\color{blue}{cosTheta\_i \cdot cosTheta\_O}}{v} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
    7. *-commutativeN/A

      \[\leadsto \frac{\color{blue}{cosTheta\_O \cdot cosTheta\_i}}{v} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
    8. associate-/l*N/A

      \[\leadsto \color{blue}{\left(cosTheta\_O \cdot \frac{cosTheta\_i}{v}\right)} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
    9. associate-*l*N/A

      \[\leadsto \color{blue}{cosTheta\_O \cdot \left(\frac{cosTheta\_i}{v} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}\right)} \]
    10. lower-*.f32N/A

      \[\leadsto \color{blue}{cosTheta\_O \cdot \left(\frac{cosTheta\_i}{v} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}\right)} \]
    11. lower-*.f32N/A

      \[\leadsto cosTheta\_O \cdot \color{blue}{\left(\frac{cosTheta\_i}{v} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}\right)} \]
    12. lower-/.f32N/A

      \[\leadsto cosTheta\_O \cdot \left(\color{blue}{\frac{cosTheta\_i}{v}} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}\right) \]
    13. lift-*.f32N/A

      \[\leadsto cosTheta\_O \cdot \left(\frac{cosTheta\_i}{v} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\color{blue}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}}\right) \]
    14. lift-*.f32N/A

      \[\leadsto cosTheta\_O \cdot \left(\frac{cosTheta\_i}{v} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\color{blue}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right)} \cdot v}\right) \]
    15. associate-*l*N/A

      \[\leadsto cosTheta\_O \cdot \left(\frac{cosTheta\_i}{v} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\color{blue}{\sinh \left(\frac{1}{v}\right) \cdot \left(2 \cdot v\right)}}\right) \]
  4. Applied rewrites98.9%

    \[\leadsto \color{blue}{cosTheta\_O \cdot \left(\frac{cosTheta\_i}{v} \cdot \frac{\frac{{\left(e^{sinTheta\_O}\right)}^{\left(\frac{-sinTheta\_i}{v}\right)}}{2 \cdot v}}{\sinh \left(\frac{1}{v}\right)}\right)} \]
  5. Step-by-step derivation
    1. lift-*.f32N/A

      \[\leadsto \color{blue}{cosTheta\_O \cdot \left(\frac{cosTheta\_i}{v} \cdot \frac{\frac{{\left(e^{sinTheta\_O}\right)}^{\left(\frac{-sinTheta\_i}{v}\right)}}{2 \cdot v}}{\sinh \left(\frac{1}{v}\right)}\right)} \]
    2. *-commutativeN/A

      \[\leadsto \color{blue}{\left(\frac{cosTheta\_i}{v} \cdot \frac{\frac{{\left(e^{sinTheta\_O}\right)}^{\left(\frac{-sinTheta\_i}{v}\right)}}{2 \cdot v}}{\sinh \left(\frac{1}{v}\right)}\right) \cdot cosTheta\_O} \]
    3. lower-*.f3298.9

      \[\leadsto \color{blue}{\left(\frac{cosTheta\_i}{v} \cdot \frac{\frac{{\left(e^{sinTheta\_O}\right)}^{\left(\frac{-sinTheta\_i}{v}\right)}}{2 \cdot v}}{\sinh \left(\frac{1}{v}\right)}\right) \cdot cosTheta\_O} \]
  6. Applied rewrites98.9%

    \[\leadsto \color{blue}{\frac{\frac{{\left(e^{sinTheta\_O}\right)}^{\left(\frac{-sinTheta\_i}{v}\right)}}{-2 \cdot v} \cdot \frac{cosTheta\_i}{v}}{\sinh \left(\frac{-1}{v}\right)} \cdot cosTheta\_O} \]
  7. Taylor expanded in sinTheta_i around 0

    \[\leadsto \frac{\color{blue}{\frac{\frac{-1}{2}}{v}} \cdot \frac{cosTheta\_i}{v}}{\sinh \left(\frac{-1}{v}\right)} \cdot cosTheta\_O \]
  8. Step-by-step derivation
    1. lower-/.f3298.9

      \[\leadsto \frac{\color{blue}{\frac{-0.5}{v}} \cdot \frac{cosTheta\_i}{v}}{\sinh \left(\frac{-1}{v}\right)} \cdot cosTheta\_O \]
  9. Applied rewrites98.9%

    \[\leadsto \frac{\color{blue}{\frac{-0.5}{v}} \cdot \frac{cosTheta\_i}{v}}{\sinh \left(\frac{-1}{v}\right)} \cdot cosTheta\_O \]
  10. Add Preprocessing

Alternative 4: 98.5% accurate, 1.8× speedup?

\[\begin{array}{l} cosTheta_i\_m = \left|cosTheta\_i\right| \\ cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right) \\ [cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])\\ \\ cosTheta\_i\_s \cdot \left(cosTheta\_O \cdot \left(\frac{1}{v} \cdot \frac{cosTheta\_i\_m}{\sinh \left(\frac{-1}{v}\right) \cdot \left(-2 \cdot v\right)}\right)\right) \end{array} \]
cosTheta_i\_m = (fabs.f32 cosTheta_i)
cosTheta_i\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_i)
NOTE: cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
(FPCore (cosTheta_i_s cosTheta_i_m cosTheta_O sinTheta_i sinTheta_O v)
 :precision binary32
 (*
  cosTheta_i_s
  (*
   cosTheta_O
   (* (/ 1.0 v) (/ cosTheta_i_m (* (sinh (/ -1.0 v)) (* -2.0 v)))))))
cosTheta_i\_m = fabs(cosTheta_i);
cosTheta_i\_s = copysign(1.0, cosTheta_i);
assert(cosTheta_i_m < cosTheta_O && cosTheta_O < sinTheta_i && sinTheta_i < sinTheta_O && sinTheta_O < v);
float code(float cosTheta_i_s, float cosTheta_i_m, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
	return cosTheta_i_s * (cosTheta_O * ((1.0f / v) * (cosTheta_i_m / (sinhf((-1.0f / v)) * (-2.0f * v)))));
}
cosTheta_i\_m =     private
cosTheta_i\_s =     private
NOTE: cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
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(costheta_i_s, costheta_i_m, costheta_o, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
    real(4), intent (in) :: costheta_i_s
    real(4), intent (in) :: costheta_i_m
    real(4), intent (in) :: costheta_o
    real(4), intent (in) :: sintheta_i
    real(4), intent (in) :: sintheta_o
    real(4), intent (in) :: v
    code = costheta_i_s * (costheta_o * ((1.0e0 / v) * (costheta_i_m / (sinh(((-1.0e0) / v)) * ((-2.0e0) * v)))))
end function
cosTheta_i\_m = abs(cosTheta_i)
cosTheta_i\_s = copysign(1.0, cosTheta_i)
cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v = sort([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])
function code(cosTheta_i_s, cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v)
	return Float32(cosTheta_i_s * Float32(cosTheta_O * Float32(Float32(Float32(1.0) / v) * Float32(cosTheta_i_m / Float32(sinh(Float32(Float32(-1.0) / v)) * Float32(Float32(-2.0) * v))))))
end
cosTheta_i\_m = abs(cosTheta_i);
cosTheta_i\_s = sign(cosTheta_i) * abs(1.0);
cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v = num2cell(sort([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])){:}
function tmp = code(cosTheta_i_s, cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v)
	tmp = cosTheta_i_s * (cosTheta_O * ((single(1.0) / v) * (cosTheta_i_m / (sinh((single(-1.0) / v)) * (single(-2.0) * v)))));
end
\begin{array}{l}
cosTheta_i\_m = \left|cosTheta\_i\right|
\\
cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right)
\\
[cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])\\
\\
cosTheta\_i\_s \cdot \left(cosTheta\_O \cdot \left(\frac{1}{v} \cdot \frac{cosTheta\_i\_m}{\sinh \left(\frac{-1}{v}\right) \cdot \left(-2 \cdot v\right)}\right)\right)
\end{array}
Derivation
  1. Initial program 98.5%

    \[\frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-/.f32N/A

      \[\leadsto \color{blue}{\frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}} \]
    2. lift-*.f32N/A

      \[\leadsto \frac{\color{blue}{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
    3. *-commutativeN/A

      \[\leadsto \frac{\color{blue}{\frac{cosTheta\_i \cdot cosTheta\_O}{v} \cdot e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
    4. associate-/l*N/A

      \[\leadsto \color{blue}{\frac{cosTheta\_i \cdot cosTheta\_O}{v} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}} \]
    5. lift-/.f32N/A

      \[\leadsto \color{blue}{\frac{cosTheta\_i \cdot cosTheta\_O}{v}} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
    6. lift-*.f32N/A

      \[\leadsto \frac{\color{blue}{cosTheta\_i \cdot cosTheta\_O}}{v} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
    7. *-commutativeN/A

      \[\leadsto \frac{\color{blue}{cosTheta\_O \cdot cosTheta\_i}}{v} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
    8. associate-/l*N/A

      \[\leadsto \color{blue}{\left(cosTheta\_O \cdot \frac{cosTheta\_i}{v}\right)} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
    9. associate-*l*N/A

      \[\leadsto \color{blue}{cosTheta\_O \cdot \left(\frac{cosTheta\_i}{v} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}\right)} \]
    10. lower-*.f32N/A

      \[\leadsto \color{blue}{cosTheta\_O \cdot \left(\frac{cosTheta\_i}{v} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}\right)} \]
    11. lower-*.f32N/A

      \[\leadsto cosTheta\_O \cdot \color{blue}{\left(\frac{cosTheta\_i}{v} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}\right)} \]
    12. lower-/.f32N/A

      \[\leadsto cosTheta\_O \cdot \left(\color{blue}{\frac{cosTheta\_i}{v}} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}\right) \]
    13. lift-*.f32N/A

      \[\leadsto cosTheta\_O \cdot \left(\frac{cosTheta\_i}{v} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\color{blue}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}}\right) \]
    14. lift-*.f32N/A

      \[\leadsto cosTheta\_O \cdot \left(\frac{cosTheta\_i}{v} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\color{blue}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right)} \cdot v}\right) \]
    15. associate-*l*N/A

      \[\leadsto cosTheta\_O \cdot \left(\frac{cosTheta\_i}{v} \cdot \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}}}{\color{blue}{\sinh \left(\frac{1}{v}\right) \cdot \left(2 \cdot v\right)}}\right) \]
  4. Applied rewrites98.9%

    \[\leadsto \color{blue}{cosTheta\_O \cdot \left(\frac{cosTheta\_i}{v} \cdot \frac{\frac{{\left(e^{sinTheta\_O}\right)}^{\left(\frac{-sinTheta\_i}{v}\right)}}{2 \cdot v}}{\sinh \left(\frac{1}{v}\right)}\right)} \]
  5. Taylor expanded in sinTheta_i around 0

    \[\leadsto cosTheta\_O \cdot \left(\frac{cosTheta\_i}{v} \cdot \frac{\frac{\color{blue}{1}}{2 \cdot v}}{\sinh \left(\frac{1}{v}\right)}\right) \]
  6. Step-by-step derivation
    1. Applied rewrites98.9%

      \[\leadsto cosTheta\_O \cdot \left(\frac{cosTheta\_i}{v} \cdot \frac{\frac{\color{blue}{1}}{2 \cdot v}}{\sinh \left(\frac{1}{v}\right)}\right) \]
    2. Step-by-step derivation
      1. lift-*.f32N/A

        \[\leadsto cosTheta\_O \cdot \color{blue}{\left(\frac{cosTheta\_i}{v} \cdot \frac{\frac{1}{2 \cdot v}}{\sinh \left(\frac{1}{v}\right)}\right)} \]
      2. *-commutativeN/A

        \[\leadsto cosTheta\_O \cdot \color{blue}{\left(\frac{\frac{1}{2 \cdot v}}{\sinh \left(\frac{1}{v}\right)} \cdot \frac{cosTheta\_i}{v}\right)} \]
      3. lift-/.f32N/A

        \[\leadsto cosTheta\_O \cdot \left(\color{blue}{\frac{\frac{1}{2 \cdot v}}{\sinh \left(\frac{1}{v}\right)}} \cdot \frac{cosTheta\_i}{v}\right) \]
      4. lift-/.f32N/A

        \[\leadsto cosTheta\_O \cdot \left(\frac{\color{blue}{\frac{1}{2 \cdot v}}}{\sinh \left(\frac{1}{v}\right)} \cdot \frac{cosTheta\_i}{v}\right) \]
      5. associate-/l/N/A

        \[\leadsto cosTheta\_O \cdot \left(\color{blue}{\frac{1}{\left(2 \cdot v\right) \cdot \sinh \left(\frac{1}{v}\right)}} \cdot \frac{cosTheta\_i}{v}\right) \]
      6. lift-/.f32N/A

        \[\leadsto cosTheta\_O \cdot \left(\frac{1}{\left(2 \cdot v\right) \cdot \sinh \left(\frac{1}{v}\right)} \cdot \color{blue}{\frac{cosTheta\_i}{v}}\right) \]
      7. frac-timesN/A

        \[\leadsto cosTheta\_O \cdot \color{blue}{\frac{1 \cdot cosTheta\_i}{\left(\left(2 \cdot v\right) \cdot \sinh \left(\frac{1}{v}\right)\right) \cdot v}} \]
      8. associate-*r*N/A

        \[\leadsto cosTheta\_O \cdot \frac{1 \cdot cosTheta\_i}{\color{blue}{\left(2 \cdot v\right) \cdot \left(\sinh \left(\frac{1}{v}\right) \cdot v\right)}} \]
      9. lift-*.f32N/A

        \[\leadsto cosTheta\_O \cdot \frac{1 \cdot cosTheta\_i}{\left(2 \cdot v\right) \cdot \color{blue}{\left(\sinh \left(\frac{1}{v}\right) \cdot v\right)}} \]
      10. lift-*.f32N/A

        \[\leadsto cosTheta\_O \cdot \frac{1 \cdot cosTheta\_i}{\color{blue}{\left(2 \cdot v\right)} \cdot \left(\sinh \left(\frac{1}{v}\right) \cdot v\right)} \]
      11. *-commutativeN/A

        \[\leadsto cosTheta\_O \cdot \frac{1 \cdot cosTheta\_i}{\color{blue}{\left(v \cdot 2\right)} \cdot \left(\sinh \left(\frac{1}{v}\right) \cdot v\right)} \]
      12. associate-*l*N/A

        \[\leadsto cosTheta\_O \cdot \frac{1 \cdot cosTheta\_i}{\color{blue}{v \cdot \left(2 \cdot \left(\sinh \left(\frac{1}{v}\right) \cdot v\right)\right)}} \]
      13. lift-*.f32N/A

        \[\leadsto cosTheta\_O \cdot \frac{1 \cdot cosTheta\_i}{v \cdot \left(2 \cdot \color{blue}{\left(\sinh \left(\frac{1}{v}\right) \cdot v\right)}\right)} \]
      14. *-commutativeN/A

        \[\leadsto cosTheta\_O \cdot \frac{1 \cdot cosTheta\_i}{v \cdot \left(2 \cdot \color{blue}{\left(v \cdot \sinh \left(\frac{1}{v}\right)\right)}\right)} \]
      15. associate-*l*N/A

        \[\leadsto cosTheta\_O \cdot \frac{1 \cdot cosTheta\_i}{v \cdot \color{blue}{\left(\left(2 \cdot v\right) \cdot \sinh \left(\frac{1}{v}\right)\right)}} \]
      16. lift-*.f32N/A

        \[\leadsto cosTheta\_O \cdot \frac{1 \cdot cosTheta\_i}{v \cdot \left(\color{blue}{\left(2 \cdot v\right)} \cdot \sinh \left(\frac{1}{v}\right)\right)} \]
    3. Applied rewrites98.9%

      \[\leadsto cosTheta\_O \cdot \color{blue}{\left(\frac{1}{v} \cdot \frac{cosTheta\_i}{\sinh \left(\frac{-1}{v}\right) \cdot \left(-2 \cdot v\right)}\right)} \]
    4. Add Preprocessing

    Alternative 5: 98.4% accurate, 1.8× speedup?

    \[\begin{array}{l} cosTheta_i\_m = \left|cosTheta\_i\right| \\ cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right) \\ [cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])\\ \\ cosTheta\_i\_s \cdot \left(\frac{cosTheta\_O}{v + v} \cdot \frac{\frac{cosTheta\_i\_m}{v}}{\sinh \left(\frac{1}{v}\right)}\right) \end{array} \]
    cosTheta_i\_m = (fabs.f32 cosTheta_i)
    cosTheta_i\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_i)
    NOTE: cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
    (FPCore (cosTheta_i_s cosTheta_i_m cosTheta_O sinTheta_i sinTheta_O v)
     :precision binary32
     (*
      cosTheta_i_s
      (* (/ cosTheta_O (+ v v)) (/ (/ cosTheta_i_m v) (sinh (/ 1.0 v))))))
    cosTheta_i\_m = fabs(cosTheta_i);
    cosTheta_i\_s = copysign(1.0, cosTheta_i);
    assert(cosTheta_i_m < cosTheta_O && cosTheta_O < sinTheta_i && sinTheta_i < sinTheta_O && sinTheta_O < v);
    float code(float cosTheta_i_s, float cosTheta_i_m, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
    	return cosTheta_i_s * ((cosTheta_O / (v + v)) * ((cosTheta_i_m / v) / sinhf((1.0f / v))));
    }
    
    cosTheta_i\_m =     private
    cosTheta_i\_s =     private
    NOTE: cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
    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(costheta_i_s, costheta_i_m, costheta_o, sintheta_i, sintheta_o, v)
    use fmin_fmax_functions
        real(4), intent (in) :: costheta_i_s
        real(4), intent (in) :: costheta_i_m
        real(4), intent (in) :: costheta_o
        real(4), intent (in) :: sintheta_i
        real(4), intent (in) :: sintheta_o
        real(4), intent (in) :: v
        code = costheta_i_s * ((costheta_o / (v + v)) * ((costheta_i_m / v) / sinh((1.0e0 / v))))
    end function
    
    cosTheta_i\_m = abs(cosTheta_i)
    cosTheta_i\_s = copysign(1.0, cosTheta_i)
    cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v = sort([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])
    function code(cosTheta_i_s, cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v)
    	return Float32(cosTheta_i_s * Float32(Float32(cosTheta_O / Float32(v + v)) * Float32(Float32(cosTheta_i_m / v) / sinh(Float32(Float32(1.0) / v)))))
    end
    
    cosTheta_i\_m = abs(cosTheta_i);
    cosTheta_i\_s = sign(cosTheta_i) * abs(1.0);
    cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v = num2cell(sort([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])){:}
    function tmp = code(cosTheta_i_s, cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v)
    	tmp = cosTheta_i_s * ((cosTheta_O / (v + v)) * ((cosTheta_i_m / v) / sinh((single(1.0) / v))));
    end
    
    \begin{array}{l}
    cosTheta_i\_m = \left|cosTheta\_i\right|
    \\
    cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right)
    \\
    [cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])\\
    \\
    cosTheta\_i\_s \cdot \left(\frac{cosTheta\_O}{v + v} \cdot \frac{\frac{cosTheta\_i\_m}{v}}{\sinh \left(\frac{1}{v}\right)}\right)
    \end{array}
    
    Derivation
    1. Initial program 98.5%

      \[\frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
    2. Add Preprocessing
    3. Taylor expanded in sinTheta_i around 0

      \[\leadsto \color{blue}{\frac{cosTheta\_O \cdot cosTheta\_i}{{v}^{2} \cdot \left(e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}\right)}} \]
    4. Step-by-step derivation
      1. times-fracN/A

        \[\leadsto \color{blue}{\frac{cosTheta\_O}{{v}^{2}} \cdot \frac{cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}}} \]
      2. associate-*r/N/A

        \[\leadsto \color{blue}{\frac{\frac{cosTheta\_O}{{v}^{2}} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}}} \]
      3. lower-/.f32N/A

        \[\leadsto \color{blue}{\frac{\frac{cosTheta\_O}{{v}^{2}} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}}} \]
      4. lower-*.f32N/A

        \[\leadsto \frac{\color{blue}{\frac{cosTheta\_O}{{v}^{2}} \cdot cosTheta\_i}}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}} \]
      5. lower-/.f32N/A

        \[\leadsto \frac{\color{blue}{\frac{cosTheta\_O}{{v}^{2}}} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}} \]
      6. unpow2N/A

        \[\leadsto \frac{\frac{cosTheta\_O}{\color{blue}{v \cdot v}} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}} \]
      7. lower-*.f32N/A

        \[\leadsto \frac{\frac{cosTheta\_O}{\color{blue}{v \cdot v}} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}} \]
      8. lower--.f32N/A

        \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{\color{blue}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}}} \]
      9. lower-exp.f32N/A

        \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{\color{blue}{e^{\frac{1}{v}}} - \frac{1}{e^{\frac{1}{v}}}} \]
      10. lower-/.f32N/A

        \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\color{blue}{\frac{1}{v}}} - \frac{1}{e^{\frac{1}{v}}}} \]
      11. rec-expN/A

        \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \color{blue}{e^{\mathsf{neg}\left(\frac{1}{v}\right)}}} \]
      12. distribute-neg-fracN/A

        \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - e^{\color{blue}{\frac{\mathsf{neg}\left(1\right)}{v}}}} \]
      13. metadata-evalN/A

        \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - e^{\frac{\color{blue}{-1}}{v}}} \]
      14. lower-exp.f32N/A

        \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \color{blue}{e^{\frac{-1}{v}}}} \]
      15. lower-/.f3298.6

        \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - e^{\color{blue}{\frac{-1}{v}}}} \]
    5. Applied rewrites98.6%

      \[\leadsto \color{blue}{\frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - e^{\frac{-1}{v}}}} \]
    6. Step-by-step derivation
      1. Applied rewrites98.7%

        \[\leadsto \frac{cosTheta\_O}{2 \cdot v} \cdot \color{blue}{\frac{\frac{cosTheta\_i}{v}}{\sinh \left(\frac{1}{v}\right)}} \]
      2. Step-by-step derivation
        1. Applied rewrites98.7%

          \[\leadsto \frac{cosTheta\_O}{v + v} \cdot \frac{\frac{cosTheta\_i}{\color{blue}{v}}}{\sinh \left(\frac{1}{v}\right)} \]
        2. Add Preprocessing

        Alternative 6: 98.4% accurate, 1.8× speedup?

        \[\begin{array}{l} cosTheta_i\_m = \left|cosTheta\_i\right| \\ cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right) \\ [cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])\\ \\ cosTheta\_i\_s \cdot \frac{cosTheta\_O \cdot \frac{cosTheta\_i\_m}{v}}{\sinh \left(\frac{1}{v}\right) \cdot \left(2 \cdot v\right)} \end{array} \]
        cosTheta_i\_m = (fabs.f32 cosTheta_i)
        cosTheta_i\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_i)
        NOTE: cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
        (FPCore (cosTheta_i_s cosTheta_i_m cosTheta_O sinTheta_i sinTheta_O v)
         :precision binary32
         (*
          cosTheta_i_s
          (/ (* cosTheta_O (/ cosTheta_i_m v)) (* (sinh (/ 1.0 v)) (* 2.0 v)))))
        cosTheta_i\_m = fabs(cosTheta_i);
        cosTheta_i\_s = copysign(1.0, cosTheta_i);
        assert(cosTheta_i_m < cosTheta_O && cosTheta_O < sinTheta_i && sinTheta_i < sinTheta_O && sinTheta_O < v);
        float code(float cosTheta_i_s, float cosTheta_i_m, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
        	return cosTheta_i_s * ((cosTheta_O * (cosTheta_i_m / v)) / (sinhf((1.0f / v)) * (2.0f * v)));
        }
        
        cosTheta_i\_m =     private
        cosTheta_i\_s =     private
        NOTE: cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
        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(costheta_i_s, costheta_i_m, costheta_o, sintheta_i, sintheta_o, v)
        use fmin_fmax_functions
            real(4), intent (in) :: costheta_i_s
            real(4), intent (in) :: costheta_i_m
            real(4), intent (in) :: costheta_o
            real(4), intent (in) :: sintheta_i
            real(4), intent (in) :: sintheta_o
            real(4), intent (in) :: v
            code = costheta_i_s * ((costheta_o * (costheta_i_m / v)) / (sinh((1.0e0 / v)) * (2.0e0 * v)))
        end function
        
        cosTheta_i\_m = abs(cosTheta_i)
        cosTheta_i\_s = copysign(1.0, cosTheta_i)
        cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v = sort([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])
        function code(cosTheta_i_s, cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v)
        	return Float32(cosTheta_i_s * Float32(Float32(cosTheta_O * Float32(cosTheta_i_m / v)) / Float32(sinh(Float32(Float32(1.0) / v)) * Float32(Float32(2.0) * v))))
        end
        
        cosTheta_i\_m = abs(cosTheta_i);
        cosTheta_i\_s = sign(cosTheta_i) * abs(1.0);
        cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v = num2cell(sort([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])){:}
        function tmp = code(cosTheta_i_s, cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v)
        	tmp = cosTheta_i_s * ((cosTheta_O * (cosTheta_i_m / v)) / (sinh((single(1.0) / v)) * (single(2.0) * v)));
        end
        
        \begin{array}{l}
        cosTheta_i\_m = \left|cosTheta\_i\right|
        \\
        cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right)
        \\
        [cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])\\
        \\
        cosTheta\_i\_s \cdot \frac{cosTheta\_O \cdot \frac{cosTheta\_i\_m}{v}}{\sinh \left(\frac{1}{v}\right) \cdot \left(2 \cdot v\right)}
        \end{array}
        
        Derivation
        1. Initial program 98.5%

          \[\frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
        2. Add Preprocessing
        3. Taylor expanded in sinTheta_i around 0

          \[\leadsto \color{blue}{\frac{cosTheta\_O \cdot cosTheta\_i}{{v}^{2} \cdot \left(e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}\right)}} \]
        4. Step-by-step derivation
          1. times-fracN/A

            \[\leadsto \color{blue}{\frac{cosTheta\_O}{{v}^{2}} \cdot \frac{cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}}} \]
          2. associate-*r/N/A

            \[\leadsto \color{blue}{\frac{\frac{cosTheta\_O}{{v}^{2}} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}}} \]
          3. lower-/.f32N/A

            \[\leadsto \color{blue}{\frac{\frac{cosTheta\_O}{{v}^{2}} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}}} \]
          4. lower-*.f32N/A

            \[\leadsto \frac{\color{blue}{\frac{cosTheta\_O}{{v}^{2}} \cdot cosTheta\_i}}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}} \]
          5. lower-/.f32N/A

            \[\leadsto \frac{\color{blue}{\frac{cosTheta\_O}{{v}^{2}}} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}} \]
          6. unpow2N/A

            \[\leadsto \frac{\frac{cosTheta\_O}{\color{blue}{v \cdot v}} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}} \]
          7. lower-*.f32N/A

            \[\leadsto \frac{\frac{cosTheta\_O}{\color{blue}{v \cdot v}} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}} \]
          8. lower--.f32N/A

            \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{\color{blue}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}}} \]
          9. lower-exp.f32N/A

            \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{\color{blue}{e^{\frac{1}{v}}} - \frac{1}{e^{\frac{1}{v}}}} \]
          10. lower-/.f32N/A

            \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\color{blue}{\frac{1}{v}}} - \frac{1}{e^{\frac{1}{v}}}} \]
          11. rec-expN/A

            \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \color{blue}{e^{\mathsf{neg}\left(\frac{1}{v}\right)}}} \]
          12. distribute-neg-fracN/A

            \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - e^{\color{blue}{\frac{\mathsf{neg}\left(1\right)}{v}}}} \]
          13. metadata-evalN/A

            \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - e^{\frac{\color{blue}{-1}}{v}}} \]
          14. lower-exp.f32N/A

            \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \color{blue}{e^{\frac{-1}{v}}}} \]
          15. lower-/.f3298.6

            \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - e^{\color{blue}{\frac{-1}{v}}}} \]
        5. Applied rewrites98.6%

          \[\leadsto \color{blue}{\frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - e^{\frac{-1}{v}}}} \]
        6. Step-by-step derivation
          1. Applied rewrites98.7%

            \[\leadsto \color{blue}{\frac{cosTheta\_O \cdot \frac{cosTheta\_i}{v}}{\sinh \left(\frac{1}{v}\right) \cdot \left(2 \cdot v\right)}} \]
          2. Add Preprocessing

          Alternative 7: 98.4% accurate, 1.9× speedup?

          \[\begin{array}{l} cosTheta_i\_m = \left|cosTheta\_i\right| \\ cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right) \\ [cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])\\ \\ cosTheta\_i\_s \cdot \left(\frac{cosTheta\_i\_m}{v + v} \cdot \frac{cosTheta\_O}{\sinh \left(\frac{1}{v}\right) \cdot v}\right) \end{array} \]
          cosTheta_i\_m = (fabs.f32 cosTheta_i)
          cosTheta_i\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_i)
          NOTE: cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
          (FPCore (cosTheta_i_s cosTheta_i_m cosTheta_O sinTheta_i sinTheta_O v)
           :precision binary32
           (*
            cosTheta_i_s
            (* (/ cosTheta_i_m (+ v v)) (/ cosTheta_O (* (sinh (/ 1.0 v)) v)))))
          cosTheta_i\_m = fabs(cosTheta_i);
          cosTheta_i\_s = copysign(1.0, cosTheta_i);
          assert(cosTheta_i_m < cosTheta_O && cosTheta_O < sinTheta_i && sinTheta_i < sinTheta_O && sinTheta_O < v);
          float code(float cosTheta_i_s, float cosTheta_i_m, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
          	return cosTheta_i_s * ((cosTheta_i_m / (v + v)) * (cosTheta_O / (sinhf((1.0f / v)) * v)));
          }
          
          cosTheta_i\_m =     private
          cosTheta_i\_s =     private
          NOTE: cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
          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(costheta_i_s, costheta_i_m, costheta_o, sintheta_i, sintheta_o, v)
          use fmin_fmax_functions
              real(4), intent (in) :: costheta_i_s
              real(4), intent (in) :: costheta_i_m
              real(4), intent (in) :: costheta_o
              real(4), intent (in) :: sintheta_i
              real(4), intent (in) :: sintheta_o
              real(4), intent (in) :: v
              code = costheta_i_s * ((costheta_i_m / (v + v)) * (costheta_o / (sinh((1.0e0 / v)) * v)))
          end function
          
          cosTheta_i\_m = abs(cosTheta_i)
          cosTheta_i\_s = copysign(1.0, cosTheta_i)
          cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v = sort([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])
          function code(cosTheta_i_s, cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v)
          	return Float32(cosTheta_i_s * Float32(Float32(cosTheta_i_m / Float32(v + v)) * Float32(cosTheta_O / Float32(sinh(Float32(Float32(1.0) / v)) * v))))
          end
          
          cosTheta_i\_m = abs(cosTheta_i);
          cosTheta_i\_s = sign(cosTheta_i) * abs(1.0);
          cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v = num2cell(sort([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])){:}
          function tmp = code(cosTheta_i_s, cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v)
          	tmp = cosTheta_i_s * ((cosTheta_i_m / (v + v)) * (cosTheta_O / (sinh((single(1.0) / v)) * v)));
          end
          
          \begin{array}{l}
          cosTheta_i\_m = \left|cosTheta\_i\right|
          \\
          cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right)
          \\
          [cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])\\
          \\
          cosTheta\_i\_s \cdot \left(\frac{cosTheta\_i\_m}{v + v} \cdot \frac{cosTheta\_O}{\sinh \left(\frac{1}{v}\right) \cdot v}\right)
          \end{array}
          
          Derivation
          1. Initial program 98.5%

            \[\frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
          2. Add Preprocessing
          3. Taylor expanded in sinTheta_i around 0

            \[\leadsto \color{blue}{\frac{cosTheta\_O \cdot cosTheta\_i}{{v}^{2} \cdot \left(e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}\right)}} \]
          4. Step-by-step derivation
            1. times-fracN/A

              \[\leadsto \color{blue}{\frac{cosTheta\_O}{{v}^{2}} \cdot \frac{cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}}} \]
            2. associate-*r/N/A

              \[\leadsto \color{blue}{\frac{\frac{cosTheta\_O}{{v}^{2}} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}}} \]
            3. lower-/.f32N/A

              \[\leadsto \color{blue}{\frac{\frac{cosTheta\_O}{{v}^{2}} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}}} \]
            4. lower-*.f32N/A

              \[\leadsto \frac{\color{blue}{\frac{cosTheta\_O}{{v}^{2}} \cdot cosTheta\_i}}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}} \]
            5. lower-/.f32N/A

              \[\leadsto \frac{\color{blue}{\frac{cosTheta\_O}{{v}^{2}}} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}} \]
            6. unpow2N/A

              \[\leadsto \frac{\frac{cosTheta\_O}{\color{blue}{v \cdot v}} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}} \]
            7. lower-*.f32N/A

              \[\leadsto \frac{\frac{cosTheta\_O}{\color{blue}{v \cdot v}} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}} \]
            8. lower--.f32N/A

              \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{\color{blue}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}}} \]
            9. lower-exp.f32N/A

              \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{\color{blue}{e^{\frac{1}{v}}} - \frac{1}{e^{\frac{1}{v}}}} \]
            10. lower-/.f32N/A

              \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\color{blue}{\frac{1}{v}}} - \frac{1}{e^{\frac{1}{v}}}} \]
            11. rec-expN/A

              \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \color{blue}{e^{\mathsf{neg}\left(\frac{1}{v}\right)}}} \]
            12. distribute-neg-fracN/A

              \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - e^{\color{blue}{\frac{\mathsf{neg}\left(1\right)}{v}}}} \]
            13. metadata-evalN/A

              \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - e^{\frac{\color{blue}{-1}}{v}}} \]
            14. lower-exp.f32N/A

              \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \color{blue}{e^{\frac{-1}{v}}}} \]
            15. lower-/.f3298.6

              \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - e^{\color{blue}{\frac{-1}{v}}}} \]
          5. Applied rewrites98.6%

            \[\leadsto \color{blue}{\frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - e^{\frac{-1}{v}}}} \]
          6. Step-by-step derivation
            1. Applied rewrites98.7%

              \[\leadsto \frac{cosTheta\_O}{2 \cdot v} \cdot \color{blue}{\frac{\frac{cosTheta\_i}{v}}{\sinh \left(\frac{1}{v}\right)}} \]
            2. Step-by-step derivation
              1. Applied rewrites98.7%

                \[\leadsto \frac{cosTheta\_i}{2 \cdot v} \cdot \color{blue}{\frac{cosTheta\_O}{\sinh \left(\frac{1}{v}\right) \cdot v}} \]
              2. Step-by-step derivation
                1. Applied rewrites98.7%

                  \[\leadsto \frac{cosTheta\_i}{v + v} \cdot \frac{cosTheta\_O}{\sinh \left(\frac{1}{v}\right) \cdot v} \]
                2. Add Preprocessing

                Alternative 8: 98.4% accurate, 1.9× speedup?

                \[\begin{array}{l} cosTheta_i\_m = \left|cosTheta\_i\right| \\ cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right) \\ [cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])\\ \\ cosTheta\_i\_s \cdot \left(cosTheta\_O \cdot \frac{cosTheta\_i\_m}{\left(\left(2 \cdot v\right) \cdot v\right) \cdot \sinh \left(\frac{1}{v}\right)}\right) \end{array} \]
                cosTheta_i\_m = (fabs.f32 cosTheta_i)
                cosTheta_i\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_i)
                NOTE: cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
                (FPCore (cosTheta_i_s cosTheta_i_m cosTheta_O sinTheta_i sinTheta_O v)
                 :precision binary32
                 (*
                  cosTheta_i_s
                  (* cosTheta_O (/ cosTheta_i_m (* (* (* 2.0 v) v) (sinh (/ 1.0 v)))))))
                cosTheta_i\_m = fabs(cosTheta_i);
                cosTheta_i\_s = copysign(1.0, cosTheta_i);
                assert(cosTheta_i_m < cosTheta_O && cosTheta_O < sinTheta_i && sinTheta_i < sinTheta_O && sinTheta_O < v);
                float code(float cosTheta_i_s, float cosTheta_i_m, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
                	return cosTheta_i_s * (cosTheta_O * (cosTheta_i_m / (((2.0f * v) * v) * sinhf((1.0f / v)))));
                }
                
                cosTheta_i\_m =     private
                cosTheta_i\_s =     private
                NOTE: cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
                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(costheta_i_s, costheta_i_m, costheta_o, sintheta_i, sintheta_o, v)
                use fmin_fmax_functions
                    real(4), intent (in) :: costheta_i_s
                    real(4), intent (in) :: costheta_i_m
                    real(4), intent (in) :: costheta_o
                    real(4), intent (in) :: sintheta_i
                    real(4), intent (in) :: sintheta_o
                    real(4), intent (in) :: v
                    code = costheta_i_s * (costheta_o * (costheta_i_m / (((2.0e0 * v) * v) * sinh((1.0e0 / v)))))
                end function
                
                cosTheta_i\_m = abs(cosTheta_i)
                cosTheta_i\_s = copysign(1.0, cosTheta_i)
                cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v = sort([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])
                function code(cosTheta_i_s, cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v)
                	return Float32(cosTheta_i_s * Float32(cosTheta_O * Float32(cosTheta_i_m / Float32(Float32(Float32(Float32(2.0) * v) * v) * sinh(Float32(Float32(1.0) / v))))))
                end
                
                cosTheta_i\_m = abs(cosTheta_i);
                cosTheta_i\_s = sign(cosTheta_i) * abs(1.0);
                cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v = num2cell(sort([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])){:}
                function tmp = code(cosTheta_i_s, cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v)
                	tmp = cosTheta_i_s * (cosTheta_O * (cosTheta_i_m / (((single(2.0) * v) * v) * sinh((single(1.0) / v)))));
                end
                
                \begin{array}{l}
                cosTheta_i\_m = \left|cosTheta\_i\right|
                \\
                cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right)
                \\
                [cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])\\
                \\
                cosTheta\_i\_s \cdot \left(cosTheta\_O \cdot \frac{cosTheta\_i\_m}{\left(\left(2 \cdot v\right) \cdot v\right) \cdot \sinh \left(\frac{1}{v}\right)}\right)
                \end{array}
                
                Derivation
                1. Initial program 98.5%

                  \[\frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
                2. Add Preprocessing
                3. Taylor expanded in sinTheta_i around 0

                  \[\leadsto \color{blue}{\frac{cosTheta\_O \cdot cosTheta\_i}{{v}^{2} \cdot \left(e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}\right)}} \]
                4. Step-by-step derivation
                  1. times-fracN/A

                    \[\leadsto \color{blue}{\frac{cosTheta\_O}{{v}^{2}} \cdot \frac{cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}}} \]
                  2. associate-*r/N/A

                    \[\leadsto \color{blue}{\frac{\frac{cosTheta\_O}{{v}^{2}} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}}} \]
                  3. lower-/.f32N/A

                    \[\leadsto \color{blue}{\frac{\frac{cosTheta\_O}{{v}^{2}} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}}} \]
                  4. lower-*.f32N/A

                    \[\leadsto \frac{\color{blue}{\frac{cosTheta\_O}{{v}^{2}} \cdot cosTheta\_i}}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}} \]
                  5. lower-/.f32N/A

                    \[\leadsto \frac{\color{blue}{\frac{cosTheta\_O}{{v}^{2}}} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}} \]
                  6. unpow2N/A

                    \[\leadsto \frac{\frac{cosTheta\_O}{\color{blue}{v \cdot v}} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}} \]
                  7. lower-*.f32N/A

                    \[\leadsto \frac{\frac{cosTheta\_O}{\color{blue}{v \cdot v}} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}} \]
                  8. lower--.f32N/A

                    \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{\color{blue}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}}} \]
                  9. lower-exp.f32N/A

                    \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{\color{blue}{e^{\frac{1}{v}}} - \frac{1}{e^{\frac{1}{v}}}} \]
                  10. lower-/.f32N/A

                    \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\color{blue}{\frac{1}{v}}} - \frac{1}{e^{\frac{1}{v}}}} \]
                  11. rec-expN/A

                    \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \color{blue}{e^{\mathsf{neg}\left(\frac{1}{v}\right)}}} \]
                  12. distribute-neg-fracN/A

                    \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - e^{\color{blue}{\frac{\mathsf{neg}\left(1\right)}{v}}}} \]
                  13. metadata-evalN/A

                    \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - e^{\frac{\color{blue}{-1}}{v}}} \]
                  14. lower-exp.f32N/A

                    \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \color{blue}{e^{\frac{-1}{v}}}} \]
                  15. lower-/.f3298.6

                    \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - e^{\color{blue}{\frac{-1}{v}}}} \]
                5. Applied rewrites98.6%

                  \[\leadsto \color{blue}{\frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - e^{\frac{-1}{v}}}} \]
                6. Step-by-step derivation
                  1. Applied rewrites98.7%

                    \[\leadsto \frac{cosTheta\_O}{2 \cdot v} \cdot \color{blue}{\frac{\frac{cosTheta\_i}{v}}{\sinh \left(\frac{1}{v}\right)}} \]
                  2. Step-by-step derivation
                    1. Applied rewrites98.7%

                      \[\leadsto \frac{cosTheta\_i}{2 \cdot v} \cdot \color{blue}{\frac{cosTheta\_O}{\sinh \left(\frac{1}{v}\right) \cdot v}} \]
                    2. Step-by-step derivation
                      1. Applied rewrites98.7%

                        \[\leadsto cosTheta\_O \cdot \color{blue}{\frac{cosTheta\_i}{\left(\left(2 \cdot v\right) \cdot v\right) \cdot \sinh \left(\frac{1}{v}\right)}} \]
                      2. Add Preprocessing

                      Alternative 9: 64.0% accurate, 4.3× speedup?

                      \[\begin{array}{l} cosTheta_i\_m = \left|cosTheta\_i\right| \\ cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right) \\ [cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])\\ \\ cosTheta\_i\_s \cdot \frac{cosTheta\_O \cdot \frac{cosTheta\_i\_m}{\frac{\frac{0.3333333333333333}{v \cdot v} + 2}{v}}}{v \cdot v} \end{array} \]
                      cosTheta_i\_m = (fabs.f32 cosTheta_i)
                      cosTheta_i\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_i)
                      NOTE: cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
                      (FPCore (cosTheta_i_s cosTheta_i_m cosTheta_O sinTheta_i sinTheta_O v)
                       :precision binary32
                       (*
                        cosTheta_i_s
                        (/
                         (* cosTheta_O (/ cosTheta_i_m (/ (+ (/ 0.3333333333333333 (* v v)) 2.0) v)))
                         (* v v))))
                      cosTheta_i\_m = fabs(cosTheta_i);
                      cosTheta_i\_s = copysign(1.0, cosTheta_i);
                      assert(cosTheta_i_m < cosTheta_O && cosTheta_O < sinTheta_i && sinTheta_i < sinTheta_O && sinTheta_O < v);
                      float code(float cosTheta_i_s, float cosTheta_i_m, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
                      	return cosTheta_i_s * ((cosTheta_O * (cosTheta_i_m / (((0.3333333333333333f / (v * v)) + 2.0f) / v))) / (v * v));
                      }
                      
                      cosTheta_i\_m =     private
                      cosTheta_i\_s =     private
                      NOTE: cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
                      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(costheta_i_s, costheta_i_m, costheta_o, sintheta_i, sintheta_o, v)
                      use fmin_fmax_functions
                          real(4), intent (in) :: costheta_i_s
                          real(4), intent (in) :: costheta_i_m
                          real(4), intent (in) :: costheta_o
                          real(4), intent (in) :: sintheta_i
                          real(4), intent (in) :: sintheta_o
                          real(4), intent (in) :: v
                          code = costheta_i_s * ((costheta_o * (costheta_i_m / (((0.3333333333333333e0 / (v * v)) + 2.0e0) / v))) / (v * v))
                      end function
                      
                      cosTheta_i\_m = abs(cosTheta_i)
                      cosTheta_i\_s = copysign(1.0, cosTheta_i)
                      cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v = sort([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])
                      function code(cosTheta_i_s, cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v)
                      	return Float32(cosTheta_i_s * Float32(Float32(cosTheta_O * Float32(cosTheta_i_m / Float32(Float32(Float32(Float32(0.3333333333333333) / Float32(v * v)) + Float32(2.0)) / v))) / Float32(v * v)))
                      end
                      
                      cosTheta_i\_m = abs(cosTheta_i);
                      cosTheta_i\_s = sign(cosTheta_i) * abs(1.0);
                      cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v = num2cell(sort([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])){:}
                      function tmp = code(cosTheta_i_s, cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v)
                      	tmp = cosTheta_i_s * ((cosTheta_O * (cosTheta_i_m / (((single(0.3333333333333333) / (v * v)) + single(2.0)) / v))) / (v * v));
                      end
                      
                      \begin{array}{l}
                      cosTheta_i\_m = \left|cosTheta\_i\right|
                      \\
                      cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right)
                      \\
                      [cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])\\
                      \\
                      cosTheta\_i\_s \cdot \frac{cosTheta\_O \cdot \frac{cosTheta\_i\_m}{\frac{\frac{0.3333333333333333}{v \cdot v} + 2}{v}}}{v \cdot v}
                      \end{array}
                      
                      Derivation
                      1. Initial program 98.5%

                        \[\frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
                      2. Add Preprocessing
                      3. Taylor expanded in sinTheta_i around 0

                        \[\leadsto \color{blue}{\frac{cosTheta\_O \cdot cosTheta\_i}{{v}^{2} \cdot \left(e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}\right)}} \]
                      4. Step-by-step derivation
                        1. times-fracN/A

                          \[\leadsto \color{blue}{\frac{cosTheta\_O}{{v}^{2}} \cdot \frac{cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}}} \]
                        2. associate-*r/N/A

                          \[\leadsto \color{blue}{\frac{\frac{cosTheta\_O}{{v}^{2}} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}}} \]
                        3. lower-/.f32N/A

                          \[\leadsto \color{blue}{\frac{\frac{cosTheta\_O}{{v}^{2}} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}}} \]
                        4. lower-*.f32N/A

                          \[\leadsto \frac{\color{blue}{\frac{cosTheta\_O}{{v}^{2}} \cdot cosTheta\_i}}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}} \]
                        5. lower-/.f32N/A

                          \[\leadsto \frac{\color{blue}{\frac{cosTheta\_O}{{v}^{2}}} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}} \]
                        6. unpow2N/A

                          \[\leadsto \frac{\frac{cosTheta\_O}{\color{blue}{v \cdot v}} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}} \]
                        7. lower-*.f32N/A

                          \[\leadsto \frac{\frac{cosTheta\_O}{\color{blue}{v \cdot v}} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}} \]
                        8. lower--.f32N/A

                          \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{\color{blue}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}}} \]
                        9. lower-exp.f32N/A

                          \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{\color{blue}{e^{\frac{1}{v}}} - \frac{1}{e^{\frac{1}{v}}}} \]
                        10. lower-/.f32N/A

                          \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\color{blue}{\frac{1}{v}}} - \frac{1}{e^{\frac{1}{v}}}} \]
                        11. rec-expN/A

                          \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \color{blue}{e^{\mathsf{neg}\left(\frac{1}{v}\right)}}} \]
                        12. distribute-neg-fracN/A

                          \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - e^{\color{blue}{\frac{\mathsf{neg}\left(1\right)}{v}}}} \]
                        13. metadata-evalN/A

                          \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - e^{\frac{\color{blue}{-1}}{v}}} \]
                        14. lower-exp.f32N/A

                          \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \color{blue}{e^{\frac{-1}{v}}}} \]
                        15. lower-/.f3298.6

                          \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - e^{\color{blue}{\frac{-1}{v}}}} \]
                      5. Applied rewrites98.6%

                        \[\leadsto \color{blue}{\frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - e^{\frac{-1}{v}}}} \]
                      6. Taylor expanded in v around inf

                        \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{\frac{2 + \frac{1}{3} \cdot \frac{1}{{v}^{2}}}{\color{blue}{v}}} \]
                      7. Step-by-step derivation
                        1. Applied rewrites64.9%

                          \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{\frac{\frac{0.3333333333333333}{v \cdot v} + 2}{\color{blue}{v}}} \]
                        2. Step-by-step derivation
                          1. Applied rewrites64.9%

                            \[\leadsto \frac{cosTheta\_O \cdot \frac{cosTheta\_i}{\frac{\frac{0.3333333333333333}{v \cdot v} + 2}{v}}}{\color{blue}{v \cdot v}} \]
                          2. Add Preprocessing

                          Alternative 10: 64.0% accurate, 4.3× speedup?

                          \[\begin{array}{l} cosTheta_i\_m = \left|cosTheta\_i\right| \\ cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right) \\ [cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])\\ \\ cosTheta\_i\_s \cdot \left(\frac{cosTheta\_i\_m}{v \cdot v} \cdot \frac{cosTheta\_O}{\frac{\frac{0.3333333333333333}{v \cdot v} + 2}{v}}\right) \end{array} \]
                          cosTheta_i\_m = (fabs.f32 cosTheta_i)
                          cosTheta_i\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_i)
                          NOTE: cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
                          (FPCore (cosTheta_i_s cosTheta_i_m cosTheta_O sinTheta_i sinTheta_O v)
                           :precision binary32
                           (*
                            cosTheta_i_s
                            (*
                             (/ cosTheta_i_m (* v v))
                             (/ cosTheta_O (/ (+ (/ 0.3333333333333333 (* v v)) 2.0) v)))))
                          cosTheta_i\_m = fabs(cosTheta_i);
                          cosTheta_i\_s = copysign(1.0, cosTheta_i);
                          assert(cosTheta_i_m < cosTheta_O && cosTheta_O < sinTheta_i && sinTheta_i < sinTheta_O && sinTheta_O < v);
                          float code(float cosTheta_i_s, float cosTheta_i_m, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
                          	return cosTheta_i_s * ((cosTheta_i_m / (v * v)) * (cosTheta_O / (((0.3333333333333333f / (v * v)) + 2.0f) / v)));
                          }
                          
                          cosTheta_i\_m =     private
                          cosTheta_i\_s =     private
                          NOTE: cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
                          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(costheta_i_s, costheta_i_m, costheta_o, sintheta_i, sintheta_o, v)
                          use fmin_fmax_functions
                              real(4), intent (in) :: costheta_i_s
                              real(4), intent (in) :: costheta_i_m
                              real(4), intent (in) :: costheta_o
                              real(4), intent (in) :: sintheta_i
                              real(4), intent (in) :: sintheta_o
                              real(4), intent (in) :: v
                              code = costheta_i_s * ((costheta_i_m / (v * v)) * (costheta_o / (((0.3333333333333333e0 / (v * v)) + 2.0e0) / v)))
                          end function
                          
                          cosTheta_i\_m = abs(cosTheta_i)
                          cosTheta_i\_s = copysign(1.0, cosTheta_i)
                          cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v = sort([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])
                          function code(cosTheta_i_s, cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v)
                          	return Float32(cosTheta_i_s * Float32(Float32(cosTheta_i_m / Float32(v * v)) * Float32(cosTheta_O / Float32(Float32(Float32(Float32(0.3333333333333333) / Float32(v * v)) + Float32(2.0)) / v))))
                          end
                          
                          cosTheta_i\_m = abs(cosTheta_i);
                          cosTheta_i\_s = sign(cosTheta_i) * abs(1.0);
                          cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v = num2cell(sort([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])){:}
                          function tmp = code(cosTheta_i_s, cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v)
                          	tmp = cosTheta_i_s * ((cosTheta_i_m / (v * v)) * (cosTheta_O / (((single(0.3333333333333333) / (v * v)) + single(2.0)) / v)));
                          end
                          
                          \begin{array}{l}
                          cosTheta_i\_m = \left|cosTheta\_i\right|
                          \\
                          cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right)
                          \\
                          [cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])\\
                          \\
                          cosTheta\_i\_s \cdot \left(\frac{cosTheta\_i\_m}{v \cdot v} \cdot \frac{cosTheta\_O}{\frac{\frac{0.3333333333333333}{v \cdot v} + 2}{v}}\right)
                          \end{array}
                          
                          Derivation
                          1. Initial program 98.5%

                            \[\frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
                          2. Add Preprocessing
                          3. Taylor expanded in sinTheta_i around 0

                            \[\leadsto \color{blue}{\frac{cosTheta\_O \cdot cosTheta\_i}{{v}^{2} \cdot \left(e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}\right)}} \]
                          4. Step-by-step derivation
                            1. times-fracN/A

                              \[\leadsto \color{blue}{\frac{cosTheta\_O}{{v}^{2}} \cdot \frac{cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}}} \]
                            2. associate-*r/N/A

                              \[\leadsto \color{blue}{\frac{\frac{cosTheta\_O}{{v}^{2}} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}}} \]
                            3. lower-/.f32N/A

                              \[\leadsto \color{blue}{\frac{\frac{cosTheta\_O}{{v}^{2}} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}}} \]
                            4. lower-*.f32N/A

                              \[\leadsto \frac{\color{blue}{\frac{cosTheta\_O}{{v}^{2}} \cdot cosTheta\_i}}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}} \]
                            5. lower-/.f32N/A

                              \[\leadsto \frac{\color{blue}{\frac{cosTheta\_O}{{v}^{2}}} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}} \]
                            6. unpow2N/A

                              \[\leadsto \frac{\frac{cosTheta\_O}{\color{blue}{v \cdot v}} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}} \]
                            7. lower-*.f32N/A

                              \[\leadsto \frac{\frac{cosTheta\_O}{\color{blue}{v \cdot v}} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}} \]
                            8. lower--.f32N/A

                              \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{\color{blue}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}}} \]
                            9. lower-exp.f32N/A

                              \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{\color{blue}{e^{\frac{1}{v}}} - \frac{1}{e^{\frac{1}{v}}}} \]
                            10. lower-/.f32N/A

                              \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\color{blue}{\frac{1}{v}}} - \frac{1}{e^{\frac{1}{v}}}} \]
                            11. rec-expN/A

                              \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \color{blue}{e^{\mathsf{neg}\left(\frac{1}{v}\right)}}} \]
                            12. distribute-neg-fracN/A

                              \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - e^{\color{blue}{\frac{\mathsf{neg}\left(1\right)}{v}}}} \]
                            13. metadata-evalN/A

                              \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - e^{\frac{\color{blue}{-1}}{v}}} \]
                            14. lower-exp.f32N/A

                              \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \color{blue}{e^{\frac{-1}{v}}}} \]
                            15. lower-/.f3298.6

                              \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - e^{\color{blue}{\frac{-1}{v}}}} \]
                          5. Applied rewrites98.6%

                            \[\leadsto \color{blue}{\frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - e^{\frac{-1}{v}}}} \]
                          6. Taylor expanded in v around inf

                            \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{\frac{2 + \frac{1}{3} \cdot \frac{1}{{v}^{2}}}{\color{blue}{v}}} \]
                          7. Step-by-step derivation
                            1. Applied rewrites64.9%

                              \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{\frac{\frac{0.3333333333333333}{v \cdot v} + 2}{\color{blue}{v}}} \]
                            2. Step-by-step derivation
                              1. Applied rewrites64.9%

                                \[\leadsto \frac{cosTheta\_i}{v \cdot v} \cdot \color{blue}{\frac{cosTheta\_O}{\frac{\frac{0.3333333333333333}{v \cdot v} + 2}{v}}} \]
                              2. Add Preprocessing

                              Alternative 11: 64.0% accurate, 4.3× speedup?

                              \[\begin{array}{l} cosTheta_i\_m = \left|cosTheta\_i\right| \\ cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right) \\ [cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])\\ \\ cosTheta\_i\_s \cdot \left(\frac{cosTheta\_i\_m}{\frac{\frac{0.3333333333333333}{v \cdot v} + 2}{v}} \cdot \frac{cosTheta\_O}{v \cdot v}\right) \end{array} \]
                              cosTheta_i\_m = (fabs.f32 cosTheta_i)
                              cosTheta_i\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_i)
                              NOTE: cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
                              (FPCore (cosTheta_i_s cosTheta_i_m cosTheta_O sinTheta_i sinTheta_O v)
                               :precision binary32
                               (*
                                cosTheta_i_s
                                (*
                                 (/ cosTheta_i_m (/ (+ (/ 0.3333333333333333 (* v v)) 2.0) v))
                                 (/ cosTheta_O (* v v)))))
                              cosTheta_i\_m = fabs(cosTheta_i);
                              cosTheta_i\_s = copysign(1.0, cosTheta_i);
                              assert(cosTheta_i_m < cosTheta_O && cosTheta_O < sinTheta_i && sinTheta_i < sinTheta_O && sinTheta_O < v);
                              float code(float cosTheta_i_s, float cosTheta_i_m, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
                              	return cosTheta_i_s * ((cosTheta_i_m / (((0.3333333333333333f / (v * v)) + 2.0f) / v)) * (cosTheta_O / (v * v)));
                              }
                              
                              cosTheta_i\_m =     private
                              cosTheta_i\_s =     private
                              NOTE: cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
                              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(costheta_i_s, costheta_i_m, costheta_o, sintheta_i, sintheta_o, v)
                              use fmin_fmax_functions
                                  real(4), intent (in) :: costheta_i_s
                                  real(4), intent (in) :: costheta_i_m
                                  real(4), intent (in) :: costheta_o
                                  real(4), intent (in) :: sintheta_i
                                  real(4), intent (in) :: sintheta_o
                                  real(4), intent (in) :: v
                                  code = costheta_i_s * ((costheta_i_m / (((0.3333333333333333e0 / (v * v)) + 2.0e0) / v)) * (costheta_o / (v * v)))
                              end function
                              
                              cosTheta_i\_m = abs(cosTheta_i)
                              cosTheta_i\_s = copysign(1.0, cosTheta_i)
                              cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v = sort([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])
                              function code(cosTheta_i_s, cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v)
                              	return Float32(cosTheta_i_s * Float32(Float32(cosTheta_i_m / Float32(Float32(Float32(Float32(0.3333333333333333) / Float32(v * v)) + Float32(2.0)) / v)) * Float32(cosTheta_O / Float32(v * v))))
                              end
                              
                              cosTheta_i\_m = abs(cosTheta_i);
                              cosTheta_i\_s = sign(cosTheta_i) * abs(1.0);
                              cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v = num2cell(sort([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])){:}
                              function tmp = code(cosTheta_i_s, cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v)
                              	tmp = cosTheta_i_s * ((cosTheta_i_m / (((single(0.3333333333333333) / (v * v)) + single(2.0)) / v)) * (cosTheta_O / (v * v)));
                              end
                              
                              \begin{array}{l}
                              cosTheta_i\_m = \left|cosTheta\_i\right|
                              \\
                              cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right)
                              \\
                              [cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])\\
                              \\
                              cosTheta\_i\_s \cdot \left(\frac{cosTheta\_i\_m}{\frac{\frac{0.3333333333333333}{v \cdot v} + 2}{v}} \cdot \frac{cosTheta\_O}{v \cdot v}\right)
                              \end{array}
                              
                              Derivation
                              1. Initial program 98.5%

                                \[\frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
                              2. Add Preprocessing
                              3. Taylor expanded in sinTheta_i around 0

                                \[\leadsto \color{blue}{\frac{cosTheta\_O \cdot cosTheta\_i}{{v}^{2} \cdot \left(e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}\right)}} \]
                              4. Step-by-step derivation
                                1. times-fracN/A

                                  \[\leadsto \color{blue}{\frac{cosTheta\_O}{{v}^{2}} \cdot \frac{cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}}} \]
                                2. associate-*r/N/A

                                  \[\leadsto \color{blue}{\frac{\frac{cosTheta\_O}{{v}^{2}} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}}} \]
                                3. lower-/.f32N/A

                                  \[\leadsto \color{blue}{\frac{\frac{cosTheta\_O}{{v}^{2}} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}}} \]
                                4. lower-*.f32N/A

                                  \[\leadsto \frac{\color{blue}{\frac{cosTheta\_O}{{v}^{2}} \cdot cosTheta\_i}}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}} \]
                                5. lower-/.f32N/A

                                  \[\leadsto \frac{\color{blue}{\frac{cosTheta\_O}{{v}^{2}}} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}} \]
                                6. unpow2N/A

                                  \[\leadsto \frac{\frac{cosTheta\_O}{\color{blue}{v \cdot v}} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}} \]
                                7. lower-*.f32N/A

                                  \[\leadsto \frac{\frac{cosTheta\_O}{\color{blue}{v \cdot v}} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}} \]
                                8. lower--.f32N/A

                                  \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{\color{blue}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}}} \]
                                9. lower-exp.f32N/A

                                  \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{\color{blue}{e^{\frac{1}{v}}} - \frac{1}{e^{\frac{1}{v}}}} \]
                                10. lower-/.f32N/A

                                  \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\color{blue}{\frac{1}{v}}} - \frac{1}{e^{\frac{1}{v}}}} \]
                                11. rec-expN/A

                                  \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \color{blue}{e^{\mathsf{neg}\left(\frac{1}{v}\right)}}} \]
                                12. distribute-neg-fracN/A

                                  \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - e^{\color{blue}{\frac{\mathsf{neg}\left(1\right)}{v}}}} \]
                                13. metadata-evalN/A

                                  \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - e^{\frac{\color{blue}{-1}}{v}}} \]
                                14. lower-exp.f32N/A

                                  \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \color{blue}{e^{\frac{-1}{v}}}} \]
                                15. lower-/.f3298.6

                                  \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - e^{\color{blue}{\frac{-1}{v}}}} \]
                              5. Applied rewrites98.6%

                                \[\leadsto \color{blue}{\frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - e^{\frac{-1}{v}}}} \]
                              6. Taylor expanded in v around inf

                                \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{\frac{2 + \frac{1}{3} \cdot \frac{1}{{v}^{2}}}{\color{blue}{v}}} \]
                              7. Step-by-step derivation
                                1. Applied rewrites64.9%

                                  \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{\frac{\frac{0.3333333333333333}{v \cdot v} + 2}{\color{blue}{v}}} \]
                                2. Step-by-step derivation
                                  1. Applied rewrites64.9%

                                    \[\leadsto \frac{cosTheta\_i}{\frac{\frac{0.3333333333333333}{v \cdot v} + 2}{v}} \cdot \color{blue}{\frac{cosTheta\_O}{v \cdot v}} \]
                                  2. Add Preprocessing

                                  Alternative 12: 64.0% accurate, 5.2× speedup?

                                  \[\begin{array}{l} cosTheta_i\_m = \left|cosTheta\_i\right| \\ cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right) \\ [cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])\\ \\ cosTheta\_i\_s \cdot \left(\frac{cosTheta\_i\_m}{2 \cdot v} \cdot \frac{cosTheta\_O}{\frac{0.16666666666666666}{v \cdot v} + 1}\right) \end{array} \]
                                  cosTheta_i\_m = (fabs.f32 cosTheta_i)
                                  cosTheta_i\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_i)
                                  NOTE: cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
                                  (FPCore (cosTheta_i_s cosTheta_i_m cosTheta_O sinTheta_i sinTheta_O v)
                                   :precision binary32
                                   (*
                                    cosTheta_i_s
                                    (*
                                     (/ cosTheta_i_m (* 2.0 v))
                                     (/ cosTheta_O (+ (/ 0.16666666666666666 (* v v)) 1.0)))))
                                  cosTheta_i\_m = fabs(cosTheta_i);
                                  cosTheta_i\_s = copysign(1.0, cosTheta_i);
                                  assert(cosTheta_i_m < cosTheta_O && cosTheta_O < sinTheta_i && sinTheta_i < sinTheta_O && sinTheta_O < v);
                                  float code(float cosTheta_i_s, float cosTheta_i_m, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
                                  	return cosTheta_i_s * ((cosTheta_i_m / (2.0f * v)) * (cosTheta_O / ((0.16666666666666666f / (v * v)) + 1.0f)));
                                  }
                                  
                                  cosTheta_i\_m =     private
                                  cosTheta_i\_s =     private
                                  NOTE: cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
                                  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(costheta_i_s, costheta_i_m, costheta_o, sintheta_i, sintheta_o, v)
                                  use fmin_fmax_functions
                                      real(4), intent (in) :: costheta_i_s
                                      real(4), intent (in) :: costheta_i_m
                                      real(4), intent (in) :: costheta_o
                                      real(4), intent (in) :: sintheta_i
                                      real(4), intent (in) :: sintheta_o
                                      real(4), intent (in) :: v
                                      code = costheta_i_s * ((costheta_i_m / (2.0e0 * v)) * (costheta_o / ((0.16666666666666666e0 / (v * v)) + 1.0e0)))
                                  end function
                                  
                                  cosTheta_i\_m = abs(cosTheta_i)
                                  cosTheta_i\_s = copysign(1.0, cosTheta_i)
                                  cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v = sort([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])
                                  function code(cosTheta_i_s, cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v)
                                  	return Float32(cosTheta_i_s * Float32(Float32(cosTheta_i_m / Float32(Float32(2.0) * v)) * Float32(cosTheta_O / Float32(Float32(Float32(0.16666666666666666) / Float32(v * v)) + Float32(1.0)))))
                                  end
                                  
                                  cosTheta_i\_m = abs(cosTheta_i);
                                  cosTheta_i\_s = sign(cosTheta_i) * abs(1.0);
                                  cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v = num2cell(sort([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])){:}
                                  function tmp = code(cosTheta_i_s, cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v)
                                  	tmp = cosTheta_i_s * ((cosTheta_i_m / (single(2.0) * v)) * (cosTheta_O / ((single(0.16666666666666666) / (v * v)) + single(1.0))));
                                  end
                                  
                                  \begin{array}{l}
                                  cosTheta_i\_m = \left|cosTheta\_i\right|
                                  \\
                                  cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right)
                                  \\
                                  [cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])\\
                                  \\
                                  cosTheta\_i\_s \cdot \left(\frac{cosTheta\_i\_m}{2 \cdot v} \cdot \frac{cosTheta\_O}{\frac{0.16666666666666666}{v \cdot v} + 1}\right)
                                  \end{array}
                                  
                                  Derivation
                                  1. Initial program 98.5%

                                    \[\frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
                                  2. Add Preprocessing
                                  3. Taylor expanded in sinTheta_i around 0

                                    \[\leadsto \color{blue}{\frac{cosTheta\_O \cdot cosTheta\_i}{{v}^{2} \cdot \left(e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}\right)}} \]
                                  4. Step-by-step derivation
                                    1. times-fracN/A

                                      \[\leadsto \color{blue}{\frac{cosTheta\_O}{{v}^{2}} \cdot \frac{cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}}} \]
                                    2. associate-*r/N/A

                                      \[\leadsto \color{blue}{\frac{\frac{cosTheta\_O}{{v}^{2}} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}}} \]
                                    3. lower-/.f32N/A

                                      \[\leadsto \color{blue}{\frac{\frac{cosTheta\_O}{{v}^{2}} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}}} \]
                                    4. lower-*.f32N/A

                                      \[\leadsto \frac{\color{blue}{\frac{cosTheta\_O}{{v}^{2}} \cdot cosTheta\_i}}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}} \]
                                    5. lower-/.f32N/A

                                      \[\leadsto \frac{\color{blue}{\frac{cosTheta\_O}{{v}^{2}}} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}} \]
                                    6. unpow2N/A

                                      \[\leadsto \frac{\frac{cosTheta\_O}{\color{blue}{v \cdot v}} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}} \]
                                    7. lower-*.f32N/A

                                      \[\leadsto \frac{\frac{cosTheta\_O}{\color{blue}{v \cdot v}} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}} \]
                                    8. lower--.f32N/A

                                      \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{\color{blue}{e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}}} \]
                                    9. lower-exp.f32N/A

                                      \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{\color{blue}{e^{\frac{1}{v}}} - \frac{1}{e^{\frac{1}{v}}}} \]
                                    10. lower-/.f32N/A

                                      \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\color{blue}{\frac{1}{v}}} - \frac{1}{e^{\frac{1}{v}}}} \]
                                    11. rec-expN/A

                                      \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \color{blue}{e^{\mathsf{neg}\left(\frac{1}{v}\right)}}} \]
                                    12. distribute-neg-fracN/A

                                      \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - e^{\color{blue}{\frac{\mathsf{neg}\left(1\right)}{v}}}} \]
                                    13. metadata-evalN/A

                                      \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - e^{\frac{\color{blue}{-1}}{v}}} \]
                                    14. lower-exp.f32N/A

                                      \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - \color{blue}{e^{\frac{-1}{v}}}} \]
                                    15. lower-/.f3298.6

                                      \[\leadsto \frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - e^{\color{blue}{\frac{-1}{v}}}} \]
                                  5. Applied rewrites98.6%

                                    \[\leadsto \color{blue}{\frac{\frac{cosTheta\_O}{v \cdot v} \cdot cosTheta\_i}{e^{\frac{1}{v}} - e^{\frac{-1}{v}}}} \]
                                  6. Step-by-step derivation
                                    1. Applied rewrites98.7%

                                      \[\leadsto \frac{cosTheta\_O}{2 \cdot v} \cdot \color{blue}{\frac{\frac{cosTheta\_i}{v}}{\sinh \left(\frac{1}{v}\right)}} \]
                                    2. Step-by-step derivation
                                      1. Applied rewrites98.7%

                                        \[\leadsto \frac{cosTheta\_i}{2 \cdot v} \cdot \color{blue}{\frac{cosTheta\_O}{\sinh \left(\frac{1}{v}\right) \cdot v}} \]
                                      2. Taylor expanded in v around inf

                                        \[\leadsto \frac{cosTheta\_i}{2 \cdot v} \cdot \frac{cosTheta\_O}{1 + \color{blue}{\frac{1}{6} \cdot \frac{1}{{v}^{2}}}} \]
                                      3. Step-by-step derivation
                                        1. Applied rewrites64.9%

                                          \[\leadsto \frac{cosTheta\_i}{2 \cdot v} \cdot \frac{cosTheta\_O}{\frac{0.16666666666666666}{v \cdot v} + \color{blue}{1}} \]
                                        2. Add Preprocessing

                                        Alternative 13: 58.3% accurate, 12.4× speedup?

                                        \[\begin{array}{l} cosTheta_i\_m = \left|cosTheta\_i\right| \\ cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right) \\ [cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])\\ \\ cosTheta\_i\_s \cdot \left(cosTheta\_i\_m \cdot \left(cosTheta\_O \cdot \frac{0.5}{v}\right)\right) \end{array} \]
                                        cosTheta_i\_m = (fabs.f32 cosTheta_i)
                                        cosTheta_i\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_i)
                                        NOTE: cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
                                        (FPCore (cosTheta_i_s cosTheta_i_m cosTheta_O sinTheta_i sinTheta_O v)
                                         :precision binary32
                                         (* cosTheta_i_s (* cosTheta_i_m (* cosTheta_O (/ 0.5 v)))))
                                        cosTheta_i\_m = fabs(cosTheta_i);
                                        cosTheta_i\_s = copysign(1.0, cosTheta_i);
                                        assert(cosTheta_i_m < cosTheta_O && cosTheta_O < sinTheta_i && sinTheta_i < sinTheta_O && sinTheta_O < v);
                                        float code(float cosTheta_i_s, float cosTheta_i_m, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
                                        	return cosTheta_i_s * (cosTheta_i_m * (cosTheta_O * (0.5f / v)));
                                        }
                                        
                                        cosTheta_i\_m =     private
                                        cosTheta_i\_s =     private
                                        NOTE: cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
                                        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(costheta_i_s, costheta_i_m, costheta_o, sintheta_i, sintheta_o, v)
                                        use fmin_fmax_functions
                                            real(4), intent (in) :: costheta_i_s
                                            real(4), intent (in) :: costheta_i_m
                                            real(4), intent (in) :: costheta_o
                                            real(4), intent (in) :: sintheta_i
                                            real(4), intent (in) :: sintheta_o
                                            real(4), intent (in) :: v
                                            code = costheta_i_s * (costheta_i_m * (costheta_o * (0.5e0 / v)))
                                        end function
                                        
                                        cosTheta_i\_m = abs(cosTheta_i)
                                        cosTheta_i\_s = copysign(1.0, cosTheta_i)
                                        cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v = sort([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])
                                        function code(cosTheta_i_s, cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v)
                                        	return Float32(cosTheta_i_s * Float32(cosTheta_i_m * Float32(cosTheta_O * Float32(Float32(0.5) / v))))
                                        end
                                        
                                        cosTheta_i\_m = abs(cosTheta_i);
                                        cosTheta_i\_s = sign(cosTheta_i) * abs(1.0);
                                        cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v = num2cell(sort([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])){:}
                                        function tmp = code(cosTheta_i_s, cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v)
                                        	tmp = cosTheta_i_s * (cosTheta_i_m * (cosTheta_O * (single(0.5) / v)));
                                        end
                                        
                                        \begin{array}{l}
                                        cosTheta_i\_m = \left|cosTheta\_i\right|
                                        \\
                                        cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right)
                                        \\
                                        [cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])\\
                                        \\
                                        cosTheta\_i\_s \cdot \left(cosTheta\_i\_m \cdot \left(cosTheta\_O \cdot \frac{0.5}{v}\right)\right)
                                        \end{array}
                                        
                                        Derivation
                                        1. Initial program 98.5%

                                          \[\frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
                                        2. Add Preprocessing
                                        3. Taylor expanded in v around inf

                                          \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{cosTheta\_O \cdot cosTheta\_i}{v}} \]
                                        4. Step-by-step derivation
                                          1. lower-*.f32N/A

                                            \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{cosTheta\_O \cdot cosTheta\_i}{v}} \]
                                          2. lower-/.f32N/A

                                            \[\leadsto \frac{1}{2} \cdot \color{blue}{\frac{cosTheta\_O \cdot cosTheta\_i}{v}} \]
                                          3. lower-*.f3259.2

                                            \[\leadsto 0.5 \cdot \frac{\color{blue}{cosTheta\_O \cdot cosTheta\_i}}{v} \]
                                        5. Applied rewrites59.2%

                                          \[\leadsto \color{blue}{0.5 \cdot \frac{cosTheta\_O \cdot cosTheta\_i}{v}} \]
                                        6. Step-by-step derivation
                                          1. Applied rewrites59.2%

                                            \[\leadsto \frac{\left(cosTheta\_O \cdot cosTheta\_i\right) \cdot 0.5}{\color{blue}{v}} \]
                                          2. Step-by-step derivation
                                            1. Applied rewrites59.2%

                                              \[\leadsto cosTheta\_i \cdot \color{blue}{\left(cosTheta\_O \cdot \frac{0.5}{v}\right)} \]
                                            2. Add Preprocessing

                                            Alternative 14: 58.3% accurate, 12.4× speedup?

                                            \[\begin{array}{l} cosTheta_i\_m = \left|cosTheta\_i\right| \\ cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right) \\ [cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])\\ \\ cosTheta\_i\_s \cdot \left(cosTheta\_O \cdot \left(cosTheta\_i\_m \cdot \frac{0.5}{v}\right)\right) \end{array} \]
                                            cosTheta_i\_m = (fabs.f32 cosTheta_i)
                                            cosTheta_i\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_i)
                                            NOTE: cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
                                            (FPCore (cosTheta_i_s cosTheta_i_m cosTheta_O sinTheta_i sinTheta_O v)
                                             :precision binary32
                                             (* cosTheta_i_s (* cosTheta_O (* cosTheta_i_m (/ 0.5 v)))))
                                            cosTheta_i\_m = fabs(cosTheta_i);
                                            cosTheta_i\_s = copysign(1.0, cosTheta_i);
                                            assert(cosTheta_i_m < cosTheta_O && cosTheta_O < sinTheta_i && sinTheta_i < sinTheta_O && sinTheta_O < v);
                                            float code(float cosTheta_i_s, float cosTheta_i_m, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
                                            	return cosTheta_i_s * (cosTheta_O * (cosTheta_i_m * (0.5f / v)));
                                            }
                                            
                                            cosTheta_i\_m =     private
                                            cosTheta_i\_s =     private
                                            NOTE: cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
                                            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(costheta_i_s, costheta_i_m, costheta_o, sintheta_i, sintheta_o, v)
                                            use fmin_fmax_functions
                                                real(4), intent (in) :: costheta_i_s
                                                real(4), intent (in) :: costheta_i_m
                                                real(4), intent (in) :: costheta_o
                                                real(4), intent (in) :: sintheta_i
                                                real(4), intent (in) :: sintheta_o
                                                real(4), intent (in) :: v
                                                code = costheta_i_s * (costheta_o * (costheta_i_m * (0.5e0 / v)))
                                            end function
                                            
                                            cosTheta_i\_m = abs(cosTheta_i)
                                            cosTheta_i\_s = copysign(1.0, cosTheta_i)
                                            cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v = sort([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])
                                            function code(cosTheta_i_s, cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v)
                                            	return Float32(cosTheta_i_s * Float32(cosTheta_O * Float32(cosTheta_i_m * Float32(Float32(0.5) / v))))
                                            end
                                            
                                            cosTheta_i\_m = abs(cosTheta_i);
                                            cosTheta_i\_s = sign(cosTheta_i) * abs(1.0);
                                            cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v = num2cell(sort([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])){:}
                                            function tmp = code(cosTheta_i_s, cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v)
                                            	tmp = cosTheta_i_s * (cosTheta_O * (cosTheta_i_m * (single(0.5) / v)));
                                            end
                                            
                                            \begin{array}{l}
                                            cosTheta_i\_m = \left|cosTheta\_i\right|
                                            \\
                                            cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right)
                                            \\
                                            [cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])\\
                                            \\
                                            cosTheta\_i\_s \cdot \left(cosTheta\_O \cdot \left(cosTheta\_i\_m \cdot \frac{0.5}{v}\right)\right)
                                            \end{array}
                                            
                                            Derivation
                                            1. Initial program 98.5%

                                              \[\frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
                                            2. Add Preprocessing
                                            3. Taylor expanded in v around inf

                                              \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{cosTheta\_O \cdot cosTheta\_i}{v}} \]
                                            4. Step-by-step derivation
                                              1. lower-*.f32N/A

                                                \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{cosTheta\_O \cdot cosTheta\_i}{v}} \]
                                              2. lower-/.f32N/A

                                                \[\leadsto \frac{1}{2} \cdot \color{blue}{\frac{cosTheta\_O \cdot cosTheta\_i}{v}} \]
                                              3. lower-*.f3259.2

                                                \[\leadsto 0.5 \cdot \frac{\color{blue}{cosTheta\_O \cdot cosTheta\_i}}{v} \]
                                            5. Applied rewrites59.2%

                                              \[\leadsto \color{blue}{0.5 \cdot \frac{cosTheta\_O \cdot cosTheta\_i}{v}} \]
                                            6. Step-by-step derivation
                                              1. Applied rewrites59.2%

                                                \[\leadsto \frac{\left(cosTheta\_O \cdot cosTheta\_i\right) \cdot 0.5}{\color{blue}{v}} \]
                                              2. Step-by-step derivation
                                                1. Applied rewrites59.2%

                                                  \[\leadsto cosTheta\_O \cdot \color{blue}{\left(cosTheta\_i \cdot \frac{0.5}{v}\right)} \]
                                                2. Add Preprocessing

                                                Alternative 15: 58.3% accurate, 12.4× speedup?

                                                \[\begin{array}{l} cosTheta_i\_m = \left|cosTheta\_i\right| \\ cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right) \\ [cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])\\ \\ cosTheta\_i\_s \cdot \left(0.5 \cdot \left(\frac{cosTheta\_O}{v} \cdot cosTheta\_i\_m\right)\right) \end{array} \]
                                                cosTheta_i\_m = (fabs.f32 cosTheta_i)
                                                cosTheta_i\_s = (copysign.f32 #s(literal 1 binary32) cosTheta_i)
                                                NOTE: cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
                                                (FPCore (cosTheta_i_s cosTheta_i_m cosTheta_O sinTheta_i sinTheta_O v)
                                                 :precision binary32
                                                 (* cosTheta_i_s (* 0.5 (* (/ cosTheta_O v) cosTheta_i_m))))
                                                cosTheta_i\_m = fabs(cosTheta_i);
                                                cosTheta_i\_s = copysign(1.0, cosTheta_i);
                                                assert(cosTheta_i_m < cosTheta_O && cosTheta_O < sinTheta_i && sinTheta_i < sinTheta_O && sinTheta_O < v);
                                                float code(float cosTheta_i_s, float cosTheta_i_m, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
                                                	return cosTheta_i_s * (0.5f * ((cosTheta_O / v) * cosTheta_i_m));
                                                }
                                                
                                                cosTheta_i\_m =     private
                                                cosTheta_i\_s =     private
                                                NOTE: cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, and v should be sorted in increasing order before calling this function.
                                                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(costheta_i_s, costheta_i_m, costheta_o, sintheta_i, sintheta_o, v)
                                                use fmin_fmax_functions
                                                    real(4), intent (in) :: costheta_i_s
                                                    real(4), intent (in) :: costheta_i_m
                                                    real(4), intent (in) :: costheta_o
                                                    real(4), intent (in) :: sintheta_i
                                                    real(4), intent (in) :: sintheta_o
                                                    real(4), intent (in) :: v
                                                    code = costheta_i_s * (0.5e0 * ((costheta_o / v) * costheta_i_m))
                                                end function
                                                
                                                cosTheta_i\_m = abs(cosTheta_i)
                                                cosTheta_i\_s = copysign(1.0, cosTheta_i)
                                                cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v = sort([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])
                                                function code(cosTheta_i_s, cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v)
                                                	return Float32(cosTheta_i_s * Float32(Float32(0.5) * Float32(Float32(cosTheta_O / v) * cosTheta_i_m)))
                                                end
                                                
                                                cosTheta_i\_m = abs(cosTheta_i);
                                                cosTheta_i\_s = sign(cosTheta_i) * abs(1.0);
                                                cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v = num2cell(sort([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])){:}
                                                function tmp = code(cosTheta_i_s, cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v)
                                                	tmp = cosTheta_i_s * (single(0.5) * ((cosTheta_O / v) * cosTheta_i_m));
                                                end
                                                
                                                \begin{array}{l}
                                                cosTheta_i\_m = \left|cosTheta\_i\right|
                                                \\
                                                cosTheta_i\_s = \mathsf{copysign}\left(1, cosTheta\_i\right)
                                                \\
                                                [cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v] = \mathsf{sort}([cosTheta_i_m, cosTheta_O, sinTheta_i, sinTheta_O, v])\\
                                                \\
                                                cosTheta\_i\_s \cdot \left(0.5 \cdot \left(\frac{cosTheta\_O}{v} \cdot cosTheta\_i\_m\right)\right)
                                                \end{array}
                                                
                                                Derivation
                                                1. Initial program 98.5%

                                                  \[\frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
                                                2. Add Preprocessing
                                                3. Taylor expanded in v around inf

                                                  \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{cosTheta\_O \cdot cosTheta\_i}{v}} \]
                                                4. Step-by-step derivation
                                                  1. lower-*.f32N/A

                                                    \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{cosTheta\_O \cdot cosTheta\_i}{v}} \]
                                                  2. lower-/.f32N/A

                                                    \[\leadsto \frac{1}{2} \cdot \color{blue}{\frac{cosTheta\_O \cdot cosTheta\_i}{v}} \]
                                                  3. lower-*.f3259.2

                                                    \[\leadsto 0.5 \cdot \frac{\color{blue}{cosTheta\_O \cdot cosTheta\_i}}{v} \]
                                                5. Applied rewrites59.2%

                                                  \[\leadsto \color{blue}{0.5 \cdot \frac{cosTheta\_O \cdot cosTheta\_i}{v}} \]
                                                6. Step-by-step derivation
                                                  1. Applied rewrites59.2%

                                                    \[\leadsto 0.5 \cdot \left(\frac{cosTheta\_O}{v} \cdot \color{blue}{cosTheta\_i}\right) \]
                                                  2. Add Preprocessing

                                                  Reproduce

                                                  ?
                                                  herbie shell --seed 2024346 
                                                  (FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
                                                    :name "HairBSDF, Mp, upper"
                                                    :precision binary32
                                                    :pre (and (and (and (and (and (and (<= -1.0 cosTheta_i) (<= cosTheta_i 1.0)) (and (<= -1.0 cosTheta_O) (<= cosTheta_O 1.0))) (and (<= -1.0 sinTheta_i) (<= sinTheta_i 1.0))) (and (<= -1.0 sinTheta_O) (<= sinTheta_O 1.0))) (< 0.1 v)) (<= v 1.5707964))
                                                    (/ (* (exp (- (/ (* sinTheta_i sinTheta_O) v))) (/ (* cosTheta_i cosTheta_O) v)) (* (* (sinh (/ 1.0 v)) 2.0) v)))