rsin B (should all be same)

Percentage Accurate: 77.1% → 99.5%
Time: 5.2s
Alternatives: 18
Speedup: 1.0×

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}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 18 alternatives:

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

Initial Program: 77.1% 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.4× 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 78.4%

    \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
  2. Add Preprocessing
  3. 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}} \]
  4. Applied rewrites99.5%

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

Alternative 2: 76.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -0.095:\\ \;\;\;\;\frac{\sin b \cdot r}{\cos b}\\ \mathbf{elif}\;b \leq 2.35 \cdot 10^{-7}:\\ \;\;\;\;\frac{r \cdot \left(\mathsf{fma}\left(\left(\mathsf{fma}\left(b \cdot b, -0.0001984126984126984, 0.008333333333333333\right) \cdot b\right) \cdot b - 0.16666666666666666, b \cdot b, 1\right) \cdot b\right)}{\cos \left(a + b\right)}\\ \mathbf{else}:\\ \;\;\;\;r \cdot \tan b\\ \end{array} \end{array} \]
(FPCore (r a b)
 :precision binary64
 (if (<= b -0.095)
   (/ (* (sin b) r) (cos b))
   (if (<= b 2.35e-7)
     (/
      (*
       r
       (*
        (fma
         (-
          (* (* (fma (* b b) -0.0001984126984126984 0.008333333333333333) b) b)
          0.16666666666666666)
         (* b b)
         1.0)
        b))
      (cos (+ a b)))
     (* r (tan b)))))
double code(double r, double a, double b) {
	double tmp;
	if (b <= -0.095) {
		tmp = (sin(b) * r) / cos(b);
	} else if (b <= 2.35e-7) {
		tmp = (r * (fma((((fma((b * b), -0.0001984126984126984, 0.008333333333333333) * b) * b) - 0.16666666666666666), (b * b), 1.0) * b)) / cos((a + b));
	} else {
		tmp = r * tan(b);
	}
	return tmp;
}
function code(r, a, b)
	tmp = 0.0
	if (b <= -0.095)
		tmp = Float64(Float64(sin(b) * r) / cos(b));
	elseif (b <= 2.35e-7)
		tmp = Float64(Float64(r * Float64(fma(Float64(Float64(Float64(fma(Float64(b * b), -0.0001984126984126984, 0.008333333333333333) * b) * b) - 0.16666666666666666), Float64(b * b), 1.0) * b)) / cos(Float64(a + b)));
	else
		tmp = Float64(r * tan(b));
	end
	return tmp
end
code[r_, a_, b_] := If[LessEqual[b, -0.095], N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.35e-7], N[(N[(r * N[(N[(N[(N[(N[(N[(N[(b * b), $MachinePrecision] * -0.0001984126984126984 + 0.008333333333333333), $MachinePrecision] * b), $MachinePrecision] * b), $MachinePrecision] - 0.16666666666666666), $MachinePrecision] * N[(b * b), $MachinePrecision] + 1.0), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.095:\\
\;\;\;\;\frac{\sin b \cdot r}{\cos b}\\

\mathbf{elif}\;b \leq 2.35 \cdot 10^{-7}:\\
\;\;\;\;\frac{r \cdot \left(\mathsf{fma}\left(\left(\mathsf{fma}\left(b \cdot b, -0.0001984126984126984, 0.008333333333333333\right) \cdot b\right) \cdot b - 0.16666666666666666, b \cdot b, 1\right) \cdot b\right)}{\cos \left(a + b\right)}\\

\mathbf{else}:\\
\;\;\;\;r \cdot \tan b\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < -0.095000000000000001

    1. Initial program 49.7%

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

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

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

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

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

        \[\leadsto r \cdot \frac{\sin b}{\cos \left(\left(\frac{b}{a} + 1\right) \cdot a\right)} \]
      5. lower-/.f6429.4

        \[\leadsto r \cdot \frac{\sin b}{\cos \left(\left(\frac{b}{a} + 1\right) \cdot a\right)} \]
    5. Applied rewrites29.4%

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{\color{blue}{\sin b \cdot r}}{\cos a} \]
        8. lift-sin.f6412.7

          \[\leadsto \frac{\color{blue}{\sin b} \cdot r}{\cos a} \]
      3. Applied rewrites12.7%

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

        \[\leadsto \frac{\sin b \cdot r}{\cos b} \]
      5. Step-by-step derivation
        1. Applied rewrites50.6%

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

        if -0.095000000000000001 < b < 2.35e-7

        1. Initial program 98.9%

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

          \[\leadsto r \cdot \frac{\color{blue}{b \cdot \left(1 + {b}^{2} \cdot \left({b}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}\right) - \frac{1}{6}\right)\right)}}{\cos \left(a + b\right)} \]
        4. Step-by-step derivation
          1. *-commutativeN/A

            \[\leadsto r \cdot \frac{\left(1 + {b}^{2} \cdot \left({b}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}\right) - \frac{1}{6}\right)\right) \cdot \color{blue}{b}}{\cos \left(a + b\right)} \]
          2. lower-*.f64N/A

            \[\leadsto r \cdot \frac{\left(1 + {b}^{2} \cdot \left({b}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}\right) - \frac{1}{6}\right)\right) \cdot \color{blue}{b}}{\cos \left(a + b\right)} \]
        5. Applied rewrites98.9%

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

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

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

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

            \[\leadsto r \cdot \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{5040}, b \cdot b, \frac{1}{120}\right) \cdot \left(b \cdot b\right) - \frac{1}{6}, b \cdot b, 1\right) \cdot b}{\color{blue}{\cos \left(a + b\right)}} \]
          5. associate-*r/N/A

            \[\leadsto \color{blue}{\frac{r \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{5040}, b \cdot b, \frac{1}{120}\right) \cdot \left(b \cdot b\right) - \frac{1}{6}, b \cdot b, 1\right) \cdot b\right)}{\cos \left(a + b\right)}} \]
          6. lower-/.f64N/A

            \[\leadsto \color{blue}{\frac{r \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{5040}, b \cdot b, \frac{1}{120}\right) \cdot \left(b \cdot b\right) - \frac{1}{6}, b \cdot b, 1\right) \cdot b\right)}{\cos \left(a + b\right)}} \]
        7. Applied rewrites98.9%

          \[\leadsto \color{blue}{\frac{r \cdot \left(\mathsf{fma}\left(\left(\mathsf{fma}\left(b \cdot b, -0.0001984126984126984, 0.008333333333333333\right) \cdot b\right) \cdot b - 0.16666666666666666, b \cdot b, 1\right) \cdot b\right)}{\cos \left(a + b\right)}} \]

        if 2.35e-7 < b

        1. Initial program 60.2%

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

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

            \[\leadsto r \cdot \tan b \]
          2. lower-tan.f6461.1

            \[\leadsto r \cdot \tan b \]
        5. Applied rewrites61.1%

          \[\leadsto r \cdot \color{blue}{\tan b} \]
      6. Recombined 3 regimes into one program.
      7. Final simplification78.9%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -0.095:\\ \;\;\;\;\frac{\sin b \cdot r}{\cos b}\\ \mathbf{elif}\;b \leq 2.35 \cdot 10^{-7}:\\ \;\;\;\;\frac{r \cdot \left(\mathsf{fma}\left(\left(\mathsf{fma}\left(b \cdot b, -0.0001984126984126984, 0.008333333333333333\right) \cdot b\right) \cdot b - 0.16666666666666666, b \cdot b, 1\right) \cdot b\right)}{\cos \left(a + b\right)}\\ \mathbf{else}:\\ \;\;\;\;r \cdot \tan b\\ \end{array} \]
      8. Add Preprocessing

      Alternative 3: 76.9% accurate, 1.0× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -0.095:\\ \;\;\;\;r \cdot \frac{\sin b}{\cos b}\\ \mathbf{elif}\;b \leq 2.35 \cdot 10^{-7}:\\ \;\;\;\;\frac{r \cdot \left(\mathsf{fma}\left(\left(\mathsf{fma}\left(b \cdot b, -0.0001984126984126984, 0.008333333333333333\right) \cdot b\right) \cdot b - 0.16666666666666666, b \cdot b, 1\right) \cdot b\right)}{\cos \left(a + b\right)}\\ \mathbf{else}:\\ \;\;\;\;r \cdot \tan b\\ \end{array} \end{array} \]
      (FPCore (r a b)
       :precision binary64
       (if (<= b -0.095)
         (* r (/ (sin b) (cos b)))
         (if (<= b 2.35e-7)
           (/
            (*
             r
             (*
              (fma
               (-
                (* (* (fma (* b b) -0.0001984126984126984 0.008333333333333333) b) b)
                0.16666666666666666)
               (* b b)
               1.0)
              b))
            (cos (+ a b)))
           (* r (tan b)))))
      double code(double r, double a, double b) {
      	double tmp;
      	if (b <= -0.095) {
      		tmp = r * (sin(b) / cos(b));
      	} else if (b <= 2.35e-7) {
      		tmp = (r * (fma((((fma((b * b), -0.0001984126984126984, 0.008333333333333333) * b) * b) - 0.16666666666666666), (b * b), 1.0) * b)) / cos((a + b));
      	} else {
      		tmp = r * tan(b);
      	}
      	return tmp;
      }
      
      function code(r, a, b)
      	tmp = 0.0
      	if (b <= -0.095)
      		tmp = Float64(r * Float64(sin(b) / cos(b)));
      	elseif (b <= 2.35e-7)
      		tmp = Float64(Float64(r * Float64(fma(Float64(Float64(Float64(fma(Float64(b * b), -0.0001984126984126984, 0.008333333333333333) * b) * b) - 0.16666666666666666), Float64(b * b), 1.0) * b)) / cos(Float64(a + b)));
      	else
      		tmp = Float64(r * tan(b));
      	end
      	return tmp
      end
      
      code[r_, a_, b_] := If[LessEqual[b, -0.095], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.35e-7], N[(N[(r * N[(N[(N[(N[(N[(N[(N[(b * b), $MachinePrecision] * -0.0001984126984126984 + 0.008333333333333333), $MachinePrecision] * b), $MachinePrecision] * b), $MachinePrecision] - 0.16666666666666666), $MachinePrecision] * N[(b * b), $MachinePrecision] + 1.0), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;b \leq -0.095:\\
      \;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
      
      \mathbf{elif}\;b \leq 2.35 \cdot 10^{-7}:\\
      \;\;\;\;\frac{r \cdot \left(\mathsf{fma}\left(\left(\mathsf{fma}\left(b \cdot b, -0.0001984126984126984, 0.008333333333333333\right) \cdot b\right) \cdot b - 0.16666666666666666, b \cdot b, 1\right) \cdot b\right)}{\cos \left(a + b\right)}\\
      
      \mathbf{else}:\\
      \;\;\;\;r \cdot \tan b\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if b < -0.095000000000000001

        1. Initial program 49.7%

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

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

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

          if -0.095000000000000001 < b < 2.35e-7

          1. Initial program 98.9%

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

            \[\leadsto r \cdot \frac{\color{blue}{b \cdot \left(1 + {b}^{2} \cdot \left({b}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}\right) - \frac{1}{6}\right)\right)}}{\cos \left(a + b\right)} \]
          4. Step-by-step derivation
            1. *-commutativeN/A

              \[\leadsto r \cdot \frac{\left(1 + {b}^{2} \cdot \left({b}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}\right) - \frac{1}{6}\right)\right) \cdot \color{blue}{b}}{\cos \left(a + b\right)} \]
            2. lower-*.f64N/A

              \[\leadsto r \cdot \frac{\left(1 + {b}^{2} \cdot \left({b}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}\right) - \frac{1}{6}\right)\right) \cdot \color{blue}{b}}{\cos \left(a + b\right)} \]
          5. Applied rewrites98.9%

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

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

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

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

              \[\leadsto r \cdot \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{5040}, b \cdot b, \frac{1}{120}\right) \cdot \left(b \cdot b\right) - \frac{1}{6}, b \cdot b, 1\right) \cdot b}{\color{blue}{\cos \left(a + b\right)}} \]
            5. associate-*r/N/A

              \[\leadsto \color{blue}{\frac{r \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{5040}, b \cdot b, \frac{1}{120}\right) \cdot \left(b \cdot b\right) - \frac{1}{6}, b \cdot b, 1\right) \cdot b\right)}{\cos \left(a + b\right)}} \]
            6. lower-/.f64N/A

              \[\leadsto \color{blue}{\frac{r \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{5040}, b \cdot b, \frac{1}{120}\right) \cdot \left(b \cdot b\right) - \frac{1}{6}, b \cdot b, 1\right) \cdot b\right)}{\cos \left(a + b\right)}} \]
          7. Applied rewrites98.9%

            \[\leadsto \color{blue}{\frac{r \cdot \left(\mathsf{fma}\left(\left(\mathsf{fma}\left(b \cdot b, -0.0001984126984126984, 0.008333333333333333\right) \cdot b\right) \cdot b - 0.16666666666666666, b \cdot b, 1\right) \cdot b\right)}{\cos \left(a + b\right)}} \]

          if 2.35e-7 < b

          1. Initial program 60.2%

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

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

              \[\leadsto r \cdot \tan b \]
            2. lower-tan.f6461.1

              \[\leadsto r \cdot \tan b \]
          5. Applied rewrites61.1%

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

        Alternative 4: 77.1% 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 78.4%

          \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
        2. Add Preprocessing
        3. 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-+.f6478.5

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

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

        Alternative 5: 77.1% accurate, 1.0× speedup?

        \[\begin{array}{l} \\ \sin b \cdot \frac{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(sin(b) * Float64(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[Sin[b], $MachinePrecision] * N[(r / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
        
        \begin{array}{l}
        
        \\
        \sin b \cdot \frac{r}{\cos \left(a + b\right)}
        \end{array}
        
        Derivation
        1. Initial program 78.4%

          \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
        2. Add Preprocessing
        3. 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}} \]
        4. Applied rewrites99.5%

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

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

            \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \color{blue}{{\cos a}^{1}} - \sin b \cdot \sin a} \]
          3. metadata-evalN/A

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

            \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \color{blue}{\frac{1}{{\cos a}^{-1}}} - \sin b \cdot \sin a} \]
          5. inv-powN/A

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

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

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

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

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

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

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

            \[\leadsto r \cdot \frac{\sin b}{\cos b \cdot \frac{1}{\color{blue}{{\cos a}^{-1}}} - \sin b \cdot \sin a} \]
          3. inv-powN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{\frac{r \cdot \sin b}{\cos b \cdot \frac{1}{\frac{1}{\cos a}} - \sin b \cdot \sin a}} \]
        10. Applied rewrites78.4%

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

        Alternative 6: 77.1% 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 78.4%

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

        Alternative 7: 76.9% accurate, 1.3× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -0.095 \lor \neg \left(b \leq 2.35 \cdot 10^{-7}\right):\\ \;\;\;\;r \cdot \tan b\\ \mathbf{else}:\\ \;\;\;\;\frac{r \cdot \left(\mathsf{fma}\left(\left(\mathsf{fma}\left(b \cdot b, -0.0001984126984126984, 0.008333333333333333\right) \cdot b\right) \cdot b - 0.16666666666666666, b \cdot b, 1\right) \cdot b\right)}{\cos \left(a + b\right)}\\ \end{array} \end{array} \]
        (FPCore (r a b)
         :precision binary64
         (if (or (<= b -0.095) (not (<= b 2.35e-7)))
           (* r (tan b))
           (/
            (*
             r
             (*
              (fma
               (-
                (* (* (fma (* b b) -0.0001984126984126984 0.008333333333333333) b) b)
                0.16666666666666666)
               (* b b)
               1.0)
              b))
            (cos (+ a b)))))
        double code(double r, double a, double b) {
        	double tmp;
        	if ((b <= -0.095) || !(b <= 2.35e-7)) {
        		tmp = r * tan(b);
        	} else {
        		tmp = (r * (fma((((fma((b * b), -0.0001984126984126984, 0.008333333333333333) * b) * b) - 0.16666666666666666), (b * b), 1.0) * b)) / cos((a + b));
        	}
        	return tmp;
        }
        
        function code(r, a, b)
        	tmp = 0.0
        	if ((b <= -0.095) || !(b <= 2.35e-7))
        		tmp = Float64(r * tan(b));
        	else
        		tmp = Float64(Float64(r * Float64(fma(Float64(Float64(Float64(fma(Float64(b * b), -0.0001984126984126984, 0.008333333333333333) * b) * b) - 0.16666666666666666), Float64(b * b), 1.0) * b)) / cos(Float64(a + b)));
        	end
        	return tmp
        end
        
        code[r_, a_, b_] := If[Or[LessEqual[b, -0.095], N[Not[LessEqual[b, 2.35e-7]], $MachinePrecision]], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], N[(N[(r * N[(N[(N[(N[(N[(N[(N[(b * b), $MachinePrecision] * -0.0001984126984126984 + 0.008333333333333333), $MachinePrecision] * b), $MachinePrecision] * b), $MachinePrecision] - 0.16666666666666666), $MachinePrecision] * N[(b * b), $MachinePrecision] + 1.0), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;b \leq -0.095 \lor \neg \left(b \leq 2.35 \cdot 10^{-7}\right):\\
        \;\;\;\;r \cdot \tan b\\
        
        \mathbf{else}:\\
        \;\;\;\;\frac{r \cdot \left(\mathsf{fma}\left(\left(\mathsf{fma}\left(b \cdot b, -0.0001984126984126984, 0.008333333333333333\right) \cdot b\right) \cdot b - 0.16666666666666666, b \cdot b, 1\right) \cdot b\right)}{\cos \left(a + b\right)}\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if b < -0.095000000000000001 or 2.35e-7 < b

          1. Initial program 55.2%

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

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

              \[\leadsto r \cdot \tan b \]
            2. lower-tan.f6456.1

              \[\leadsto r \cdot \tan b \]
          5. Applied rewrites56.1%

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

          if -0.095000000000000001 < b < 2.35e-7

          1. Initial program 98.9%

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

            \[\leadsto r \cdot \frac{\color{blue}{b \cdot \left(1 + {b}^{2} \cdot \left({b}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}\right) - \frac{1}{6}\right)\right)}}{\cos \left(a + b\right)} \]
          4. Step-by-step derivation
            1. *-commutativeN/A

              \[\leadsto r \cdot \frac{\left(1 + {b}^{2} \cdot \left({b}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}\right) - \frac{1}{6}\right)\right) \cdot \color{blue}{b}}{\cos \left(a + b\right)} \]
            2. lower-*.f64N/A

              \[\leadsto r \cdot \frac{\left(1 + {b}^{2} \cdot \left({b}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}\right) - \frac{1}{6}\right)\right) \cdot \color{blue}{b}}{\cos \left(a + b\right)} \]
          5. Applied rewrites98.9%

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

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

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

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

              \[\leadsto r \cdot \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{5040}, b \cdot b, \frac{1}{120}\right) \cdot \left(b \cdot b\right) - \frac{1}{6}, b \cdot b, 1\right) \cdot b}{\color{blue}{\cos \left(a + b\right)}} \]
            5. associate-*r/N/A

              \[\leadsto \color{blue}{\frac{r \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{5040}, b \cdot b, \frac{1}{120}\right) \cdot \left(b \cdot b\right) - \frac{1}{6}, b \cdot b, 1\right) \cdot b\right)}{\cos \left(a + b\right)}} \]
            6. lower-/.f64N/A

              \[\leadsto \color{blue}{\frac{r \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{5040}, b \cdot b, \frac{1}{120}\right) \cdot \left(b \cdot b\right) - \frac{1}{6}, b \cdot b, 1\right) \cdot b\right)}{\cos \left(a + b\right)}} \]
          7. Applied rewrites98.9%

            \[\leadsto \color{blue}{\frac{r \cdot \left(\mathsf{fma}\left(\left(\mathsf{fma}\left(b \cdot b, -0.0001984126984126984, 0.008333333333333333\right) \cdot b\right) \cdot b - 0.16666666666666666, b \cdot b, 1\right) \cdot b\right)}{\cos \left(a + b\right)}} \]
        3. Recombined 2 regimes into one program.
        4. Final simplification78.8%

          \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -0.095 \lor \neg \left(b \leq 2.35 \cdot 10^{-7}\right):\\ \;\;\;\;r \cdot \tan b\\ \mathbf{else}:\\ \;\;\;\;\frac{r \cdot \left(\mathsf{fma}\left(\left(\mathsf{fma}\left(b \cdot b, -0.0001984126984126984, 0.008333333333333333\right) \cdot b\right) \cdot b - 0.16666666666666666, b \cdot b, 1\right) \cdot b\right)}{\cos \left(a + b\right)}\\ \end{array} \]
        5. Add Preprocessing

        Alternative 8: 76.9% accurate, 1.3× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -0.095 \lor \neg \left(b \leq 2.35 \cdot 10^{-7}\right):\\ \;\;\;\;r \cdot \tan b\\ \mathbf{else}:\\ \;\;\;\;r \cdot \frac{\mathsf{fma}\left(\mathsf{fma}\left(-0.0001984126984126984, b \cdot b, 0.008333333333333333\right) \cdot \left(b \cdot b\right) - 0.16666666666666666, b \cdot b, 1\right) \cdot b}{\cos \left(a + b\right)}\\ \end{array} \end{array} \]
        (FPCore (r a b)
         :precision binary64
         (if (or (<= b -0.095) (not (<= b 2.35e-7)))
           (* r (tan b))
           (*
            r
            (/
             (*
              (fma
               (-
                (* (fma -0.0001984126984126984 (* b b) 0.008333333333333333) (* b b))
                0.16666666666666666)
               (* b b)
               1.0)
              b)
             (cos (+ a b))))))
        double code(double r, double a, double b) {
        	double tmp;
        	if ((b <= -0.095) || !(b <= 2.35e-7)) {
        		tmp = r * tan(b);
        	} else {
        		tmp = r * ((fma(((fma(-0.0001984126984126984, (b * b), 0.008333333333333333) * (b * b)) - 0.16666666666666666), (b * b), 1.0) * b) / cos((a + b)));
        	}
        	return tmp;
        }
        
        function code(r, a, b)
        	tmp = 0.0
        	if ((b <= -0.095) || !(b <= 2.35e-7))
        		tmp = Float64(r * tan(b));
        	else
        		tmp = Float64(r * Float64(Float64(fma(Float64(Float64(fma(-0.0001984126984126984, Float64(b * b), 0.008333333333333333) * Float64(b * b)) - 0.16666666666666666), Float64(b * b), 1.0) * b) / cos(Float64(a + b))));
        	end
        	return tmp
        end
        
        code[r_, a_, b_] := If[Or[LessEqual[b, -0.095], N[Not[LessEqual[b, 2.35e-7]], $MachinePrecision]], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], N[(r * N[(N[(N[(N[(N[(N[(-0.0001984126984126984 * N[(b * b), $MachinePrecision] + 0.008333333333333333), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision] - 0.16666666666666666), $MachinePrecision] * N[(b * b), $MachinePrecision] + 1.0), $MachinePrecision] * b), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;b \leq -0.095 \lor \neg \left(b \leq 2.35 \cdot 10^{-7}\right):\\
        \;\;\;\;r \cdot \tan b\\
        
        \mathbf{else}:\\
        \;\;\;\;r \cdot \frac{\mathsf{fma}\left(\mathsf{fma}\left(-0.0001984126984126984, b \cdot b, 0.008333333333333333\right) \cdot \left(b \cdot b\right) - 0.16666666666666666, b \cdot b, 1\right) \cdot b}{\cos \left(a + b\right)}\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if b < -0.095000000000000001 or 2.35e-7 < b

          1. Initial program 55.2%

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

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

              \[\leadsto r \cdot \tan b \]
            2. lower-tan.f6456.1

              \[\leadsto r \cdot \tan b \]
          5. Applied rewrites56.1%

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

          if -0.095000000000000001 < b < 2.35e-7

          1. Initial program 98.9%

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

            \[\leadsto r \cdot \frac{\color{blue}{b \cdot \left(1 + {b}^{2} \cdot \left({b}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}\right) - \frac{1}{6}\right)\right)}}{\cos \left(a + b\right)} \]
          4. Step-by-step derivation
            1. *-commutativeN/A

              \[\leadsto r \cdot \frac{\left(1 + {b}^{2} \cdot \left({b}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}\right) - \frac{1}{6}\right)\right) \cdot \color{blue}{b}}{\cos \left(a + b\right)} \]
            2. lower-*.f64N/A

              \[\leadsto r \cdot \frac{\left(1 + {b}^{2} \cdot \left({b}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}\right) - \frac{1}{6}\right)\right) \cdot \color{blue}{b}}{\cos \left(a + b\right)} \]
          5. Applied rewrites98.9%

            \[\leadsto r \cdot \frac{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(-0.0001984126984126984, b \cdot b, 0.008333333333333333\right) \cdot \left(b \cdot b\right) - 0.16666666666666666, b \cdot b, 1\right) \cdot b}}{\cos \left(a + b\right)} \]
        3. Recombined 2 regimes into one program.
        4. Final simplification78.8%

          \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -0.095 \lor \neg \left(b \leq 2.35 \cdot 10^{-7}\right):\\ \;\;\;\;r \cdot \tan b\\ \mathbf{else}:\\ \;\;\;\;r \cdot \frac{\mathsf{fma}\left(\mathsf{fma}\left(-0.0001984126984126984, b \cdot b, 0.008333333333333333\right) \cdot \left(b \cdot b\right) - 0.16666666666666666, b \cdot b, 1\right) \cdot b}{\cos \left(a + b\right)}\\ \end{array} \]
        5. Add Preprocessing

        Alternative 9: 76.9% accurate, 1.5× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -0.0082 \lor \neg \left(b \leq 2.35 \cdot 10^{-7}\right):\\ \;\;\;\;r \cdot \tan b\\ \mathbf{else}:\\ \;\;\;\;r \cdot \frac{\mathsf{fma}\left(b \cdot b, -0.16666666666666666, 1\right) \cdot b}{\cos \left(a + b\right)}\\ \end{array} \end{array} \]
        (FPCore (r a b)
         :precision binary64
         (if (or (<= b -0.0082) (not (<= b 2.35e-7)))
           (* r (tan b))
           (* r (/ (* (fma (* b b) -0.16666666666666666 1.0) b) (cos (+ a b))))))
        double code(double r, double a, double b) {
        	double tmp;
        	if ((b <= -0.0082) || !(b <= 2.35e-7)) {
        		tmp = r * tan(b);
        	} else {
        		tmp = r * ((fma((b * b), -0.16666666666666666, 1.0) * b) / cos((a + b)));
        	}
        	return tmp;
        }
        
        function code(r, a, b)
        	tmp = 0.0
        	if ((b <= -0.0082) || !(b <= 2.35e-7))
        		tmp = Float64(r * tan(b));
        	else
        		tmp = Float64(r * Float64(Float64(fma(Float64(b * b), -0.16666666666666666, 1.0) * b) / cos(Float64(a + b))));
        	end
        	return tmp
        end
        
        code[r_, a_, b_] := If[Or[LessEqual[b, -0.0082], N[Not[LessEqual[b, 2.35e-7]], $MachinePrecision]], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], N[(r * N[(N[(N[(N[(b * b), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * b), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;b \leq -0.0082 \lor \neg \left(b \leq 2.35 \cdot 10^{-7}\right):\\
        \;\;\;\;r \cdot \tan b\\
        
        \mathbf{else}:\\
        \;\;\;\;r \cdot \frac{\mathsf{fma}\left(b \cdot b, -0.16666666666666666, 1\right) \cdot b}{\cos \left(a + b\right)}\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if b < -0.00820000000000000069 or 2.35e-7 < b

          1. Initial program 55.6%

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

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

              \[\leadsto r \cdot \tan b \]
            2. lower-tan.f6456.4

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

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

          if -0.00820000000000000069 < b < 2.35e-7

          1. Initial program 98.9%

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

            \[\leadsto r \cdot \frac{\color{blue}{b \cdot \left(1 + \frac{-1}{6} \cdot {b}^{2}\right)}}{\cos \left(a + b\right)} \]
          4. Step-by-step derivation
            1. *-commutativeN/A

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

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

              \[\leadsto r \cdot \frac{\left(\frac{-1}{6} \cdot {b}^{2} + 1\right) \cdot b}{\cos \left(a + b\right)} \]
            4. *-commutativeN/A

              \[\leadsto r \cdot \frac{\left({b}^{2} \cdot \frac{-1}{6} + 1\right) \cdot b}{\cos \left(a + b\right)} \]
            5. lower-fma.f64N/A

              \[\leadsto r \cdot \frac{\mathsf{fma}\left({b}^{2}, \frac{-1}{6}, 1\right) \cdot b}{\cos \left(a + b\right)} \]
            6. unpow2N/A

              \[\leadsto r \cdot \frac{\mathsf{fma}\left(b \cdot b, \frac{-1}{6}, 1\right) \cdot b}{\cos \left(a + b\right)} \]
            7. lower-*.f6498.9

              \[\leadsto r \cdot \frac{\mathsf{fma}\left(b \cdot b, -0.16666666666666666, 1\right) \cdot b}{\cos \left(a + b\right)} \]
          5. Applied rewrites98.9%

            \[\leadsto r \cdot \frac{\color{blue}{\mathsf{fma}\left(b \cdot b, -0.16666666666666666, 1\right) \cdot b}}{\cos \left(a + b\right)} \]
        3. Recombined 2 regimes into one program.
        4. Final simplification78.8%

          \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -0.0082 \lor \neg \left(b \leq 2.35 \cdot 10^{-7}\right):\\ \;\;\;\;r \cdot \tan b\\ \mathbf{else}:\\ \;\;\;\;r \cdot \frac{\mathsf{fma}\left(b \cdot b, -0.16666666666666666, 1\right) \cdot b}{\cos \left(a + b\right)}\\ \end{array} \]
        5. Add Preprocessing

        Alternative 10: 76.8% accurate, 1.5× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -1.6 \cdot 10^{-5} \lor \neg \left(b \leq 2.35 \cdot 10^{-7}\right):\\ \;\;\;\;r \cdot \tan b\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\mathsf{fma}\left(b \cdot b, -0.16666666666666666, 1\right) \cdot b\right) \cdot r}{\cos a}\\ \end{array} \end{array} \]
        (FPCore (r a b)
         :precision binary64
         (if (or (<= b -1.6e-5) (not (<= b 2.35e-7)))
           (* r (tan b))
           (/ (* (* (fma (* b b) -0.16666666666666666 1.0) b) r) (cos a))))
        double code(double r, double a, double b) {
        	double tmp;
        	if ((b <= -1.6e-5) || !(b <= 2.35e-7)) {
        		tmp = r * tan(b);
        	} else {
        		tmp = ((fma((b * b), -0.16666666666666666, 1.0) * b) * r) / cos(a);
        	}
        	return tmp;
        }
        
        function code(r, a, b)
        	tmp = 0.0
        	if ((b <= -1.6e-5) || !(b <= 2.35e-7))
        		tmp = Float64(r * tan(b));
        	else
        		tmp = Float64(Float64(Float64(fma(Float64(b * b), -0.16666666666666666, 1.0) * b) * r) / cos(a));
        	end
        	return tmp
        end
        
        code[r_, a_, b_] := If[Or[LessEqual[b, -1.6e-5], N[Not[LessEqual[b, 2.35e-7]], $MachinePrecision]], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(b * b), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * b), $MachinePrecision] * r), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;b \leq -1.6 \cdot 10^{-5} \lor \neg \left(b \leq 2.35 \cdot 10^{-7}\right):\\
        \;\;\;\;r \cdot \tan b\\
        
        \mathbf{else}:\\
        \;\;\;\;\frac{\left(\mathsf{fma}\left(b \cdot b, -0.16666666666666666, 1\right) \cdot b\right) \cdot r}{\cos a}\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if b < -1.59999999999999993e-5 or 2.35e-7 < b

          1. Initial program 55.7%

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

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

              \[\leadsto r \cdot \tan b \]
            2. lower-tan.f6456.4

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

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

          if -1.59999999999999993e-5 < b < 2.35e-7

          1. Initial program 99.4%

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

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

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

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

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

              \[\leadsto r \cdot \frac{\sin b}{\cos \left(\left(\frac{b}{a} + 1\right) \cdot a\right)} \]
            5. lower-/.f6499.4

              \[\leadsto r \cdot \frac{\sin b}{\cos \left(\left(\frac{b}{a} + 1\right) \cdot a\right)} \]
          5. Applied rewrites99.4%

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

            \[\leadsto r \cdot \frac{\sin b}{\cos a} \]
          7. Step-by-step derivation
            1. Applied rewrites99.4%

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \frac{\color{blue}{\left(b \cdot \left(1 + \frac{-1}{6} \cdot {b}^{2}\right)\right)} \cdot r}{\cos a} \]
            5. Step-by-step derivation
              1. *-commutativeN/A

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

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

                \[\leadsto \frac{\left(\left(\frac{-1}{6} \cdot {b}^{2} + 1\right) \cdot b\right) \cdot r}{\cos a} \]
              4. *-commutativeN/A

                \[\leadsto \frac{\left(\left({b}^{2} \cdot \frac{-1}{6} + 1\right) \cdot b\right) \cdot r}{\cos a} \]
              5. lower-fma.f64N/A

                \[\leadsto \frac{\left(\mathsf{fma}\left({b}^{2}, \frac{-1}{6}, 1\right) \cdot b\right) \cdot r}{\cos a} \]
              6. pow2N/A

                \[\leadsto \frac{\left(\mathsf{fma}\left(b \cdot b, \frac{-1}{6}, 1\right) \cdot b\right) \cdot r}{\cos a} \]
              7. lift-*.f6499.4

                \[\leadsto \frac{\left(\mathsf{fma}\left(b \cdot b, -0.16666666666666666, 1\right) \cdot b\right) \cdot r}{\cos a} \]
            6. Applied rewrites99.4%

              \[\leadsto \frac{\color{blue}{\left(\mathsf{fma}\left(b \cdot b, -0.16666666666666666, 1\right) \cdot b\right)} \cdot r}{\cos a} \]
          8. Recombined 2 regimes into one program.
          9. Final simplification78.7%

            \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -1.6 \cdot 10^{-5} \lor \neg \left(b \leq 2.35 \cdot 10^{-7}\right):\\ \;\;\;\;r \cdot \tan b\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\mathsf{fma}\left(b \cdot b, -0.16666666666666666, 1\right) \cdot b\right) \cdot r}{\cos a}\\ \end{array} \]
          10. Add Preprocessing

          Alternative 11: 76.8% accurate, 1.7× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -1.6 \cdot 10^{-5} \lor \neg \left(b \leq 2.35 \cdot 10^{-7}\right):\\ \;\;\;\;r \cdot \tan b\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot r}{\cos a}\\ \end{array} \end{array} \]
          (FPCore (r a b)
           :precision binary64
           (if (or (<= b -1.6e-5) (not (<= b 2.35e-7)))
             (* r (tan b))
             (/ (* b r) (cos a))))
          double code(double r, double a, double b) {
          	double tmp;
          	if ((b <= -1.6e-5) || !(b <= 2.35e-7)) {
          		tmp = r * tan(b);
          	} else {
          		tmp = (b * r) / cos(a);
          	}
          	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) :: tmp
              if ((b <= (-1.6d-5)) .or. (.not. (b <= 2.35d-7))) then
                  tmp = r * tan(b)
              else
                  tmp = (b * r) / cos(a)
              end if
              code = tmp
          end function
          
          public static double code(double r, double a, double b) {
          	double tmp;
          	if ((b <= -1.6e-5) || !(b <= 2.35e-7)) {
          		tmp = r * Math.tan(b);
          	} else {
          		tmp = (b * r) / Math.cos(a);
          	}
          	return tmp;
          }
          
          def code(r, a, b):
          	tmp = 0
          	if (b <= -1.6e-5) or not (b <= 2.35e-7):
          		tmp = r * math.tan(b)
          	else:
          		tmp = (b * r) / math.cos(a)
          	return tmp
          
          function code(r, a, b)
          	tmp = 0.0
          	if ((b <= -1.6e-5) || !(b <= 2.35e-7))
          		tmp = Float64(r * tan(b));
          	else
          		tmp = Float64(Float64(b * r) / cos(a));
          	end
          	return tmp
          end
          
          function tmp_2 = code(r, a, b)
          	tmp = 0.0;
          	if ((b <= -1.6e-5) || ~((b <= 2.35e-7)))
          		tmp = r * tan(b);
          	else
          		tmp = (b * r) / cos(a);
          	end
          	tmp_2 = tmp;
          end
          
          code[r_, a_, b_] := If[Or[LessEqual[b, -1.6e-5], N[Not[LessEqual[b, 2.35e-7]], $MachinePrecision]], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], N[(N[(b * r), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;b \leq -1.6 \cdot 10^{-5} \lor \neg \left(b \leq 2.35 \cdot 10^{-7}\right):\\
          \;\;\;\;r \cdot \tan b\\
          
          \mathbf{else}:\\
          \;\;\;\;\frac{b \cdot r}{\cos a}\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if b < -1.59999999999999993e-5 or 2.35e-7 < b

            1. Initial program 55.7%

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

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

                \[\leadsto r \cdot \tan b \]
              2. lower-tan.f6456.4

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

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

            if -1.59999999999999993e-5 < b < 2.35e-7

            1. Initial program 99.4%

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

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

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

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

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

                \[\leadsto r \cdot \frac{\sin b}{\cos \left(\left(\frac{b}{a} + 1\right) \cdot a\right)} \]
              5. lower-/.f6499.4

                \[\leadsto r \cdot \frac{\sin b}{\cos \left(\left(\frac{b}{a} + 1\right) \cdot a\right)} \]
            5. Applied rewrites99.4%

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

              \[\leadsto r \cdot \frac{\sin b}{\cos a} \]
            7. Step-by-step derivation
              1. Applied rewrites99.4%

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \frac{\color{blue}{b} \cdot r}{\cos a} \]
              6. Recombined 2 regimes into one program.
              7. Final simplification78.7%

                \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -1.6 \cdot 10^{-5} \lor \neg \left(b \leq 2.35 \cdot 10^{-7}\right):\\ \;\;\;\;r \cdot \tan b\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot r}{\cos a}\\ \end{array} \]
              8. Add Preprocessing

              Alternative 12: 76.8% accurate, 1.7× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -1.6 \cdot 10^{-5} \lor \neg \left(b \leq 2.35 \cdot 10^{-7}\right):\\ \;\;\;\;r \cdot \tan b\\ \mathbf{else}:\\ \;\;\;\;b \cdot \frac{r}{\cos a}\\ \end{array} \end{array} \]
              (FPCore (r a b)
               :precision binary64
               (if (or (<= b -1.6e-5) (not (<= b 2.35e-7)))
                 (* r (tan b))
                 (* b (/ r (cos a)))))
              double code(double r, double a, double b) {
              	double tmp;
              	if ((b <= -1.6e-5) || !(b <= 2.35e-7)) {
              		tmp = r * tan(b);
              	} else {
              		tmp = b * (r / cos(a));
              	}
              	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) :: tmp
                  if ((b <= (-1.6d-5)) .or. (.not. (b <= 2.35d-7))) then
                      tmp = r * tan(b)
                  else
                      tmp = b * (r / cos(a))
                  end if
                  code = tmp
              end function
              
              public static double code(double r, double a, double b) {
              	double tmp;
              	if ((b <= -1.6e-5) || !(b <= 2.35e-7)) {
              		tmp = r * Math.tan(b);
              	} else {
              		tmp = b * (r / Math.cos(a));
              	}
              	return tmp;
              }
              
              def code(r, a, b):
              	tmp = 0
              	if (b <= -1.6e-5) or not (b <= 2.35e-7):
              		tmp = r * math.tan(b)
              	else:
              		tmp = b * (r / math.cos(a))
              	return tmp
              
              function code(r, a, b)
              	tmp = 0.0
              	if ((b <= -1.6e-5) || !(b <= 2.35e-7))
              		tmp = Float64(r * tan(b));
              	else
              		tmp = Float64(b * Float64(r / cos(a)));
              	end
              	return tmp
              end
              
              function tmp_2 = code(r, a, b)
              	tmp = 0.0;
              	if ((b <= -1.6e-5) || ~((b <= 2.35e-7)))
              		tmp = r * tan(b);
              	else
              		tmp = b * (r / cos(a));
              	end
              	tmp_2 = tmp;
              end
              
              code[r_, a_, b_] := If[Or[LessEqual[b, -1.6e-5], N[Not[LessEqual[b, 2.35e-7]], $MachinePrecision]], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              \mathbf{if}\;b \leq -1.6 \cdot 10^{-5} \lor \neg \left(b \leq 2.35 \cdot 10^{-7}\right):\\
              \;\;\;\;r \cdot \tan b\\
              
              \mathbf{else}:\\
              \;\;\;\;b \cdot \frac{r}{\cos a}\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if b < -1.59999999999999993e-5 or 2.35e-7 < b

                1. Initial program 55.7%

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

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

                    \[\leadsto r \cdot \tan b \]
                  2. lower-tan.f6456.4

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

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

                if -1.59999999999999993e-5 < b < 2.35e-7

                1. Initial program 99.4%

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

                  \[\leadsto \color{blue}{\frac{b \cdot r}{\cos a}} \]
                4. 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.4

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

                  \[\leadsto \color{blue}{b \cdot \frac{r}{\cos a}} \]
              3. Recombined 2 regimes into one program.
              4. Final simplification78.7%

                \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -1.6 \cdot 10^{-5} \lor \neg \left(b \leq 2.35 \cdot 10^{-7}\right):\\ \;\;\;\;r \cdot \tan b\\ \mathbf{else}:\\ \;\;\;\;b \cdot \frac{r}{\cos a}\\ \end{array} \]
              5. Add Preprocessing

              Alternative 13: 60.6% accurate, 2.1× 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 78.4%

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

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

                  \[\leadsto r \cdot \tan b \]
                2. lower-tan.f6459.4

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

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

              Alternative 14: 34.3% accurate, 5.0× speedup?

              \[\begin{array}{l} \\ r \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.05396825396825397, b \cdot b, 0.13333333333333333\right), b \cdot b, 0.3333333333333333\right), b \cdot b, 1\right) \cdot b\right) \end{array} \]
              (FPCore (r a b)
               :precision binary64
               (*
                r
                (*
                 (fma
                  (fma
                   (fma 0.05396825396825397 (* b b) 0.13333333333333333)
                   (* b b)
                   0.3333333333333333)
                  (* b b)
                  1.0)
                 b)))
              double code(double r, double a, double b) {
              	return r * (fma(fma(fma(0.05396825396825397, (b * b), 0.13333333333333333), (b * b), 0.3333333333333333), (b * b), 1.0) * b);
              }
              
              function code(r, a, b)
              	return Float64(r * Float64(fma(fma(fma(0.05396825396825397, Float64(b * b), 0.13333333333333333), Float64(b * b), 0.3333333333333333), Float64(b * b), 1.0) * b))
              end
              
              code[r_, a_, b_] := N[(r * N[(N[(N[(N[(0.05396825396825397 * N[(b * b), $MachinePrecision] + 0.13333333333333333), $MachinePrecision] * N[(b * b), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(b * b), $MachinePrecision] + 1.0), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
              
              \begin{array}{l}
              
              \\
              r \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.05396825396825397, b \cdot b, 0.13333333333333333\right), b \cdot b, 0.3333333333333333\right), b \cdot b, 1\right) \cdot b\right)
              \end{array}
              
              Derivation
              1. Initial program 78.4%

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

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

                  \[\leadsto r \cdot \tan b \]
                2. lower-tan.f6459.4

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

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

                \[\leadsto r \cdot \left(b \cdot \color{blue}{\left(1 + {b}^{2} \cdot \left(\frac{1}{3} + {b}^{2} \cdot \left(\frac{2}{15} + \frac{17}{315} \cdot {b}^{2}\right)\right)\right)}\right) \]
              7. Step-by-step derivation
                1. *-commutativeN/A

                  \[\leadsto r \cdot \left(\left(1 + {b}^{2} \cdot \left(\frac{1}{3} + {b}^{2} \cdot \left(\frac{2}{15} + \frac{17}{315} \cdot {b}^{2}\right)\right)\right) \cdot b\right) \]
                2. lower-*.f64N/A

                  \[\leadsto r \cdot \left(\left(1 + {b}^{2} \cdot \left(\frac{1}{3} + {b}^{2} \cdot \left(\frac{2}{15} + \frac{17}{315} \cdot {b}^{2}\right)\right)\right) \cdot b\right) \]
                3. +-commutativeN/A

                  \[\leadsto r \cdot \left(\left({b}^{2} \cdot \left(\frac{1}{3} + {b}^{2} \cdot \left(\frac{2}{15} + \frac{17}{315} \cdot {b}^{2}\right)\right) + 1\right) \cdot b\right) \]
                4. *-commutativeN/A

                  \[\leadsto r \cdot \left(\left(\left(\frac{1}{3} + {b}^{2} \cdot \left(\frac{2}{15} + \frac{17}{315} \cdot {b}^{2}\right)\right) \cdot {b}^{2} + 1\right) \cdot b\right) \]
                5. lower-fma.f64N/A

                  \[\leadsto r \cdot \left(\mathsf{fma}\left(\frac{1}{3} + {b}^{2} \cdot \left(\frac{2}{15} + \frac{17}{315} \cdot {b}^{2}\right), {b}^{2}, 1\right) \cdot b\right) \]
                6. +-commutativeN/A

                  \[\leadsto r \cdot \left(\mathsf{fma}\left({b}^{2} \cdot \left(\frac{2}{15} + \frac{17}{315} \cdot {b}^{2}\right) + \frac{1}{3}, {b}^{2}, 1\right) \cdot b\right) \]
                7. *-commutativeN/A

                  \[\leadsto r \cdot \left(\mathsf{fma}\left(\left(\frac{2}{15} + \frac{17}{315} \cdot {b}^{2}\right) \cdot {b}^{2} + \frac{1}{3}, {b}^{2}, 1\right) \cdot b\right) \]
                8. lower-fma.f64N/A

                  \[\leadsto r \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{2}{15} + \frac{17}{315} \cdot {b}^{2}, {b}^{2}, \frac{1}{3}\right), {b}^{2}, 1\right) \cdot b\right) \]
                9. +-commutativeN/A

                  \[\leadsto r \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{17}{315} \cdot {b}^{2} + \frac{2}{15}, {b}^{2}, \frac{1}{3}\right), {b}^{2}, 1\right) \cdot b\right) \]
                10. lower-fma.f64N/A

                  \[\leadsto r \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{17}{315}, {b}^{2}, \frac{2}{15}\right), {b}^{2}, \frac{1}{3}\right), {b}^{2}, 1\right) \cdot b\right) \]
                11. pow2N/A

                  \[\leadsto r \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{17}{315}, b \cdot b, \frac{2}{15}\right), {b}^{2}, \frac{1}{3}\right), {b}^{2}, 1\right) \cdot b\right) \]
                12. lift-*.f64N/A

                  \[\leadsto r \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{17}{315}, b \cdot b, \frac{2}{15}\right), {b}^{2}, \frac{1}{3}\right), {b}^{2}, 1\right) \cdot b\right) \]
                13. pow2N/A

                  \[\leadsto r \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{17}{315}, b \cdot b, \frac{2}{15}\right), b \cdot b, \frac{1}{3}\right), {b}^{2}, 1\right) \cdot b\right) \]
                14. lift-*.f64N/A

                  \[\leadsto r \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{17}{315}, b \cdot b, \frac{2}{15}\right), b \cdot b, \frac{1}{3}\right), {b}^{2}, 1\right) \cdot b\right) \]
                15. pow2N/A

                  \[\leadsto r \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{17}{315}, b \cdot b, \frac{2}{15}\right), b \cdot b, \frac{1}{3}\right), b \cdot b, 1\right) \cdot b\right) \]
                16. lift-*.f6435.7

                  \[\leadsto r \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.05396825396825397, b \cdot b, 0.13333333333333333\right), b \cdot b, 0.3333333333333333\right), b \cdot b, 1\right) \cdot b\right) \]
              8. Applied rewrites35.7%

                \[\leadsto r \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.05396825396825397, b \cdot b, 0.13333333333333333\right), b \cdot b, 0.3333333333333333\right), b \cdot b, 1\right) \cdot \color{blue}{b}\right) \]
              9. Add Preprocessing

              Alternative 15: 34.3% accurate, 6.7× speedup?

              \[\begin{array}{l} \\ r \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(0.13333333333333333, b \cdot b, 0.3333333333333333\right), b \cdot b, 1\right) \cdot b\right) \end{array} \]
              (FPCore (r a b)
               :precision binary64
               (*
                r
                (*
                 (fma (fma 0.13333333333333333 (* b b) 0.3333333333333333) (* b b) 1.0)
                 b)))
              double code(double r, double a, double b) {
              	return r * (fma(fma(0.13333333333333333, (b * b), 0.3333333333333333), (b * b), 1.0) * b);
              }
              
              function code(r, a, b)
              	return Float64(r * Float64(fma(fma(0.13333333333333333, Float64(b * b), 0.3333333333333333), Float64(b * b), 1.0) * b))
              end
              
              code[r_, a_, b_] := N[(r * N[(N[(N[(0.13333333333333333 * N[(b * b), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(b * b), $MachinePrecision] + 1.0), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
              
              \begin{array}{l}
              
              \\
              r \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(0.13333333333333333, b \cdot b, 0.3333333333333333\right), b \cdot b, 1\right) \cdot b\right)
              \end{array}
              
              Derivation
              1. Initial program 78.4%

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

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

                  \[\leadsto r \cdot \tan b \]
                2. lower-tan.f6459.4

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

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

                \[\leadsto r \cdot \left(b \cdot \color{blue}{\left(1 + {b}^{2} \cdot \left(\frac{1}{3} + \frac{2}{15} \cdot {b}^{2}\right)\right)}\right) \]
              7. Step-by-step derivation
                1. *-commutativeN/A

                  \[\leadsto r \cdot \left(\left(1 + {b}^{2} \cdot \left(\frac{1}{3} + \frac{2}{15} \cdot {b}^{2}\right)\right) \cdot b\right) \]
                2. lower-*.f64N/A

                  \[\leadsto r \cdot \left(\left(1 + {b}^{2} \cdot \left(\frac{1}{3} + \frac{2}{15} \cdot {b}^{2}\right)\right) \cdot b\right) \]
                3. +-commutativeN/A

                  \[\leadsto r \cdot \left(\left({b}^{2} \cdot \left(\frac{1}{3} + \frac{2}{15} \cdot {b}^{2}\right) + 1\right) \cdot b\right) \]
                4. *-commutativeN/A

                  \[\leadsto r \cdot \left(\left(\left(\frac{1}{3} + \frac{2}{15} \cdot {b}^{2}\right) \cdot {b}^{2} + 1\right) \cdot b\right) \]
                5. lower-fma.f64N/A

                  \[\leadsto r \cdot \left(\mathsf{fma}\left(\frac{1}{3} + \frac{2}{15} \cdot {b}^{2}, {b}^{2}, 1\right) \cdot b\right) \]
                6. +-commutativeN/A

                  \[\leadsto r \cdot \left(\mathsf{fma}\left(\frac{2}{15} \cdot {b}^{2} + \frac{1}{3}, {b}^{2}, 1\right) \cdot b\right) \]
                7. lower-fma.f64N/A

                  \[\leadsto r \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{2}{15}, {b}^{2}, \frac{1}{3}\right), {b}^{2}, 1\right) \cdot b\right) \]
                8. pow2N/A

                  \[\leadsto r \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{2}{15}, b \cdot b, \frac{1}{3}\right), {b}^{2}, 1\right) \cdot b\right) \]
                9. lift-*.f64N/A

                  \[\leadsto r \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{2}{15}, b \cdot b, \frac{1}{3}\right), {b}^{2}, 1\right) \cdot b\right) \]
                10. pow2N/A

                  \[\leadsto r \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{2}{15}, b \cdot b, \frac{1}{3}\right), b \cdot b, 1\right) \cdot b\right) \]
                11. lift-*.f6435.6

                  \[\leadsto r \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(0.13333333333333333, b \cdot b, 0.3333333333333333\right), b \cdot b, 1\right) \cdot b\right) \]
              8. Applied rewrites35.6%

                \[\leadsto r \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(0.13333333333333333, b \cdot b, 0.3333333333333333\right), b \cdot b, 1\right) \cdot \color{blue}{b}\right) \]
              9. Add Preprocessing

              Alternative 16: 34.4% accurate, 8.1× speedup?

              \[\begin{array}{l} \\ r \cdot \mathsf{fma}\left(b, 1, b \cdot \left(\left(b \cdot b\right) \cdot 0.3333333333333333\right)\right) \end{array} \]
              (FPCore (r a b)
               :precision binary64
               (* r (fma b 1.0 (* b (* (* b b) 0.3333333333333333)))))
              double code(double r, double a, double b) {
              	return r * fma(b, 1.0, (b * ((b * b) * 0.3333333333333333)));
              }
              
              function code(r, a, b)
              	return Float64(r * fma(b, 1.0, Float64(b * Float64(Float64(b * b) * 0.3333333333333333))))
              end
              
              code[r_, a_, b_] := N[(r * N[(b * 1.0 + N[(b * N[(N[(b * b), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
              
              \begin{array}{l}
              
              \\
              r \cdot \mathsf{fma}\left(b, 1, b \cdot \left(\left(b \cdot b\right) \cdot 0.3333333333333333\right)\right)
              \end{array}
              
              Derivation
              1. Initial program 78.4%

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

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

                  \[\leadsto r \cdot \tan b \]
                2. lower-tan.f6459.4

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

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

                \[\leadsto r \cdot \left(b \cdot \color{blue}{\left(1 + \frac{1}{3} \cdot {b}^{2}\right)}\right) \]
              7. Step-by-step derivation
                1. *-commutativeN/A

                  \[\leadsto r \cdot \left(\left(1 + \frac{1}{3} \cdot {b}^{2}\right) \cdot b\right) \]
                2. lower-*.f64N/A

                  \[\leadsto r \cdot \left(\left(1 + \frac{1}{3} \cdot {b}^{2}\right) \cdot b\right) \]
                3. +-commutativeN/A

                  \[\leadsto r \cdot \left(\left(\frac{1}{3} \cdot {b}^{2} + 1\right) \cdot b\right) \]
                4. lower-fma.f64N/A

                  \[\leadsto r \cdot \left(\mathsf{fma}\left(\frac{1}{3}, {b}^{2}, 1\right) \cdot b\right) \]
                5. pow2N/A

                  \[\leadsto r \cdot \left(\mathsf{fma}\left(\frac{1}{3}, b \cdot b, 1\right) \cdot b\right) \]
                6. lift-*.f6435.5

                  \[\leadsto r \cdot \left(\mathsf{fma}\left(0.3333333333333333, b \cdot b, 1\right) \cdot b\right) \]
              8. Applied rewrites35.5%

                \[\leadsto r \cdot \left(\mathsf{fma}\left(0.3333333333333333, b \cdot b, 1\right) \cdot \color{blue}{b}\right) \]
              9. Step-by-step derivation
                1. lift-*.f64N/A

                  \[\leadsto r \cdot \left(\mathsf{fma}\left(\frac{1}{3}, b \cdot b, 1\right) \cdot b\right) \]
                2. lift-*.f64N/A

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

                  \[\leadsto r \cdot \left(\left(\frac{1}{3} \cdot \left(b \cdot b\right) + 1\right) \cdot b\right) \]
                4. +-commutativeN/A

                  \[\leadsto r \cdot \left(\left(1 + \frac{1}{3} \cdot \left(b \cdot b\right)\right) \cdot b\right) \]
                5. pow2N/A

                  \[\leadsto r \cdot \left(\left(1 + \frac{1}{3} \cdot {b}^{2}\right) \cdot b\right) \]
                6. *-commutativeN/A

                  \[\leadsto r \cdot \left(b \cdot \left(1 + \color{blue}{\frac{1}{3} \cdot {b}^{2}}\right)\right) \]
                7. distribute-lft-inN/A

                  \[\leadsto r \cdot \left(b \cdot 1 + b \cdot \color{blue}{\left(\frac{1}{3} \cdot {b}^{2}\right)}\right) \]
                8. lower-fma.f64N/A

                  \[\leadsto r \cdot \mathsf{fma}\left(b, 1, b \cdot \left(\frac{1}{3} \cdot {b}^{2}\right)\right) \]
                9. lower-*.f64N/A

                  \[\leadsto r \cdot \mathsf{fma}\left(b, 1, b \cdot \left(\frac{1}{3} \cdot {b}^{2}\right)\right) \]
                10. *-commutativeN/A

                  \[\leadsto r \cdot \mathsf{fma}\left(b, 1, b \cdot \left({b}^{2} \cdot \frac{1}{3}\right)\right) \]
                11. lower-*.f64N/A

                  \[\leadsto r \cdot \mathsf{fma}\left(b, 1, b \cdot \left({b}^{2} \cdot \frac{1}{3}\right)\right) \]
                12. pow2N/A

                  \[\leadsto r \cdot \mathsf{fma}\left(b, 1, b \cdot \left(\left(b \cdot b\right) \cdot \frac{1}{3}\right)\right) \]
                13. lift-*.f6435.5

                  \[\leadsto r \cdot \mathsf{fma}\left(b, 1, b \cdot \left(\left(b \cdot b\right) \cdot 0.3333333333333333\right)\right) \]
              10. Applied rewrites35.5%

                \[\leadsto r \cdot \mathsf{fma}\left(b, 1, b \cdot \left(\left(b \cdot b\right) \cdot 0.3333333333333333\right)\right) \]
              11. Add Preprocessing

              Alternative 17: 34.4% accurate, 10.0× speedup?

              \[\begin{array}{l} \\ r \cdot \left(\mathsf{fma}\left(0.3333333333333333, b \cdot b, 1\right) \cdot b\right) \end{array} \]
              (FPCore (r a b)
               :precision binary64
               (* r (* (fma 0.3333333333333333 (* b b) 1.0) b)))
              double code(double r, double a, double b) {
              	return r * (fma(0.3333333333333333, (b * b), 1.0) * b);
              }
              
              function code(r, a, b)
              	return Float64(r * Float64(fma(0.3333333333333333, Float64(b * b), 1.0) * b))
              end
              
              code[r_, a_, b_] := N[(r * N[(N[(0.3333333333333333 * N[(b * b), $MachinePrecision] + 1.0), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
              
              \begin{array}{l}
              
              \\
              r \cdot \left(\mathsf{fma}\left(0.3333333333333333, b \cdot b, 1\right) \cdot b\right)
              \end{array}
              
              Derivation
              1. Initial program 78.4%

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

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

                  \[\leadsto r \cdot \tan b \]
                2. lower-tan.f6459.4

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

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

                \[\leadsto r \cdot \left(b \cdot \color{blue}{\left(1 + \frac{1}{3} \cdot {b}^{2}\right)}\right) \]
              7. Step-by-step derivation
                1. *-commutativeN/A

                  \[\leadsto r \cdot \left(\left(1 + \frac{1}{3} \cdot {b}^{2}\right) \cdot b\right) \]
                2. lower-*.f64N/A

                  \[\leadsto r \cdot \left(\left(1 + \frac{1}{3} \cdot {b}^{2}\right) \cdot b\right) \]
                3. +-commutativeN/A

                  \[\leadsto r \cdot \left(\left(\frac{1}{3} \cdot {b}^{2} + 1\right) \cdot b\right) \]
                4. lower-fma.f64N/A

                  \[\leadsto r \cdot \left(\mathsf{fma}\left(\frac{1}{3}, {b}^{2}, 1\right) \cdot b\right) \]
                5. pow2N/A

                  \[\leadsto r \cdot \left(\mathsf{fma}\left(\frac{1}{3}, b \cdot b, 1\right) \cdot b\right) \]
                6. lift-*.f6435.5

                  \[\leadsto r \cdot \left(\mathsf{fma}\left(0.3333333333333333, b \cdot b, 1\right) \cdot b\right) \]
              8. Applied rewrites35.5%

                \[\leadsto r \cdot \left(\mathsf{fma}\left(0.3333333333333333, b \cdot b, 1\right) \cdot \color{blue}{b}\right) \]
              9. Add Preprocessing

              Alternative 18: 34.8% accurate, 36.7× 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 78.4%

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

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

                  \[\leadsto r \cdot \tan b \]
                2. lower-tan.f6459.4

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

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

                \[\leadsto r \cdot b \]
              7. Step-by-step derivation
                1. Applied rewrites35.5%

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

                Reproduce

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