rsin A (should all be same)

Percentage Accurate: 77.0% → 99.5%
Time: 11.8s
Alternatives: 16
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ \frac{r \cdot \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));
}
real(8) function code(r, a, b)
    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(Float64(r * 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[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{r \cdot \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 16 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.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{r \cdot \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));
}
real(8) function code(r, a, b)
    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(Float64(r * 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[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 99.5% accurate, 0.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 76.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin b \cdot r\\ \mathbf{if}\;a \leq -0.000102:\\ \;\;\;\;\frac{t\_0}{\cos a}\\ \mathbf{elif}\;a \leq 1.05 \cdot 10^{-5}:\\ \;\;\;\;\frac{t\_0}{\cos b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin b}{\cos a} \cdot r\\ \end{array} \end{array} \]
(FPCore (r a b)
 :precision binary64
 (let* ((t_0 (* (sin b) r)))
   (if (<= a -0.000102)
     (/ t_0 (cos a))
     (if (<= a 1.05e-5) (/ t_0 (cos b)) (* (/ (sin b) (cos a)) r)))))
double code(double r, double a, double b) {
	double t_0 = sin(b) * r;
	double tmp;
	if (a <= -0.000102) {
		tmp = t_0 / cos(a);
	} else if (a <= 1.05e-5) {
		tmp = t_0 / cos(b);
	} else {
		tmp = (sin(b) / cos(a)) * r;
	}
	return tmp;
}
real(8) function code(r, a, b)
    real(8), intent (in) :: r
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sin(b) * r
    if (a <= (-0.000102d0)) then
        tmp = t_0 / cos(a)
    else if (a <= 1.05d-5) then
        tmp = t_0 / cos(b)
    else
        tmp = (sin(b) / cos(a)) * r
    end if
    code = tmp
end function
public static double code(double r, double a, double b) {
	double t_0 = Math.sin(b) * r;
	double tmp;
	if (a <= -0.000102) {
		tmp = t_0 / Math.cos(a);
	} else if (a <= 1.05e-5) {
		tmp = t_0 / Math.cos(b);
	} else {
		tmp = (Math.sin(b) / Math.cos(a)) * r;
	}
	return tmp;
}
def code(r, a, b):
	t_0 = math.sin(b) * r
	tmp = 0
	if a <= -0.000102:
		tmp = t_0 / math.cos(a)
	elif a <= 1.05e-5:
		tmp = t_0 / math.cos(b)
	else:
		tmp = (math.sin(b) / math.cos(a)) * r
	return tmp
function code(r, a, b)
	t_0 = Float64(sin(b) * r)
	tmp = 0.0
	if (a <= -0.000102)
		tmp = Float64(t_0 / cos(a));
	elseif (a <= 1.05e-5)
		tmp = Float64(t_0 / cos(b));
	else
		tmp = Float64(Float64(sin(b) / cos(a)) * r);
	end
	return tmp
end
function tmp_2 = code(r, a, b)
	t_0 = sin(b) * r;
	tmp = 0.0;
	if (a <= -0.000102)
		tmp = t_0 / cos(a);
	elseif (a <= 1.05e-5)
		tmp = t_0 / cos(b);
	else
		tmp = (sin(b) / cos(a)) * r;
	end
	tmp_2 = tmp;
end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision]}, If[LessEqual[a, -0.000102], N[(t$95$0 / N[Cos[a], $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 1.05e-5], N[(t$95$0 / N[Cos[b], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision] * r), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin b \cdot r\\
\mathbf{if}\;a \leq -0.000102:\\
\;\;\;\;\frac{t\_0}{\cos a}\\

\mathbf{elif}\;a \leq 1.05 \cdot 10^{-5}:\\
\;\;\;\;\frac{t\_0}{\cos b}\\

\mathbf{else}:\\
\;\;\;\;\frac{\sin b}{\cos a} \cdot r\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if a < -1.01999999999999999e-4

    1. Initial program 51.4%

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

      \[\leadsto \frac{r \cdot \sin b}{\color{blue}{\cos a}} \]
    4. Step-by-step derivation
      1. lower-cos.f6451.7

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

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

    if -1.01999999999999999e-4 < a < 1.04999999999999994e-5

    1. Initial program 99.3%

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

      \[\leadsto \frac{r \cdot \sin b}{\color{blue}{\cos b}} \]
    4. Step-by-step derivation
      1. lower-cos.f6499.3

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

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

    if 1.04999999999999994e-5 < a

    1. Initial program 60.8%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{r}{\frac{\color{blue}{{\cos \left(a + b\right)}^{1}}}{\sin b}} \]
      2. metadata-evalN/A

        \[\leadsto \frac{r}{\frac{{\cos \left(a + b\right)}^{\color{blue}{\left(\frac{1}{2} + \frac{1}{2}\right)}}}{\sin b}} \]
      3. pow-prod-upN/A

        \[\leadsto \frac{r}{\frac{\color{blue}{{\cos \left(a + b\right)}^{\frac{1}{2}} \cdot {\cos \left(a + b\right)}^{\frac{1}{2}}}}{\sin b}} \]
      4. pow-prod-downN/A

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

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

        \[\leadsto \frac{r}{\frac{{\color{blue}{\left({\cos \left(a + b\right)}^{2}\right)}}^{\frac{1}{2}}}{\sin b}} \]
      7. lower-pow.f6447.6

        \[\leadsto \frac{r}{\frac{{\color{blue}{\left({\cos \left(a + b\right)}^{2}\right)}}^{0.5}}{\sin b}} \]
    6. Applied rewrites47.6%

      \[\leadsto \frac{r}{\frac{\color{blue}{{\left({\cos \left(a + b\right)}^{2}\right)}^{0.5}}}{\sin b}} \]
    7. Taylor expanded in b around 0

      \[\leadsto \frac{r}{\frac{{\left({\color{blue}{\cos a}}^{2}\right)}^{\frac{1}{2}}}{\sin b}} \]
    8. Step-by-step derivation
      1. lower-cos.f6447.4

        \[\leadsto \frac{r}{\frac{{\left({\color{blue}{\cos a}}^{2}\right)}^{0.5}}{\sin b}} \]
    9. Applied rewrites47.4%

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

        \[\leadsto \color{blue}{\frac{r}{\frac{{\left({\cos a}^{2}\right)}^{\frac{1}{2}}}{\sin b}}} \]
      2. clear-numN/A

        \[\leadsto \color{blue}{\frac{1}{\frac{\frac{{\left({\cos a}^{2}\right)}^{\frac{1}{2}}}{\sin b}}{r}}} \]
      3. associate-/r/N/A

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

        \[\leadsto \frac{1}{\color{blue}{\frac{{\left({\cos a}^{2}\right)}^{\frac{1}{2}}}{\sin b}}} \cdot r \]
      5. clear-numN/A

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

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

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

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

        \[\leadsto \frac{\sin b}{{\color{blue}{\left({\cos a}^{2}\right)}}^{\frac{1}{2}}} \cdot r \]
      10. pow-powN/A

        \[\leadsto \frac{\sin b}{\color{blue}{{\cos a}^{\left(2 \cdot \frac{1}{2}\right)}}} \cdot r \]
      11. metadata-evalN/A

        \[\leadsto \frac{\sin b}{{\cos a}^{\color{blue}{1}}} \cdot r \]
      12. unpow160.8

        \[\leadsto \frac{\sin b}{\color{blue}{\cos a}} \cdot r \]
    11. Applied rewrites60.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -0.000102:\\ \;\;\;\;\frac{\sin b \cdot r}{\cos a}\\ \mathbf{elif}\;a \leq 1.05 \cdot 10^{-5}:\\ \;\;\;\;\frac{\sin b \cdot r}{\cos b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin b}{\cos a} \cdot r\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 76.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -0.000102:\\ \;\;\;\;\frac{\sin b \cdot r}{\cos a}\\ \mathbf{elif}\;a \leq 1.05 \cdot 10^{-5}:\\ \;\;\;\;\frac{r}{\cos b} \cdot \sin b\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin b}{\cos a} \cdot r\\ \end{array} \end{array} \]
(FPCore (r a b)
 :precision binary64
 (if (<= a -0.000102)
   (/ (* (sin b) r) (cos a))
   (if (<= a 1.05e-5) (* (/ r (cos b)) (sin b)) (* (/ (sin b) (cos a)) r))))
double code(double r, double a, double b) {
	double tmp;
	if (a <= -0.000102) {
		tmp = (sin(b) * r) / cos(a);
	} else if (a <= 1.05e-5) {
		tmp = (r / cos(b)) * sin(b);
	} else {
		tmp = (sin(b) / cos(a)) * r;
	}
	return tmp;
}
real(8) function code(r, a, b)
    real(8), intent (in) :: r
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: tmp
    if (a <= (-0.000102d0)) then
        tmp = (sin(b) * r) / cos(a)
    else if (a <= 1.05d-5) then
        tmp = (r / cos(b)) * sin(b)
    else
        tmp = (sin(b) / cos(a)) * r
    end if
    code = tmp
end function
public static double code(double r, double a, double b) {
	double tmp;
	if (a <= -0.000102) {
		tmp = (Math.sin(b) * r) / Math.cos(a);
	} else if (a <= 1.05e-5) {
		tmp = (r / Math.cos(b)) * Math.sin(b);
	} else {
		tmp = (Math.sin(b) / Math.cos(a)) * r;
	}
	return tmp;
}
def code(r, a, b):
	tmp = 0
	if a <= -0.000102:
		tmp = (math.sin(b) * r) / math.cos(a)
	elif a <= 1.05e-5:
		tmp = (r / math.cos(b)) * math.sin(b)
	else:
		tmp = (math.sin(b) / math.cos(a)) * r
	return tmp
function code(r, a, b)
	tmp = 0.0
	if (a <= -0.000102)
		tmp = Float64(Float64(sin(b) * r) / cos(a));
	elseif (a <= 1.05e-5)
		tmp = Float64(Float64(r / cos(b)) * sin(b));
	else
		tmp = Float64(Float64(sin(b) / cos(a)) * r);
	end
	return tmp
end
function tmp_2 = code(r, a, b)
	tmp = 0.0;
	if (a <= -0.000102)
		tmp = (sin(b) * r) / cos(a);
	elseif (a <= 1.05e-5)
		tmp = (r / cos(b)) * sin(b);
	else
		tmp = (sin(b) / cos(a)) * r;
	end
	tmp_2 = tmp;
end
code[r_, a_, b_] := If[LessEqual[a, -0.000102], N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 1.05e-5], N[(N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision] * r), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;a \leq 1.05 \cdot 10^{-5}:\\
\;\;\;\;\frac{r}{\cos b} \cdot \sin b\\

\mathbf{else}:\\
\;\;\;\;\frac{\sin b}{\cos a} \cdot r\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if a < -1.01999999999999999e-4

    1. Initial program 51.4%

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

      \[\leadsto \frac{r \cdot \sin b}{\color{blue}{\cos a}} \]
    4. Step-by-step derivation
      1. lower-cos.f6451.7

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

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

    if -1.01999999999999999e-4 < a < 1.04999999999999994e-5

    1. Initial program 99.3%

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

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

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

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

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

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

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

        \[\leadsto \frac{r}{\color{blue}{\cos b}} \cdot \sin b \]
      7. lower-sin.f6499.1

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

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

    if 1.04999999999999994e-5 < a

    1. Initial program 60.8%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{r}{\frac{\color{blue}{{\cos \left(a + b\right)}^{1}}}{\sin b}} \]
      2. metadata-evalN/A

        \[\leadsto \frac{r}{\frac{{\cos \left(a + b\right)}^{\color{blue}{\left(\frac{1}{2} + \frac{1}{2}\right)}}}{\sin b}} \]
      3. pow-prod-upN/A

        \[\leadsto \frac{r}{\frac{\color{blue}{{\cos \left(a + b\right)}^{\frac{1}{2}} \cdot {\cos \left(a + b\right)}^{\frac{1}{2}}}}{\sin b}} \]
      4. pow-prod-downN/A

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

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

        \[\leadsto \frac{r}{\frac{{\color{blue}{\left({\cos \left(a + b\right)}^{2}\right)}}^{\frac{1}{2}}}{\sin b}} \]
      7. lower-pow.f6447.6

        \[\leadsto \frac{r}{\frac{{\color{blue}{\left({\cos \left(a + b\right)}^{2}\right)}}^{0.5}}{\sin b}} \]
    6. Applied rewrites47.6%

      \[\leadsto \frac{r}{\frac{\color{blue}{{\left({\cos \left(a + b\right)}^{2}\right)}^{0.5}}}{\sin b}} \]
    7. Taylor expanded in b around 0

      \[\leadsto \frac{r}{\frac{{\left({\color{blue}{\cos a}}^{2}\right)}^{\frac{1}{2}}}{\sin b}} \]
    8. Step-by-step derivation
      1. lower-cos.f6447.4

        \[\leadsto \frac{r}{\frac{{\left({\color{blue}{\cos a}}^{2}\right)}^{0.5}}{\sin b}} \]
    9. Applied rewrites47.4%

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

        \[\leadsto \color{blue}{\frac{r}{\frac{{\left({\cos a}^{2}\right)}^{\frac{1}{2}}}{\sin b}}} \]
      2. clear-numN/A

        \[\leadsto \color{blue}{\frac{1}{\frac{\frac{{\left({\cos a}^{2}\right)}^{\frac{1}{2}}}{\sin b}}{r}}} \]
      3. associate-/r/N/A

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

        \[\leadsto \frac{1}{\color{blue}{\frac{{\left({\cos a}^{2}\right)}^{\frac{1}{2}}}{\sin b}}} \cdot r \]
      5. clear-numN/A

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

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

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

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

        \[\leadsto \frac{\sin b}{{\color{blue}{\left({\cos a}^{2}\right)}}^{\frac{1}{2}}} \cdot r \]
      10. pow-powN/A

        \[\leadsto \frac{\sin b}{\color{blue}{{\cos a}^{\left(2 \cdot \frac{1}{2}\right)}}} \cdot r \]
      11. metadata-evalN/A

        \[\leadsto \frac{\sin b}{{\cos a}^{\color{blue}{1}}} \cdot r \]
      12. unpow160.8

        \[\leadsto \frac{\sin b}{\color{blue}{\cos a}} \cdot r \]
    11. Applied rewrites60.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -0.000102:\\ \;\;\;\;\frac{\sin b \cdot r}{\cos a}\\ \mathbf{elif}\;a \leq 1.05 \cdot 10^{-5}:\\ \;\;\;\;\frac{r}{\cos b} \cdot \sin b\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin b}{\cos a} \cdot r\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 76.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -0.000102:\\ \;\;\;\;\frac{r}{\cos a} \cdot \sin b\\ \mathbf{elif}\;a \leq 1.05 \cdot 10^{-5}:\\ \;\;\;\;\frac{r}{\cos b} \cdot \sin b\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin b}{\cos a} \cdot r\\ \end{array} \end{array} \]
(FPCore (r a b)
 :precision binary64
 (if (<= a -0.000102)
   (* (/ r (cos a)) (sin b))
   (if (<= a 1.05e-5) (* (/ r (cos b)) (sin b)) (* (/ (sin b) (cos a)) r))))
double code(double r, double a, double b) {
	double tmp;
	if (a <= -0.000102) {
		tmp = (r / cos(a)) * sin(b);
	} else if (a <= 1.05e-5) {
		tmp = (r / cos(b)) * sin(b);
	} else {
		tmp = (sin(b) / cos(a)) * r;
	}
	return tmp;
}
real(8) function code(r, a, b)
    real(8), intent (in) :: r
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: tmp
    if (a <= (-0.000102d0)) then
        tmp = (r / cos(a)) * sin(b)
    else if (a <= 1.05d-5) then
        tmp = (r / cos(b)) * sin(b)
    else
        tmp = (sin(b) / cos(a)) * r
    end if
    code = tmp
end function
public static double code(double r, double a, double b) {
	double tmp;
	if (a <= -0.000102) {
		tmp = (r / Math.cos(a)) * Math.sin(b);
	} else if (a <= 1.05e-5) {
		tmp = (r / Math.cos(b)) * Math.sin(b);
	} else {
		tmp = (Math.sin(b) / Math.cos(a)) * r;
	}
	return tmp;
}
def code(r, a, b):
	tmp = 0
	if a <= -0.000102:
		tmp = (r / math.cos(a)) * math.sin(b)
	elif a <= 1.05e-5:
		tmp = (r / math.cos(b)) * math.sin(b)
	else:
		tmp = (math.sin(b) / math.cos(a)) * r
	return tmp
function code(r, a, b)
	tmp = 0.0
	if (a <= -0.000102)
		tmp = Float64(Float64(r / cos(a)) * sin(b));
	elseif (a <= 1.05e-5)
		tmp = Float64(Float64(r / cos(b)) * sin(b));
	else
		tmp = Float64(Float64(sin(b) / cos(a)) * r);
	end
	return tmp
end
function tmp_2 = code(r, a, b)
	tmp = 0.0;
	if (a <= -0.000102)
		tmp = (r / cos(a)) * sin(b);
	elseif (a <= 1.05e-5)
		tmp = (r / cos(b)) * sin(b);
	else
		tmp = (sin(b) / cos(a)) * r;
	end
	tmp_2 = tmp;
end
code[r_, a_, b_] := If[LessEqual[a, -0.000102], N[(N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 1.05e-5], N[(N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision] * r), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;a \leq 1.05 \cdot 10^{-5}:\\
\;\;\;\;\frac{r}{\cos b} \cdot \sin b\\

\mathbf{else}:\\
\;\;\;\;\frac{\sin b}{\cos a} \cdot r\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if a < -1.01999999999999999e-4

    1. Initial program 51.4%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{r}{\frac{\color{blue}{{\cos \left(a + b\right)}^{1}}}{\sin b}} \]
      2. metadata-evalN/A

        \[\leadsto \frac{r}{\frac{{\cos \left(a + b\right)}^{\color{blue}{\left(\frac{1}{2} + \frac{1}{2}\right)}}}{\sin b}} \]
      3. pow-prod-upN/A

        \[\leadsto \frac{r}{\frac{\color{blue}{{\cos \left(a + b\right)}^{\frac{1}{2}} \cdot {\cos \left(a + b\right)}^{\frac{1}{2}}}}{\sin b}} \]
      4. pow-prod-downN/A

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

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

        \[\leadsto \frac{r}{\frac{{\color{blue}{\left({\cos \left(a + b\right)}^{2}\right)}}^{\frac{1}{2}}}{\sin b}} \]
      7. lower-pow.f6430.8

        \[\leadsto \frac{r}{\frac{{\color{blue}{\left({\cos \left(a + b\right)}^{2}\right)}}^{0.5}}{\sin b}} \]
    6. Applied rewrites30.8%

      \[\leadsto \frac{r}{\frac{\color{blue}{{\left({\cos \left(a + b\right)}^{2}\right)}^{0.5}}}{\sin b}} \]
    7. Taylor expanded in b around 0

      \[\leadsto \frac{r}{\frac{{\left({\color{blue}{\cos a}}^{2}\right)}^{\frac{1}{2}}}{\sin b}} \]
    8. Step-by-step derivation
      1. lower-cos.f6430.8

        \[\leadsto \frac{r}{\frac{{\left({\color{blue}{\cos a}}^{2}\right)}^{0.5}}{\sin b}} \]
    9. Applied rewrites30.8%

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

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

        \[\leadsto \frac{r}{\color{blue}{\frac{{\left({\cos a}^{2}\right)}^{\frac{1}{2}}}{\sin b}}} \]
      3. associate-/r/N/A

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

        \[\leadsto \color{blue}{\frac{r}{{\left({\cos a}^{2}\right)}^{\frac{1}{2}}} \cdot \sin b} \]
      5. lower-/.f6430.8

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

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

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

        \[\leadsto \frac{r}{\color{blue}{{\cos a}^{\left(2 \cdot \frac{1}{2}\right)}}} \cdot \sin b \]
      9. metadata-evalN/A

        \[\leadsto \frac{r}{{\cos a}^{\color{blue}{1}}} \cdot \sin b \]
      10. unpow151.6

        \[\leadsto \frac{r}{\color{blue}{\cos a}} \cdot \sin b \]
    11. Applied rewrites51.6%

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

    if -1.01999999999999999e-4 < a < 1.04999999999999994e-5

    1. Initial program 99.3%

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

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

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

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

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

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

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

        \[\leadsto \frac{r}{\color{blue}{\cos b}} \cdot \sin b \]
      7. lower-sin.f6499.1

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

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

    if 1.04999999999999994e-5 < a

    1. Initial program 60.8%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{r}{\frac{\color{blue}{{\cos \left(a + b\right)}^{1}}}{\sin b}} \]
      2. metadata-evalN/A

        \[\leadsto \frac{r}{\frac{{\cos \left(a + b\right)}^{\color{blue}{\left(\frac{1}{2} + \frac{1}{2}\right)}}}{\sin b}} \]
      3. pow-prod-upN/A

        \[\leadsto \frac{r}{\frac{\color{blue}{{\cos \left(a + b\right)}^{\frac{1}{2}} \cdot {\cos \left(a + b\right)}^{\frac{1}{2}}}}{\sin b}} \]
      4. pow-prod-downN/A

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

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

        \[\leadsto \frac{r}{\frac{{\color{blue}{\left({\cos \left(a + b\right)}^{2}\right)}}^{\frac{1}{2}}}{\sin b}} \]
      7. lower-pow.f6447.6

        \[\leadsto \frac{r}{\frac{{\color{blue}{\left({\cos \left(a + b\right)}^{2}\right)}}^{0.5}}{\sin b}} \]
    6. Applied rewrites47.6%

      \[\leadsto \frac{r}{\frac{\color{blue}{{\left({\cos \left(a + b\right)}^{2}\right)}^{0.5}}}{\sin b}} \]
    7. Taylor expanded in b around 0

      \[\leadsto \frac{r}{\frac{{\left({\color{blue}{\cos a}}^{2}\right)}^{\frac{1}{2}}}{\sin b}} \]
    8. Step-by-step derivation
      1. lower-cos.f6447.4

        \[\leadsto \frac{r}{\frac{{\left({\color{blue}{\cos a}}^{2}\right)}^{0.5}}{\sin b}} \]
    9. Applied rewrites47.4%

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

        \[\leadsto \color{blue}{\frac{r}{\frac{{\left({\cos a}^{2}\right)}^{\frac{1}{2}}}{\sin b}}} \]
      2. clear-numN/A

        \[\leadsto \color{blue}{\frac{1}{\frac{\frac{{\left({\cos a}^{2}\right)}^{\frac{1}{2}}}{\sin b}}{r}}} \]
      3. associate-/r/N/A

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

        \[\leadsto \frac{1}{\color{blue}{\frac{{\left({\cos a}^{2}\right)}^{\frac{1}{2}}}{\sin b}}} \cdot r \]
      5. clear-numN/A

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

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

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

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

        \[\leadsto \frac{\sin b}{{\color{blue}{\left({\cos a}^{2}\right)}}^{\frac{1}{2}}} \cdot r \]
      10. pow-powN/A

        \[\leadsto \frac{\sin b}{\color{blue}{{\cos a}^{\left(2 \cdot \frac{1}{2}\right)}}} \cdot r \]
      11. metadata-evalN/A

        \[\leadsto \frac{\sin b}{{\cos a}^{\color{blue}{1}}} \cdot r \]
      12. unpow160.8

        \[\leadsto \frac{\sin b}{\color{blue}{\cos a}} \cdot r \]
    11. Applied rewrites60.8%

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

Alternative 5: 76.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{r}{\cos a} \cdot \sin b\\ \mathbf{if}\;a \leq -0.000102:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;a \leq 1.05 \cdot 10^{-5}:\\ \;\;\;\;\frac{r}{\cos b} \cdot \sin b\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (r a b)
 :precision binary64
 (let* ((t_0 (* (/ r (cos a)) (sin b))))
   (if (<= a -0.000102)
     t_0
     (if (<= a 1.05e-5) (* (/ r (cos b)) (sin b)) t_0))))
double code(double r, double a, double b) {
	double t_0 = (r / cos(a)) * sin(b);
	double tmp;
	if (a <= -0.000102) {
		tmp = t_0;
	} else if (a <= 1.05e-5) {
		tmp = (r / cos(b)) * sin(b);
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(r, a, b)
    real(8), intent (in) :: r
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (r / cos(a)) * sin(b)
    if (a <= (-0.000102d0)) then
        tmp = t_0
    else if (a <= 1.05d-5) then
        tmp = (r / cos(b)) * sin(b)
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double r, double a, double b) {
	double t_0 = (r / Math.cos(a)) * Math.sin(b);
	double tmp;
	if (a <= -0.000102) {
		tmp = t_0;
	} else if (a <= 1.05e-5) {
		tmp = (r / Math.cos(b)) * Math.sin(b);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(r, a, b):
	t_0 = (r / math.cos(a)) * math.sin(b)
	tmp = 0
	if a <= -0.000102:
		tmp = t_0
	elif a <= 1.05e-5:
		tmp = (r / math.cos(b)) * math.sin(b)
	else:
		tmp = t_0
	return tmp
function code(r, a, b)
	t_0 = Float64(Float64(r / cos(a)) * sin(b))
	tmp = 0.0
	if (a <= -0.000102)
		tmp = t_0;
	elseif (a <= 1.05e-5)
		tmp = Float64(Float64(r / cos(b)) * sin(b));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(r, a, b)
	t_0 = (r / cos(a)) * sin(b);
	tmp = 0.0;
	if (a <= -0.000102)
		tmp = t_0;
	elseif (a <= 1.05e-5)
		tmp = (r / cos(b)) * sin(b);
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -0.000102], t$95$0, If[LessEqual[a, 1.05e-5], N[(N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{r}{\cos a} \cdot \sin b\\
\mathbf{if}\;a \leq -0.000102:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;a \leq 1.05 \cdot 10^{-5}:\\
\;\;\;\;\frac{r}{\cos b} \cdot \sin b\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -1.01999999999999999e-4 or 1.04999999999999994e-5 < a

    1. Initial program 56.1%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{r}{\frac{\color{blue}{{\cos \left(a + b\right)}^{1}}}{\sin b}} \]
      2. metadata-evalN/A

        \[\leadsto \frac{r}{\frac{{\cos \left(a + b\right)}^{\color{blue}{\left(\frac{1}{2} + \frac{1}{2}\right)}}}{\sin b}} \]
      3. pow-prod-upN/A

        \[\leadsto \frac{r}{\frac{\color{blue}{{\cos \left(a + b\right)}^{\frac{1}{2}} \cdot {\cos \left(a + b\right)}^{\frac{1}{2}}}}{\sin b}} \]
      4. pow-prod-downN/A

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

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

        \[\leadsto \frac{r}{\frac{{\color{blue}{\left({\cos \left(a + b\right)}^{2}\right)}}^{\frac{1}{2}}}{\sin b}} \]
      7. lower-pow.f6439.2

        \[\leadsto \frac{r}{\frac{{\color{blue}{\left({\cos \left(a + b\right)}^{2}\right)}}^{0.5}}{\sin b}} \]
    6. Applied rewrites39.2%

      \[\leadsto \frac{r}{\frac{\color{blue}{{\left({\cos \left(a + b\right)}^{2}\right)}^{0.5}}}{\sin b}} \]
    7. Taylor expanded in b around 0

      \[\leadsto \frac{r}{\frac{{\left({\color{blue}{\cos a}}^{2}\right)}^{\frac{1}{2}}}{\sin b}} \]
    8. Step-by-step derivation
      1. lower-cos.f6439.1

        \[\leadsto \frac{r}{\frac{{\left({\color{blue}{\cos a}}^{2}\right)}^{0.5}}{\sin b}} \]
    9. Applied rewrites39.1%

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

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

        \[\leadsto \frac{r}{\color{blue}{\frac{{\left({\cos a}^{2}\right)}^{\frac{1}{2}}}{\sin b}}} \]
      3. associate-/r/N/A

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

        \[\leadsto \color{blue}{\frac{r}{{\left({\cos a}^{2}\right)}^{\frac{1}{2}}} \cdot \sin b} \]
      5. lower-/.f6439.1

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

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

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

        \[\leadsto \frac{r}{\color{blue}{{\cos a}^{\left(2 \cdot \frac{1}{2}\right)}}} \cdot \sin b \]
      9. metadata-evalN/A

        \[\leadsto \frac{r}{{\cos a}^{\color{blue}{1}}} \cdot \sin b \]
      10. unpow156.2

        \[\leadsto \frac{r}{\color{blue}{\cos a}} \cdot \sin b \]
    11. Applied rewrites56.2%

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

    if -1.01999999999999999e-4 < a < 1.04999999999999994e-5

    1. Initial program 99.3%

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

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

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

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

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

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

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

        \[\leadsto \frac{r}{\color{blue}{\cos b}} \cdot \sin b \]
      7. lower-sin.f6499.1

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

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

Alternative 6: 76.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{r}{\cos b} \cdot \sin b\\ \mathbf{if}\;b \leq -0.024:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;b \leq 3 \cdot 10^{-7}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.008333333333333333, b \cdot b, -0.16666666666666666\right) \cdot r, b \cdot b, r\right) \cdot b}{\cos \left(a + b\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (r a b)
 :precision binary64
 (let* ((t_0 (* (/ r (cos b)) (sin b))))
   (if (<= b -0.024)
     t_0
     (if (<= b 3e-7)
       (/
        (*
         (fma
          (* (fma 0.008333333333333333 (* b b) -0.16666666666666666) r)
          (* b b)
          r)
         b)
        (cos (+ a b)))
       t_0))))
double code(double r, double a, double b) {
	double t_0 = (r / cos(b)) * sin(b);
	double tmp;
	if (b <= -0.024) {
		tmp = t_0;
	} else if (b <= 3e-7) {
		tmp = (fma((fma(0.008333333333333333, (b * b), -0.16666666666666666) * r), (b * b), r) * b) / cos((a + b));
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(r, a, b)
	t_0 = Float64(Float64(r / cos(b)) * sin(b))
	tmp = 0.0
	if (b <= -0.024)
		tmp = t_0;
	elseif (b <= 3e-7)
		tmp = Float64(Float64(fma(Float64(fma(0.008333333333333333, Float64(b * b), -0.16666666666666666) * r), Float64(b * b), r) * b) / cos(Float64(a + b)));
	else
		tmp = t_0;
	end
	return tmp
end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -0.024], t$95$0, If[LessEqual[b, 3e-7], N[(N[(N[(N[(N[(0.008333333333333333 * N[(b * b), $MachinePrecision] + -0.16666666666666666), $MachinePrecision] * r), $MachinePrecision] * N[(b * b), $MachinePrecision] + r), $MachinePrecision] * b), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{r}{\cos b} \cdot \sin b\\
\mathbf{if}\;b \leq -0.024:\\
\;\;\;\;t\_0\\

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

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -0.024 or 2.9999999999999999e-7 < b

    1. Initial program 51.9%

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

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

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

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

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

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

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

        \[\leadsto \frac{r}{\color{blue}{\cos b}} \cdot \sin b \]
      7. lower-sin.f6451.6

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

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

    if -0.024 < b < 2.9999999999999999e-7

    1. Initial program 99.3%

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

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

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

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

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

Alternative 7: 77.0% accurate, 1.0× speedup?

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

\\
\frac{\sin b \cdot r}{\cos \left(a + b\right)}
\end{array}
Derivation
  1. Initial program 76.3%

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

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

Alternative 8: 77.0% accurate, 1.0× speedup?

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

\\
\frac{\sin b}{\cos \left(a + b\right)} \cdot r
\end{array}
Derivation
  1. Initial program 76.3%

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

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

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

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

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

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

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

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

Alternative 9: 77.0% accurate, 1.0× speedup?

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

\\
\frac{r}{\cos \left(a + b\right)} \cdot \sin b
\end{array}
Derivation
  1. Initial program 76.3%

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

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

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

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

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

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

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

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

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

Alternative 10: 52.1% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 3.6 \cdot 10^{+16}:\\ \;\;\;\;\frac{b \cdot r}{\cos \left(a + b\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{r}{\frac{\left(-b\right) \cdot \sin a}{b}}\\ \end{array} \end{array} \]
(FPCore (r a b)
 :precision binary64
 (if (<= b 3.6e+16) (/ (* b r) (cos (+ a b))) (/ r (/ (* (- b) (sin a)) b))))
double code(double r, double a, double b) {
	double tmp;
	if (b <= 3.6e+16) {
		tmp = (b * r) / cos((a + b));
	} else {
		tmp = r / ((-b * sin(a)) / b);
	}
	return tmp;
}
real(8) function code(r, a, b)
    real(8), intent (in) :: r
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: tmp
    if (b <= 3.6d+16) then
        tmp = (b * r) / cos((a + b))
    else
        tmp = r / ((-b * sin(a)) / b)
    end if
    code = tmp
end function
public static double code(double r, double a, double b) {
	double tmp;
	if (b <= 3.6e+16) {
		tmp = (b * r) / Math.cos((a + b));
	} else {
		tmp = r / ((-b * Math.sin(a)) / b);
	}
	return tmp;
}
def code(r, a, b):
	tmp = 0
	if b <= 3.6e+16:
		tmp = (b * r) / math.cos((a + b))
	else:
		tmp = r / ((-b * math.sin(a)) / b)
	return tmp
function code(r, a, b)
	tmp = 0.0
	if (b <= 3.6e+16)
		tmp = Float64(Float64(b * r) / cos(Float64(a + b)));
	else
		tmp = Float64(r / Float64(Float64(Float64(-b) * sin(a)) / b));
	end
	return tmp
end
function tmp_2 = code(r, a, b)
	tmp = 0.0;
	if (b <= 3.6e+16)
		tmp = (b * r) / cos((a + b));
	else
		tmp = r / ((-b * sin(a)) / b);
	end
	tmp_2 = tmp;
end
code[r_, a_, b_] := If[LessEqual[b, 3.6e+16], N[(N[(b * r), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(r / N[(N[((-b) * N[Sin[a], $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.6 \cdot 10^{+16}:\\
\;\;\;\;\frac{b \cdot r}{\cos \left(a + b\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{r}{\frac{\left(-b\right) \cdot \sin a}{b}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 3.6e16

    1. Initial program 83.5%

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

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

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

      \[\leadsto \frac{\color{blue}{b \cdot r}}{\cos \left(a + b\right)} \]

    if 3.6e16 < b

    1. Initial program 53.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{r}{\frac{\mathsf{fma}\left(-b, \color{blue}{\sin a}, \cos a\right)}{b}} \]
      14. lower-cos.f6410.3

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

      \[\leadsto \frac{r}{\color{blue}{\frac{\mathsf{fma}\left(-b, \sin a, \cos a\right)}{b}}} \]
    8. Taylor expanded in b around inf

      \[\leadsto \frac{r}{\frac{-1 \cdot \left(b \cdot \sin a\right)}{b}} \]
    9. Step-by-step derivation
      1. Applied rewrites10.0%

        \[\leadsto \frac{r}{\frac{\left(-\sin a\right) \cdot b}{b}} \]
    10. Recombined 2 regimes into one program.
    11. Final simplification55.3%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 3.6 \cdot 10^{+16}:\\ \;\;\;\;\frac{b \cdot r}{\cos \left(a + b\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{r}{\frac{\left(-b\right) \cdot \sin a}{b}}\\ \end{array} \]
    12. Add Preprocessing

    Alternative 11: 53.5% accurate, 1.7× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{r}{-\sin a}\\ \mathbf{if}\;b \leq -7 \cdot 10^{+15}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;b \leq 5.2 \cdot 10^{+18}:\\ \;\;\;\;\frac{b \cdot r}{\cos a}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
    (FPCore (r a b)
     :precision binary64
     (let* ((t_0 (/ r (- (sin a)))))
       (if (<= b -7e+15) t_0 (if (<= b 5.2e+18) (/ (* b r) (cos a)) t_0))))
    double code(double r, double a, double b) {
    	double t_0 = r / -sin(a);
    	double tmp;
    	if (b <= -7e+15) {
    		tmp = t_0;
    	} else if (b <= 5.2e+18) {
    		tmp = (b * r) / cos(a);
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    real(8) function code(r, a, b)
        real(8), intent (in) :: r
        real(8), intent (in) :: a
        real(8), intent (in) :: b
        real(8) :: t_0
        real(8) :: tmp
        t_0 = r / -sin(a)
        if (b <= (-7d+15)) then
            tmp = t_0
        else if (b <= 5.2d+18) then
            tmp = (b * r) / cos(a)
        else
            tmp = t_0
        end if
        code = tmp
    end function
    
    public static double code(double r, double a, double b) {
    	double t_0 = r / -Math.sin(a);
    	double tmp;
    	if (b <= -7e+15) {
    		tmp = t_0;
    	} else if (b <= 5.2e+18) {
    		tmp = (b * r) / Math.cos(a);
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    def code(r, a, b):
    	t_0 = r / -math.sin(a)
    	tmp = 0
    	if b <= -7e+15:
    		tmp = t_0
    	elif b <= 5.2e+18:
    		tmp = (b * r) / math.cos(a)
    	else:
    		tmp = t_0
    	return tmp
    
    function code(r, a, b)
    	t_0 = Float64(r / Float64(-sin(a)))
    	tmp = 0.0
    	if (b <= -7e+15)
    		tmp = t_0;
    	elseif (b <= 5.2e+18)
    		tmp = Float64(Float64(b * r) / cos(a));
    	else
    		tmp = t_0;
    	end
    	return tmp
    end
    
    function tmp_2 = code(r, a, b)
    	t_0 = r / -sin(a);
    	tmp = 0.0;
    	if (b <= -7e+15)
    		tmp = t_0;
    	elseif (b <= 5.2e+18)
    		tmp = (b * r) / cos(a);
    	else
    		tmp = t_0;
    	end
    	tmp_2 = tmp;
    end
    
    code[r_, a_, b_] := Block[{t$95$0 = N[(r / (-N[Sin[a], $MachinePrecision])), $MachinePrecision]}, If[LessEqual[b, -7e+15], t$95$0, If[LessEqual[b, 5.2e+18], N[(N[(b * r), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], t$95$0]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \frac{r}{-\sin a}\\
    \mathbf{if}\;b \leq -7 \cdot 10^{+15}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;b \leq 5.2 \cdot 10^{+18}:\\
    \;\;\;\;\frac{b \cdot r}{\cos a}\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if b < -7e15 or 5.2e18 < b

      1. Initial program 49.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{r}{\color{blue}{\frac{\mathsf{fma}\left(-b, \sin a, \cos a\right)}{b}}} \]
      8. Taylor expanded in b around inf

        \[\leadsto \frac{r}{-1 \cdot \color{blue}{\sin a}} \]
      9. Step-by-step derivation
        1. Applied rewrites10.5%

          \[\leadsto \frac{r}{-\sin a} \]

        if -7e15 < b < 5.2e18

        1. Initial program 98.6%

          \[\frac{r \cdot \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. *-commutativeN/A

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

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

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

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

            \[\leadsto \frac{r}{\color{blue}{\cos a}} \cdot b \]
        5. Applied rewrites95.8%

          \[\leadsto \color{blue}{\frac{r}{\cos a} \cdot b} \]
        6. Step-by-step derivation
          1. Applied rewrites95.8%

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

        Alternative 12: 53.5% accurate, 1.7× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{r}{-\sin a}\\ \mathbf{if}\;b \leq -7 \cdot 10^{+15}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;b \leq 5.2 \cdot 10^{+18}:\\ \;\;\;\;\frac{r}{\cos a} \cdot b\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
        (FPCore (r a b)
         :precision binary64
         (let* ((t_0 (/ r (- (sin a)))))
           (if (<= b -7e+15) t_0 (if (<= b 5.2e+18) (* (/ r (cos a)) b) t_0))))
        double code(double r, double a, double b) {
        	double t_0 = r / -sin(a);
        	double tmp;
        	if (b <= -7e+15) {
        		tmp = t_0;
        	} else if (b <= 5.2e+18) {
        		tmp = (r / cos(a)) * b;
        	} else {
        		tmp = t_0;
        	}
        	return tmp;
        }
        
        real(8) function code(r, a, b)
            real(8), intent (in) :: r
            real(8), intent (in) :: a
            real(8), intent (in) :: b
            real(8) :: t_0
            real(8) :: tmp
            t_0 = r / -sin(a)
            if (b <= (-7d+15)) then
                tmp = t_0
            else if (b <= 5.2d+18) then
                tmp = (r / cos(a)) * b
            else
                tmp = t_0
            end if
            code = tmp
        end function
        
        public static double code(double r, double a, double b) {
        	double t_0 = r / -Math.sin(a);
        	double tmp;
        	if (b <= -7e+15) {
        		tmp = t_0;
        	} else if (b <= 5.2e+18) {
        		tmp = (r / Math.cos(a)) * b;
        	} else {
        		tmp = t_0;
        	}
        	return tmp;
        }
        
        def code(r, a, b):
        	t_0 = r / -math.sin(a)
        	tmp = 0
        	if b <= -7e+15:
        		tmp = t_0
        	elif b <= 5.2e+18:
        		tmp = (r / math.cos(a)) * b
        	else:
        		tmp = t_0
        	return tmp
        
        function code(r, a, b)
        	t_0 = Float64(r / Float64(-sin(a)))
        	tmp = 0.0
        	if (b <= -7e+15)
        		tmp = t_0;
        	elseif (b <= 5.2e+18)
        		tmp = Float64(Float64(r / cos(a)) * b);
        	else
        		tmp = t_0;
        	end
        	return tmp
        end
        
        function tmp_2 = code(r, a, b)
        	t_0 = r / -sin(a);
        	tmp = 0.0;
        	if (b <= -7e+15)
        		tmp = t_0;
        	elseif (b <= 5.2e+18)
        		tmp = (r / cos(a)) * b;
        	else
        		tmp = t_0;
        	end
        	tmp_2 = tmp;
        end
        
        code[r_, a_, b_] := Block[{t$95$0 = N[(r / (-N[Sin[a], $MachinePrecision])), $MachinePrecision]}, If[LessEqual[b, -7e+15], t$95$0, If[LessEqual[b, 5.2e+18], N[(N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision], t$95$0]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := \frac{r}{-\sin a}\\
        \mathbf{if}\;b \leq -7 \cdot 10^{+15}:\\
        \;\;\;\;t\_0\\
        
        \mathbf{elif}\;b \leq 5.2 \cdot 10^{+18}:\\
        \;\;\;\;\frac{r}{\cos a} \cdot b\\
        
        \mathbf{else}:\\
        \;\;\;\;t\_0\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if b < -7e15 or 5.2e18 < b

          1. Initial program 49.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \frac{r}{\color{blue}{\frac{\mathsf{fma}\left(-b, \sin a, \cos a\right)}{b}}} \]
          8. Taylor expanded in b around inf

            \[\leadsto \frac{r}{-1 \cdot \color{blue}{\sin a}} \]
          9. Step-by-step derivation
            1. Applied rewrites10.5%

              \[\leadsto \frac{r}{-\sin a} \]

            if -7e15 < b < 5.2e18

            1. Initial program 98.6%

              \[\frac{r \cdot \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. *-commutativeN/A

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

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

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

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

                \[\leadsto \frac{r}{\color{blue}{\cos a}} \cdot b \]
            5. Applied rewrites95.8%

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

          Alternative 13: 53.5% accurate, 1.7× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{r}{-\sin a}\\ \mathbf{if}\;b \leq -7 \cdot 10^{+15}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;b \leq 5.2 \cdot 10^{+18}:\\ \;\;\;\;\frac{b}{\cos a} \cdot r\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
          (FPCore (r a b)
           :precision binary64
           (let* ((t_0 (/ r (- (sin a)))))
             (if (<= b -7e+15) t_0 (if (<= b 5.2e+18) (* (/ b (cos a)) r) t_0))))
          double code(double r, double a, double b) {
          	double t_0 = r / -sin(a);
          	double tmp;
          	if (b <= -7e+15) {
          		tmp = t_0;
          	} else if (b <= 5.2e+18) {
          		tmp = (b / cos(a)) * r;
          	} else {
          		tmp = t_0;
          	}
          	return tmp;
          }
          
          real(8) function code(r, a, b)
              real(8), intent (in) :: r
              real(8), intent (in) :: a
              real(8), intent (in) :: b
              real(8) :: t_0
              real(8) :: tmp
              t_0 = r / -sin(a)
              if (b <= (-7d+15)) then
                  tmp = t_0
              else if (b <= 5.2d+18) then
                  tmp = (b / cos(a)) * r
              else
                  tmp = t_0
              end if
              code = tmp
          end function
          
          public static double code(double r, double a, double b) {
          	double t_0 = r / -Math.sin(a);
          	double tmp;
          	if (b <= -7e+15) {
          		tmp = t_0;
          	} else if (b <= 5.2e+18) {
          		tmp = (b / Math.cos(a)) * r;
          	} else {
          		tmp = t_0;
          	}
          	return tmp;
          }
          
          def code(r, a, b):
          	t_0 = r / -math.sin(a)
          	tmp = 0
          	if b <= -7e+15:
          		tmp = t_0
          	elif b <= 5.2e+18:
          		tmp = (b / math.cos(a)) * r
          	else:
          		tmp = t_0
          	return tmp
          
          function code(r, a, b)
          	t_0 = Float64(r / Float64(-sin(a)))
          	tmp = 0.0
          	if (b <= -7e+15)
          		tmp = t_0;
          	elseif (b <= 5.2e+18)
          		tmp = Float64(Float64(b / cos(a)) * r);
          	else
          		tmp = t_0;
          	end
          	return tmp
          end
          
          function tmp_2 = code(r, a, b)
          	t_0 = r / -sin(a);
          	tmp = 0.0;
          	if (b <= -7e+15)
          		tmp = t_0;
          	elseif (b <= 5.2e+18)
          		tmp = (b / cos(a)) * r;
          	else
          		tmp = t_0;
          	end
          	tmp_2 = tmp;
          end
          
          code[r_, a_, b_] := Block[{t$95$0 = N[(r / (-N[Sin[a], $MachinePrecision])), $MachinePrecision]}, If[LessEqual[b, -7e+15], t$95$0, If[LessEqual[b, 5.2e+18], N[(N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision] * r), $MachinePrecision], t$95$0]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_0 := \frac{r}{-\sin a}\\
          \mathbf{if}\;b \leq -7 \cdot 10^{+15}:\\
          \;\;\;\;t\_0\\
          
          \mathbf{elif}\;b \leq 5.2 \cdot 10^{+18}:\\
          \;\;\;\;\frac{b}{\cos a} \cdot r\\
          
          \mathbf{else}:\\
          \;\;\;\;t\_0\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if b < -7e15 or 5.2e18 < b

            1. Initial program 49.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \frac{r}{\color{blue}{\frac{\mathsf{fma}\left(-b, \sin a, \cos a\right)}{b}}} \]
            8. Taylor expanded in b around inf

              \[\leadsto \frac{r}{-1 \cdot \color{blue}{\sin a}} \]
            9. Step-by-step derivation
              1. Applied rewrites10.5%

                \[\leadsto \frac{r}{-\sin a} \]

              if -7e15 < b < 5.2e18

              1. Initial program 98.6%

                \[\frac{r \cdot \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. *-commutativeN/A

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

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

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

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

                  \[\leadsto \frac{r}{\color{blue}{\cos a}} \cdot b \]
              5. Applied rewrites95.8%

                \[\leadsto \color{blue}{\frac{r}{\cos a} \cdot b} \]
              6. Step-by-step derivation
                1. Applied rewrites95.8%

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

              Alternative 14: 37.2% accurate, 1.7× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{r}{-\sin a}\\ \mathbf{if}\;b \leq -7 \cdot 10^{+15}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;b \leq 5.2 \cdot 10^{+18}:\\ \;\;\;\;b \cdot r\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
              (FPCore (r a b)
               :precision binary64
               (let* ((t_0 (/ r (- (sin a)))))
                 (if (<= b -7e+15) t_0 (if (<= b 5.2e+18) (* b r) t_0))))
              double code(double r, double a, double b) {
              	double t_0 = r / -sin(a);
              	double tmp;
              	if (b <= -7e+15) {
              		tmp = t_0;
              	} else if (b <= 5.2e+18) {
              		tmp = b * r;
              	} else {
              		tmp = t_0;
              	}
              	return tmp;
              }
              
              real(8) function code(r, a, b)
                  real(8), intent (in) :: r
                  real(8), intent (in) :: a
                  real(8), intent (in) :: b
                  real(8) :: t_0
                  real(8) :: tmp
                  t_0 = r / -sin(a)
                  if (b <= (-7d+15)) then
                      tmp = t_0
                  else if (b <= 5.2d+18) then
                      tmp = b * r
                  else
                      tmp = t_0
                  end if
                  code = tmp
              end function
              
              public static double code(double r, double a, double b) {
              	double t_0 = r / -Math.sin(a);
              	double tmp;
              	if (b <= -7e+15) {
              		tmp = t_0;
              	} else if (b <= 5.2e+18) {
              		tmp = b * r;
              	} else {
              		tmp = t_0;
              	}
              	return tmp;
              }
              
              def code(r, a, b):
              	t_0 = r / -math.sin(a)
              	tmp = 0
              	if b <= -7e+15:
              		tmp = t_0
              	elif b <= 5.2e+18:
              		tmp = b * r
              	else:
              		tmp = t_0
              	return tmp
              
              function code(r, a, b)
              	t_0 = Float64(r / Float64(-sin(a)))
              	tmp = 0.0
              	if (b <= -7e+15)
              		tmp = t_0;
              	elseif (b <= 5.2e+18)
              		tmp = Float64(b * r);
              	else
              		tmp = t_0;
              	end
              	return tmp
              end
              
              function tmp_2 = code(r, a, b)
              	t_0 = r / -sin(a);
              	tmp = 0.0;
              	if (b <= -7e+15)
              		tmp = t_0;
              	elseif (b <= 5.2e+18)
              		tmp = b * r;
              	else
              		tmp = t_0;
              	end
              	tmp_2 = tmp;
              end
              
              code[r_, a_, b_] := Block[{t$95$0 = N[(r / (-N[Sin[a], $MachinePrecision])), $MachinePrecision]}, If[LessEqual[b, -7e+15], t$95$0, If[LessEqual[b, 5.2e+18], N[(b * r), $MachinePrecision], t$95$0]]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              t_0 := \frac{r}{-\sin a}\\
              \mathbf{if}\;b \leq -7 \cdot 10^{+15}:\\
              \;\;\;\;t\_0\\
              
              \mathbf{elif}\;b \leq 5.2 \cdot 10^{+18}:\\
              \;\;\;\;b \cdot r\\
              
              \mathbf{else}:\\
              \;\;\;\;t\_0\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if b < -7e15 or 5.2e18 < b

                1. Initial program 49.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \frac{r}{\color{blue}{\frac{\mathsf{fma}\left(-b, \sin a, \cos a\right)}{b}}} \]
                8. Taylor expanded in b around inf

                  \[\leadsto \frac{r}{-1 \cdot \color{blue}{\sin a}} \]
                9. Step-by-step derivation
                  1. Applied rewrites10.5%

                    \[\leadsto \frac{r}{-\sin a} \]

                  if -7e15 < b < 5.2e18

                  1. Initial program 98.6%

                    \[\frac{r \cdot \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. *-commutativeN/A

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

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

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

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

                      \[\leadsto \frac{r}{\color{blue}{\cos a}} \cdot b \]
                  5. Applied rewrites95.8%

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

                    \[\leadsto b \cdot \color{blue}{r} \]
                  7. Step-by-step derivation
                    1. Applied rewrites66.5%

                      \[\leadsto b \cdot \color{blue}{r} \]
                  8. Recombined 2 regimes into one program.
                  9. Add Preprocessing

                  Alternative 15: 52.1% accurate, 1.7× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 3.6 \cdot 10^{+16}:\\ \;\;\;\;\frac{b \cdot r}{\cos \left(a + b\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{r}{-\sin a}\\ \end{array} \end{array} \]
                  (FPCore (r a b)
                   :precision binary64
                   (if (<= b 3.6e+16) (/ (* b r) (cos (+ a b))) (/ r (- (sin a)))))
                  double code(double r, double a, double b) {
                  	double tmp;
                  	if (b <= 3.6e+16) {
                  		tmp = (b * r) / cos((a + b));
                  	} else {
                  		tmp = r / -sin(a);
                  	}
                  	return tmp;
                  }
                  
                  real(8) function code(r, a, b)
                      real(8), intent (in) :: r
                      real(8), intent (in) :: a
                      real(8), intent (in) :: b
                      real(8) :: tmp
                      if (b <= 3.6d+16) then
                          tmp = (b * r) / cos((a + b))
                      else
                          tmp = r / -sin(a)
                      end if
                      code = tmp
                  end function
                  
                  public static double code(double r, double a, double b) {
                  	double tmp;
                  	if (b <= 3.6e+16) {
                  		tmp = (b * r) / Math.cos((a + b));
                  	} else {
                  		tmp = r / -Math.sin(a);
                  	}
                  	return tmp;
                  }
                  
                  def code(r, a, b):
                  	tmp = 0
                  	if b <= 3.6e+16:
                  		tmp = (b * r) / math.cos((a + b))
                  	else:
                  		tmp = r / -math.sin(a)
                  	return tmp
                  
                  function code(r, a, b)
                  	tmp = 0.0
                  	if (b <= 3.6e+16)
                  		tmp = Float64(Float64(b * r) / cos(Float64(a + b)));
                  	else
                  		tmp = Float64(r / Float64(-sin(a)));
                  	end
                  	return tmp
                  end
                  
                  function tmp_2 = code(r, a, b)
                  	tmp = 0.0;
                  	if (b <= 3.6e+16)
                  		tmp = (b * r) / cos((a + b));
                  	else
                  		tmp = r / -sin(a);
                  	end
                  	tmp_2 = tmp;
                  end
                  
                  code[r_, a_, b_] := If[LessEqual[b, 3.6e+16], N[(N[(b * r), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(r / (-N[Sin[a], $MachinePrecision])), $MachinePrecision]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  \mathbf{if}\;b \leq 3.6 \cdot 10^{+16}:\\
                  \;\;\;\;\frac{b \cdot r}{\cos \left(a + b\right)}\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;\frac{r}{-\sin a}\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if b < 3.6e16

                    1. Initial program 83.5%

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

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

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

                      \[\leadsto \frac{\color{blue}{b \cdot r}}{\cos \left(a + b\right)} \]

                    if 3.6e16 < b

                    1. Initial program 53.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                        \[\leadsto \frac{r}{\frac{\mathsf{fma}\left(-b, \color{blue}{\sin a}, \cos a\right)}{b}} \]
                      14. lower-cos.f6410.3

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

                      \[\leadsto \frac{r}{\color{blue}{\frac{\mathsf{fma}\left(-b, \sin a, \cos a\right)}{b}}} \]
                    8. Taylor expanded in b around inf

                      \[\leadsto \frac{r}{-1 \cdot \color{blue}{\sin a}} \]
                    9. Step-by-step derivation
                      1. Applied rewrites10.0%

                        \[\leadsto \frac{r}{-\sin a} \]
                    10. Recombined 2 regimes into one program.
                    11. Add Preprocessing

                    Alternative 16: 34.3% accurate, 36.7× speedup?

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

                      \[\frac{r \cdot \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. *-commutativeN/A

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

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

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

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

                        \[\leadsto \frac{r}{\color{blue}{\cos a}} \cdot b \]
                    5. Applied rewrites53.6%

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

                      \[\leadsto b \cdot \color{blue}{r} \]
                    7. Step-by-step derivation
                      1. Applied rewrites37.6%

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

                      Reproduce

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