HairBSDF, Mp, upper

Percentage Accurate: 98.6% → 98.8%
Time: 7.8s
Alternatives: 18
Speedup: 1.5×

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\]
\[\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} \]
(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
\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}

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 18 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?

\[\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} \]
(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
\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}

Alternative 1: 98.8% accurate, 0.5× speedup?

\[\begin{array}{l} t_0 := \frac{e^{\frac{1}{v}}}{2}\\ \left(\frac{e^{sinTheta\_i \cdot \frac{-sinTheta\_O}{v}}}{v} \cdot \left(cosTheta\_O \cdot cosTheta\_i\right)\right) \cdot \frac{\frac{0.5}{v}}{\left(1 - \frac{\frac{e^{\frac{-1}{v}}}{2}}{t\_0}\right) \cdot t\_0} \end{array} \]
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
 :precision binary32
 (let* ((t_0 (/ (exp (/ 1.0 v)) 2.0)))
   (*
    (*
     (/ (exp (* sinTheta_i (/ (- sinTheta_O) v))) v)
     (* cosTheta_O cosTheta_i))
    (/ (/ 0.5 v) (* (- 1.0 (/ (/ (exp (/ -1.0 v)) 2.0) t_0)) t_0)))))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
	float t_0 = expf((1.0f / v)) / 2.0f;
	return ((expf((sinTheta_i * (-sinTheta_O / v))) / v) * (cosTheta_O * cosTheta_i)) * ((0.5f / v) / ((1.0f - ((expf((-1.0f / v)) / 2.0f) / t_0)) * t_0));
}
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
    real(4) :: t_0
    t_0 = exp((1.0e0 / v)) / 2.0e0
    code = ((exp((sintheta_i * (-sintheta_o / v))) / v) * (costheta_o * costheta_i)) * ((0.5e0 / v) / ((1.0e0 - ((exp(((-1.0e0) / v)) / 2.0e0) / t_0)) * t_0))
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
	t_0 = Float32(exp(Float32(Float32(1.0) / v)) / Float32(2.0))
	return Float32(Float32(Float32(exp(Float32(sinTheta_i * Float32(Float32(-sinTheta_O) / v))) / v) * Float32(cosTheta_O * cosTheta_i)) * Float32(Float32(Float32(0.5) / v) / Float32(Float32(Float32(1.0) - Float32(Float32(exp(Float32(Float32(-1.0) / v)) / Float32(2.0)) / t_0)) * t_0)))
end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
	t_0 = exp((single(1.0) / v)) / single(2.0);
	tmp = ((exp((sinTheta_i * (-sinTheta_O / v))) / v) * (cosTheta_O * cosTheta_i)) * ((single(0.5) / v) / ((single(1.0) - ((exp((single(-1.0) / v)) / single(2.0)) / t_0)) * t_0));
end
\begin{array}{l}
t_0 := \frac{e^{\frac{1}{v}}}{2}\\
\left(\frac{e^{sinTheta\_i \cdot \frac{-sinTheta\_O}{v}}}{v} \cdot \left(cosTheta\_O \cdot cosTheta\_i\right)\right) \cdot \frac{\frac{0.5}{v}}{\left(1 - \frac{\frac{e^{\frac{-1}{v}}}{2}}{t\_0}\right) \cdot t\_0}
\end{array}
Derivation
  1. Initial program 98.6%

    \[\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. 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. lift-/.f32N/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} \]
    5. mult-flipN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\left(\frac{e^{\frac{-sinTheta\_O}{v} \cdot sinTheta\_i}}{v} \cdot cosTheta\_i\right) \cdot cosTheta\_O\right) \cdot \frac{\frac{\frac{1}{2}}{v}}{\color{blue}{\frac{e^{\frac{1}{v}}}{2} - \frac{e^{\mathsf{neg}\left(\frac{1}{v}\right)}}{2}}} \]
    4. sub-to-multN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 98.8% accurate, 0.5× speedup?

\[\begin{array}{l} t_0 := \frac{e^{\frac{1}{v}}}{2}\\ \left(\left(\frac{e^{\frac{-sinTheta\_O}{v} \cdot sinTheta\_i}}{v} \cdot \mathsf{min}\left(cosTheta\_i, cosTheta\_O\right)\right) \cdot \mathsf{max}\left(cosTheta\_i, cosTheta\_O\right)\right) \cdot \frac{\frac{0.5}{v}}{\left(1 - \frac{\frac{e^{\frac{-1}{v}}}{2}}{t\_0}\right) \cdot t\_0} \end{array} \]
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
 :precision binary32
 (let* ((t_0 (/ (exp (/ 1.0 v)) 2.0)))
   (*
    (*
     (*
      (/ (exp (* (/ (- sinTheta_O) v) sinTheta_i)) v)
      (fmin cosTheta_i cosTheta_O))
     (fmax cosTheta_i cosTheta_O))
    (/ (/ 0.5 v) (* (- 1.0 (/ (/ (exp (/ -1.0 v)) 2.0) t_0)) t_0)))))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
	float t_0 = expf((1.0f / v)) / 2.0f;
	return (((expf(((-sinTheta_O / v) * sinTheta_i)) / v) * fminf(cosTheta_i, cosTheta_O)) * fmaxf(cosTheta_i, cosTheta_O)) * ((0.5f / v) / ((1.0f - ((expf((-1.0f / v)) / 2.0f) / t_0)) * t_0));
}
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
    real(4) :: t_0
    t_0 = exp((1.0e0 / v)) / 2.0e0
    code = (((exp(((-sintheta_o / v) * sintheta_i)) / v) * fmin(costheta_i, costheta_o)) * fmax(costheta_i, costheta_o)) * ((0.5e0 / v) / ((1.0e0 - ((exp(((-1.0e0) / v)) / 2.0e0) / t_0)) * t_0))
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
	t_0 = Float32(exp(Float32(Float32(1.0) / v)) / Float32(2.0))
	return Float32(Float32(Float32(Float32(exp(Float32(Float32(Float32(-sinTheta_O) / v) * sinTheta_i)) / v) * fmin(cosTheta_i, cosTheta_O)) * fmax(cosTheta_i, cosTheta_O)) * Float32(Float32(Float32(0.5) / v) / Float32(Float32(Float32(1.0) - Float32(Float32(exp(Float32(Float32(-1.0) / v)) / Float32(2.0)) / t_0)) * t_0)))
end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
	t_0 = exp((single(1.0) / v)) / single(2.0);
	tmp = (((exp(((-sinTheta_O / v) * sinTheta_i)) / v) * min(cosTheta_i, cosTheta_O)) * max(cosTheta_i, cosTheta_O)) * ((single(0.5) / v) / ((single(1.0) - ((exp((single(-1.0) / v)) / single(2.0)) / t_0)) * t_0));
end
\begin{array}{l}
t_0 := \frac{e^{\frac{1}{v}}}{2}\\
\left(\left(\frac{e^{\frac{-sinTheta\_O}{v} \cdot sinTheta\_i}}{v} \cdot \mathsf{min}\left(cosTheta\_i, cosTheta\_O\right)\right) \cdot \mathsf{max}\left(cosTheta\_i, cosTheta\_O\right)\right) \cdot \frac{\frac{0.5}{v}}{\left(1 - \frac{\frac{e^{\frac{-1}{v}}}{2}}{t\_0}\right) \cdot t\_0}
\end{array}
Derivation
  1. Initial program 98.6%

    \[\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. 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. lift-/.f32N/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} \]
    5. mult-flipN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\left(\frac{e^{\frac{-sinTheta\_O}{v} \cdot sinTheta\_i}}{v} \cdot cosTheta\_i\right) \cdot cosTheta\_O\right) \cdot \frac{\frac{\frac{1}{2}}{v}}{\color{blue}{\frac{e^{\frac{1}{v}}}{2} - \frac{e^{\mathsf{neg}\left(\frac{1}{v}\right)}}{2}}} \]
    4. sub-to-multN/A

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

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

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

Alternative 3: 98.8% accurate, 1.0× speedup?

\[\left(\left(\left(-1 \cdot \frac{\frac{sinTheta\_O \cdot sinTheta\_i}{v} - 1}{v}\right) \cdot \mathsf{min}\left(cosTheta\_i, cosTheta\_O\right)\right) \cdot \mathsf{max}\left(cosTheta\_i, cosTheta\_O\right)\right) \cdot \frac{\frac{0.5}{v}}{\sinh \left(\frac{1}{v}\right)} \]
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
 :precision binary32
 (*
  (*
   (*
    (* -1.0 (/ (- (/ (* sinTheta_O sinTheta_i) v) 1.0) v))
    (fmin cosTheta_i cosTheta_O))
   (fmax cosTheta_i cosTheta_O))
  (/ (/ 0.5 v) (sinh (/ 1.0 v)))))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
	return (((-1.0f * ((((sinTheta_O * sinTheta_i) / v) - 1.0f) / v)) * fminf(cosTheta_i, cosTheta_O)) * fmaxf(cosTheta_i, cosTheta_O)) * ((0.5f / v) / sinhf((1.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 = ((((-1.0e0) * ((((sintheta_o * sintheta_i) / v) - 1.0e0) / v)) * fmin(costheta_i, costheta_o)) * fmax(costheta_i, costheta_o)) * ((0.5e0 / v) / sinh((1.0e0 / v)))
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
	return Float32(Float32(Float32(Float32(Float32(-1.0) * Float32(Float32(Float32(Float32(sinTheta_O * sinTheta_i) / v) - Float32(1.0)) / v)) * fmin(cosTheta_i, cosTheta_O)) * fmax(cosTheta_i, cosTheta_O)) * Float32(Float32(Float32(0.5) / v) / sinh(Float32(Float32(1.0) / v))))
end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
	tmp = (((single(-1.0) * ((((sinTheta_O * sinTheta_i) / v) - single(1.0)) / v)) * min(cosTheta_i, cosTheta_O)) * max(cosTheta_i, cosTheta_O)) * ((single(0.5) / v) / sinh((single(1.0) / v)));
end
\left(\left(\left(-1 \cdot \frac{\frac{sinTheta\_O \cdot sinTheta\_i}{v} - 1}{v}\right) \cdot \mathsf{min}\left(cosTheta\_i, cosTheta\_O\right)\right) \cdot \mathsf{max}\left(cosTheta\_i, cosTheta\_O\right)\right) \cdot \frac{\frac{0.5}{v}}{\sinh \left(\frac{1}{v}\right)}
Derivation
  1. Initial program 98.6%

    \[\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. 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. lift-/.f32N/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} \]
    5. mult-flipN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\left(\left(-1 \cdot \frac{\frac{sinTheta\_O \cdot sinTheta\_i}{v} - 1}{v}\right) \cdot cosTheta\_i\right) \cdot cosTheta\_O\right) \cdot \frac{\frac{\frac{1}{2}}{v}}{\sinh \left(\frac{1}{v}\right)} \]
    5. lower-*.f3298.8%

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

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

Alternative 4: 98.6% accurate, 1.5× speedup?

\[\left(cosTheta\_i \cdot \left(cosTheta\_O \cdot \frac{0.5}{v}\right)\right) \cdot \frac{\frac{1}{v}}{\sinh \left(\frac{1}{v}\right)} \]
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
 :precision binary32
 (* (* cosTheta_i (* cosTheta_O (/ 0.5 v))) (/ (/ 1.0 v) (sinh (/ 1.0 v)))))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
	return (cosTheta_i * (cosTheta_O * (0.5f / v))) * ((1.0f / v) / sinhf((1.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 = (costheta_i * (costheta_o * (0.5e0 / v))) * ((1.0e0 / v) / sinh((1.0e0 / v)))
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
	return Float32(Float32(cosTheta_i * Float32(cosTheta_O * Float32(Float32(0.5) / v))) * Float32(Float32(Float32(1.0) / v) / sinh(Float32(Float32(1.0) / v))))
end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
	tmp = (cosTheta_i * (cosTheta_O * (single(0.5) / v))) * ((single(1.0) / v) / sinh((single(1.0) / v)));
end
\left(cosTheta\_i \cdot \left(cosTheta\_O \cdot \frac{0.5}{v}\right)\right) \cdot \frac{\frac{1}{v}}{\sinh \left(\frac{1}{v}\right)}
Derivation
  1. Initial program 98.6%

    \[\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. 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. lift-/.f32N/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} \]
    5. mult-flipN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 5: 98.5% accurate, 1.0× speedup?

    \[\mathsf{copysign}\left(1, cosTheta\_i\right) \cdot \left(\mathsf{copysign}\left(1, cosTheta\_O\right) \cdot \left(\left(\mathsf{min}\left(\left|cosTheta\_i\right|, \left|cosTheta\_O\right|\right) \cdot \frac{\mathsf{max}\left(\left|cosTheta\_i\right|, \left|cosTheta\_O\right|\right)}{v + v}\right) \cdot \frac{\frac{1}{v}}{\sinh \left(\frac{1}{v}\right)}\right)\right) \]
    (FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
     :precision binary32
     (*
      (copysign 1.0 cosTheta_i)
      (*
       (copysign 1.0 cosTheta_O)
       (*
        (*
         (fmin (fabs cosTheta_i) (fabs cosTheta_O))
         (/ (fmax (fabs cosTheta_i) (fabs cosTheta_O)) (+ v v)))
        (/ (/ 1.0 v) (sinh (/ 1.0 v)))))))
    float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
    	return copysignf(1.0f, cosTheta_i) * (copysignf(1.0f, cosTheta_O) * ((fminf(fabsf(cosTheta_i), fabsf(cosTheta_O)) * (fmaxf(fabsf(cosTheta_i), fabsf(cosTheta_O)) / (v + v))) * ((1.0f / v) / sinhf((1.0f / v)))));
    }
    
    function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
    	return Float32(copysign(Float32(1.0), cosTheta_i) * Float32(copysign(Float32(1.0), cosTheta_O) * Float32(Float32(fmin(abs(cosTheta_i), abs(cosTheta_O)) * Float32(fmax(abs(cosTheta_i), abs(cosTheta_O)) / Float32(v + v))) * Float32(Float32(Float32(1.0) / v) / sinh(Float32(Float32(1.0) / v))))))
    end
    
    function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
    	tmp = (sign(cosTheta_i) * abs(single(1.0))) * ((sign(cosTheta_O) * abs(single(1.0))) * ((min(abs(cosTheta_i), abs(cosTheta_O)) * (max(abs(cosTheta_i), abs(cosTheta_O)) / (v + v))) * ((single(1.0) / v) / sinh((single(1.0) / v)))));
    end
    
    \mathsf{copysign}\left(1, cosTheta\_i\right) \cdot \left(\mathsf{copysign}\left(1, cosTheta\_O\right) \cdot \left(\left(\mathsf{min}\left(\left|cosTheta\_i\right|, \left|cosTheta\_O\right|\right) \cdot \frac{\mathsf{max}\left(\left|cosTheta\_i\right|, \left|cosTheta\_O\right|\right)}{v + v}\right) \cdot \frac{\frac{1}{v}}{\sinh \left(\frac{1}{v}\right)}\right)\right)
    
    Derivation
    1. Initial program 98.6%

      \[\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. 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. lift-/.f32N/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} \]
      5. mult-flipN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{\left(cosTheta\_i \cdot \frac{cosTheta\_O}{v + v}\right)} \cdot \frac{\frac{1}{v}}{\sinh \left(\frac{1}{v}\right)} \]
        6. lower-/.f3298.5%

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

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

      Alternative 6: 98.5% accurate, 1.6× speedup?

      \[\frac{cosTheta\_O \cdot cosTheta\_i}{v} \cdot \frac{\frac{0.5}{v}}{\sinh \left(\frac{1}{v}\right)} \]
      (FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
       :precision binary32
       (* (/ (* cosTheta_O cosTheta_i) v) (/ (/ 0.5 v) (sinh (/ 1.0 v)))))
      float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
      	return ((cosTheta_O * cosTheta_i) / v) * ((0.5f / v) / sinhf((1.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 = ((costheta_o * costheta_i) / v) * ((0.5e0 / v) / sinh((1.0e0 / v)))
      end function
      
      function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
      	return Float32(Float32(Float32(cosTheta_O * cosTheta_i) / v) * Float32(Float32(Float32(0.5) / v) / sinh(Float32(Float32(1.0) / v))))
      end
      
      function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
      	tmp = ((cosTheta_O * cosTheta_i) / v) * ((single(0.5) / v) / sinh((single(1.0) / v)));
      end
      
      \frac{cosTheta\_O \cdot cosTheta\_i}{v} \cdot \frac{\frac{0.5}{v}}{\sinh \left(\frac{1}{v}\right)}
      
      Derivation
      1. Initial program 98.6%

        \[\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. 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. lift-/.f32N/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} \]
        5. mult-flipN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{cosTheta\_O \cdot cosTheta\_i}{\color{blue}{v}} \cdot \frac{\frac{\frac{1}{2}}{v}}{\sinh \left(\frac{1}{v}\right)} \]
        2. lower-*.f3298.5%

          \[\leadsto \frac{cosTheta\_O \cdot cosTheta\_i}{v} \cdot \frac{\frac{0.5}{v}}{\sinh \left(\frac{1}{v}\right)} \]
      7. Applied rewrites98.5%

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

      Alternative 7: 98.3% accurate, 1.2× speedup?

      \[\mathsf{copysign}\left(1, cosTheta\_O\right) \cdot \frac{\frac{\frac{\mathsf{min}\left(cosTheta\_i, \left|cosTheta\_O\right|\right)}{v + v} \cdot \mathsf{max}\left(cosTheta\_i, \left|cosTheta\_O\right|\right)}{v}}{\sinh \left(\frac{1}{v}\right)} \]
      (FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
       :precision binary32
       (*
        (copysign 1.0 cosTheta_O)
        (/
         (/
          (*
           (/ (fmin cosTheta_i (fabs cosTheta_O)) (+ v v))
           (fmax cosTheta_i (fabs cosTheta_O)))
          v)
         (sinh (/ 1.0 v)))))
      float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
      	return copysignf(1.0f, cosTheta_O) * ((((fminf(cosTheta_i, fabsf(cosTheta_O)) / (v + v)) * fmaxf(cosTheta_i, fabsf(cosTheta_O))) / v) / sinhf((1.0f / v)));
      }
      
      function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
      	return Float32(copysign(Float32(1.0), cosTheta_O) * Float32(Float32(Float32(Float32(fmin(cosTheta_i, abs(cosTheta_O)) / Float32(v + v)) * fmax(cosTheta_i, abs(cosTheta_O))) / v) / sinh(Float32(Float32(1.0) / v))))
      end
      
      function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
      	tmp = (sign(cosTheta_O) * abs(single(1.0))) * ((((min(cosTheta_i, abs(cosTheta_O)) / (v + v)) * max(cosTheta_i, abs(cosTheta_O))) / v) / sinh((single(1.0) / v)));
      end
      
      \mathsf{copysign}\left(1, cosTheta\_O\right) \cdot \frac{\frac{\frac{\mathsf{min}\left(cosTheta\_i, \left|cosTheta\_O\right|\right)}{v + v} \cdot \mathsf{max}\left(cosTheta\_i, \left|cosTheta\_O\right|\right)}{v}}{\sinh \left(\frac{1}{v}\right)}
      
      Derivation
      1. Initial program 98.6%

        \[\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. 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. lift-/.f32N/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} \]
        5. mult-flipN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \frac{\mathsf{neg}\left(\frac{-1}{v} \cdot \left(\frac{cosTheta\_i}{v + v} \cdot cosTheta\_O\right)\right)}{\mathsf{neg}\left(\color{blue}{\sinh \left(\frac{-1}{v}\right)}\right)} \]
          4. sinh-neg-revN/A

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

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

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

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

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

            \[\leadsto \frac{\mathsf{neg}\left(\frac{-1}{v} \cdot \left(\frac{cosTheta\_i}{v + v} \cdot cosTheta\_O\right)\right)}{\color{blue}{\sinh \left(\frac{1}{v}\right)}} \]
          10. lower-/.f32N/A

            \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\frac{-1}{v} \cdot \left(\frac{cosTheta\_i}{v + v} \cdot cosTheta\_O\right)\right)}{\sinh \left(\frac{1}{v}\right)}} \]
        5. Applied rewrites98.3%

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

        Alternative 8: 98.3% accurate, 1.6× speedup?

        \[\frac{\frac{cosTheta\_i}{v + v} \cdot cosTheta\_O}{v \cdot \sinh \left(\frac{1}{v}\right)} \]
        (FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
         :precision binary32
         (/ (* (/ cosTheta_i (+ v v)) cosTheta_O) (* v (sinh (/ 1.0 v)))))
        float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
        	return ((cosTheta_i / (v + v)) * cosTheta_O) / (v * sinhf((1.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 = ((costheta_i / (v + v)) * costheta_o) / (v * sinh((1.0e0 / v)))
        end function
        
        function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
        	return Float32(Float32(Float32(cosTheta_i / Float32(v + v)) * cosTheta_O) / Float32(v * sinh(Float32(Float32(1.0) / v))))
        end
        
        function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
        	tmp = ((cosTheta_i / (v + v)) * cosTheta_O) / (v * sinh((single(1.0) / v)));
        end
        
        \frac{\frac{cosTheta\_i}{v + v} \cdot cosTheta\_O}{v \cdot \sinh \left(\frac{1}{v}\right)}
        
        Derivation
        1. Initial program 98.6%

          \[\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. 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. lift-/.f32N/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} \]
          5. mult-flipN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \frac{cosTheta\_O \cdot cosTheta\_i}{v + v} \cdot \color{blue}{\frac{1}{v \cdot \sinh \left(\frac{1}{v}\right)}} \]
            5. mult-flip-revN/A

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

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

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

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

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

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

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

              \[\leadsto \frac{\color{blue}{\frac{cosTheta\_i}{v + v}} \cdot cosTheta\_O}{v \cdot \sinh \left(\frac{1}{v}\right)} \]
            13. lower-*.f3298.3%

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

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

          Alternative 9: 98.3% accurate, 1.6× speedup?

          \[\left(cosTheta\_O \cdot cosTheta\_i\right) \cdot \frac{0.5}{\left(v \cdot \sinh \left(\frac{1}{v}\right)\right) \cdot v} \]
          (FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
           :precision binary32
           (* (* cosTheta_O cosTheta_i) (/ 0.5 (* (* v (sinh (/ 1.0 v))) v))))
          float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
          	return (cosTheta_O * cosTheta_i) * (0.5f / ((v * sinhf((1.0f / v))) * 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 = (costheta_o * costheta_i) * (0.5e0 / ((v * sinh((1.0e0 / v))) * v))
          end function
          
          function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
          	return Float32(Float32(cosTheta_O * cosTheta_i) * Float32(Float32(0.5) / Float32(Float32(v * sinh(Float32(Float32(1.0) / v))) * v)))
          end
          
          function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
          	tmp = (cosTheta_O * cosTheta_i) * (single(0.5) / ((v * sinh((single(1.0) / v))) * v));
          end
          
          \left(cosTheta\_O \cdot cosTheta\_i\right) \cdot \frac{0.5}{\left(v \cdot \sinh \left(\frac{1}{v}\right)\right) \cdot v}
          
          Derivation
          1. Initial program 98.6%

            \[\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. 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. lift-/.f32N/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} \]
            5. mult-flipN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            Alternative 10: 59.0% accurate, 3.9× speedup?

            \[\frac{1}{\frac{v}{0.5 \cdot \left(cosTheta\_i \cdot cosTheta\_O\right)}} \]
            (FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
             :precision binary32
             (/ 1.0 (/ v (* 0.5 (* cosTheta_i cosTheta_O)))))
            float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
            	return 1.0f / (v / (0.5f * (cosTheta_i * cosTheta_O)));
            }
            
            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 = 1.0e0 / (v / (0.5e0 * (costheta_i * costheta_o)))
            end function
            
            function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
            	return Float32(Float32(1.0) / Float32(v / Float32(Float32(0.5) * Float32(cosTheta_i * cosTheta_O))))
            end
            
            function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
            	tmp = single(1.0) / (v / (single(0.5) * (cosTheta_i * cosTheta_O)));
            end
            
            \frac{1}{\frac{v}{0.5 \cdot \left(cosTheta\_i \cdot cosTheta\_O\right)}}
            
            Derivation
            1. Initial program 98.6%

              \[\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. Taylor expanded in v around inf

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

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

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

                \[\leadsto 0.5 \cdot \frac{cosTheta\_O \cdot cosTheta\_i}{v} \]
            4. Applied rewrites58.4%

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

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

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

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

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

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

                \[\leadsto \frac{1}{\frac{v}{\color{blue}{\frac{1}{2} \cdot \left(cosTheta\_O \cdot cosTheta\_i\right)}}} \]
              7. lower-*.f3259.0%

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

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

                \[\leadsto \frac{1}{\frac{v}{\frac{1}{2} \cdot \left(cosTheta\_i \cdot \color{blue}{cosTheta\_O}\right)}} \]
              10. lower-*.f3259.0%

                \[\leadsto \frac{1}{\frac{v}{0.5 \cdot \left(cosTheta\_i \cdot \color{blue}{cosTheta\_O}\right)}} \]
            6. Applied rewrites59.0%

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

            Alternative 11: 59.0% accurate, 4.0× speedup?

            \[\frac{1}{\frac{v + v}{cosTheta\_O \cdot cosTheta\_i}} \]
            (FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
             :precision binary32
             (/ 1.0 (/ (+ v v) (* cosTheta_O cosTheta_i))))
            float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
            	return 1.0f / ((v + v) / (cosTheta_O * cosTheta_i));
            }
            
            module fmin_fmax_functions
                implicit none
                private
                public fmax
                public fmin
            
                interface fmax
                    module procedure fmax88
                    module procedure fmax44
                    module procedure fmax84
                    module procedure fmax48
                end interface
                interface fmin
                    module procedure fmin88
                    module procedure fmin44
                    module procedure fmin84
                    module procedure fmin48
                end interface
            contains
                real(8) function fmax88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(4) function fmax44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(8) function fmax84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmax48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                end function
                real(8) function fmin88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(4) function fmin44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(8) function fmin84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmin48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                end function
            end module
            
            real(4) function code(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 = 1.0e0 / ((v + v) / (costheta_o * costheta_i))
            end function
            
            function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
            	return Float32(Float32(1.0) / Float32(Float32(v + v) / Float32(cosTheta_O * cosTheta_i)))
            end
            
            function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
            	tmp = single(1.0) / ((v + v) / (cosTheta_O * cosTheta_i));
            end
            
            \frac{1}{\frac{v + v}{cosTheta\_O \cdot cosTheta\_i}}
            
            Derivation
            1. Initial program 98.6%

              \[\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. Taylor expanded in v around inf

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

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

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

                \[\leadsto 0.5 \cdot \frac{cosTheta\_O \cdot cosTheta\_i}{v} \]
            4. Applied rewrites58.4%

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

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

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

                \[\leadsto \frac{1}{2} \cdot \frac{cosTheta\_O \cdot cosTheta\_i}{v} \]
              4. associate-/l*N/A

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

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

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

                \[\leadsto \left(\frac{1}{2} \cdot cosTheta\_O\right) \cdot \frac{\color{blue}{cosTheta\_i}}{v} \]
              8. lower-/.f3258.4%

                \[\leadsto \left(0.5 \cdot cosTheta\_O\right) \cdot \frac{cosTheta\_i}{\color{blue}{v}} \]
            6. Applied rewrites58.4%

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

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

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

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

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

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

                \[\leadsto \frac{1}{2} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v} \]
              7. *-commutativeN/A

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

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

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

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

                \[\leadsto \left(\frac{cosTheta\_O}{v} \cdot cosTheta\_i\right) \cdot \frac{1}{2} \]
              12. lower-/.f3258.4%

                \[\leadsto \left(\frac{cosTheta\_O}{v} \cdot cosTheta\_i\right) \cdot 0.5 \]
            8. Applied rewrites58.4%

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

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

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

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

                \[\leadsto \frac{cosTheta\_O \cdot cosTheta\_i}{v} \cdot \frac{1}{2} \]
              5. lift-*.f32N/A

                \[\leadsto \frac{cosTheta\_O \cdot cosTheta\_i}{v} \cdot \frac{1}{2} \]
              6. associate-*l/N/A

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

                \[\leadsto \frac{\left(cosTheta\_O \cdot cosTheta\_i\right) \cdot \frac{1}{2}}{v} \]
              8. mult-flip-revN/A

                \[\leadsto \frac{\frac{cosTheta\_O \cdot cosTheta\_i}{2}}{v} \]
              9. associate-/r*N/A

                \[\leadsto \frac{cosTheta\_O \cdot cosTheta\_i}{\color{blue}{2 \cdot v}} \]
              10. count-2N/A

                \[\leadsto \frac{cosTheta\_O \cdot cosTheta\_i}{v + \color{blue}{v}} \]
              11. lift-+.f32N/A

                \[\leadsto \frac{cosTheta\_O \cdot cosTheta\_i}{v + \color{blue}{v}} \]
              12. div-flipN/A

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

                \[\leadsto \frac{1}{\color{blue}{\frac{v + v}{cosTheta\_O \cdot cosTheta\_i}}} \]
              14. lower-unsound-/.f3259.0%

                \[\leadsto \frac{1}{\frac{v + v}{\color{blue}{cosTheta\_O \cdot cosTheta\_i}}} \]
            10. Applied rewrites59.0%

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

            Alternative 12: 58.5% accurate, 4.1× speedup?

            \[\left(0.5 \cdot \left(cosTheta\_i \cdot cosTheta\_O\right)\right) \cdot \frac{1}{v} \]
            (FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
             :precision binary32
             (* (* 0.5 (* cosTheta_i cosTheta_O)) (/ 1.0 v)))
            float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
            	return (0.5f * (cosTheta_i * cosTheta_O)) * (1.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 = (0.5e0 * (costheta_i * costheta_o)) * (1.0e0 / v)
            end function
            
            function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
            	return Float32(Float32(Float32(0.5) * Float32(cosTheta_i * cosTheta_O)) * Float32(Float32(1.0) / v))
            end
            
            function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
            	tmp = (single(0.5) * (cosTheta_i * cosTheta_O)) * (single(1.0) / v);
            end
            
            \left(0.5 \cdot \left(cosTheta\_i \cdot cosTheta\_O\right)\right) \cdot \frac{1}{v}
            
            Derivation
            1. Initial program 98.6%

              \[\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. Taylor expanded in v around inf

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

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

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

                \[\leadsto 0.5 \cdot \frac{cosTheta\_O \cdot cosTheta\_i}{v} \]
            4. Applied rewrites58.4%

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

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

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

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

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

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

                \[\leadsto \left(\frac{1}{2} \cdot \left(cosTheta\_O \cdot cosTheta\_i\right)\right) \cdot \color{blue}{\frac{1}{v}} \]
              7. lower-*.f3258.5%

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

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

                \[\leadsto \left(\frac{1}{2} \cdot \left(cosTheta\_i \cdot cosTheta\_O\right)\right) \cdot \frac{1}{v} \]
              10. lower-*.f3258.5%

                \[\leadsto \left(0.5 \cdot \left(cosTheta\_i \cdot cosTheta\_O\right)\right) \cdot \frac{1}{v} \]
            6. Applied rewrites58.5%

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

            Alternative 13: 58.5% accurate, 5.2× speedup?

            \[\frac{0.5 \cdot \left(cosTheta\_i \cdot cosTheta\_O\right)}{v} \]
            (FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
             :precision binary32
             (/ (* 0.5 (* cosTheta_i cosTheta_O)) v))
            float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
            	return (0.5f * (cosTheta_i * cosTheta_O)) / 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 = (0.5e0 * (costheta_i * costheta_o)) / v
            end function
            
            function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
            	return Float32(Float32(Float32(0.5) * Float32(cosTheta_i * cosTheta_O)) / v)
            end
            
            function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
            	tmp = (single(0.5) * (cosTheta_i * cosTheta_O)) / v;
            end
            
            \frac{0.5 \cdot \left(cosTheta\_i \cdot cosTheta\_O\right)}{v}
            
            Derivation
            1. Initial program 98.6%

              \[\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. Taylor expanded in v around inf

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

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

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

                \[\leadsto 0.5 \cdot \frac{cosTheta\_O \cdot cosTheta\_i}{v} \]
            4. Applied rewrites58.4%

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

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

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

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

                \[\leadsto \frac{\frac{1}{2} \cdot \left(cosTheta\_O \cdot cosTheta\_i\right)}{\color{blue}{v}} \]
              5. lower-*.f3258.5%

                \[\leadsto \frac{0.5 \cdot \left(cosTheta\_O \cdot cosTheta\_i\right)}{v} \]
              6. lift-*.f32N/A

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

                \[\leadsto \frac{\frac{1}{2} \cdot \left(cosTheta\_i \cdot cosTheta\_O\right)}{v} \]
              8. lower-*.f3258.5%

                \[\leadsto \frac{0.5 \cdot \left(cosTheta\_i \cdot cosTheta\_O\right)}{v} \]
            6. Applied rewrites58.5%

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

            Alternative 14: 58.4% accurate, 2.3× speedup?

            \[\mathsf{copysign}\left(1, cosTheta\_i\right) \cdot \left(\left(\frac{\mathsf{max}\left(\left|cosTheta\_i\right|, cosTheta\_O\right)}{v} \cdot \mathsf{min}\left(\left|cosTheta\_i\right|, cosTheta\_O\right)\right) \cdot 0.5\right) \]
            (FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
             :precision binary32
             (*
              (copysign 1.0 cosTheta_i)
              (*
               (*
                (/ (fmax (fabs cosTheta_i) cosTheta_O) v)
                (fmin (fabs cosTheta_i) cosTheta_O))
               0.5)))
            float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
            	return copysignf(1.0f, cosTheta_i) * (((fmaxf(fabsf(cosTheta_i), cosTheta_O) / v) * fminf(fabsf(cosTheta_i), cosTheta_O)) * 0.5f);
            }
            
            function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
            	return Float32(copysign(Float32(1.0), cosTheta_i) * Float32(Float32(Float32(fmax(abs(cosTheta_i), cosTheta_O) / v) * fmin(abs(cosTheta_i), cosTheta_O)) * Float32(0.5)))
            end
            
            function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
            	tmp = (sign(cosTheta_i) * abs(single(1.0))) * (((max(abs(cosTheta_i), cosTheta_O) / v) * min(abs(cosTheta_i), cosTheta_O)) * single(0.5));
            end
            
            \mathsf{copysign}\left(1, cosTheta\_i\right) \cdot \left(\left(\frac{\mathsf{max}\left(\left|cosTheta\_i\right|, cosTheta\_O\right)}{v} \cdot \mathsf{min}\left(\left|cosTheta\_i\right|, cosTheta\_O\right)\right) \cdot 0.5\right)
            
            Derivation
            1. Initial program 98.6%

              \[\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. Taylor expanded in v around inf

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

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

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

                \[\leadsto 0.5 \cdot \frac{cosTheta\_O \cdot cosTheta\_i}{v} \]
            4. Applied rewrites58.4%

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

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

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

                \[\leadsto \frac{1}{2} \cdot \frac{cosTheta\_O \cdot cosTheta\_i}{v} \]
              4. associate-/l*N/A

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

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

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

                \[\leadsto \left(\frac{1}{2} \cdot cosTheta\_O\right) \cdot \frac{\color{blue}{cosTheta\_i}}{v} \]
              8. lower-/.f3258.4%

                \[\leadsto \left(0.5 \cdot cosTheta\_O\right) \cdot \frac{cosTheta\_i}{\color{blue}{v}} \]
            6. Applied rewrites58.4%

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

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

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

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

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

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

                \[\leadsto \frac{1}{2} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v} \]
              7. *-commutativeN/A

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

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

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

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

                \[\leadsto \left(\frac{cosTheta\_O}{v} \cdot cosTheta\_i\right) \cdot \frac{1}{2} \]
              12. lower-/.f3258.4%

                \[\leadsto \left(\frac{cosTheta\_O}{v} \cdot cosTheta\_i\right) \cdot 0.5 \]
            8. Applied rewrites58.4%

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

            Alternative 15: 58.4% accurate, 5.2× speedup?

            \[\left(cosTheta\_O \cdot cosTheta\_i\right) \cdot \frac{0.5}{v} \]
            (FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
             :precision binary32
             (* (* cosTheta_O cosTheta_i) (/ 0.5 v)))
            float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
            	return (cosTheta_O * cosTheta_i) * (0.5f / 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 = (costheta_o * costheta_i) * (0.5e0 / v)
            end function
            
            function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
            	return Float32(Float32(cosTheta_O * cosTheta_i) * Float32(Float32(0.5) / v))
            end
            
            function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
            	tmp = (cosTheta_O * cosTheta_i) * (single(0.5) / v);
            end
            
            \left(cosTheta\_O \cdot cosTheta\_i\right) \cdot \frac{0.5}{v}
            
            Derivation
            1. Initial program 98.6%

              \[\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. Taylor expanded in v around inf

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

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

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

                \[\leadsto 0.5 \cdot \frac{cosTheta\_O \cdot cosTheta\_i}{v} \]
            4. Applied rewrites58.4%

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

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

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

                \[\leadsto \frac{1}{2} \cdot \frac{cosTheta\_O \cdot cosTheta\_i}{v} \]
              4. associate-/l*N/A

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

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

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

                \[\leadsto \left(\frac{1}{2} \cdot cosTheta\_O\right) \cdot \frac{\color{blue}{cosTheta\_i}}{v} \]
              8. lower-/.f3258.4%

                \[\leadsto \left(0.5 \cdot cosTheta\_O\right) \cdot \frac{cosTheta\_i}{\color{blue}{v}} \]
            6. Applied rewrites58.4%

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

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

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

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

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

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

                \[\leadsto \frac{1}{2} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v} \]
              7. *-commutativeN/A

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

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

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

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

                \[\leadsto \left(\frac{cosTheta\_O}{v} \cdot cosTheta\_i\right) \cdot \frac{1}{2} \]
              12. lower-/.f3258.4%

                \[\leadsto \left(\frac{cosTheta\_O}{v} \cdot cosTheta\_i\right) \cdot 0.5 \]
            8. Applied rewrites58.4%

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

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

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

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

                \[\leadsto \frac{cosTheta\_O \cdot cosTheta\_i}{v} \cdot \frac{1}{2} \]
              5. lift-*.f32N/A

                \[\leadsto \frac{cosTheta\_O \cdot cosTheta\_i}{v} \cdot \frac{1}{2} \]
              6. mult-flip-revN/A

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

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

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

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

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

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

                \[\leadsto \left(cosTheta\_O \cdot cosTheta\_i\right) \cdot \frac{\frac{1}{2}}{\color{blue}{v}} \]
              13. lower-*.f3258.4%

                \[\leadsto \left(cosTheta\_O \cdot cosTheta\_i\right) \cdot \color{blue}{\frac{0.5}{v}} \]
            10. Applied rewrites58.4%

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

            Alternative 16: 58.4% accurate, 5.5× speedup?

            \[\frac{cosTheta\_O \cdot cosTheta\_i}{v + v} \]
            (FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
             :precision binary32
             (/ (* cosTheta_O cosTheta_i) (+ v v)))
            float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
            	return (cosTheta_O * cosTheta_i) / (v + 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 = (costheta_o * costheta_i) / (v + v)
            end function
            
            function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
            	return Float32(Float32(cosTheta_O * cosTheta_i) / Float32(v + v))
            end
            
            function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
            	tmp = (cosTheta_O * cosTheta_i) / (v + v);
            end
            
            \frac{cosTheta\_O \cdot cosTheta\_i}{v + v}
            
            Derivation
            1. Initial program 98.6%

              \[\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. Taylor expanded in v around inf

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

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

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

                \[\leadsto 0.5 \cdot \frac{cosTheta\_O \cdot cosTheta\_i}{v} \]
            4. Applied rewrites58.4%

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

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

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

                \[\leadsto \frac{1}{2} \cdot \frac{cosTheta\_O \cdot cosTheta\_i}{v} \]
              4. associate-/l*N/A

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

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

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

                \[\leadsto \left(\frac{1}{2} \cdot cosTheta\_O\right) \cdot \frac{\color{blue}{cosTheta\_i}}{v} \]
              8. lower-/.f3258.4%

                \[\leadsto \left(0.5 \cdot cosTheta\_O\right) \cdot \frac{cosTheta\_i}{\color{blue}{v}} \]
            6. Applied rewrites58.4%

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

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

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

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

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

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

                \[\leadsto \frac{1}{2} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v} \]
              7. *-commutativeN/A

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

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

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

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

                \[\leadsto \left(\frac{cosTheta\_O}{v} \cdot cosTheta\_i\right) \cdot \frac{1}{2} \]
              12. lower-/.f3258.4%

                \[\leadsto \left(\frac{cosTheta\_O}{v} \cdot cosTheta\_i\right) \cdot 0.5 \]
            8. Applied rewrites58.4%

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

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

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

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

                \[\leadsto \frac{cosTheta\_O \cdot cosTheta\_i}{v} \cdot \frac{1}{2} \]
              5. lift-*.f32N/A

                \[\leadsto \frac{cosTheta\_O \cdot cosTheta\_i}{v} \cdot \frac{1}{2} \]
              6. associate-*l/N/A

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

                \[\leadsto \frac{\left(cosTheta\_O \cdot cosTheta\_i\right) \cdot \frac{1}{2}}{v} \]
              8. mult-flip-revN/A

                \[\leadsto \frac{\frac{cosTheta\_O \cdot cosTheta\_i}{2}}{v} \]
              9. associate-/r*N/A

                \[\leadsto \frac{cosTheta\_O \cdot cosTheta\_i}{\color{blue}{2 \cdot v}} \]
              10. count-2N/A

                \[\leadsto \frac{cosTheta\_O \cdot cosTheta\_i}{v + \color{blue}{v}} \]
              11. lift-+.f32N/A

                \[\leadsto \frac{cosTheta\_O \cdot cosTheta\_i}{v + \color{blue}{v}} \]
              12. lower-/.f3258.4%

                \[\leadsto \frac{cosTheta\_O \cdot cosTheta\_i}{\color{blue}{v + v}} \]
            10. Applied rewrites58.4%

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

            Alternative 17: 58.4% accurate, 5.5× speedup?

            \[\frac{cosTheta\_i}{v + v} \cdot cosTheta\_O \]
            (FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
             :precision binary32
             (* (/ cosTheta_i (+ v v)) cosTheta_O))
            float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
            	return (cosTheta_i / (v + v)) * cosTheta_O;
            }
            
            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 = (costheta_i / (v + v)) * costheta_o
            end function
            
            function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
            	return Float32(Float32(cosTheta_i / Float32(v + v)) * cosTheta_O)
            end
            
            function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
            	tmp = (cosTheta_i / (v + v)) * cosTheta_O;
            end
            
            \frac{cosTheta\_i}{v + v} \cdot cosTheta\_O
            
            Derivation
            1. Initial program 98.6%

              \[\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. Taylor expanded in v around inf

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

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

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

                \[\leadsto 0.5 \cdot \frac{cosTheta\_O \cdot cosTheta\_i}{v} \]
            4. Applied rewrites58.4%

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

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

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

                \[\leadsto \frac{1}{2} \cdot \frac{cosTheta\_O \cdot cosTheta\_i}{v} \]
              4. associate-/l*N/A

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

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

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

                \[\leadsto \left(\frac{1}{2} \cdot cosTheta\_O\right) \cdot \frac{\color{blue}{cosTheta\_i}}{v} \]
              8. lower-/.f3258.4%

                \[\leadsto \left(0.5 \cdot cosTheta\_O\right) \cdot \frac{cosTheta\_i}{\color{blue}{v}} \]
            6. Applied rewrites58.4%

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

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

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

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

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

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

                \[\leadsto \frac{1}{2} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v} \]
              7. *-commutativeN/A

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

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

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

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

                \[\leadsto \left(\frac{cosTheta\_O}{v} \cdot cosTheta\_i\right) \cdot \frac{1}{2} \]
              12. lower-/.f3258.4%

                \[\leadsto \left(\frac{cosTheta\_O}{v} \cdot cosTheta\_i\right) \cdot 0.5 \]
            8. Applied rewrites58.4%

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

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

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

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

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

                \[\leadsto \left(cosTheta\_i \cdot \frac{1}{2}\right) \cdot \frac{cosTheta\_O}{v} \]
              6. mult-flip-revN/A

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

                \[\leadsto \frac{cosTheta\_i}{2} \cdot \frac{cosTheta\_O}{\color{blue}{v}} \]
              8. times-fracN/A

                \[\leadsto \frac{cosTheta\_i \cdot cosTheta\_O}{\color{blue}{2 \cdot v}} \]
              9. count-2N/A

                \[\leadsto \frac{cosTheta\_i \cdot cosTheta\_O}{v + \color{blue}{v}} \]
              10. lift-+.f32N/A

                \[\leadsto \frac{cosTheta\_i \cdot cosTheta\_O}{v + \color{blue}{v}} \]
              11. associate-*l/N/A

                \[\leadsto \frac{cosTheta\_i}{v + v} \cdot \color{blue}{cosTheta\_O} \]
              12. lift-/.f32N/A

                \[\leadsto \frac{cosTheta\_i}{v + v} \cdot cosTheta\_O \]
              13. lift-*.f3258.4%

                \[\leadsto \frac{cosTheta\_i}{v + v} \cdot \color{blue}{cosTheta\_O} \]
            10. Applied rewrites58.4%

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

            Alternative 18: 58.4% accurate, 2.4× speedup?

            \[\mathsf{copysign}\left(1, cosTheta\_i\right) \cdot \left(\mathsf{min}\left(\left|cosTheta\_i\right|, cosTheta\_O\right) \cdot \frac{\mathsf{max}\left(\left|cosTheta\_i\right|, cosTheta\_O\right)}{v + v}\right) \]
            (FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
             :precision binary32
             (*
              (copysign 1.0 cosTheta_i)
              (*
               (fmin (fabs cosTheta_i) cosTheta_O)
               (/ (fmax (fabs cosTheta_i) cosTheta_O) (+ v v)))))
            float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
            	return copysignf(1.0f, cosTheta_i) * (fminf(fabsf(cosTheta_i), cosTheta_O) * (fmaxf(fabsf(cosTheta_i), cosTheta_O) / (v + v)));
            }
            
            function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
            	return Float32(copysign(Float32(1.0), cosTheta_i) * Float32(fmin(abs(cosTheta_i), cosTheta_O) * Float32(fmax(abs(cosTheta_i), cosTheta_O) / Float32(v + v))))
            end
            
            function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
            	tmp = (sign(cosTheta_i) * abs(single(1.0))) * (min(abs(cosTheta_i), cosTheta_O) * (max(abs(cosTheta_i), cosTheta_O) / (v + v)));
            end
            
            \mathsf{copysign}\left(1, cosTheta\_i\right) \cdot \left(\mathsf{min}\left(\left|cosTheta\_i\right|, cosTheta\_O\right) \cdot \frac{\mathsf{max}\left(\left|cosTheta\_i\right|, cosTheta\_O\right)}{v + v}\right)
            
            Derivation
            1. Initial program 98.6%

              \[\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. Taylor expanded in v around inf

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

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

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

                \[\leadsto 0.5 \cdot \frac{cosTheta\_O \cdot cosTheta\_i}{v} \]
            4. Applied rewrites58.4%

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

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

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

                \[\leadsto \frac{1}{2} \cdot \frac{cosTheta\_O \cdot cosTheta\_i}{v} \]
              4. associate-/l*N/A

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

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

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

                \[\leadsto \left(\frac{1}{2} \cdot cosTheta\_O\right) \cdot \frac{\color{blue}{cosTheta\_i}}{v} \]
              8. lower-/.f3258.4%

                \[\leadsto \left(0.5 \cdot cosTheta\_O\right) \cdot \frac{cosTheta\_i}{\color{blue}{v}} \]
            6. Applied rewrites58.4%

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

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

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

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

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

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

                \[\leadsto \frac{1}{2} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v} \]
              7. *-commutativeN/A

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

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

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

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

                \[\leadsto \left(\frac{cosTheta\_O}{v} \cdot cosTheta\_i\right) \cdot \frac{1}{2} \]
              12. lower-/.f3258.4%

                \[\leadsto \left(\frac{cosTheta\_O}{v} \cdot cosTheta\_i\right) \cdot 0.5 \]
            8. Applied rewrites58.4%

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

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

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

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

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

                \[\leadsto \left(cosTheta\_i \cdot \frac{1}{2}\right) \cdot \frac{cosTheta\_O}{v} \]
              6. mult-flip-revN/A

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

                \[\leadsto \frac{cosTheta\_i}{2} \cdot \frac{cosTheta\_O}{\color{blue}{v}} \]
              8. times-fracN/A

                \[\leadsto \frac{cosTheta\_i \cdot cosTheta\_O}{\color{blue}{2 \cdot v}} \]
              9. count-2N/A

                \[\leadsto \frac{cosTheta\_i \cdot cosTheta\_O}{v + \color{blue}{v}} \]
              10. lift-+.f32N/A

                \[\leadsto \frac{cosTheta\_i \cdot cosTheta\_O}{v + \color{blue}{v}} \]
              11. associate-/l*N/A

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

                \[\leadsto cosTheta\_i \cdot \color{blue}{\frac{cosTheta\_O}{v + v}} \]
              13. lower-/.f3258.4%

                \[\leadsto cosTheta\_i \cdot \frac{cosTheta\_O}{\color{blue}{v + v}} \]
            10. Applied rewrites58.4%

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

            Reproduce

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