HairBSDF, Mp, upper

Percentage Accurate: 98.6% → 98.8%
Time: 9.6s
Alternatives: 12
Speedup: 1.0×

Specification

?
\[\left(\left(\left(\left(\left(-1 \leq cosTheta\_i \land cosTheta\_i \leq 1\right) \land \left(-1 \leq cosTheta\_O \land cosTheta\_O \leq 1\right)\right) \land \left(-1 \leq sinTheta\_i \land sinTheta\_i \leq 1\right)\right) \land \left(-1 \leq sinTheta\_O \land sinTheta\_O \leq 1\right)\right) \land 0.1 < v\right) \land v \leq 1.5707964\]
\[\begin{array}{l} \\ \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \end{array} \]
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
 :precision binary32
 (/
  (* (exp (- (/ (* sinTheta_i sinTheta_O) v))) (/ (* cosTheta_i cosTheta_O) v))
  (* (* (sinh (/ 1.0 v)) 2.0) v)))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
	return (expf(-((sinTheta_i * sinTheta_O) / v)) * ((cosTheta_i * cosTheta_O) / v)) / ((sinhf((1.0f / v)) * 2.0f) * v);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(4) function code(costheta_i, costheta_o, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
    real(4), intent (in) :: costheta_i
    real(4), intent (in) :: costheta_o
    real(4), intent (in) :: sintheta_i
    real(4), intent (in) :: sintheta_o
    real(4), intent (in) :: v
    code = (exp(-((sintheta_i * sintheta_o) / v)) * ((costheta_i * costheta_o) / v)) / ((sinh((1.0e0 / v)) * 2.0e0) * v)
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
	return Float32(Float32(exp(Float32(-Float32(Float32(sinTheta_i * sinTheta_O) / v))) * Float32(Float32(cosTheta_i * cosTheta_O) / v)) / Float32(Float32(sinh(Float32(Float32(1.0) / v)) * Float32(2.0)) * v))
end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
	tmp = (exp(-((sinTheta_i * sinTheta_O) / v)) * ((cosTheta_i * cosTheta_O) / v)) / ((sinh((single(1.0) / v)) * single(2.0)) * v);
end
\begin{array}{l}

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

Sampling outcomes in binary32 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 12 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 98.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \end{array} \]
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
 :precision binary32
 (/
  (* (exp (- (/ (* sinTheta_i sinTheta_O) v))) (/ (* cosTheta_i cosTheta_O) v))
  (* (* (sinh (/ 1.0 v)) 2.0) v)))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
	return (expf(-((sinTheta_i * sinTheta_O) / v)) * ((cosTheta_i * cosTheta_O) / v)) / ((sinhf((1.0f / v)) * 2.0f) * v);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(4) function code(costheta_i, costheta_o, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
    real(4), intent (in) :: costheta_i
    real(4), intent (in) :: costheta_o
    real(4), intent (in) :: sintheta_i
    real(4), intent (in) :: sintheta_o
    real(4), intent (in) :: v
    code = (exp(-((sintheta_i * sintheta_o) / v)) * ((costheta_i * costheta_o) / v)) / ((sinh((1.0e0 / v)) * 2.0e0) * v)
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
	return Float32(Float32(exp(Float32(-Float32(Float32(sinTheta_i * sinTheta_O) / v))) * Float32(Float32(cosTheta_i * cosTheta_O) / v)) / Float32(Float32(sinh(Float32(Float32(1.0) / v)) * Float32(2.0)) * v))
end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
	tmp = (exp(-((sinTheta_i * sinTheta_O) / v)) * ((cosTheta_i * cosTheta_O) / v)) / ((sinh((single(1.0) / v)) * single(2.0)) * v);
end
\begin{array}{l}

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

Alternative 1: 98.8% accurate, 1.0× speedup?

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

\\
\frac{\frac{cosTheta\_i}{v} \cdot \left(\left(cosTheta\_O \cdot \frac{e^{\left(-sinTheta\_O\right) \cdot \frac{sinTheta\_i}{v}}}{v}\right) \cdot 0.5\right)}{\sinh \left(\frac{1}{v}\right)}
\end{array}
Derivation
  1. Initial program 98.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{cosTheta\_i}{v} \cdot \left(\left(cosTheta\_O \cdot \frac{e^{\mathsf{neg}\left(\color{blue}{sinTheta\_O \cdot \frac{sinTheta\_i}{v}}\right)}}{v}\right) \cdot \frac{1}{2}\right)}{\sinh \left(\frac{1}{v}\right)} \]
    9. distribute-lft-neg-inN/A

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

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

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

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

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

Alternative 2: 98.6% accurate, 1.0× speedup?

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

\\
\left(\frac{cosTheta\_O}{v} \cdot cosTheta\_i\right) \cdot \frac{\frac{1}{v}}{e^{\frac{1}{v}} - e^{\frac{-1}{v}}}
\end{array}
Derivation
  1. Initial program 98.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{cosTheta\_O \cdot cosTheta\_i}{v} \cdot \frac{e^{\mathsf{neg}\left(\color{blue}{sinTheta\_i \cdot \frac{sinTheta\_O}{v}}\right)}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
    14. distribute-lft-neg-inN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \left(\frac{cosTheta\_O}{v} \cdot cosTheta\_i\right) \cdot \color{blue}{\frac{1}{v \cdot \left(e^{\frac{1}{v}} - \frac{1}{e^{\frac{1}{v}}}\right)}} \]
  8. Step-by-step derivation
    1. associate-/r*N/A

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

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

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

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

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

      \[\leadsto \left(\frac{cosTheta\_O}{v} \cdot cosTheta\_i\right) \cdot \frac{\frac{1}{v}}{e^{\color{blue}{\frac{1}{v}}} - \frac{1}{e^{\frac{1}{v}}}} \]
    7. rec-expN/A

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

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

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

      \[\leadsto \left(\frac{cosTheta\_O}{v} \cdot cosTheta\_i\right) \cdot \frac{\frac{1}{v}}{e^{\frac{1}{v}} - \color{blue}{e^{\frac{-1}{v}}}} \]
    11. lower-/.f3298.7

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

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

Alternative 3: 98.6% accurate, 1.8× speedup?

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

\\
\frac{\frac{0.5}{v} \cdot \left(\frac{cosTheta\_i}{v} \cdot cosTheta\_O\right)}{\sinh \left(\frac{1}{v}\right)}
\end{array}
Derivation
  1. Initial program 98.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 98.4% accurate, 1.8× speedup?

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

\\
\frac{\frac{0.5 \cdot cosTheta\_O}{v} \cdot \frac{cosTheta\_i}{v}}{\sinh \left(\frac{1}{v}\right)}
\end{array}
Derivation
  1. Initial program 98.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 98.4% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \frac{\left(1 \cdot cosTheta\_i\right) \cdot \frac{cosTheta\_O}{v}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \end{array} \]
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
 :precision binary32
 (/ (* (* 1.0 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 ((1.0f * 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 = ((1.0e0 * 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(Float32(Float32(1.0) * cosTheta_i) * Float32(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 = ((single(1.0) * cosTheta_i) * (cosTheta_O / v)) / ((sinh((single(1.0) / v)) * single(2.0)) * v);
end
\begin{array}{l}

\\
\frac{\left(1 \cdot cosTheta\_i\right) \cdot \frac{cosTheta\_O}{v}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}
\end{array}
Derivation
  1. Initial program 98.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 6: 98.4% accurate, 1.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\left(1 \cdot cosTheta\_O\right) \cdot cosTheta\_i}{v \cdot \left(\sinh \left(\frac{1}{v}\right) \cdot \left(2 \cdot v\right)\right)}} \]
      4. Final simplification98.6%

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

      Alternative 7: 70.6% accurate, 2.8× speedup?

      \[\begin{array}{l} \\ \frac{1 \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}{\left(\frac{\frac{\mathsf{fma}\left(\frac{0.008333333333333333}{v \cdot v}, -1, -0.16666666666666666\right)}{v \cdot v} - 1}{-v} \cdot 2\right) \cdot v} \end{array} \]
      (FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
       :precision binary32
       (/
        (* 1.0 (/ (* cosTheta_i cosTheta_O) v))
        (*
         (*
          (/
           (-
            (/
             (fma (/ 0.008333333333333333 (* v v)) -1.0 -0.16666666666666666)
             (* v v))
            1.0)
           (- v))
          2.0)
         v)))
      float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
      	return (1.0f * ((cosTheta_i * cosTheta_O) / v)) / (((((fmaf((0.008333333333333333f / (v * v)), -1.0f, -0.16666666666666666f) / (v * v)) - 1.0f) / -v) * 2.0f) * v);
      }
      
      function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
      	return Float32(Float32(Float32(1.0) * Float32(Float32(cosTheta_i * cosTheta_O) / v)) / Float32(Float32(Float32(Float32(Float32(fma(Float32(Float32(0.008333333333333333) / Float32(v * v)), Float32(-1.0), Float32(-0.16666666666666666)) / Float32(v * v)) - Float32(1.0)) / Float32(-v)) * Float32(2.0)) * v))
      end
      
      \begin{array}{l}
      
      \\
      \frac{1 \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}{\left(\frac{\frac{\mathsf{fma}\left(\frac{0.008333333333333333}{v \cdot v}, -1, -0.16666666666666666\right)}{v \cdot v} - 1}{-v} \cdot 2\right) \cdot v}
      \end{array}
      
      Derivation
      1. Initial program 98.5%

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

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

          \[\leadsto \frac{\color{blue}{1} \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 \frac{1 \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}{\left(\color{blue}{\left(-1 \cdot \frac{-1 \cdot \frac{\frac{1}{6} + \frac{1}{120} \cdot \frac{1}{{v}^{2}}}{{v}^{2}} - 1}{v}\right)} \cdot 2\right) \cdot v} \]
        3. Step-by-step derivation
          1. mul-1-negN/A

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

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

            \[\leadsto \frac{1 \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}{\left(\color{blue}{\frac{-1 \cdot \frac{\frac{1}{6} + \frac{1}{120} \cdot \frac{1}{{v}^{2}}}{{v}^{2}} - 1}{\mathsf{neg}\left(v\right)}} \cdot 2\right) \cdot v} \]
        4. Applied rewrites68.9%

          \[\leadsto \frac{1 \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}{\left(\color{blue}{\frac{\frac{\mathsf{fma}\left(\frac{0.008333333333333333}{v \cdot v}, -1, -0.16666666666666666\right)}{v \cdot v} - 1}{-v}} \cdot 2\right) \cdot v} \]
        5. Final simplification68.9%

          \[\leadsto \frac{1 \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}{\left(\frac{\frac{\mathsf{fma}\left(\frac{0.008333333333333333}{v \cdot v}, -1, -0.16666666666666666\right)}{v \cdot v} - 1}{-v} \cdot 2\right) \cdot v} \]
        6. Add Preprocessing

        Alternative 8: 64.5% accurate, 2.8× speedup?

        \[\begin{array}{l} \\ \frac{\frac{\mathsf{fma}\left(-cosTheta\_O, \frac{\left(sinTheta\_i \cdot sinTheta\_O\right) \cdot cosTheta\_i}{v}, cosTheta\_O \cdot cosTheta\_i\right)}{v}}{\left(\frac{\frac{0.16666666666666666}{v \cdot v} + 1}{v} \cdot 2\right) \cdot v} \end{array} \]
        (FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
         :precision binary32
         (/
          (/
           (fma
            (- cosTheta_O)
            (/ (* (* sinTheta_i sinTheta_O) cosTheta_i) v)
            (* cosTheta_O cosTheta_i))
           v)
          (* (* (/ (+ (/ 0.16666666666666666 (* v v)) 1.0) v) 2.0) v)))
        float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
        	return (fmaf(-cosTheta_O, (((sinTheta_i * sinTheta_O) * cosTheta_i) / v), (cosTheta_O * cosTheta_i)) / v) / (((((0.16666666666666666f / (v * v)) + 1.0f) / v) * 2.0f) * v);
        }
        
        function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
        	return Float32(Float32(fma(Float32(-cosTheta_O), Float32(Float32(Float32(sinTheta_i * sinTheta_O) * cosTheta_i) / v), Float32(cosTheta_O * cosTheta_i)) / v) / Float32(Float32(Float32(Float32(Float32(Float32(0.16666666666666666) / Float32(v * v)) + Float32(1.0)) / v) * Float32(2.0)) * v))
        end
        
        \begin{array}{l}
        
        \\
        \frac{\frac{\mathsf{fma}\left(-cosTheta\_O, \frac{\left(sinTheta\_i \cdot sinTheta\_O\right) \cdot cosTheta\_i}{v}, cosTheta\_O \cdot cosTheta\_i\right)}{v}}{\left(\frac{\frac{0.16666666666666666}{v \cdot v} + 1}{v} \cdot 2\right) \cdot v}
        \end{array}
        
        Derivation
        1. Initial program 98.5%

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{cosTheta\_i}{v}, cosTheta\_O, \frac{\mathsf{fma}\left(-cosTheta\_i, sinTheta\_i \cdot cosTheta\_O, \frac{\left(\left(\left(\left(sinTheta\_i \cdot sinTheta\_i\right) \cdot sinTheta\_O\right) \cdot cosTheta\_i\right) \cdot cosTheta\_O\right) \cdot 0.5}{v}\right)}{v \cdot v} \cdot sinTheta\_O\right)}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
        6. Taylor expanded in v around inf

          \[\leadsto \frac{\mathsf{fma}\left(\frac{cosTheta\_i}{v}, cosTheta\_O, \frac{\mathsf{fma}\left(-cosTheta\_i, sinTheta\_i \cdot cosTheta\_O, \frac{\left(\left(\left(\left(sinTheta\_i \cdot sinTheta\_i\right) \cdot sinTheta\_O\right) \cdot cosTheta\_i\right) \cdot cosTheta\_O\right) \cdot \frac{1}{2}}{v}\right)}{v \cdot v} \cdot sinTheta\_O\right)}{\left(\color{blue}{\frac{1 + \frac{1}{6} \cdot \frac{1}{{v}^{2}}}{v}} \cdot 2\right) \cdot v} \]
        7. Step-by-step derivation
          1. lower-/.f32N/A

            \[\leadsto \frac{\mathsf{fma}\left(\frac{cosTheta\_i}{v}, cosTheta\_O, \frac{\mathsf{fma}\left(-cosTheta\_i, sinTheta\_i \cdot cosTheta\_O, \frac{\left(\left(\left(\left(sinTheta\_i \cdot sinTheta\_i\right) \cdot sinTheta\_O\right) \cdot cosTheta\_i\right) \cdot cosTheta\_O\right) \cdot \frac{1}{2}}{v}\right)}{v \cdot v} \cdot sinTheta\_O\right)}{\left(\color{blue}{\frac{1 + \frac{1}{6} \cdot \frac{1}{{v}^{2}}}{v}} \cdot 2\right) \cdot v} \]
          2. +-commutativeN/A

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

            \[\leadsto \frac{\mathsf{fma}\left(\frac{cosTheta\_i}{v}, cosTheta\_O, \frac{\mathsf{fma}\left(-cosTheta\_i, sinTheta\_i \cdot cosTheta\_O, \frac{\left(\left(\left(\left(sinTheta\_i \cdot sinTheta\_i\right) \cdot sinTheta\_O\right) \cdot cosTheta\_i\right) \cdot cosTheta\_O\right) \cdot \frac{1}{2}}{v}\right)}{v \cdot v} \cdot sinTheta\_O\right)}{\left(\frac{\color{blue}{\frac{1}{6} \cdot \frac{1}{{v}^{2}} + 1}}{v} \cdot 2\right) \cdot v} \]
          4. associate-*r/N/A

            \[\leadsto \frac{\mathsf{fma}\left(\frac{cosTheta\_i}{v}, cosTheta\_O, \frac{\mathsf{fma}\left(-cosTheta\_i, sinTheta\_i \cdot cosTheta\_O, \frac{\left(\left(\left(\left(sinTheta\_i \cdot sinTheta\_i\right) \cdot sinTheta\_O\right) \cdot cosTheta\_i\right) \cdot cosTheta\_O\right) \cdot \frac{1}{2}}{v}\right)}{v \cdot v} \cdot sinTheta\_O\right)}{\left(\frac{\color{blue}{\frac{\frac{1}{6} \cdot 1}{{v}^{2}}} + 1}{v} \cdot 2\right) \cdot v} \]
          5. metadata-evalN/A

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

            \[\leadsto \frac{\mathsf{fma}\left(\frac{cosTheta\_i}{v}, cosTheta\_O, \frac{\mathsf{fma}\left(-cosTheta\_i, sinTheta\_i \cdot cosTheta\_O, \frac{\left(\left(\left(\left(sinTheta\_i \cdot sinTheta\_i\right) \cdot sinTheta\_O\right) \cdot cosTheta\_i\right) \cdot cosTheta\_O\right) \cdot \frac{1}{2}}{v}\right)}{v \cdot v} \cdot sinTheta\_O\right)}{\left(\frac{\color{blue}{\frac{\frac{1}{6}}{{v}^{2}}} + 1}{v} \cdot 2\right) \cdot v} \]
          7. unpow2N/A

            \[\leadsto \frac{\mathsf{fma}\left(\frac{cosTheta\_i}{v}, cosTheta\_O, \frac{\mathsf{fma}\left(-cosTheta\_i, sinTheta\_i \cdot cosTheta\_O, \frac{\left(\left(\left(\left(sinTheta\_i \cdot sinTheta\_i\right) \cdot sinTheta\_O\right) \cdot cosTheta\_i\right) \cdot cosTheta\_O\right) \cdot \frac{1}{2}}{v}\right)}{v \cdot v} \cdot sinTheta\_O\right)}{\left(\frac{\frac{\frac{1}{6}}{\color{blue}{v \cdot v}} + 1}{v} \cdot 2\right) \cdot v} \]
          8. lower-*.f3262.3

            \[\leadsto \frac{\mathsf{fma}\left(\frac{cosTheta\_i}{v}, cosTheta\_O, \frac{\mathsf{fma}\left(-cosTheta\_i, sinTheta\_i \cdot cosTheta\_O, \frac{\left(\left(\left(\left(sinTheta\_i \cdot sinTheta\_i\right) \cdot sinTheta\_O\right) \cdot cosTheta\_i\right) \cdot cosTheta\_O\right) \cdot 0.5}{v}\right)}{v \cdot v} \cdot sinTheta\_O\right)}{\left(\frac{\frac{0.16666666666666666}{\color{blue}{v \cdot v}} + 1}{v} \cdot 2\right) \cdot v} \]
        8. Applied rewrites62.3%

          \[\leadsto \frac{\mathsf{fma}\left(\frac{cosTheta\_i}{v}, cosTheta\_O, \frac{\mathsf{fma}\left(-cosTheta\_i, sinTheta\_i \cdot cosTheta\_O, \frac{\left(\left(\left(\left(sinTheta\_i \cdot sinTheta\_i\right) \cdot sinTheta\_O\right) \cdot cosTheta\_i\right) \cdot cosTheta\_O\right) \cdot 0.5}{v}\right)}{v \cdot v} \cdot sinTheta\_O\right)}{\left(\color{blue}{\frac{\frac{0.16666666666666666}{v \cdot v} + 1}{v}} \cdot 2\right) \cdot v} \]
        9. Taylor expanded in v around inf

          \[\leadsto \frac{\frac{-1 \cdot \frac{cosTheta\_O \cdot \left(cosTheta\_i \cdot \left(sinTheta\_O \cdot sinTheta\_i\right)\right)}{v} + cosTheta\_O \cdot cosTheta\_i}{\color{blue}{v}}}{\left(\frac{\frac{\frac{1}{6}}{v \cdot v} + 1}{v} \cdot 2\right) \cdot v} \]
        10. Step-by-step derivation
          1. Applied rewrites62.3%

            \[\leadsto \frac{\frac{\mathsf{fma}\left(-cosTheta\_O, \frac{\left(sinTheta\_i \cdot sinTheta\_O\right) \cdot cosTheta\_i}{v}, cosTheta\_O \cdot cosTheta\_i\right)}{\color{blue}{v}}}{\left(\frac{\frac{0.16666666666666666}{v \cdot v} + 1}{v} \cdot 2\right) \cdot v} \]
          2. Add Preprocessing

          Alternative 9: 64.5% accurate, 4.0× speedup?

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{cosTheta\_i}{v}, cosTheta\_O, \frac{\mathsf{fma}\left(-cosTheta\_i, sinTheta\_i \cdot cosTheta\_O, \frac{\left(\left(\left(\left(sinTheta\_i \cdot sinTheta\_i\right) \cdot sinTheta\_O\right) \cdot cosTheta\_i\right) \cdot cosTheta\_O\right) \cdot 0.5}{v}\right)}{v \cdot v} \cdot sinTheta\_O\right)}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
          6. Taylor expanded in v around inf

            \[\leadsto \frac{\mathsf{fma}\left(\frac{cosTheta\_i}{v}, cosTheta\_O, \frac{\mathsf{fma}\left(-cosTheta\_i, sinTheta\_i \cdot cosTheta\_O, \frac{\left(\left(\left(\left(sinTheta\_i \cdot sinTheta\_i\right) \cdot sinTheta\_O\right) \cdot cosTheta\_i\right) \cdot cosTheta\_O\right) \cdot \frac{1}{2}}{v}\right)}{v \cdot v} \cdot sinTheta\_O\right)}{\left(\color{blue}{\frac{1 + \frac{1}{6} \cdot \frac{1}{{v}^{2}}}{v}} \cdot 2\right) \cdot v} \]
          7. Step-by-step derivation
            1. lower-/.f32N/A

              \[\leadsto \frac{\mathsf{fma}\left(\frac{cosTheta\_i}{v}, cosTheta\_O, \frac{\mathsf{fma}\left(-cosTheta\_i, sinTheta\_i \cdot cosTheta\_O, \frac{\left(\left(\left(\left(sinTheta\_i \cdot sinTheta\_i\right) \cdot sinTheta\_O\right) \cdot cosTheta\_i\right) \cdot cosTheta\_O\right) \cdot \frac{1}{2}}{v}\right)}{v \cdot v} \cdot sinTheta\_O\right)}{\left(\color{blue}{\frac{1 + \frac{1}{6} \cdot \frac{1}{{v}^{2}}}{v}} \cdot 2\right) \cdot v} \]
            2. +-commutativeN/A

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

              \[\leadsto \frac{\mathsf{fma}\left(\frac{cosTheta\_i}{v}, cosTheta\_O, \frac{\mathsf{fma}\left(-cosTheta\_i, sinTheta\_i \cdot cosTheta\_O, \frac{\left(\left(\left(\left(sinTheta\_i \cdot sinTheta\_i\right) \cdot sinTheta\_O\right) \cdot cosTheta\_i\right) \cdot cosTheta\_O\right) \cdot \frac{1}{2}}{v}\right)}{v \cdot v} \cdot sinTheta\_O\right)}{\left(\frac{\color{blue}{\frac{1}{6} \cdot \frac{1}{{v}^{2}} + 1}}{v} \cdot 2\right) \cdot v} \]
            4. associate-*r/N/A

              \[\leadsto \frac{\mathsf{fma}\left(\frac{cosTheta\_i}{v}, cosTheta\_O, \frac{\mathsf{fma}\left(-cosTheta\_i, sinTheta\_i \cdot cosTheta\_O, \frac{\left(\left(\left(\left(sinTheta\_i \cdot sinTheta\_i\right) \cdot sinTheta\_O\right) \cdot cosTheta\_i\right) \cdot cosTheta\_O\right) \cdot \frac{1}{2}}{v}\right)}{v \cdot v} \cdot sinTheta\_O\right)}{\left(\frac{\color{blue}{\frac{\frac{1}{6} \cdot 1}{{v}^{2}}} + 1}{v} \cdot 2\right) \cdot v} \]
            5. metadata-evalN/A

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

              \[\leadsto \frac{\mathsf{fma}\left(\frac{cosTheta\_i}{v}, cosTheta\_O, \frac{\mathsf{fma}\left(-cosTheta\_i, sinTheta\_i \cdot cosTheta\_O, \frac{\left(\left(\left(\left(sinTheta\_i \cdot sinTheta\_i\right) \cdot sinTheta\_O\right) \cdot cosTheta\_i\right) \cdot cosTheta\_O\right) \cdot \frac{1}{2}}{v}\right)}{v \cdot v} \cdot sinTheta\_O\right)}{\left(\frac{\color{blue}{\frac{\frac{1}{6}}{{v}^{2}}} + 1}{v} \cdot 2\right) \cdot v} \]
            7. unpow2N/A

              \[\leadsto \frac{\mathsf{fma}\left(\frac{cosTheta\_i}{v}, cosTheta\_O, \frac{\mathsf{fma}\left(-cosTheta\_i, sinTheta\_i \cdot cosTheta\_O, \frac{\left(\left(\left(\left(sinTheta\_i \cdot sinTheta\_i\right) \cdot sinTheta\_O\right) \cdot cosTheta\_i\right) \cdot cosTheta\_O\right) \cdot \frac{1}{2}}{v}\right)}{v \cdot v} \cdot sinTheta\_O\right)}{\left(\frac{\frac{\frac{1}{6}}{\color{blue}{v \cdot v}} + 1}{v} \cdot 2\right) \cdot v} \]
            8. lower-*.f3262.3

              \[\leadsto \frac{\mathsf{fma}\left(\frac{cosTheta\_i}{v}, cosTheta\_O, \frac{\mathsf{fma}\left(-cosTheta\_i, sinTheta\_i \cdot cosTheta\_O, \frac{\left(\left(\left(\left(sinTheta\_i \cdot sinTheta\_i\right) \cdot sinTheta\_O\right) \cdot cosTheta\_i\right) \cdot cosTheta\_O\right) \cdot 0.5}{v}\right)}{v \cdot v} \cdot sinTheta\_O\right)}{\left(\frac{\frac{0.16666666666666666}{\color{blue}{v \cdot v}} + 1}{v} \cdot 2\right) \cdot v} \]
          8. Applied rewrites62.3%

            \[\leadsto \frac{\mathsf{fma}\left(\frac{cosTheta\_i}{v}, cosTheta\_O, \frac{\mathsf{fma}\left(-cosTheta\_i, sinTheta\_i \cdot cosTheta\_O, \frac{\left(\left(\left(\left(sinTheta\_i \cdot sinTheta\_i\right) \cdot sinTheta\_O\right) \cdot cosTheta\_i\right) \cdot cosTheta\_O\right) \cdot 0.5}{v}\right)}{v \cdot v} \cdot sinTheta\_O\right)}{\left(\color{blue}{\frac{\frac{0.16666666666666666}{v \cdot v} + 1}{v}} \cdot 2\right) \cdot v} \]
          9. Taylor expanded in v around inf

            \[\leadsto \frac{\frac{-1 \cdot \frac{cosTheta\_O \cdot \left(cosTheta\_i \cdot \left(sinTheta\_O \cdot sinTheta\_i\right)\right)}{v} + cosTheta\_O \cdot cosTheta\_i}{\color{blue}{v}}}{\left(\frac{\frac{\frac{1}{6}}{v \cdot v} + 1}{v} \cdot 2\right) \cdot v} \]
          10. Step-by-step derivation
            1. Applied rewrites62.3%

              \[\leadsto \frac{\frac{\mathsf{fma}\left(-cosTheta\_O, \frac{\left(sinTheta\_i \cdot sinTheta\_O\right) \cdot cosTheta\_i}{v}, cosTheta\_O \cdot cosTheta\_i\right)}{\color{blue}{v}}}{\left(\frac{\frac{0.16666666666666666}{v \cdot v} + 1}{v} \cdot 2\right) \cdot v} \]
            2. Taylor expanded in sinTheta_i around 0

              \[\leadsto \frac{\frac{cosTheta\_O \cdot cosTheta\_i}{v}}{\left(\frac{\frac{\frac{1}{6}}{v \cdot v} + 1}{v} \cdot 2\right) \cdot v} \]
            3. Step-by-step derivation
              1. Applied rewrites62.3%

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

              Alternative 10: 58.8% accurate, 6.2× speedup?

              \[\begin{array}{l} \\ \frac{cosTheta\_O \cdot cosTheta\_i}{v} \cdot \mathsf{fma}\left(-0.5, \frac{sinTheta\_O \cdot sinTheta\_i}{v}, 0.5\right) \end{array} \]
              (FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
               :precision binary32
               (*
                (/ (* cosTheta_O cosTheta_i) v)
                (fma -0.5 (/ (* sinTheta_O sinTheta_i) v) 0.5)))
              float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
              	return ((cosTheta_O * cosTheta_i) / v) * fmaf(-0.5f, ((sinTheta_O * sinTheta_i) / v), 0.5f);
              }
              
              function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
              	return Float32(Float32(Float32(cosTheta_O * cosTheta_i) / v) * fma(Float32(-0.5), Float32(Float32(sinTheta_O * sinTheta_i) / v), Float32(0.5)))
              end
              
              \begin{array}{l}
              
              \\
              \frac{cosTheta\_O \cdot cosTheta\_i}{v} \cdot \mathsf{fma}\left(-0.5, \frac{sinTheta\_O \cdot sinTheta\_i}{v}, 0.5\right)
              \end{array}
              
              Derivation
              1. Initial program 98.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \frac{cosTheta\_O \cdot cosTheta\_i}{v} \cdot \frac{e^{\mathsf{neg}\left(\color{blue}{sinTheta\_i \cdot \frac{sinTheta\_O}{v}}\right)}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v} \]
                14. distribute-lft-neg-inN/A

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

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

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

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

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

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

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

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

                  \[\leadsto \frac{cosTheta\_O \cdot cosTheta\_i}{v} \cdot \mathsf{fma}\left(\frac{-1}{2}, \color{blue}{\frac{sinTheta\_O \cdot sinTheta\_i}{v}}, \frac{1}{2}\right) \]
                4. lower-*.f3256.2

                  \[\leadsto \frac{cosTheta\_O \cdot cosTheta\_i}{v} \cdot \mathsf{fma}\left(-0.5, \frac{\color{blue}{sinTheta\_O \cdot sinTheta\_i}}{v}, 0.5\right) \]
              7. Applied rewrites56.2%

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

              Alternative 11: 58.8% accurate, 12.4× speedup?

              \[\begin{array}{l} \\ \left(0.5 \cdot cosTheta\_i\right) \cdot \frac{cosTheta\_O}{v} \end{array} \]
              (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) * cosTheta_i) * Float32(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
              
              \begin{array}{l}
              
              \\
              \left(0.5 \cdot cosTheta\_i\right) \cdot \frac{cosTheta\_O}{v}
              \end{array}
              
              Derivation
              1. Initial program 98.5%

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

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

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

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

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

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

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

                Alternative 12: 58.8% accurate, 12.4× speedup?

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

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

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

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

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

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

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

                Reproduce

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