rsin B (should all be same)

Percentage Accurate: 76.4% → 99.5%
Time: 4.3s
Alternatives: 14
Speedup: 0.6×

Specification

?
\[\begin{array}{l} \\ r \cdot \frac{\sin b}{\cos \left(a + b\right)} \end{array} \]
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (cos (+ a b)))))
double code(double r, double a, double b) {
	return r * (sin(b) / cos((a + b)));
}
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(8) function code(r, a, b)
use fmin_fmax_functions
    real(8), intent (in) :: r
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = r * (sin(b) / cos((a + b)))
end function
public static double code(double r, double a, double b) {
	return r * (Math.sin(b) / Math.cos((a + b)));
}
def code(r, a, b):
	return r * (math.sin(b) / math.cos((a + b)))
function code(r, a, b)
	return Float64(r * Float64(sin(b) / cos(Float64(a + b))))
end
function tmp = code(r, a, b)
	tmp = r * (sin(b) / cos((a + b)));
end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
r \cdot \frac{\sin b}{\cos \left(a + b\right)}
\end{array}

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 14 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: 76.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ r \cdot \frac{\sin b}{\cos \left(a + b\right)} \end{array} \]
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (cos (+ a b)))))
double code(double r, double a, double b) {
	return r * (sin(b) / cos((a + b)));
}
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(8) function code(r, a, b)
use fmin_fmax_functions
    real(8), intent (in) :: r
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = r * (sin(b) / cos((a + b)))
end function
public static double code(double r, double a, double b) {
	return r * (Math.sin(b) / Math.cos((a + b)));
}
def code(r, a, b):
	return r * (math.sin(b) / math.cos((a + b)))
function code(r, a, b)
	return Float64(r * Float64(sin(b) / cos(Float64(a + b))))
end
function tmp = code(r, a, b)
	tmp = r * (sin(b) / cos((a + b)));
end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
r \cdot \frac{\sin b}{\cos \left(a + b\right)}
\end{array}

Alternative 1: 99.5% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \frac{\sin b \cdot r}{\cos b \cdot \cos a - \sin a \cdot \sin b} \end{array} \]
(FPCore (r a b)
 :precision binary64
 (/ (* (sin b) r) (- (* (cos b) (cos a)) (* (sin a) (sin b)))))
double code(double r, double a, double b) {
	return (sin(b) * r) / ((cos(b) * cos(a)) - (sin(a) * sin(b)));
}
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(8) function code(r, a, b)
use fmin_fmax_functions
    real(8), intent (in) :: r
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = (sin(b) * r) / ((cos(b) * cos(a)) - (sin(a) * sin(b)))
end function
public static double code(double r, double a, double b) {
	return (Math.sin(b) * r) / ((Math.cos(b) * Math.cos(a)) - (Math.sin(a) * Math.sin(b)));
}
def code(r, a, b):
	return (math.sin(b) * r) / ((math.cos(b) * math.cos(a)) - (math.sin(a) * math.sin(b)))
function code(r, a, b)
	return Float64(Float64(sin(b) * r) / Float64(Float64(cos(b) * cos(a)) - Float64(sin(a) * sin(b))))
end
function tmp = code(r, a, b)
	tmp = (sin(b) * r) / ((cos(b) * cos(a)) - (sin(a) * sin(b)));
end
code[r_, a_, b_] := N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[(N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[a], $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\sin b \cdot r}{\cos b \cdot \cos a - \sin a \cdot \sin b}
\end{array}
Derivation
  1. Initial program 76.4%

    \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
  2. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \color{blue}{r \cdot \frac{\sin b}{\cos \left(a + b\right)}} \]
    2. lift-/.f64N/A

      \[\leadsto r \cdot \color{blue}{\frac{\sin b}{\cos \left(a + b\right)}} \]
    3. lift-sin.f64N/A

      \[\leadsto r \cdot \frac{\color{blue}{\sin b}}{\cos \left(a + b\right)} \]
    4. lift-+.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\cos \color{blue}{\left(a + b\right)}} \]
    5. lift-cos.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos \left(a + b\right)}} \]
    6. associate-*r/N/A

      \[\leadsto \color{blue}{\frac{r \cdot \sin b}{\cos \left(a + b\right)}} \]
    7. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{r \cdot \sin b}{\cos \left(a + b\right)}} \]
    8. *-commutativeN/A

      \[\leadsto \frac{\color{blue}{\sin b \cdot r}}{\cos \left(a + b\right)} \]
    9. lower-*.f64N/A

      \[\leadsto \frac{\color{blue}{\sin b \cdot r}}{\cos \left(a + b\right)} \]
    10. lift-sin.f64N/A

      \[\leadsto \frac{\color{blue}{\sin b} \cdot r}{\cos \left(a + b\right)} \]
    11. lift-cos.f64N/A

      \[\leadsto \frac{\sin b \cdot r}{\color{blue}{\cos \left(a + b\right)}} \]
    12. lift-+.f6476.4

      \[\leadsto \frac{\sin b \cdot r}{\cos \color{blue}{\left(a + b\right)}} \]
  3. Applied rewrites76.4%

    \[\leadsto \color{blue}{\frac{\sin b \cdot r}{\cos \left(a + b\right)}} \]
  4. Step-by-step derivation
    1. lift-+.f64N/A

      \[\leadsto \frac{\sin b \cdot r}{\cos \color{blue}{\left(a + b\right)}} \]
    2. lift-cos.f64N/A

      \[\leadsto \frac{\sin b \cdot r}{\color{blue}{\cos \left(a + b\right)}} \]
    3. cos-sumN/A

      \[\leadsto \frac{\sin b \cdot r}{\color{blue}{\cos a \cdot \cos b - \sin a \cdot \sin b}} \]
    4. lower--.f64N/A

      \[\leadsto \frac{\sin b \cdot r}{\color{blue}{\cos a \cdot \cos b - \sin a \cdot \sin b}} \]
    5. *-commutativeN/A

      \[\leadsto \frac{\sin b \cdot r}{\color{blue}{\cos b \cdot \cos a} - \sin a \cdot \sin b} \]
    6. lower-*.f64N/A

      \[\leadsto \frac{\sin b \cdot r}{\color{blue}{\cos b \cdot \cos a} - \sin a \cdot \sin b} \]
    7. lift-cos.f64N/A

      \[\leadsto \frac{\sin b \cdot r}{\color{blue}{\cos b} \cdot \cos a - \sin a \cdot \sin b} \]
    8. lift-cos.f64N/A

      \[\leadsto \frac{\sin b \cdot r}{\cos b \cdot \color{blue}{\cos a} - \sin a \cdot \sin b} \]
    9. lower-*.f64N/A

      \[\leadsto \frac{\sin b \cdot r}{\cos b \cdot \cos a - \color{blue}{\sin a \cdot \sin b}} \]
    10. lift-sin.f64N/A

      \[\leadsto \frac{\sin b \cdot r}{\cos b \cdot \cos a - \color{blue}{\sin a} \cdot \sin b} \]
    11. lift-sin.f6499.5

      \[\leadsto \frac{\sin b \cdot r}{\cos b \cdot \cos a - \sin a \cdot \color{blue}{\sin b}} \]
  5. Applied rewrites99.5%

    \[\leadsto \frac{\sin b \cdot r}{\color{blue}{\cos b \cdot \cos a - \sin a \cdot \sin b}} \]
  6. Add Preprocessing

Alternative 2: 99.5% accurate, 0.6× speedup?

\[\begin{array}{l} \\ r \cdot \frac{\sin b}{\mathsf{fma}\left(\sin a, -\sin b, \cos a \cdot \cos b\right)} \end{array} \]
(FPCore (r a b)
 :precision binary64
 (* r (/ (sin b) (fma (sin a) (- (sin b)) (* (cos a) (cos b))))))
double code(double r, double a, double b) {
	return r * (sin(b) / fma(sin(a), -sin(b), (cos(a) * cos(b))));
}
function code(r, a, b)
	return Float64(r * Float64(sin(b) / fma(sin(a), Float64(-sin(b)), Float64(cos(a) * cos(b)))))
end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[Sin[a], $MachinePrecision] * (-N[Sin[b], $MachinePrecision]) + N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
r \cdot \frac{\sin b}{\mathsf{fma}\left(\sin a, -\sin b, \cos a \cdot \cos b\right)}
\end{array}
Derivation
  1. Initial program 76.4%

    \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
  2. Step-by-step derivation
    1. lift-+.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\cos \color{blue}{\left(a + b\right)}} \]
    2. lift-cos.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos \left(a + b\right)}} \]
    3. +-commutativeN/A

      \[\leadsto r \cdot \frac{\sin b}{\cos \color{blue}{\left(b + a\right)}} \]
    4. cos-sumN/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos b \cdot \cos a - \sin b \cdot \sin a}} \]
    5. cos-neg-revN/A

      \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \color{blue}{\cos \left(\mathsf{neg}\left(a\right)\right)} - \sin b \cdot \sin a} \]
    6. mul-1-negN/A

      \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \cos \color{blue}{\left(-1 \cdot a\right)} - \sin b \cdot \sin a} \]
    7. lower--.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos b \cdot \cos \left(-1 \cdot a\right) - \sin b \cdot \sin a}} \]
    8. mul-1-negN/A

      \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \cos \color{blue}{\left(\mathsf{neg}\left(a\right)\right)} - \sin b \cdot \sin a} \]
    9. cos-neg-revN/A

      \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \color{blue}{\cos a} - \sin b \cdot \sin a} \]
    10. lower-*.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos b \cdot \cos a} - \sin b \cdot \sin a} \]
    11. lower-cos.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos b} \cdot \cos a - \sin b \cdot \sin a} \]
    12. lower-cos.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \color{blue}{\cos a} - \sin b \cdot \sin a} \]
    13. lower-*.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \cos a - \color{blue}{\sin b \cdot \sin a}} \]
    14. lift-sin.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \cos a - \color{blue}{\sin b} \cdot \sin a} \]
    15. lower-sin.f6499.5

      \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \cos a - \sin b \cdot \color{blue}{\sin a}} \]
  3. Applied rewrites99.5%

    \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos b \cdot \cos a - \sin b \cdot \sin a}} \]
  4. Step-by-step derivation
    1. lift--.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos b \cdot \cos a - \sin b \cdot \sin a}} \]
    2. lift-*.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos b \cdot \cos a} - \sin b \cdot \sin a} \]
    3. lift-cos.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos b} \cdot \cos a - \sin b \cdot \sin a} \]
    4. lift-cos.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \color{blue}{\cos a} - \sin b \cdot \sin a} \]
    5. lift-*.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \cos a - \color{blue}{\sin b \cdot \sin a}} \]
    6. lift-sin.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \cos a - \color{blue}{\sin b} \cdot \sin a} \]
    7. lift-sin.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \cos a - \sin b \cdot \color{blue}{\sin a}} \]
    8. fp-cancel-sub-sign-invN/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos b \cdot \cos a + \left(\mathsf{neg}\left(\sin b\right)\right) \cdot \sin a}} \]
    9. lower-fma.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\mathsf{fma}\left(\cos b, \cos a, \left(\mathsf{neg}\left(\sin b\right)\right) \cdot \sin a\right)}} \]
    10. lift-cos.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\mathsf{fma}\left(\color{blue}{\cos b}, \cos a, \left(\mathsf{neg}\left(\sin b\right)\right) \cdot \sin a\right)} \]
    11. lift-cos.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos b, \color{blue}{\cos a}, \left(\mathsf{neg}\left(\sin b\right)\right) \cdot \sin a\right)} \]
    12. lower-*.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \color{blue}{\left(\mathsf{neg}\left(\sin b\right)\right) \cdot \sin a}\right)} \]
    13. lower-neg.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \color{blue}{\left(-\sin b\right)} \cdot \sin a\right)} \]
    14. lift-sin.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \left(-\color{blue}{\sin b}\right) \cdot \sin a\right)} \]
    15. lift-sin.f6499.5

      \[\leadsto r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \left(-\sin b\right) \cdot \color{blue}{\sin a}\right)} \]
  5. Applied rewrites99.5%

    \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\mathsf{fma}\left(\cos b, \cos a, \left(-\sin b\right) \cdot \sin a\right)}} \]
  6. Step-by-step derivation
    1. lift-cos.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\mathsf{fma}\left(\color{blue}{\cos b}, \cos a, \left(-\sin b\right) \cdot \sin a\right)} \]
    2. lift-cos.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos b, \color{blue}{\cos a}, \left(-\sin b\right) \cdot \sin a\right)} \]
    3. lift-fma.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos b \cdot \cos a + \left(-\sin b\right) \cdot \sin a}} \]
    4. lift-*.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \cos a + \color{blue}{\left(-\sin b\right) \cdot \sin a}} \]
    5. lift-neg.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \cos a + \color{blue}{\left(\mathsf{neg}\left(\sin b\right)\right)} \cdot \sin a} \]
    6. lift-sin.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \cos a + \left(\mathsf{neg}\left(\color{blue}{\sin b}\right)\right) \cdot \sin a} \]
    7. lift-sin.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \cos a + \left(\mathsf{neg}\left(\sin b\right)\right) \cdot \color{blue}{\sin a}} \]
    8. +-commutativeN/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\left(\mathsf{neg}\left(\sin b\right)\right) \cdot \sin a + \cos b \cdot \cos a}} \]
    9. mul-1-negN/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\left(-1 \cdot \sin b\right)} \cdot \sin a + \cos b \cdot \cos a} \]
    10. *-commutativeN/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\sin a \cdot \left(-1 \cdot \sin b\right)} + \cos b \cdot \cos a} \]
    11. lower-fma.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\mathsf{fma}\left(\sin a, -1 \cdot \sin b, \cos b \cdot \cos a\right)}} \]
    12. lift-sin.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\mathsf{fma}\left(\color{blue}{\sin a}, -1 \cdot \sin b, \cos b \cdot \cos a\right)} \]
    13. mul-1-negN/A

      \[\leadsto r \cdot \frac{\sin b}{\mathsf{fma}\left(\sin a, \color{blue}{\mathsf{neg}\left(\sin b\right)}, \cos b \cdot \cos a\right)} \]
    14. lift-sin.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\mathsf{fma}\left(\sin a, \mathsf{neg}\left(\color{blue}{\sin b}\right), \cos b \cdot \cos a\right)} \]
    15. lift-neg.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\mathsf{fma}\left(\sin a, \color{blue}{-\sin b}, \cos b \cdot \cos a\right)} \]
    16. *-commutativeN/A

      \[\leadsto r \cdot \frac{\sin b}{\mathsf{fma}\left(\sin a, -\sin b, \color{blue}{\cos a \cdot \cos b}\right)} \]
    17. lower-*.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\mathsf{fma}\left(\sin a, -\sin b, \color{blue}{\cos a \cdot \cos b}\right)} \]
    18. lift-cos.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\mathsf{fma}\left(\sin a, -\sin b, \color{blue}{\cos a} \cdot \cos b\right)} \]
    19. lift-cos.f6499.5

      \[\leadsto r \cdot \frac{\sin b}{\mathsf{fma}\left(\sin a, -\sin b, \cos a \cdot \color{blue}{\cos b}\right)} \]
  7. Applied rewrites99.5%

    \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\mathsf{fma}\left(\sin a, -\sin b, \cos a \cdot \cos b\right)}} \]
  8. Add Preprocessing

Alternative 3: 99.5% accurate, 0.6× speedup?

\[\begin{array}{l} \\ r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \left(-\sin b\right) \cdot \sin a\right)} \end{array} \]
(FPCore (r a b)
 :precision binary64
 (* r (/ (sin b) (fma (cos b) (cos a) (* (- (sin b)) (sin a))))))
double code(double r, double a, double b) {
	return r * (sin(b) / fma(cos(b), cos(a), (-sin(b) * sin(a))));
}
function code(r, a, b)
	return Float64(r * Float64(sin(b) / fma(cos(b), cos(a), Float64(Float64(-sin(b)) * sin(a)))))
end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision] + N[((-N[Sin[b], $MachinePrecision]) * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \left(-\sin b\right) \cdot \sin a\right)}
\end{array}
Derivation
  1. Initial program 76.4%

    \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
  2. Step-by-step derivation
    1. lift-+.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\cos \color{blue}{\left(a + b\right)}} \]
    2. lift-cos.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos \left(a + b\right)}} \]
    3. +-commutativeN/A

      \[\leadsto r \cdot \frac{\sin b}{\cos \color{blue}{\left(b + a\right)}} \]
    4. cos-sumN/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos b \cdot \cos a - \sin b \cdot \sin a}} \]
    5. cos-neg-revN/A

      \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \color{blue}{\cos \left(\mathsf{neg}\left(a\right)\right)} - \sin b \cdot \sin a} \]
    6. mul-1-negN/A

      \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \cos \color{blue}{\left(-1 \cdot a\right)} - \sin b \cdot \sin a} \]
    7. lower--.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos b \cdot \cos \left(-1 \cdot a\right) - \sin b \cdot \sin a}} \]
    8. mul-1-negN/A

      \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \cos \color{blue}{\left(\mathsf{neg}\left(a\right)\right)} - \sin b \cdot \sin a} \]
    9. cos-neg-revN/A

      \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \color{blue}{\cos a} - \sin b \cdot \sin a} \]
    10. lower-*.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos b \cdot \cos a} - \sin b \cdot \sin a} \]
    11. lower-cos.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos b} \cdot \cos a - \sin b \cdot \sin a} \]
    12. lower-cos.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \color{blue}{\cos a} - \sin b \cdot \sin a} \]
    13. lower-*.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \cos a - \color{blue}{\sin b \cdot \sin a}} \]
    14. lift-sin.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \cos a - \color{blue}{\sin b} \cdot \sin a} \]
    15. lower-sin.f6499.5

      \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \cos a - \sin b \cdot \color{blue}{\sin a}} \]
  3. Applied rewrites99.5%

    \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos b \cdot \cos a - \sin b \cdot \sin a}} \]
  4. Step-by-step derivation
    1. lift--.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos b \cdot \cos a - \sin b \cdot \sin a}} \]
    2. lift-*.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos b \cdot \cos a} - \sin b \cdot \sin a} \]
    3. lift-cos.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos b} \cdot \cos a - \sin b \cdot \sin a} \]
    4. lift-cos.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \color{blue}{\cos a} - \sin b \cdot \sin a} \]
    5. lift-*.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \cos a - \color{blue}{\sin b \cdot \sin a}} \]
    6. lift-sin.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \cos a - \color{blue}{\sin b} \cdot \sin a} \]
    7. lift-sin.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \cos a - \sin b \cdot \color{blue}{\sin a}} \]
    8. fp-cancel-sub-sign-invN/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos b \cdot \cos a + \left(\mathsf{neg}\left(\sin b\right)\right) \cdot \sin a}} \]
    9. lower-fma.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\mathsf{fma}\left(\cos b, \cos a, \left(\mathsf{neg}\left(\sin b\right)\right) \cdot \sin a\right)}} \]
    10. lift-cos.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\mathsf{fma}\left(\color{blue}{\cos b}, \cos a, \left(\mathsf{neg}\left(\sin b\right)\right) \cdot \sin a\right)} \]
    11. lift-cos.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos b, \color{blue}{\cos a}, \left(\mathsf{neg}\left(\sin b\right)\right) \cdot \sin a\right)} \]
    12. lower-*.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \color{blue}{\left(\mathsf{neg}\left(\sin b\right)\right) \cdot \sin a}\right)} \]
    13. lower-neg.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \color{blue}{\left(-\sin b\right)} \cdot \sin a\right)} \]
    14. lift-sin.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \left(-\color{blue}{\sin b}\right) \cdot \sin a\right)} \]
    15. lift-sin.f6499.5

      \[\leadsto r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \left(-\sin b\right) \cdot \color{blue}{\sin a}\right)} \]
  5. Applied rewrites99.5%

    \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\mathsf{fma}\left(\cos b, \cos a, \left(-\sin b\right) \cdot \sin a\right)}} \]
  6. Add Preprocessing

Alternative 4: 99.5% accurate, 0.6× speedup?

\[\begin{array}{l} \\ r \cdot \frac{\sin b}{\cos b \cdot \cos a - \sin b \cdot \sin a} \end{array} \]
(FPCore (r a b)
 :precision binary64
 (* r (/ (sin b) (- (* (cos b) (cos a)) (* (sin b) (sin a))))))
double code(double r, double a, double b) {
	return r * (sin(b) / ((cos(b) * cos(a)) - (sin(b) * sin(a))));
}
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(8) function code(r, a, b)
use fmin_fmax_functions
    real(8), intent (in) :: r
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = r * (sin(b) / ((cos(b) * cos(a)) - (sin(b) * sin(a))))
end function
public static double code(double r, double a, double b) {
	return r * (Math.sin(b) / ((Math.cos(b) * Math.cos(a)) - (Math.sin(b) * Math.sin(a))));
}
def code(r, a, b):
	return r * (math.sin(b) / ((math.cos(b) * math.cos(a)) - (math.sin(b) * math.sin(a))))
function code(r, a, b)
	return Float64(r * Float64(sin(b) / Float64(Float64(cos(b) * cos(a)) - Float64(sin(b) * sin(a)))))
end
function tmp = code(r, a, b)
	tmp = r * (sin(b) / ((cos(b) * cos(a)) - (sin(b) * sin(a))));
end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
r \cdot \frac{\sin b}{\cos b \cdot \cos a - \sin b \cdot \sin a}
\end{array}
Derivation
  1. Initial program 76.4%

    \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
  2. Step-by-step derivation
    1. lift-+.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\cos \color{blue}{\left(a + b\right)}} \]
    2. lift-cos.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos \left(a + b\right)}} \]
    3. +-commutativeN/A

      \[\leadsto r \cdot \frac{\sin b}{\cos \color{blue}{\left(b + a\right)}} \]
    4. cos-sumN/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos b \cdot \cos a - \sin b \cdot \sin a}} \]
    5. cos-neg-revN/A

      \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \color{blue}{\cos \left(\mathsf{neg}\left(a\right)\right)} - \sin b \cdot \sin a} \]
    6. mul-1-negN/A

      \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \cos \color{blue}{\left(-1 \cdot a\right)} - \sin b \cdot \sin a} \]
    7. lower--.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos b \cdot \cos \left(-1 \cdot a\right) - \sin b \cdot \sin a}} \]
    8. mul-1-negN/A

      \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \cos \color{blue}{\left(\mathsf{neg}\left(a\right)\right)} - \sin b \cdot \sin a} \]
    9. cos-neg-revN/A

      \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \color{blue}{\cos a} - \sin b \cdot \sin a} \]
    10. lower-*.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos b \cdot \cos a} - \sin b \cdot \sin a} \]
    11. lower-cos.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos b} \cdot \cos a - \sin b \cdot \sin a} \]
    12. lower-cos.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \color{blue}{\cos a} - \sin b \cdot \sin a} \]
    13. lower-*.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \cos a - \color{blue}{\sin b \cdot \sin a}} \]
    14. lift-sin.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \cos a - \color{blue}{\sin b} \cdot \sin a} \]
    15. lower-sin.f6499.5

      \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \cos a - \sin b \cdot \color{blue}{\sin a}} \]
  3. Applied rewrites99.5%

    \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos b \cdot \cos a - \sin b \cdot \sin a}} \]
  4. Add Preprocessing

Alternative 5: 76.4% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\sin b}{\cos \left(a + b\right)}\\ t_1 := \sin b \cdot r\\ \mathbf{if}\;t\_0 \leq -0.06:\\ \;\;\;\;r \cdot \tan \left(b + \pi\right)\\ \mathbf{elif}\;t\_0 \leq 10^{-25}:\\ \;\;\;\;\frac{t\_1}{\cos a}\\ \mathbf{else}:\\ \;\;\;\;\frac{t\_1}{\cos b}\\ \end{array} \end{array} \]
(FPCore (r a b)
 :precision binary64
 (let* ((t_0 (/ (sin b) (cos (+ a b)))) (t_1 (* (sin b) r)))
   (if (<= t_0 -0.06)
     (* r (tan (+ b PI)))
     (if (<= t_0 1e-25) (/ t_1 (cos a)) (/ t_1 (cos b))))))
double code(double r, double a, double b) {
	double t_0 = sin(b) / cos((a + b));
	double t_1 = sin(b) * r;
	double tmp;
	if (t_0 <= -0.06) {
		tmp = r * tan((b + ((double) M_PI)));
	} else if (t_0 <= 1e-25) {
		tmp = t_1 / cos(a);
	} else {
		tmp = t_1 / cos(b);
	}
	return tmp;
}
public static double code(double r, double a, double b) {
	double t_0 = Math.sin(b) / Math.cos((a + b));
	double t_1 = Math.sin(b) * r;
	double tmp;
	if (t_0 <= -0.06) {
		tmp = r * Math.tan((b + Math.PI));
	} else if (t_0 <= 1e-25) {
		tmp = t_1 / Math.cos(a);
	} else {
		tmp = t_1 / Math.cos(b);
	}
	return tmp;
}
def code(r, a, b):
	t_0 = math.sin(b) / math.cos((a + b))
	t_1 = math.sin(b) * r
	tmp = 0
	if t_0 <= -0.06:
		tmp = r * math.tan((b + math.pi))
	elif t_0 <= 1e-25:
		tmp = t_1 / math.cos(a)
	else:
		tmp = t_1 / math.cos(b)
	return tmp
function code(r, a, b)
	t_0 = Float64(sin(b) / cos(Float64(a + b)))
	t_1 = Float64(sin(b) * r)
	tmp = 0.0
	if (t_0 <= -0.06)
		tmp = Float64(r * tan(Float64(b + pi)));
	elseif (t_0 <= 1e-25)
		tmp = Float64(t_1 / cos(a));
	else
		tmp = Float64(t_1 / cos(b));
	end
	return tmp
end
function tmp_2 = code(r, a, b)
	t_0 = sin(b) / cos((a + b));
	t_1 = sin(b) * r;
	tmp = 0.0;
	if (t_0 <= -0.06)
		tmp = r * tan((b + pi));
	elseif (t_0 <= 1e-25)
		tmp = t_1 / cos(a);
	else
		tmp = t_1 / cos(b);
	end
	tmp_2 = tmp;
end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[Sin[b], $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision]}, If[LessEqual[t$95$0, -0.06], N[(r * N[Tan[N[(b + Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e-25], N[(t$95$1 / N[Cos[a], $MachinePrecision]), $MachinePrecision], N[(t$95$1 / N[Cos[b], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\sin b}{\cos \left(a + b\right)}\\
t_1 := \sin b \cdot r\\
\mathbf{if}\;t\_0 \leq -0.06:\\
\;\;\;\;r \cdot \tan \left(b + \pi\right)\\

\mathbf{elif}\;t\_0 \leq 10^{-25}:\\
\;\;\;\;\frac{t\_1}{\cos a}\\

\mathbf{else}:\\
\;\;\;\;\frac{t\_1}{\cos b}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < -0.059999999999999998

    1. Initial program 54.7%

      \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
    2. Taylor expanded in a around 0

      \[\leadsto r \cdot \color{blue}{\frac{\sin b}{\cos b}} \]
    3. Step-by-step derivation
      1. quot-tanN/A

        \[\leadsto r \cdot \tan b \]
      2. lower-tan.f6454.5

        \[\leadsto r \cdot \tan b \]
    4. Applied rewrites54.5%

      \[\leadsto r \cdot \color{blue}{\tan b} \]
    5. Step-by-step derivation
      1. lift-tan.f64N/A

        \[\leadsto r \cdot \tan b \]
      2. tan-+PI-revN/A

        \[\leadsto r \cdot \tan \left(b + \mathsf{PI}\left(\right)\right) \]
      3. lower-tan.f64N/A

        \[\leadsto r \cdot \tan \left(b + \mathsf{PI}\left(\right)\right) \]
      4. lower-+.f64N/A

        \[\leadsto r \cdot \tan \left(b + \mathsf{PI}\left(\right)\right) \]
      5. lower-PI.f6453.3

        \[\leadsto r \cdot \tan \left(b + \pi\right) \]
    6. Applied rewrites53.3%

      \[\leadsto r \cdot \tan \left(b + \pi\right) \]

    if -0.059999999999999998 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < 1.00000000000000004e-25

    1. Initial program 98.5%

      \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{r \cdot \frac{\sin b}{\cos \left(a + b\right)}} \]
      2. lift-/.f64N/A

        \[\leadsto r \cdot \color{blue}{\frac{\sin b}{\cos \left(a + b\right)}} \]
      3. lift-sin.f64N/A

        \[\leadsto r \cdot \frac{\color{blue}{\sin b}}{\cos \left(a + b\right)} \]
      4. lift-+.f64N/A

        \[\leadsto r \cdot \frac{\sin b}{\cos \color{blue}{\left(a + b\right)}} \]
      5. lift-cos.f64N/A

        \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos \left(a + b\right)}} \]
      6. associate-*r/N/A

        \[\leadsto \color{blue}{\frac{r \cdot \sin b}{\cos \left(a + b\right)}} \]
      7. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{r \cdot \sin b}{\cos \left(a + b\right)}} \]
      8. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{\sin b \cdot r}}{\cos \left(a + b\right)} \]
      9. lower-*.f64N/A

        \[\leadsto \frac{\color{blue}{\sin b \cdot r}}{\cos \left(a + b\right)} \]
      10. lift-sin.f64N/A

        \[\leadsto \frac{\color{blue}{\sin b} \cdot r}{\cos \left(a + b\right)} \]
      11. lift-cos.f64N/A

        \[\leadsto \frac{\sin b \cdot r}{\color{blue}{\cos \left(a + b\right)}} \]
      12. lift-+.f6498.5

        \[\leadsto \frac{\sin b \cdot r}{\cos \color{blue}{\left(a + b\right)}} \]
    3. Applied rewrites98.5%

      \[\leadsto \color{blue}{\frac{\sin b \cdot r}{\cos \left(a + b\right)}} \]
    4. Taylor expanded in a around inf

      \[\leadsto \frac{\sin b \cdot r}{\cos \color{blue}{a}} \]
    5. Step-by-step derivation
      1. Applied rewrites97.7%

        \[\leadsto \frac{\sin b \cdot r}{\cos \color{blue}{a}} \]

      if 1.00000000000000004e-25 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b)))

      1. Initial program 57.0%

        \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
      2. Taylor expanded in a around 0

        \[\leadsto r \cdot \frac{\sin b}{\cos \color{blue}{b}} \]
      3. Step-by-step derivation
        1. Applied rewrites54.6%

          \[\leadsto r \cdot \frac{\sin b}{\cos \color{blue}{b}} \]
        2. Step-by-step derivation
          1. lift-*.f64N/A

            \[\leadsto \color{blue}{r \cdot \frac{\sin b}{\cos b}} \]
          2. lift-/.f64N/A

            \[\leadsto r \cdot \color{blue}{\frac{\sin b}{\cos b}} \]
          3. lift-sin.f64N/A

            \[\leadsto r \cdot \frac{\color{blue}{\sin b}}{\cos b} \]
          4. associate-*r/N/A

            \[\leadsto \color{blue}{\frac{r \cdot \sin b}{\cos b}} \]
          5. lower-/.f64N/A

            \[\leadsto \color{blue}{\frac{r \cdot \sin b}{\cos b}} \]
          6. *-commutativeN/A

            \[\leadsto \frac{\color{blue}{\sin b \cdot r}}{\cos b} \]
          7. lower-*.f64N/A

            \[\leadsto \frac{\color{blue}{\sin b \cdot r}}{\cos b} \]
          8. lift-sin.f6454.6

            \[\leadsto \frac{\color{blue}{\sin b} \cdot r}{\cos b} \]
        3. Applied rewrites54.6%

          \[\leadsto \color{blue}{\frac{\sin b \cdot r}{\cos b}} \]
      4. Recombined 3 regimes into one program.
      5. Add Preprocessing

      Alternative 6: 76.4% accurate, 0.3× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\sin b}{\cos \left(a + b\right)}\\ \mathbf{if}\;t\_0 \leq -0.06:\\ \;\;\;\;r \cdot \tan \left(b + \pi\right)\\ \mathbf{elif}\;t\_0 \leq 10^{-25}:\\ \;\;\;\;\frac{\sin b \cdot r}{\cos a}\\ \mathbf{else}:\\ \;\;\;\;r \cdot \tan b\\ \end{array} \end{array} \]
      (FPCore (r a b)
       :precision binary64
       (let* ((t_0 (/ (sin b) (cos (+ a b)))))
         (if (<= t_0 -0.06)
           (* r (tan (+ b PI)))
           (if (<= t_0 1e-25) (/ (* (sin b) r) (cos a)) (* r (tan b))))))
      double code(double r, double a, double b) {
      	double t_0 = sin(b) / cos((a + b));
      	double tmp;
      	if (t_0 <= -0.06) {
      		tmp = r * tan((b + ((double) M_PI)));
      	} else if (t_0 <= 1e-25) {
      		tmp = (sin(b) * r) / cos(a);
      	} else {
      		tmp = r * tan(b);
      	}
      	return tmp;
      }
      
      public static double code(double r, double a, double b) {
      	double t_0 = Math.sin(b) / Math.cos((a + b));
      	double tmp;
      	if (t_0 <= -0.06) {
      		tmp = r * Math.tan((b + Math.PI));
      	} else if (t_0 <= 1e-25) {
      		tmp = (Math.sin(b) * r) / Math.cos(a);
      	} else {
      		tmp = r * Math.tan(b);
      	}
      	return tmp;
      }
      
      def code(r, a, b):
      	t_0 = math.sin(b) / math.cos((a + b))
      	tmp = 0
      	if t_0 <= -0.06:
      		tmp = r * math.tan((b + math.pi))
      	elif t_0 <= 1e-25:
      		tmp = (math.sin(b) * r) / math.cos(a)
      	else:
      		tmp = r * math.tan(b)
      	return tmp
      
      function code(r, a, b)
      	t_0 = Float64(sin(b) / cos(Float64(a + b)))
      	tmp = 0.0
      	if (t_0 <= -0.06)
      		tmp = Float64(r * tan(Float64(b + pi)));
      	elseif (t_0 <= 1e-25)
      		tmp = Float64(Float64(sin(b) * r) / cos(a));
      	else
      		tmp = Float64(r * tan(b));
      	end
      	return tmp
      end
      
      function tmp_2 = code(r, a, b)
      	t_0 = sin(b) / cos((a + b));
      	tmp = 0.0;
      	if (t_0 <= -0.06)
      		tmp = r * tan((b + pi));
      	elseif (t_0 <= 1e-25)
      		tmp = (sin(b) * r) / cos(a);
      	else
      		tmp = r * tan(b);
      	end
      	tmp_2 = tmp;
      end
      
      code[r_, a_, b_] := Block[{t$95$0 = N[(N[Sin[b], $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.06], N[(r * N[Tan[N[(b + Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e-25], N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := \frac{\sin b}{\cos \left(a + b\right)}\\
      \mathbf{if}\;t\_0 \leq -0.06:\\
      \;\;\;\;r \cdot \tan \left(b + \pi\right)\\
      
      \mathbf{elif}\;t\_0 \leq 10^{-25}:\\
      \;\;\;\;\frac{\sin b \cdot r}{\cos a}\\
      
      \mathbf{else}:\\
      \;\;\;\;r \cdot \tan b\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < -0.059999999999999998

        1. Initial program 54.7%

          \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
        2. Taylor expanded in a around 0

          \[\leadsto r \cdot \color{blue}{\frac{\sin b}{\cos b}} \]
        3. Step-by-step derivation
          1. quot-tanN/A

            \[\leadsto r \cdot \tan b \]
          2. lower-tan.f6454.5

            \[\leadsto r \cdot \tan b \]
        4. Applied rewrites54.5%

          \[\leadsto r \cdot \color{blue}{\tan b} \]
        5. Step-by-step derivation
          1. lift-tan.f64N/A

            \[\leadsto r \cdot \tan b \]
          2. tan-+PI-revN/A

            \[\leadsto r \cdot \tan \left(b + \mathsf{PI}\left(\right)\right) \]
          3. lower-tan.f64N/A

            \[\leadsto r \cdot \tan \left(b + \mathsf{PI}\left(\right)\right) \]
          4. lower-+.f64N/A

            \[\leadsto r \cdot \tan \left(b + \mathsf{PI}\left(\right)\right) \]
          5. lower-PI.f6453.3

            \[\leadsto r \cdot \tan \left(b + \pi\right) \]
        6. Applied rewrites53.3%

          \[\leadsto r \cdot \tan \left(b + \pi\right) \]

        if -0.059999999999999998 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < 1.00000000000000004e-25

        1. Initial program 98.5%

          \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
        2. Step-by-step derivation
          1. lift-*.f64N/A

            \[\leadsto \color{blue}{r \cdot \frac{\sin b}{\cos \left(a + b\right)}} \]
          2. lift-/.f64N/A

            \[\leadsto r \cdot \color{blue}{\frac{\sin b}{\cos \left(a + b\right)}} \]
          3. lift-sin.f64N/A

            \[\leadsto r \cdot \frac{\color{blue}{\sin b}}{\cos \left(a + b\right)} \]
          4. lift-+.f64N/A

            \[\leadsto r \cdot \frac{\sin b}{\cos \color{blue}{\left(a + b\right)}} \]
          5. lift-cos.f64N/A

            \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos \left(a + b\right)}} \]
          6. associate-*r/N/A

            \[\leadsto \color{blue}{\frac{r \cdot \sin b}{\cos \left(a + b\right)}} \]
          7. lower-/.f64N/A

            \[\leadsto \color{blue}{\frac{r \cdot \sin b}{\cos \left(a + b\right)}} \]
          8. *-commutativeN/A

            \[\leadsto \frac{\color{blue}{\sin b \cdot r}}{\cos \left(a + b\right)} \]
          9. lower-*.f64N/A

            \[\leadsto \frac{\color{blue}{\sin b \cdot r}}{\cos \left(a + b\right)} \]
          10. lift-sin.f64N/A

            \[\leadsto \frac{\color{blue}{\sin b} \cdot r}{\cos \left(a + b\right)} \]
          11. lift-cos.f64N/A

            \[\leadsto \frac{\sin b \cdot r}{\color{blue}{\cos \left(a + b\right)}} \]
          12. lift-+.f6498.5

            \[\leadsto \frac{\sin b \cdot r}{\cos \color{blue}{\left(a + b\right)}} \]
        3. Applied rewrites98.5%

          \[\leadsto \color{blue}{\frac{\sin b \cdot r}{\cos \left(a + b\right)}} \]
        4. Taylor expanded in a around inf

          \[\leadsto \frac{\sin b \cdot r}{\cos \color{blue}{a}} \]
        5. Step-by-step derivation
          1. Applied rewrites97.7%

            \[\leadsto \frac{\sin b \cdot r}{\cos \color{blue}{a}} \]

          if 1.00000000000000004e-25 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b)))

          1. Initial program 57.0%

            \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
          2. Taylor expanded in a around 0

            \[\leadsto r \cdot \color{blue}{\frac{\sin b}{\cos b}} \]
          3. Step-by-step derivation
            1. quot-tanN/A

              \[\leadsto r \cdot \tan b \]
            2. lower-tan.f6454.7

              \[\leadsto r \cdot \tan b \]
          4. Applied rewrites54.7%

            \[\leadsto r \cdot \color{blue}{\tan b} \]
        6. Recombined 3 regimes into one program.
        7. Add Preprocessing

        Alternative 7: 75.8% accurate, 0.3× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\sin b}{\cos \left(a + b\right)}\\ \mathbf{if}\;t\_0 \leq -0.06:\\ \;\;\;\;r \cdot \tan \left(b + \pi\right)\\ \mathbf{elif}\;t\_0 \leq 10^{-25}:\\ \;\;\;\;r \cdot \frac{\sin b}{\cos a}\\ \mathbf{else}:\\ \;\;\;\;r \cdot \tan b\\ \end{array} \end{array} \]
        (FPCore (r a b)
         :precision binary64
         (let* ((t_0 (/ (sin b) (cos (+ a b)))))
           (if (<= t_0 -0.06)
             (* r (tan (+ b PI)))
             (if (<= t_0 1e-25) (* r (/ (sin b) (cos a))) (* r (tan b))))))
        double code(double r, double a, double b) {
        	double t_0 = sin(b) / cos((a + b));
        	double tmp;
        	if (t_0 <= -0.06) {
        		tmp = r * tan((b + ((double) M_PI)));
        	} else if (t_0 <= 1e-25) {
        		tmp = r * (sin(b) / cos(a));
        	} else {
        		tmp = r * tan(b);
        	}
        	return tmp;
        }
        
        public static double code(double r, double a, double b) {
        	double t_0 = Math.sin(b) / Math.cos((a + b));
        	double tmp;
        	if (t_0 <= -0.06) {
        		tmp = r * Math.tan((b + Math.PI));
        	} else if (t_0 <= 1e-25) {
        		tmp = r * (Math.sin(b) / Math.cos(a));
        	} else {
        		tmp = r * Math.tan(b);
        	}
        	return tmp;
        }
        
        def code(r, a, b):
        	t_0 = math.sin(b) / math.cos((a + b))
        	tmp = 0
        	if t_0 <= -0.06:
        		tmp = r * math.tan((b + math.pi))
        	elif t_0 <= 1e-25:
        		tmp = r * (math.sin(b) / math.cos(a))
        	else:
        		tmp = r * math.tan(b)
        	return tmp
        
        function code(r, a, b)
        	t_0 = Float64(sin(b) / cos(Float64(a + b)))
        	tmp = 0.0
        	if (t_0 <= -0.06)
        		tmp = Float64(r * tan(Float64(b + pi)));
        	elseif (t_0 <= 1e-25)
        		tmp = Float64(r * Float64(sin(b) / cos(a)));
        	else
        		tmp = Float64(r * tan(b));
        	end
        	return tmp
        end
        
        function tmp_2 = code(r, a, b)
        	t_0 = sin(b) / cos((a + b));
        	tmp = 0.0;
        	if (t_0 <= -0.06)
        		tmp = r * tan((b + pi));
        	elseif (t_0 <= 1e-25)
        		tmp = r * (sin(b) / cos(a));
        	else
        		tmp = r * tan(b);
        	end
        	tmp_2 = tmp;
        end
        
        code[r_, a_, b_] := Block[{t$95$0 = N[(N[Sin[b], $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.06], N[(r * N[Tan[N[(b + Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e-25], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := \frac{\sin b}{\cos \left(a + b\right)}\\
        \mathbf{if}\;t\_0 \leq -0.06:\\
        \;\;\;\;r \cdot \tan \left(b + \pi\right)\\
        
        \mathbf{elif}\;t\_0 \leq 10^{-25}:\\
        \;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
        
        \mathbf{else}:\\
        \;\;\;\;r \cdot \tan b\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < -0.059999999999999998

          1. Initial program 54.7%

            \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
          2. Taylor expanded in a around 0

            \[\leadsto r \cdot \color{blue}{\frac{\sin b}{\cos b}} \]
          3. Step-by-step derivation
            1. quot-tanN/A

              \[\leadsto r \cdot \tan b \]
            2. lower-tan.f6454.5

              \[\leadsto r \cdot \tan b \]
          4. Applied rewrites54.5%

            \[\leadsto r \cdot \color{blue}{\tan b} \]
          5. Step-by-step derivation
            1. lift-tan.f64N/A

              \[\leadsto r \cdot \tan b \]
            2. tan-+PI-revN/A

              \[\leadsto r \cdot \tan \left(b + \mathsf{PI}\left(\right)\right) \]
            3. lower-tan.f64N/A

              \[\leadsto r \cdot \tan \left(b + \mathsf{PI}\left(\right)\right) \]
            4. lower-+.f64N/A

              \[\leadsto r \cdot \tan \left(b + \mathsf{PI}\left(\right)\right) \]
            5. lower-PI.f6453.3

              \[\leadsto r \cdot \tan \left(b + \pi\right) \]
          6. Applied rewrites53.3%

            \[\leadsto r \cdot \tan \left(b + \pi\right) \]

          if -0.059999999999999998 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < 1.00000000000000004e-25

          1. Initial program 98.5%

            \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
          2. Taylor expanded in a around inf

            \[\leadsto r \cdot \frac{\sin b}{\cos \color{blue}{a}} \]
          3. Step-by-step derivation
            1. Applied rewrites97.7%

              \[\leadsto r \cdot \frac{\sin b}{\cos \color{blue}{a}} \]

            if 1.00000000000000004e-25 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b)))

            1. Initial program 57.0%

              \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
            2. Taylor expanded in a around 0

              \[\leadsto r \cdot \color{blue}{\frac{\sin b}{\cos b}} \]
            3. Step-by-step derivation
              1. quot-tanN/A

                \[\leadsto r \cdot \tan b \]
              2. lower-tan.f6454.7

                \[\leadsto r \cdot \tan b \]
            4. Applied rewrites54.7%

              \[\leadsto r \cdot \color{blue}{\tan b} \]
          4. Recombined 3 regimes into one program.
          5. Add Preprocessing

          Alternative 8: 75.5% accurate, 0.3× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\sin b}{\cos \left(a + b\right)}\\ \mathbf{if}\;t\_0 \leq -0.01:\\ \;\;\;\;r \cdot \tan \left(b + \pi\right)\\ \mathbf{elif}\;t\_0 \leq 10^{-25}:\\ \;\;\;\;\frac{b \cdot r}{\cos a}\\ \mathbf{else}:\\ \;\;\;\;r \cdot \tan b\\ \end{array} \end{array} \]
          (FPCore (r a b)
           :precision binary64
           (let* ((t_0 (/ (sin b) (cos (+ a b)))))
             (if (<= t_0 -0.01)
               (* r (tan (+ b PI)))
               (if (<= t_0 1e-25) (/ (* b r) (cos a)) (* r (tan b))))))
          double code(double r, double a, double b) {
          	double t_0 = sin(b) / cos((a + b));
          	double tmp;
          	if (t_0 <= -0.01) {
          		tmp = r * tan((b + ((double) M_PI)));
          	} else if (t_0 <= 1e-25) {
          		tmp = (b * r) / cos(a);
          	} else {
          		tmp = r * tan(b);
          	}
          	return tmp;
          }
          
          public static double code(double r, double a, double b) {
          	double t_0 = Math.sin(b) / Math.cos((a + b));
          	double tmp;
          	if (t_0 <= -0.01) {
          		tmp = r * Math.tan((b + Math.PI));
          	} else if (t_0 <= 1e-25) {
          		tmp = (b * r) / Math.cos(a);
          	} else {
          		tmp = r * Math.tan(b);
          	}
          	return tmp;
          }
          
          def code(r, a, b):
          	t_0 = math.sin(b) / math.cos((a + b))
          	tmp = 0
          	if t_0 <= -0.01:
          		tmp = r * math.tan((b + math.pi))
          	elif t_0 <= 1e-25:
          		tmp = (b * r) / math.cos(a)
          	else:
          		tmp = r * math.tan(b)
          	return tmp
          
          function code(r, a, b)
          	t_0 = Float64(sin(b) / cos(Float64(a + b)))
          	tmp = 0.0
          	if (t_0 <= -0.01)
          		tmp = Float64(r * tan(Float64(b + pi)));
          	elseif (t_0 <= 1e-25)
          		tmp = Float64(Float64(b * r) / cos(a));
          	else
          		tmp = Float64(r * tan(b));
          	end
          	return tmp
          end
          
          function tmp_2 = code(r, a, b)
          	t_0 = sin(b) / cos((a + b));
          	tmp = 0.0;
          	if (t_0 <= -0.01)
          		tmp = r * tan((b + pi));
          	elseif (t_0 <= 1e-25)
          		tmp = (b * r) / cos(a);
          	else
          		tmp = r * tan(b);
          	end
          	tmp_2 = tmp;
          end
          
          code[r_, a_, b_] := Block[{t$95$0 = N[(N[Sin[b], $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.01], N[(r * N[Tan[N[(b + Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e-25], N[(N[(b * r), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_0 := \frac{\sin b}{\cos \left(a + b\right)}\\
          \mathbf{if}\;t\_0 \leq -0.01:\\
          \;\;\;\;r \cdot \tan \left(b + \pi\right)\\
          
          \mathbf{elif}\;t\_0 \leq 10^{-25}:\\
          \;\;\;\;\frac{b \cdot r}{\cos a}\\
          
          \mathbf{else}:\\
          \;\;\;\;r \cdot \tan b\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < -0.0100000000000000002

            1. Initial program 54.7%

              \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
            2. Taylor expanded in a around 0

              \[\leadsto r \cdot \color{blue}{\frac{\sin b}{\cos b}} \]
            3. Step-by-step derivation
              1. quot-tanN/A

                \[\leadsto r \cdot \tan b \]
              2. lower-tan.f6454.5

                \[\leadsto r \cdot \tan b \]
            4. Applied rewrites54.5%

              \[\leadsto r \cdot \color{blue}{\tan b} \]
            5. Step-by-step derivation
              1. lift-tan.f64N/A

                \[\leadsto r \cdot \tan b \]
              2. tan-+PI-revN/A

                \[\leadsto r \cdot \tan \left(b + \mathsf{PI}\left(\right)\right) \]
              3. lower-tan.f64N/A

                \[\leadsto r \cdot \tan \left(b + \mathsf{PI}\left(\right)\right) \]
              4. lower-+.f64N/A

                \[\leadsto r \cdot \tan \left(b + \mathsf{PI}\left(\right)\right) \]
              5. lower-PI.f6453.3

                \[\leadsto r \cdot \tan \left(b + \pi\right) \]
            6. Applied rewrites53.3%

              \[\leadsto r \cdot \tan \left(b + \pi\right) \]

            if -0.0100000000000000002 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < 1.00000000000000004e-25

            1. Initial program 99.3%

              \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
            2. Step-by-step derivation
              1. lift-+.f64N/A

                \[\leadsto r \cdot \frac{\sin b}{\cos \color{blue}{\left(a + b\right)}} \]
              2. lift-cos.f64N/A

                \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos \left(a + b\right)}} \]
              3. +-commutativeN/A

                \[\leadsto r \cdot \frac{\sin b}{\cos \color{blue}{\left(b + a\right)}} \]
              4. cos-sumN/A

                \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos b \cdot \cos a - \sin b \cdot \sin a}} \]
              5. cos-neg-revN/A

                \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \color{blue}{\cos \left(\mathsf{neg}\left(a\right)\right)} - \sin b \cdot \sin a} \]
              6. mul-1-negN/A

                \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \cos \color{blue}{\left(-1 \cdot a\right)} - \sin b \cdot \sin a} \]
              7. lower--.f64N/A

                \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos b \cdot \cos \left(-1 \cdot a\right) - \sin b \cdot \sin a}} \]
              8. mul-1-negN/A

                \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \cos \color{blue}{\left(\mathsf{neg}\left(a\right)\right)} - \sin b \cdot \sin a} \]
              9. cos-neg-revN/A

                \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \color{blue}{\cos a} - \sin b \cdot \sin a} \]
              10. lower-*.f64N/A

                \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos b \cdot \cos a} - \sin b \cdot \sin a} \]
              11. lower-cos.f64N/A

                \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos b} \cdot \cos a - \sin b \cdot \sin a} \]
              12. lower-cos.f64N/A

                \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \color{blue}{\cos a} - \sin b \cdot \sin a} \]
              13. lower-*.f64N/A

                \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \cos a - \color{blue}{\sin b \cdot \sin a}} \]
              14. lift-sin.f64N/A

                \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \cos a - \color{blue}{\sin b} \cdot \sin a} \]
              15. lower-sin.f6499.8

                \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \cos a - \sin b \cdot \color{blue}{\sin a}} \]
            3. Applied rewrites99.8%

              \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos b \cdot \cos a - \sin b \cdot \sin a}} \]
            4. Taylor expanded in b around 0

              \[\leadsto \color{blue}{\frac{b \cdot r}{\cos a}} \]
            5. Step-by-step derivation
              1. associate-*r/N/A

                \[\leadsto \frac{\color{blue}{b \cdot r}}{\cos a} \]
              2. cos-sum-revN/A

                \[\leadsto \frac{b \cdot \color{blue}{r}}{\cos a} \]
              3. +-commutativeN/A

                \[\leadsto \frac{b \cdot r}{\cos a} \]
              4. unpow1N/A

                \[\leadsto \frac{b \cdot r}{\cos a} \]
              5. metadata-evalN/A

                \[\leadsto \frac{b \cdot r}{\cos a} \]
              6. pow-flipN/A

                \[\leadsto \frac{b \cdot r}{\cos a} \]
              7. associate-*r/N/A

                \[\leadsto \frac{\color{blue}{b \cdot r}}{\cos a} \]
              8. associate-/l*N/A

                \[\leadsto b \cdot \color{blue}{\frac{r}{\cos a}} \]
              9. lower-*.f64N/A

                \[\leadsto b \cdot \color{blue}{\frac{r}{\cos a}} \]
              10. lower-/.f64N/A

                \[\leadsto b \cdot \frac{r}{\color{blue}{\cos a}} \]
              11. lift-cos.f6498.9

                \[\leadsto b \cdot \frac{r}{\cos a} \]
            6. Applied rewrites98.9%

              \[\leadsto \color{blue}{b \cdot \frac{r}{\cos a}} \]
            7. Step-by-step derivation
              1. lift-*.f64N/A

                \[\leadsto b \cdot \color{blue}{\frac{r}{\cos a}} \]
              2. lift-/.f64N/A

                \[\leadsto b \cdot \frac{r}{\color{blue}{\cos a}} \]
              3. lift-cos.f64N/A

                \[\leadsto b \cdot \frac{r}{\cos a} \]
              4. associate-*r/N/A

                \[\leadsto \frac{b \cdot r}{\color{blue}{\cos a}} \]
              5. lower-/.f64N/A

                \[\leadsto \frac{b \cdot r}{\color{blue}{\cos a}} \]
              6. lower-*.f64N/A

                \[\leadsto \frac{b \cdot r}{\cos \color{blue}{a}} \]
              7. lift-cos.f6499.0

                \[\leadsto \frac{b \cdot r}{\cos a} \]
            8. Applied rewrites99.0%

              \[\leadsto \frac{b \cdot r}{\color{blue}{\cos a}} \]

            if 1.00000000000000004e-25 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b)))

            1. Initial program 57.0%

              \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
            2. Taylor expanded in a around 0

              \[\leadsto r \cdot \color{blue}{\frac{\sin b}{\cos b}} \]
            3. Step-by-step derivation
              1. quot-tanN/A

                \[\leadsto r \cdot \tan b \]
              2. lower-tan.f6454.7

                \[\leadsto r \cdot \tan b \]
            4. Applied rewrites54.7%

              \[\leadsto r \cdot \color{blue}{\tan b} \]
          3. Recombined 3 regimes into one program.
          4. Add Preprocessing

          Alternative 9: 75.2% accurate, 0.3× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\sin b}{\cos \left(a + b\right)}\\ t_1 := r \cdot \tan b\\ \mathbf{if}\;t\_0 \leq -0.01:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 10^{-25}:\\ \;\;\;\;\frac{b \cdot r}{\cos a}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
          (FPCore (r a b)
           :precision binary64
           (let* ((t_0 (/ (sin b) (cos (+ a b)))) (t_1 (* r (tan b))))
             (if (<= t_0 -0.01) t_1 (if (<= t_0 1e-25) (/ (* b r) (cos a)) t_1))))
          double code(double r, double a, double b) {
          	double t_0 = sin(b) / cos((a + b));
          	double t_1 = r * tan(b);
          	double tmp;
          	if (t_0 <= -0.01) {
          		tmp = t_1;
          	} else if (t_0 <= 1e-25) {
          		tmp = (b * r) / cos(a);
          	} else {
          		tmp = t_1;
          	}
          	return tmp;
          }
          
          module fmin_fmax_functions
              implicit none
              private
              public fmax
              public fmin
          
              interface fmax
                  module procedure fmax88
                  module procedure fmax44
                  module procedure fmax84
                  module procedure fmax48
              end interface
              interface fmin
                  module procedure fmin88
                  module procedure fmin44
                  module procedure fmin84
                  module procedure fmin48
              end interface
          contains
              real(8) function fmax88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(4) function fmax44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(8) function fmax84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmax48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
              end function
              real(8) function fmin88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(4) function fmin44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(8) function fmin84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmin48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
              end function
          end module
          
          real(8) function code(r, a, b)
          use fmin_fmax_functions
              real(8), intent (in) :: r
              real(8), intent (in) :: a
              real(8), intent (in) :: b
              real(8) :: t_0
              real(8) :: t_1
              real(8) :: tmp
              t_0 = sin(b) / cos((a + b))
              t_1 = r * tan(b)
              if (t_0 <= (-0.01d0)) then
                  tmp = t_1
              else if (t_0 <= 1d-25) then
                  tmp = (b * r) / cos(a)
              else
                  tmp = t_1
              end if
              code = tmp
          end function
          
          public static double code(double r, double a, double b) {
          	double t_0 = Math.sin(b) / Math.cos((a + b));
          	double t_1 = r * Math.tan(b);
          	double tmp;
          	if (t_0 <= -0.01) {
          		tmp = t_1;
          	} else if (t_0 <= 1e-25) {
          		tmp = (b * r) / Math.cos(a);
          	} else {
          		tmp = t_1;
          	}
          	return tmp;
          }
          
          def code(r, a, b):
          	t_0 = math.sin(b) / math.cos((a + b))
          	t_1 = r * math.tan(b)
          	tmp = 0
          	if t_0 <= -0.01:
          		tmp = t_1
          	elif t_0 <= 1e-25:
          		tmp = (b * r) / math.cos(a)
          	else:
          		tmp = t_1
          	return tmp
          
          function code(r, a, b)
          	t_0 = Float64(sin(b) / cos(Float64(a + b)))
          	t_1 = Float64(r * tan(b))
          	tmp = 0.0
          	if (t_0 <= -0.01)
          		tmp = t_1;
          	elseif (t_0 <= 1e-25)
          		tmp = Float64(Float64(b * r) / cos(a));
          	else
          		tmp = t_1;
          	end
          	return tmp
          end
          
          function tmp_2 = code(r, a, b)
          	t_0 = sin(b) / cos((a + b));
          	t_1 = r * tan(b);
          	tmp = 0.0;
          	if (t_0 <= -0.01)
          		tmp = t_1;
          	elseif (t_0 <= 1e-25)
          		tmp = (b * r) / cos(a);
          	else
          		tmp = t_1;
          	end
          	tmp_2 = tmp;
          end
          
          code[r_, a_, b_] := Block[{t$95$0 = N[(N[Sin[b], $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.01], t$95$1, If[LessEqual[t$95$0, 1e-25], N[(N[(b * r), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], t$95$1]]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_0 := \frac{\sin b}{\cos \left(a + b\right)}\\
          t_1 := r \cdot \tan b\\
          \mathbf{if}\;t\_0 \leq -0.01:\\
          \;\;\;\;t\_1\\
          
          \mathbf{elif}\;t\_0 \leq 10^{-25}:\\
          \;\;\;\;\frac{b \cdot r}{\cos a}\\
          
          \mathbf{else}:\\
          \;\;\;\;t\_1\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < -0.0100000000000000002 or 1.00000000000000004e-25 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b)))

            1. Initial program 55.9%

              \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
            2. Taylor expanded in a around 0

              \[\leadsto r \cdot \color{blue}{\frac{\sin b}{\cos b}} \]
            3. Step-by-step derivation
              1. quot-tanN/A

                \[\leadsto r \cdot \tan b \]
              2. lower-tan.f6454.6

                \[\leadsto r \cdot \tan b \]
            4. Applied rewrites54.6%

              \[\leadsto r \cdot \color{blue}{\tan b} \]

            if -0.0100000000000000002 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < 1.00000000000000004e-25

            1. Initial program 99.3%

              \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
            2. Step-by-step derivation
              1. lift-+.f64N/A

                \[\leadsto r \cdot \frac{\sin b}{\cos \color{blue}{\left(a + b\right)}} \]
              2. lift-cos.f64N/A

                \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos \left(a + b\right)}} \]
              3. +-commutativeN/A

                \[\leadsto r \cdot \frac{\sin b}{\cos \color{blue}{\left(b + a\right)}} \]
              4. cos-sumN/A

                \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos b \cdot \cos a - \sin b \cdot \sin a}} \]
              5. cos-neg-revN/A

                \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \color{blue}{\cos \left(\mathsf{neg}\left(a\right)\right)} - \sin b \cdot \sin a} \]
              6. mul-1-negN/A

                \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \cos \color{blue}{\left(-1 \cdot a\right)} - \sin b \cdot \sin a} \]
              7. lower--.f64N/A

                \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos b \cdot \cos \left(-1 \cdot a\right) - \sin b \cdot \sin a}} \]
              8. mul-1-negN/A

                \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \cos \color{blue}{\left(\mathsf{neg}\left(a\right)\right)} - \sin b \cdot \sin a} \]
              9. cos-neg-revN/A

                \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \color{blue}{\cos a} - \sin b \cdot \sin a} \]
              10. lower-*.f64N/A

                \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos b \cdot \cos a} - \sin b \cdot \sin a} \]
              11. lower-cos.f64N/A

                \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos b} \cdot \cos a - \sin b \cdot \sin a} \]
              12. lower-cos.f64N/A

                \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \color{blue}{\cos a} - \sin b \cdot \sin a} \]
              13. lower-*.f64N/A

                \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \cos a - \color{blue}{\sin b \cdot \sin a}} \]
              14. lift-sin.f64N/A

                \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \cos a - \color{blue}{\sin b} \cdot \sin a} \]
              15. lower-sin.f6499.8

                \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \cos a - \sin b \cdot \color{blue}{\sin a}} \]
            3. Applied rewrites99.8%

              \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos b \cdot \cos a - \sin b \cdot \sin a}} \]
            4. Taylor expanded in b around 0

              \[\leadsto \color{blue}{\frac{b \cdot r}{\cos a}} \]
            5. Step-by-step derivation
              1. associate-*r/N/A

                \[\leadsto \frac{\color{blue}{b \cdot r}}{\cos a} \]
              2. cos-sum-revN/A

                \[\leadsto \frac{b \cdot \color{blue}{r}}{\cos a} \]
              3. +-commutativeN/A

                \[\leadsto \frac{b \cdot r}{\cos a} \]
              4. unpow1N/A

                \[\leadsto \frac{b \cdot r}{\cos a} \]
              5. metadata-evalN/A

                \[\leadsto \frac{b \cdot r}{\cos a} \]
              6. pow-flipN/A

                \[\leadsto \frac{b \cdot r}{\cos a} \]
              7. associate-*r/N/A

                \[\leadsto \frac{\color{blue}{b \cdot r}}{\cos a} \]
              8. associate-/l*N/A

                \[\leadsto b \cdot \color{blue}{\frac{r}{\cos a}} \]
              9. lower-*.f64N/A

                \[\leadsto b \cdot \color{blue}{\frac{r}{\cos a}} \]
              10. lower-/.f64N/A

                \[\leadsto b \cdot \frac{r}{\color{blue}{\cos a}} \]
              11. lift-cos.f6498.9

                \[\leadsto b \cdot \frac{r}{\cos a} \]
            6. Applied rewrites98.9%

              \[\leadsto \color{blue}{b \cdot \frac{r}{\cos a}} \]
            7. Step-by-step derivation
              1. lift-*.f64N/A

                \[\leadsto b \cdot \color{blue}{\frac{r}{\cos a}} \]
              2. lift-/.f64N/A

                \[\leadsto b \cdot \frac{r}{\color{blue}{\cos a}} \]
              3. lift-cos.f64N/A

                \[\leadsto b \cdot \frac{r}{\cos a} \]
              4. associate-*r/N/A

                \[\leadsto \frac{b \cdot r}{\color{blue}{\cos a}} \]
              5. lower-/.f64N/A

                \[\leadsto \frac{b \cdot r}{\color{blue}{\cos a}} \]
              6. lower-*.f64N/A

                \[\leadsto \frac{b \cdot r}{\cos \color{blue}{a}} \]
              7. lift-cos.f6499.0

                \[\leadsto \frac{b \cdot r}{\cos a} \]
            8. Applied rewrites99.0%

              \[\leadsto \frac{b \cdot r}{\color{blue}{\cos a}} \]
          3. Recombined 2 regimes into one program.
          4. Add Preprocessing

          Alternative 10: 75.0% accurate, 0.6× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := r \cdot \tan b\\ \mathbf{if}\;b \leq -9.2 \cdot 10^{-5}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;b \leq 1.4 \cdot 10^{-21}:\\ \;\;\;\;b \cdot \frac{r}{\cos a}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
          (FPCore (r a b)
           :precision binary64
           (let* ((t_0 (* r (tan b))))
             (if (<= b -9.2e-5) t_0 (if (<= b 1.4e-21) (* b (/ r (cos a))) t_0))))
          double code(double r, double a, double b) {
          	double t_0 = r * tan(b);
          	double tmp;
          	if (b <= -9.2e-5) {
          		tmp = t_0;
          	} else if (b <= 1.4e-21) {
          		tmp = b * (r / cos(a));
          	} else {
          		tmp = t_0;
          	}
          	return tmp;
          }
          
          module fmin_fmax_functions
              implicit none
              private
              public fmax
              public fmin
          
              interface fmax
                  module procedure fmax88
                  module procedure fmax44
                  module procedure fmax84
                  module procedure fmax48
              end interface
              interface fmin
                  module procedure fmin88
                  module procedure fmin44
                  module procedure fmin84
                  module procedure fmin48
              end interface
          contains
              real(8) function fmax88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(4) function fmax44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(8) function fmax84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmax48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
              end function
              real(8) function fmin88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(4) function fmin44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(8) function fmin84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmin48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
              end function
          end module
          
          real(8) function code(r, a, b)
          use fmin_fmax_functions
              real(8), intent (in) :: r
              real(8), intent (in) :: a
              real(8), intent (in) :: b
              real(8) :: t_0
              real(8) :: tmp
              t_0 = r * tan(b)
              if (b <= (-9.2d-5)) then
                  tmp = t_0
              else if (b <= 1.4d-21) then
                  tmp = b * (r / cos(a))
              else
                  tmp = t_0
              end if
              code = tmp
          end function
          
          public static double code(double r, double a, double b) {
          	double t_0 = r * Math.tan(b);
          	double tmp;
          	if (b <= -9.2e-5) {
          		tmp = t_0;
          	} else if (b <= 1.4e-21) {
          		tmp = b * (r / Math.cos(a));
          	} else {
          		tmp = t_0;
          	}
          	return tmp;
          }
          
          def code(r, a, b):
          	t_0 = r * math.tan(b)
          	tmp = 0
          	if b <= -9.2e-5:
          		tmp = t_0
          	elif b <= 1.4e-21:
          		tmp = b * (r / math.cos(a))
          	else:
          		tmp = t_0
          	return tmp
          
          function code(r, a, b)
          	t_0 = Float64(r * tan(b))
          	tmp = 0.0
          	if (b <= -9.2e-5)
          		tmp = t_0;
          	elseif (b <= 1.4e-21)
          		tmp = Float64(b * Float64(r / cos(a)));
          	else
          		tmp = t_0;
          	end
          	return tmp
          end
          
          function tmp_2 = code(r, a, b)
          	t_0 = r * tan(b);
          	tmp = 0.0;
          	if (b <= -9.2e-5)
          		tmp = t_0;
          	elseif (b <= 1.4e-21)
          		tmp = b * (r / cos(a));
          	else
          		tmp = t_0;
          	end
          	tmp_2 = tmp;
          end
          
          code[r_, a_, b_] := Block[{t$95$0 = N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -9.2e-5], t$95$0, If[LessEqual[b, 1.4e-21], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_0 := r \cdot \tan b\\
          \mathbf{if}\;b \leq -9.2 \cdot 10^{-5}:\\
          \;\;\;\;t\_0\\
          
          \mathbf{elif}\;b \leq 1.4 \cdot 10^{-21}:\\
          \;\;\;\;b \cdot \frac{r}{\cos a}\\
          
          \mathbf{else}:\\
          \;\;\;\;t\_0\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if b < -9.20000000000000001e-5 or 1.40000000000000002e-21 < b

            1. Initial program 55.6%

              \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
            2. Taylor expanded in a around 0

              \[\leadsto r \cdot \color{blue}{\frac{\sin b}{\cos b}} \]
            3. Step-by-step derivation
              1. quot-tanN/A

                \[\leadsto r \cdot \tan b \]
              2. lower-tan.f6454.7

                \[\leadsto r \cdot \tan b \]
            4. Applied rewrites54.7%

              \[\leadsto r \cdot \color{blue}{\tan b} \]

            if -9.20000000000000001e-5 < b < 1.40000000000000002e-21

            1. Initial program 99.6%

              \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
            2. Taylor expanded in b around 0

              \[\leadsto \color{blue}{\frac{b \cdot r}{\cos a}} \]
            3. Step-by-step derivation
              1. associate-/l*N/A

                \[\leadsto b \cdot \color{blue}{\frac{r}{\cos a}} \]
              2. lower-*.f64N/A

                \[\leadsto b \cdot \color{blue}{\frac{r}{\cos a}} \]
              3. lower-/.f64N/A

                \[\leadsto b \cdot \frac{r}{\color{blue}{\cos a}} \]
              4. lower-cos.f6499.5

                \[\leadsto b \cdot \frac{r}{\cos a} \]
            4. Applied rewrites99.5%

              \[\leadsto \color{blue}{b \cdot \frac{r}{\cos a}} \]
          3. Recombined 2 regimes into one program.
          4. Add Preprocessing

          Alternative 11: 75.0% accurate, 1.0× speedup?

          \[\begin{array}{l} \\ \frac{\sin b \cdot r}{\cos \left(a + b\right)} \end{array} \]
          (FPCore (r a b) :precision binary64 (/ (* (sin b) r) (cos (+ a b))))
          double code(double r, double a, double b) {
          	return (sin(b) * r) / cos((a + b));
          }
          
          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(8) function code(r, a, b)
          use fmin_fmax_functions
              real(8), intent (in) :: r
              real(8), intent (in) :: a
              real(8), intent (in) :: b
              code = (sin(b) * r) / cos((a + b))
          end function
          
          public static double code(double r, double a, double b) {
          	return (Math.sin(b) * r) / Math.cos((a + b));
          }
          
          def code(r, a, b):
          	return (math.sin(b) * r) / math.cos((a + b))
          
          function code(r, a, b)
          	return Float64(Float64(sin(b) * r) / cos(Float64(a + b)))
          end
          
          function tmp = code(r, a, b)
          	tmp = (sin(b) * r) / cos((a + b));
          end
          
          code[r_, a_, b_] := N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
          
          \begin{array}{l}
          
          \\
          \frac{\sin b \cdot r}{\cos \left(a + b\right)}
          \end{array}
          
          Derivation
          1. Initial program 76.4%

            \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
          2. Step-by-step derivation
            1. lift-*.f64N/A

              \[\leadsto \color{blue}{r \cdot \frac{\sin b}{\cos \left(a + b\right)}} \]
            2. lift-/.f64N/A

              \[\leadsto r \cdot \color{blue}{\frac{\sin b}{\cos \left(a + b\right)}} \]
            3. lift-sin.f64N/A

              \[\leadsto r \cdot \frac{\color{blue}{\sin b}}{\cos \left(a + b\right)} \]
            4. lift-+.f64N/A

              \[\leadsto r \cdot \frac{\sin b}{\cos \color{blue}{\left(a + b\right)}} \]
            5. lift-cos.f64N/A

              \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos \left(a + b\right)}} \]
            6. associate-*r/N/A

              \[\leadsto \color{blue}{\frac{r \cdot \sin b}{\cos \left(a + b\right)}} \]
            7. lower-/.f64N/A

              \[\leadsto \color{blue}{\frac{r \cdot \sin b}{\cos \left(a + b\right)}} \]
            8. *-commutativeN/A

              \[\leadsto \frac{\color{blue}{\sin b \cdot r}}{\cos \left(a + b\right)} \]
            9. lower-*.f64N/A

              \[\leadsto \frac{\color{blue}{\sin b \cdot r}}{\cos \left(a + b\right)} \]
            10. lift-sin.f64N/A

              \[\leadsto \frac{\color{blue}{\sin b} \cdot r}{\cos \left(a + b\right)} \]
            11. lift-cos.f64N/A

              \[\leadsto \frac{\sin b \cdot r}{\color{blue}{\cos \left(a + b\right)}} \]
            12. lift-+.f6476.4

              \[\leadsto \frac{\sin b \cdot r}{\cos \color{blue}{\left(a + b\right)}} \]
          3. Applied rewrites76.4%

            \[\leadsto \color{blue}{\frac{\sin b \cdot r}{\cos \left(a + b\right)}} \]
          4. Add Preprocessing

          Alternative 12: 75.0% accurate, 1.0× speedup?

          \[\begin{array}{l} \\ r \cdot \frac{\sin b}{\cos \left(a + b\right)} \end{array} \]
          (FPCore (r a b) :precision binary64 (* r (/ (sin b) (cos (+ a b)))))
          double code(double r, double a, double b) {
          	return r * (sin(b) / cos((a + b)));
          }
          
          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(8) function code(r, a, b)
          use fmin_fmax_functions
              real(8), intent (in) :: r
              real(8), intent (in) :: a
              real(8), intent (in) :: b
              code = r * (sin(b) / cos((a + b)))
          end function
          
          public static double code(double r, double a, double b) {
          	return r * (Math.sin(b) / Math.cos((a + b)));
          }
          
          def code(r, a, b):
          	return r * (math.sin(b) / math.cos((a + b)))
          
          function code(r, a, b)
          	return Float64(r * Float64(sin(b) / cos(Float64(a + b))))
          end
          
          function tmp = code(r, a, b)
          	tmp = r * (sin(b) / cos((a + b)));
          end
          
          code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
          
          \begin{array}{l}
          
          \\
          r \cdot \frac{\sin b}{\cos \left(a + b\right)}
          \end{array}
          
          Derivation
          1. Initial program 76.4%

            \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
          2. Add Preprocessing

          Alternative 13: 60.3% accurate, 2.3× speedup?

          \[\begin{array}{l} \\ r \cdot \tan b \end{array} \]
          (FPCore (r a b) :precision binary64 (* r (tan b)))
          double code(double r, double a, double b) {
          	return r * tan(b);
          }
          
          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(8) function code(r, a, b)
          use fmin_fmax_functions
              real(8), intent (in) :: r
              real(8), intent (in) :: a
              real(8), intent (in) :: b
              code = r * tan(b)
          end function
          
          public static double code(double r, double a, double b) {
          	return r * Math.tan(b);
          }
          
          def code(r, a, b):
          	return r * math.tan(b)
          
          function code(r, a, b)
          	return Float64(r * tan(b))
          end
          
          function tmp = code(r, a, b)
          	tmp = r * tan(b);
          end
          
          code[r_, a_, b_] := N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]
          
          \begin{array}{l}
          
          \\
          r \cdot \tan b
          \end{array}
          
          Derivation
          1. Initial program 76.4%

            \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
          2. Taylor expanded in a around 0

            \[\leadsto r \cdot \color{blue}{\frac{\sin b}{\cos b}} \]
          3. Step-by-step derivation
            1. quot-tanN/A

              \[\leadsto r \cdot \tan b \]
            2. lower-tan.f6460.3

              \[\leadsto r \cdot \tan b \]
          4. Applied rewrites60.3%

            \[\leadsto r \cdot \color{blue}{\tan b} \]
          5. Add Preprocessing

          Alternative 14: 34.1% accurate, 3.0× speedup?

          \[\begin{array}{l} \\ r \cdot b \end{array} \]
          (FPCore (r a b) :precision binary64 (* r b))
          double code(double r, double a, double b) {
          	return r * b;
          }
          
          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(8) function code(r, a, b)
          use fmin_fmax_functions
              real(8), intent (in) :: r
              real(8), intent (in) :: a
              real(8), intent (in) :: b
              code = r * b
          end function
          
          public static double code(double r, double a, double b) {
          	return r * b;
          }
          
          def code(r, a, b):
          	return r * b
          
          function code(r, a, b)
          	return Float64(r * b)
          end
          
          function tmp = code(r, a, b)
          	tmp = r * b;
          end
          
          code[r_, a_, b_] := N[(r * b), $MachinePrecision]
          
          \begin{array}{l}
          
          \\
          r \cdot b
          \end{array}
          
          Derivation
          1. Initial program 76.4%

            \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
          2. Taylor expanded in a around 0

            \[\leadsto r \cdot \color{blue}{\frac{\sin b}{\cos b}} \]
          3. Step-by-step derivation
            1. quot-tanN/A

              \[\leadsto r \cdot \tan b \]
            2. lower-tan.f6460.3

              \[\leadsto r \cdot \tan b \]
          4. Applied rewrites60.3%

            \[\leadsto r \cdot \color{blue}{\tan b} \]
          5. Taylor expanded in b around 0

            \[\leadsto r \cdot b \]
          6. Step-by-step derivation
            1. Applied rewrites34.1%

              \[\leadsto r \cdot b \]
            2. Add Preprocessing

            Reproduce

            ?
            herbie shell --seed 2025101 
            (FPCore (r a b)
              :name "rsin B (should all be same)"
              :precision binary64
              (* r (/ (sin b) (cos (+ a b)))))