HairBSDF, Mp, upper

Percentage Accurate: 98.6% → 98.8%
Time: 7.5s
Alternatives: 11
Speedup: 1.7×

Specification

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

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

real(4) function code(costheta_i, costheta_o, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
    real(4), intent (in) :: costheta_i
    real(4), intent (in) :: costheta_o
    real(4), intent (in) :: sintheta_i
    real(4), intent (in) :: sintheta_o
    real(4), intent (in) :: v
    code = (exp(-((sintheta_i * sintheta_o) / v)) * ((costheta_i * costheta_o) / v)) / ((sinh((1.0e0 / v)) * 2.0e0) * v)
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
	return Float32(Float32(exp(Float32(-Float32(Float32(sinTheta_i * sinTheta_O) / v))) * Float32(Float32(cosTheta_i * cosTheta_O) / v)) / Float32(Float32(sinh(Float32(Float32(1.0) / v)) * Float32(2.0)) * v))
end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
	tmp = (exp(-((sinTheta_i * sinTheta_O) / v)) * ((cosTheta_i * cosTheta_O) / v)) / ((sinh((single(1.0) / v)) * single(2.0)) * v);
end
\frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 alternatives:

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

Initial Program: 98.6% accurate, 1.0× speedup?

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

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

real(4) function code(costheta_i, costheta_o, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
    real(4), intent (in) :: costheta_i
    real(4), intent (in) :: costheta_o
    real(4), intent (in) :: sintheta_i
    real(4), intent (in) :: sintheta_o
    real(4), intent (in) :: v
    code = (exp(-((sintheta_i * sintheta_o) / v)) * ((costheta_i * costheta_o) / v)) / ((sinh((1.0e0 / v)) * 2.0e0) * v)
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
	return Float32(Float32(exp(Float32(-Float32(Float32(sinTheta_i * sinTheta_O) / v))) * Float32(Float32(cosTheta_i * cosTheta_O) / v)) / Float32(Float32(sinh(Float32(Float32(1.0) / v)) * Float32(2.0)) * v))
end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
	tmp = (exp(-((sinTheta_i * sinTheta_O) / v)) * ((cosTheta_i * cosTheta_O) / v)) / ((sinh((single(1.0) / v)) * single(2.0)) * v);
end
\frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}

Alternative 1: 98.8% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 98.8% accurate, 0.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 98.6% accurate, 1.7× speedup?

\[\left(cosTheta\_O \cdot cosTheta\_i\right) \cdot \left(\frac{1}{v + v} \cdot \frac{\frac{1}{v}}{\sinh \left(\frac{1}{v}\right)}\right) \]
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
  :precision binary32
  (*
 (* cosTheta_O cosTheta_i)
 (* (/ 1.0 (+ v v)) (/ (/ 1.0 v) (sinh (/ 1.0 v))))))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
	return (cosTheta_O * cosTheta_i) * ((1.0f / (v + v)) * ((1.0f / v) / sinhf((1.0f / v))));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(4) function code(costheta_i, costheta_o, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
    real(4), intent (in) :: costheta_i
    real(4), intent (in) :: costheta_o
    real(4), intent (in) :: sintheta_i
    real(4), intent (in) :: sintheta_o
    real(4), intent (in) :: v
    code = (costheta_o * costheta_i) * ((1.0e0 / (v + v)) * ((1.0e0 / v) / sinh((1.0e0 / v))))
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
	return Float32(Float32(cosTheta_O * cosTheta_i) * Float32(Float32(Float32(1.0) / Float32(v + v)) * Float32(Float32(Float32(1.0) / v) / sinh(Float32(Float32(1.0) / v)))))
end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
	tmp = (cosTheta_O * cosTheta_i) * ((single(1.0) / (v + v)) * ((single(1.0) / v) / sinh((single(1.0) / v))));
end
\left(cosTheta\_O \cdot cosTheta\_i\right) \cdot \left(\frac{1}{v + v} \cdot \frac{\frac{1}{v}}{\sinh \left(\frac{1}{v}\right)}\right)
Derivation
  1. Initial program 98.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 4: 98.5% accurate, 0.6× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      Alternative 5: 98.5% accurate, 1.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        Alternative 6: 98.5% accurate, 0.6× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        Alternative 7: 98.4% accurate, 0.6× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          Alternative 8: 58.9% accurate, 8.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          Alternative 9: 58.9% accurate, 8.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          Alternative 10: 58.4% accurate, 12.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          Alternative 11: 58.3% accurate, 12.4× speedup?

          \[0.5 \cdot \frac{cosTheta\_O \cdot cosTheta\_i}{v} \]
          (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
          
          0.5 \cdot \frac{cosTheta\_O \cdot cosTheta\_i}{v}
          
          Derivation
          1. Initial program 98.6%

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

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

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

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

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

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

          Reproduce

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