rsin A (should all be same)

Percentage Accurate: 76.7% → 99.5%
Time: 14.4s
Alternatives: 11
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 11 alternatives:

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

Initial Program: 76.7% 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.7× speedup?

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

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

    \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
  2. Step-by-step derivation
    1. associate-/l*73.7%

      \[\leadsto \color{blue}{\frac{r}{\frac{\cos \left(a + b\right)}{\sin b}}} \]
    2. +-commutative73.7%

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

    \[\leadsto \color{blue}{\frac{r}{\frac{\cos \left(b + a\right)}{\sin b}}} \]
  4. Step-by-step derivation
    1. cos-sum99.4%

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

    \[\leadsto \frac{r}{\frac{\color{blue}{\cos b \cdot \cos a - \sin b \cdot \sin a}}{\sin b}} \]
  6. Step-by-step derivation
    1. div-sub99.4%

      \[\leadsto \frac{r}{\color{blue}{\frac{\cos b \cdot \cos a}{\sin b} - \frac{\sin b \cdot \sin a}{\sin b}}} \]
    2. sub-neg99.4%

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

      \[\leadsto \frac{r}{\frac{\color{blue}{\cos a \cdot \cos b}}{\sin b} + \left(-\frac{\sin b \cdot \sin a}{\sin b}\right)} \]
    4. *-un-lft-identity99.4%

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

      \[\leadsto \frac{r}{\color{blue}{\frac{\cos a}{1} \cdot \frac{\cos b}{\sin b}} + \left(-\frac{\sin b \cdot \sin a}{\sin b}\right)} \]
    6. clear-num99.3%

      \[\leadsto \frac{r}{\frac{\cos a}{1} \cdot \color{blue}{\frac{1}{\frac{\sin b}{\cos b}}} + \left(-\frac{\sin b \cdot \sin a}{\sin b}\right)} \]
    7. quot-tan99.4%

      \[\leadsto \frac{r}{\frac{\cos a}{1} \cdot \frac{1}{\color{blue}{\tan b}} + \left(-\frac{\sin b \cdot \sin a}{\sin b}\right)} \]
  7. Applied egg-rr99.4%

    \[\leadsto \frac{r}{\color{blue}{\frac{\cos a}{1} \cdot \frac{1}{\tan b} + \left(-\frac{\sin b \cdot \sin a}{\sin b}\right)}} \]
  8. Step-by-step derivation
    1. sub-neg99.4%

      \[\leadsto \frac{r}{\color{blue}{\frac{\cos a}{1} \cdot \frac{1}{\tan b} - \frac{\sin b \cdot \sin a}{\sin b}}} \]
    2. /-rgt-identity99.4%

      \[\leadsto \frac{r}{\color{blue}{\cos a} \cdot \frac{1}{\tan b} - \frac{\sin b \cdot \sin a}{\sin b}} \]
    3. associate-*r/99.5%

      \[\leadsto \frac{r}{\color{blue}{\frac{\cos a \cdot 1}{\tan b}} - \frac{\sin b \cdot \sin a}{\sin b}} \]
    4. *-rgt-identity99.5%

      \[\leadsto \frac{r}{\frac{\color{blue}{\cos a}}{\tan b} - \frac{\sin b \cdot \sin a}{\sin b}} \]
    5. *-lft-identity99.5%

      \[\leadsto \frac{r}{\frac{\cos a}{\tan b} - \frac{\sin b \cdot \sin a}{\color{blue}{1 \cdot \sin b}}} \]
    6. times-frac99.5%

      \[\leadsto \frac{r}{\frac{\cos a}{\tan b} - \color{blue}{\frac{\sin b}{1} \cdot \frac{\sin a}{\sin b}}} \]
    7. /-rgt-identity99.5%

      \[\leadsto \frac{r}{\frac{\cos a}{\tan b} - \color{blue}{\sin b} \cdot \frac{\sin a}{\sin b}} \]
  9. Simplified99.5%

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

    \[\leadsto \frac{r}{\frac{\cos a}{\tan b} - \color{blue}{\sin a}} \]
  11. Final simplification99.5%

    \[\leadsto \frac{r}{\frac{\cos a}{\tan b} - \sin a} \]

Alternative 2: 75.6% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.000205 \lor \neg \left(a \leq 1.6 \cdot 10^{+36}\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -2.05e-4 or 1.5999999999999999e36 < a

    1. Initial program 54.2%

      \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
    2. Step-by-step derivation
      1. associate-/l*54.3%

        \[\leadsto \color{blue}{\frac{r}{\frac{\cos \left(a + b\right)}{\sin b}}} \]
      2. remove-double-neg54.3%

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

        \[\leadsto \frac{r}{\frac{\cos \left(a + b\right)}{-\color{blue}{\sin \left(-b\right)}}} \]
      4. neg-mul-154.3%

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

        \[\leadsto \frac{r}{\color{blue}{\frac{\frac{\cos \left(a + b\right)}{-1}}{\sin \left(-b\right)}}} \]
      6. associate-/l*54.2%

        \[\leadsto \color{blue}{\frac{r \cdot \sin \left(-b\right)}{\frac{\cos \left(a + b\right)}{-1}}} \]
      7. *-commutative54.2%

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

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

        \[\leadsto \color{blue}{\frac{\sin \left(-b\right) \cdot -1}{\cos \left(a + b\right)}} \cdot r \]
      10. sin-neg54.2%

        \[\leadsto \frac{\color{blue}{\left(-\sin b\right)} \cdot -1}{\cos \left(a + b\right)} \cdot r \]
      11. distribute-lft-neg-in54.2%

        \[\leadsto \frac{\color{blue}{-\sin b \cdot -1}}{\cos \left(a + b\right)} \cdot r \]
      12. distribute-rgt-neg-in54.2%

        \[\leadsto \frac{\color{blue}{\sin b \cdot \left(--1\right)}}{\cos \left(a + b\right)} \cdot r \]
      13. associate-/l*54.2%

        \[\leadsto \color{blue}{\frac{\sin b}{\frac{\cos \left(a + b\right)}{--1}}} \cdot r \]
      14. metadata-eval54.2%

        \[\leadsto \frac{\sin b}{\frac{\cos \left(a + b\right)}{\color{blue}{1}}} \cdot r \]
      15. /-rgt-identity54.2%

        \[\leadsto \frac{\sin b}{\color{blue}{\cos \left(a + b\right)}} \cdot r \]
      16. +-commutative54.2%

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

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

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

    if -2.05e-4 < a < 1.5999999999999999e36

    1. Initial program 94.9%

      \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
    2. Step-by-step derivation
      1. associate-/l*94.8%

        \[\leadsto \color{blue}{\frac{r}{\frac{\cos \left(a + b\right)}{\sin b}}} \]
      2. remove-double-neg94.8%

        \[\leadsto \frac{r}{\frac{\cos \left(a + b\right)}{\color{blue}{-\left(-\sin b\right)}}} \]
      3. sin-neg94.8%

        \[\leadsto \frac{r}{\frac{\cos \left(a + b\right)}{-\color{blue}{\sin \left(-b\right)}}} \]
      4. neg-mul-194.8%

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

        \[\leadsto \frac{r}{\color{blue}{\frac{\frac{\cos \left(a + b\right)}{-1}}{\sin \left(-b\right)}}} \]
      6. associate-/l*94.9%

        \[\leadsto \color{blue}{\frac{r \cdot \sin \left(-b\right)}{\frac{\cos \left(a + b\right)}{-1}}} \]
      7. *-commutative94.9%

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

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

        \[\leadsto \color{blue}{\frac{\sin \left(-b\right) \cdot -1}{\cos \left(a + b\right)}} \cdot r \]
      10. sin-neg94.9%

        \[\leadsto \frac{\color{blue}{\left(-\sin b\right)} \cdot -1}{\cos \left(a + b\right)} \cdot r \]
      11. distribute-lft-neg-in94.9%

        \[\leadsto \frac{\color{blue}{-\sin b \cdot -1}}{\cos \left(a + b\right)} \cdot r \]
      12. distribute-rgt-neg-in94.9%

        \[\leadsto \frac{\color{blue}{\sin b \cdot \left(--1\right)}}{\cos \left(a + b\right)} \cdot r \]
      13. associate-/l*94.9%

        \[\leadsto \color{blue}{\frac{\sin b}{\frac{\cos \left(a + b\right)}{--1}}} \cdot r \]
      14. metadata-eval94.9%

        \[\leadsto \frac{\sin b}{\frac{\cos \left(a + b\right)}{\color{blue}{1}}} \cdot r \]
      15. /-rgt-identity94.9%

        \[\leadsto \frac{\sin b}{\color{blue}{\cos \left(a + b\right)}} \cdot r \]
      16. +-commutative94.9%

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

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

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

        \[\leadsto \color{blue}{\tan b} \cdot r \]
      2. expm1-log1p-u81.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\tan b\right)\right)} \cdot r \]
      3. expm1-udef51.0%

        \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\tan b\right)} - 1\right)} \cdot r \]
    6. Applied egg-rr51.0%

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\tan b\right)} - 1\right)} \cdot r \]
    7. Step-by-step derivation
      1. expm1-def81.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\tan b\right)\right)} \cdot r \]
      2. expm1-log1p95.1%

        \[\leadsto \color{blue}{\tan b} \cdot r \]
    8. Simplified95.1%

      \[\leadsto \color{blue}{\tan b} \cdot r \]
  3. Recombined 2 regimes into one program.
  4. Final simplification73.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -0.000205 \lor \neg \left(a \leq 1.6 \cdot 10^{+36}\right):\\ \;\;\;\;r \cdot \frac{\sin b}{\cos a}\\ \mathbf{else}:\\ \;\;\;\;r \cdot \tan b\\ \end{array} \]

Alternative 3: 75.6% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.000165 \lor \neg \left(a \leq 1.6 \cdot 10^{+36}\right):\\
\;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -1.65e-4 or 1.5999999999999999e36 < a

    1. Initial program 54.2%

      \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
    2. Step-by-step derivation
      1. associate-/l*54.3%

        \[\leadsto \color{blue}{\frac{r}{\frac{\cos \left(a + b\right)}{\sin b}}} \]
      2. +-commutative54.3%

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

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

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

    if -1.65e-4 < a < 1.5999999999999999e36

    1. Initial program 94.9%

      \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
    2. Step-by-step derivation
      1. associate-/l*94.8%

        \[\leadsto \color{blue}{\frac{r}{\frac{\cos \left(a + b\right)}{\sin b}}} \]
      2. remove-double-neg94.8%

        \[\leadsto \frac{r}{\frac{\cos \left(a + b\right)}{\color{blue}{-\left(-\sin b\right)}}} \]
      3. sin-neg94.8%

        \[\leadsto \frac{r}{\frac{\cos \left(a + b\right)}{-\color{blue}{\sin \left(-b\right)}}} \]
      4. neg-mul-194.8%

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

        \[\leadsto \frac{r}{\color{blue}{\frac{\frac{\cos \left(a + b\right)}{-1}}{\sin \left(-b\right)}}} \]
      6. associate-/l*94.9%

        \[\leadsto \color{blue}{\frac{r \cdot \sin \left(-b\right)}{\frac{\cos \left(a + b\right)}{-1}}} \]
      7. *-commutative94.9%

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

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

        \[\leadsto \color{blue}{\frac{\sin \left(-b\right) \cdot -1}{\cos \left(a + b\right)}} \cdot r \]
      10. sin-neg94.9%

        \[\leadsto \frac{\color{blue}{\left(-\sin b\right)} \cdot -1}{\cos \left(a + b\right)} \cdot r \]
      11. distribute-lft-neg-in94.9%

        \[\leadsto \frac{\color{blue}{-\sin b \cdot -1}}{\cos \left(a + b\right)} \cdot r \]
      12. distribute-rgt-neg-in94.9%

        \[\leadsto \frac{\color{blue}{\sin b \cdot \left(--1\right)}}{\cos \left(a + b\right)} \cdot r \]
      13. associate-/l*94.9%

        \[\leadsto \color{blue}{\frac{\sin b}{\frac{\cos \left(a + b\right)}{--1}}} \cdot r \]
      14. metadata-eval94.9%

        \[\leadsto \frac{\sin b}{\frac{\cos \left(a + b\right)}{\color{blue}{1}}} \cdot r \]
      15. /-rgt-identity94.9%

        \[\leadsto \frac{\sin b}{\color{blue}{\cos \left(a + b\right)}} \cdot r \]
      16. +-commutative94.9%

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

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

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

        \[\leadsto \color{blue}{\tan b} \cdot r \]
      2. expm1-log1p-u81.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\tan b\right)\right)} \cdot r \]
      3. expm1-udef51.0%

        \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\tan b\right)} - 1\right)} \cdot r \]
    6. Applied egg-rr51.0%

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\tan b\right)} - 1\right)} \cdot r \]
    7. Step-by-step derivation
      1. expm1-def81.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\tan b\right)\right)} \cdot r \]
      2. expm1-log1p95.1%

        \[\leadsto \color{blue}{\tan b} \cdot r \]
    8. Simplified95.1%

      \[\leadsto \color{blue}{\tan b} \cdot r \]
  3. Recombined 2 regimes into one program.
  4. Final simplification73.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -0.000165 \lor \neg \left(a \leq 1.6 \cdot 10^{+36}\right):\\ \;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\ \mathbf{else}:\\ \;\;\;\;r \cdot \tan b\\ \end{array} \]

Alternative 4: 75.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -7.5 \cdot 10^{-5}:\\ \;\;\;\;\frac{r \cdot \sin b}{\cos a}\\ \mathbf{elif}\;a \leq 1.6 \cdot 10^{+36}:\\ \;\;\;\;r \cdot \tan b\\ \mathbf{else}:\\ \;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\ \end{array} \end{array} \]
(FPCore (r a b)
 :precision binary64
 (if (<= a -7.5e-5)
   (/ (* r (sin b)) (cos a))
   (if (<= a 1.6e+36) (* r (tan b)) (/ r (/ (cos a) (sin b))))))
double code(double r, double a, double b) {
	double tmp;
	if (a <= -7.5e-5) {
		tmp = (r * sin(b)) / cos(a);
	} else if (a <= 1.6e+36) {
		tmp = r * tan(b);
	} else {
		tmp = r / (cos(a) / sin(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 (a <= (-7.5d-5)) then
        tmp = (r * sin(b)) / cos(a)
    else if (a <= 1.6d+36) then
        tmp = r * tan(b)
    else
        tmp = r / (cos(a) / sin(b))
    end if
    code = tmp
end function
public static double code(double r, double a, double b) {
	double tmp;
	if (a <= -7.5e-5) {
		tmp = (r * Math.sin(b)) / Math.cos(a);
	} else if (a <= 1.6e+36) {
		tmp = r * Math.tan(b);
	} else {
		tmp = r / (Math.cos(a) / Math.sin(b));
	}
	return tmp;
}
def code(r, a, b):
	tmp = 0
	if a <= -7.5e-5:
		tmp = (r * math.sin(b)) / math.cos(a)
	elif a <= 1.6e+36:
		tmp = r * math.tan(b)
	else:
		tmp = r / (math.cos(a) / math.sin(b))
	return tmp
function code(r, a, b)
	tmp = 0.0
	if (a <= -7.5e-5)
		tmp = Float64(Float64(r * sin(b)) / cos(a));
	elseif (a <= 1.6e+36)
		tmp = Float64(r * tan(b));
	else
		tmp = Float64(r / Float64(cos(a) / sin(b)));
	end
	return tmp
end
function tmp_2 = code(r, a, b)
	tmp = 0.0;
	if (a <= -7.5e-5)
		tmp = (r * sin(b)) / cos(a);
	elseif (a <= 1.6e+36)
		tmp = r * tan(b);
	else
		tmp = r / (cos(a) / sin(b));
	end
	tmp_2 = tmp;
end
code[r_, a_, b_] := If[LessEqual[a, -7.5e-5], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 1.6e+36], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], N[(r / N[(N[Cos[a], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \leq -7.5 \cdot 10^{-5}:\\
\;\;\;\;\frac{r \cdot \sin b}{\cos a}\\

\mathbf{elif}\;a \leq 1.6 \cdot 10^{+36}:\\
\;\;\;\;r \cdot \tan b\\

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


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

    1. Initial program 49.9%

      \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
    2. Step-by-step derivation
      1. +-commutative49.9%

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

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

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

    if -7.49999999999999934e-5 < a < 1.5999999999999999e36

    1. Initial program 94.9%

      \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
    2. Step-by-step derivation
      1. associate-/l*94.8%

        \[\leadsto \color{blue}{\frac{r}{\frac{\cos \left(a + b\right)}{\sin b}}} \]
      2. remove-double-neg94.8%

        \[\leadsto \frac{r}{\frac{\cos \left(a + b\right)}{\color{blue}{-\left(-\sin b\right)}}} \]
      3. sin-neg94.8%

        \[\leadsto \frac{r}{\frac{\cos \left(a + b\right)}{-\color{blue}{\sin \left(-b\right)}}} \]
      4. neg-mul-194.8%

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

        \[\leadsto \frac{r}{\color{blue}{\frac{\frac{\cos \left(a + b\right)}{-1}}{\sin \left(-b\right)}}} \]
      6. associate-/l*94.9%

        \[\leadsto \color{blue}{\frac{r \cdot \sin \left(-b\right)}{\frac{\cos \left(a + b\right)}{-1}}} \]
      7. *-commutative94.9%

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

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

        \[\leadsto \color{blue}{\frac{\sin \left(-b\right) \cdot -1}{\cos \left(a + b\right)}} \cdot r \]
      10. sin-neg94.9%

        \[\leadsto \frac{\color{blue}{\left(-\sin b\right)} \cdot -1}{\cos \left(a + b\right)} \cdot r \]
      11. distribute-lft-neg-in94.9%

        \[\leadsto \frac{\color{blue}{-\sin b \cdot -1}}{\cos \left(a + b\right)} \cdot r \]
      12. distribute-rgt-neg-in94.9%

        \[\leadsto \frac{\color{blue}{\sin b \cdot \left(--1\right)}}{\cos \left(a + b\right)} \cdot r \]
      13. associate-/l*94.9%

        \[\leadsto \color{blue}{\frac{\sin b}{\frac{\cos \left(a + b\right)}{--1}}} \cdot r \]
      14. metadata-eval94.9%

        \[\leadsto \frac{\sin b}{\frac{\cos \left(a + b\right)}{\color{blue}{1}}} \cdot r \]
      15. /-rgt-identity94.9%

        \[\leadsto \frac{\sin b}{\color{blue}{\cos \left(a + b\right)}} \cdot r \]
      16. +-commutative94.9%

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

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

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

        \[\leadsto \color{blue}{\tan b} \cdot r \]
      2. expm1-log1p-u81.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\tan b\right)\right)} \cdot r \]
      3. expm1-udef51.0%

        \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\tan b\right)} - 1\right)} \cdot r \]
    6. Applied egg-rr51.0%

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\tan b\right)} - 1\right)} \cdot r \]
    7. Step-by-step derivation
      1. expm1-def81.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\tan b\right)\right)} \cdot r \]
      2. expm1-log1p95.1%

        \[\leadsto \color{blue}{\tan b} \cdot r \]
    8. Simplified95.1%

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

    if 1.5999999999999999e36 < a

    1. Initial program 59.2%

      \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
    2. Step-by-step derivation
      1. associate-/l*59.3%

        \[\leadsto \color{blue}{\frac{r}{\frac{\cos \left(a + b\right)}{\sin b}}} \]
      2. +-commutative59.3%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -7.5 \cdot 10^{-5}:\\ \;\;\;\;\frac{r \cdot \sin b}{\cos a}\\ \mathbf{elif}\;a \leq 1.6 \cdot 10^{+36}:\\ \;\;\;\;r \cdot \tan b\\ \mathbf{else}:\\ \;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\ \end{array} \]

Alternative 5: 76.7% accurate, 1.0× speedup?

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

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

    \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
  2. Step-by-step derivation
    1. associate-/l*73.7%

      \[\leadsto \color{blue}{\frac{r}{\frac{\cos \left(a + b\right)}{\sin b}}} \]
    2. +-commutative73.7%

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

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

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

    \[\leadsto \color{blue}{\frac{r}{\cos \left(b + a\right)} \cdot \sin b} \]
  6. Final simplification73.7%

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

Alternative 6: 76.7% accurate, 1.0× speedup?

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

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

    \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
  2. Step-by-step derivation
    1. associate-/l*73.7%

      \[\leadsto \color{blue}{\frac{r}{\frac{\cos \left(a + b\right)}{\sin b}}} \]
    2. remove-double-neg73.7%

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

      \[\leadsto \frac{r}{\frac{\cos \left(a + b\right)}{-\color{blue}{\sin \left(-b\right)}}} \]
    4. neg-mul-173.7%

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

      \[\leadsto \frac{r}{\color{blue}{\frac{\frac{\cos \left(a + b\right)}{-1}}{\sin \left(-b\right)}}} \]
    6. associate-/l*73.8%

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

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

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

      \[\leadsto \color{blue}{\frac{\sin \left(-b\right) \cdot -1}{\cos \left(a + b\right)}} \cdot r \]
    10. sin-neg73.8%

      \[\leadsto \frac{\color{blue}{\left(-\sin b\right)} \cdot -1}{\cos \left(a + b\right)} \cdot r \]
    11. distribute-lft-neg-in73.8%

      \[\leadsto \frac{\color{blue}{-\sin b \cdot -1}}{\cos \left(a + b\right)} \cdot r \]
    12. distribute-rgt-neg-in73.8%

      \[\leadsto \frac{\color{blue}{\sin b \cdot \left(--1\right)}}{\cos \left(a + b\right)} \cdot r \]
    13. associate-/l*73.8%

      \[\leadsto \color{blue}{\frac{\sin b}{\frac{\cos \left(a + b\right)}{--1}}} \cdot r \]
    14. metadata-eval73.8%

      \[\leadsto \frac{\sin b}{\frac{\cos \left(a + b\right)}{\color{blue}{1}}} \cdot r \]
    15. /-rgt-identity73.8%

      \[\leadsto \frac{\sin b}{\color{blue}{\cos \left(a + b\right)}} \cdot r \]
    16. +-commutative73.8%

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

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

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

Alternative 7: 76.7% 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}
Derivation
  1. Initial program 73.8%

    \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
  2. Final simplification73.8%

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

Alternative 8: 76.4% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.1 \lor \neg \left(b \leq 3.8 \cdot 10^{-8}\right):\\
\;\;\;\;r \cdot \tan b\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -0.10000000000000001 or 3.80000000000000028e-8 < b

    1. Initial program 52.9%

      \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
    2. Step-by-step derivation
      1. associate-/l*52.8%

        \[\leadsto \color{blue}{\frac{r}{\frac{\cos \left(a + b\right)}{\sin b}}} \]
      2. remove-double-neg52.8%

        \[\leadsto \frac{r}{\frac{\cos \left(a + b\right)}{\color{blue}{-\left(-\sin b\right)}}} \]
      3. sin-neg52.8%

        \[\leadsto \frac{r}{\frac{\cos \left(a + b\right)}{-\color{blue}{\sin \left(-b\right)}}} \]
      4. neg-mul-152.8%

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

        \[\leadsto \frac{r}{\color{blue}{\frac{\frac{\cos \left(a + b\right)}{-1}}{\sin \left(-b\right)}}} \]
      6. associate-/l*52.9%

        \[\leadsto \color{blue}{\frac{r \cdot \sin \left(-b\right)}{\frac{\cos \left(a + b\right)}{-1}}} \]
      7. *-commutative52.9%

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

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

        \[\leadsto \color{blue}{\frac{\sin \left(-b\right) \cdot -1}{\cos \left(a + b\right)}} \cdot r \]
      10. sin-neg52.9%

        \[\leadsto \frac{\color{blue}{\left(-\sin b\right)} \cdot -1}{\cos \left(a + b\right)} \cdot r \]
      11. distribute-lft-neg-in52.9%

        \[\leadsto \frac{\color{blue}{-\sin b \cdot -1}}{\cos \left(a + b\right)} \cdot r \]
      12. distribute-rgt-neg-in52.9%

        \[\leadsto \frac{\color{blue}{\sin b \cdot \left(--1\right)}}{\cos \left(a + b\right)} \cdot r \]
      13. associate-/l*52.9%

        \[\leadsto \color{blue}{\frac{\sin b}{\frac{\cos \left(a + b\right)}{--1}}} \cdot r \]
      14. metadata-eval52.9%

        \[\leadsto \frac{\sin b}{\frac{\cos \left(a + b\right)}{\color{blue}{1}}} \cdot r \]
      15. /-rgt-identity52.9%

        \[\leadsto \frac{\sin b}{\color{blue}{\cos \left(a + b\right)}} \cdot r \]
      16. +-commutative52.9%

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

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

      \[\leadsto \frac{\sin b}{\color{blue}{\cos b}} \cdot r \]
    5. Step-by-step derivation
      1. tan-quot52.9%

        \[\leadsto \color{blue}{\tan b} \cdot r \]
      2. expm1-log1p-u38.7%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\tan b\right)\right)} \cdot r \]
      3. expm1-udef37.8%

        \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\tan b\right)} - 1\right)} \cdot r \]
    6. Applied egg-rr37.8%

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\tan b\right)} - 1\right)} \cdot r \]
    7. Step-by-step derivation
      1. expm1-def38.7%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\tan b\right)\right)} \cdot r \]
      2. expm1-log1p52.9%

        \[\leadsto \color{blue}{\tan b} \cdot r \]
    8. Simplified52.9%

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

    if -0.10000000000000001 < b < 3.80000000000000028e-8

    1. Initial program 97.5%

      \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
    2. Step-by-step derivation
      1. associate-/l*97.4%

        \[\leadsto \color{blue}{\frac{r}{\frac{\cos \left(a + b\right)}{\sin b}}} \]
      2. remove-double-neg97.4%

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

        \[\leadsto \frac{r}{\frac{\cos \left(a + b\right)}{-\color{blue}{\sin \left(-b\right)}}} \]
      4. neg-mul-197.4%

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

        \[\leadsto \frac{r}{\color{blue}{\frac{\frac{\cos \left(a + b\right)}{-1}}{\sin \left(-b\right)}}} \]
      6. associate-/l*97.5%

        \[\leadsto \color{blue}{\frac{r \cdot \sin \left(-b\right)}{\frac{\cos \left(a + b\right)}{-1}}} \]
      7. *-commutative97.5%

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

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

        \[\leadsto \color{blue}{\frac{\sin \left(-b\right) \cdot -1}{\cos \left(a + b\right)}} \cdot r \]
      10. sin-neg97.5%

        \[\leadsto \frac{\color{blue}{\left(-\sin b\right)} \cdot -1}{\cos \left(a + b\right)} \cdot r \]
      11. distribute-lft-neg-in97.5%

        \[\leadsto \frac{\color{blue}{-\sin b \cdot -1}}{\cos \left(a + b\right)} \cdot r \]
      12. distribute-rgt-neg-in97.5%

        \[\leadsto \frac{\color{blue}{\sin b \cdot \left(--1\right)}}{\cos \left(a + b\right)} \cdot r \]
      13. associate-/l*97.5%

        \[\leadsto \color{blue}{\frac{\sin b}{\frac{\cos \left(a + b\right)}{--1}}} \cdot r \]
      14. metadata-eval97.5%

        \[\leadsto \frac{\sin b}{\frac{\cos \left(a + b\right)}{\color{blue}{1}}} \cdot r \]
      15. /-rgt-identity97.5%

        \[\leadsto \frac{\sin b}{\color{blue}{\cos \left(a + b\right)}} \cdot r \]
      16. +-commutative97.5%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -0.1 \lor \neg \left(b \leq 3.8 \cdot 10^{-8}\right):\\ \;\;\;\;r \cdot \tan b\\ \mathbf{else}:\\ \;\;\;\;r \cdot \frac{b}{\cos a}\\ \end{array} \]

Alternative 9: 76.4% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.1 \lor \neg \left(b \leq 3.8 \cdot 10^{-8}\right):\\
\;\;\;\;r \cdot \tan b\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -0.10000000000000001 or 3.80000000000000028e-8 < b

    1. Initial program 52.9%

      \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
    2. Step-by-step derivation
      1. associate-/l*52.8%

        \[\leadsto \color{blue}{\frac{r}{\frac{\cos \left(a + b\right)}{\sin b}}} \]
      2. remove-double-neg52.8%

        \[\leadsto \frac{r}{\frac{\cos \left(a + b\right)}{\color{blue}{-\left(-\sin b\right)}}} \]
      3. sin-neg52.8%

        \[\leadsto \frac{r}{\frac{\cos \left(a + b\right)}{-\color{blue}{\sin \left(-b\right)}}} \]
      4. neg-mul-152.8%

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

        \[\leadsto \frac{r}{\color{blue}{\frac{\frac{\cos \left(a + b\right)}{-1}}{\sin \left(-b\right)}}} \]
      6. associate-/l*52.9%

        \[\leadsto \color{blue}{\frac{r \cdot \sin \left(-b\right)}{\frac{\cos \left(a + b\right)}{-1}}} \]
      7. *-commutative52.9%

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

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

        \[\leadsto \color{blue}{\frac{\sin \left(-b\right) \cdot -1}{\cos \left(a + b\right)}} \cdot r \]
      10. sin-neg52.9%

        \[\leadsto \frac{\color{blue}{\left(-\sin b\right)} \cdot -1}{\cos \left(a + b\right)} \cdot r \]
      11. distribute-lft-neg-in52.9%

        \[\leadsto \frac{\color{blue}{-\sin b \cdot -1}}{\cos \left(a + b\right)} \cdot r \]
      12. distribute-rgt-neg-in52.9%

        \[\leadsto \frac{\color{blue}{\sin b \cdot \left(--1\right)}}{\cos \left(a + b\right)} \cdot r \]
      13. associate-/l*52.9%

        \[\leadsto \color{blue}{\frac{\sin b}{\frac{\cos \left(a + b\right)}{--1}}} \cdot r \]
      14. metadata-eval52.9%

        \[\leadsto \frac{\sin b}{\frac{\cos \left(a + b\right)}{\color{blue}{1}}} \cdot r \]
      15. /-rgt-identity52.9%

        \[\leadsto \frac{\sin b}{\color{blue}{\cos \left(a + b\right)}} \cdot r \]
      16. +-commutative52.9%

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

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

      \[\leadsto \frac{\sin b}{\color{blue}{\cos b}} \cdot r \]
    5. Step-by-step derivation
      1. tan-quot52.9%

        \[\leadsto \color{blue}{\tan b} \cdot r \]
      2. expm1-log1p-u38.7%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\tan b\right)\right)} \cdot r \]
      3. expm1-udef37.8%

        \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\tan b\right)} - 1\right)} \cdot r \]
    6. Applied egg-rr37.8%

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\tan b\right)} - 1\right)} \cdot r \]
    7. Step-by-step derivation
      1. expm1-def38.7%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\tan b\right)\right)} \cdot r \]
      2. expm1-log1p52.9%

        \[\leadsto \color{blue}{\tan b} \cdot r \]
    8. Simplified52.9%

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

    if -0.10000000000000001 < b < 3.80000000000000028e-8

    1. Initial program 97.5%

      \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
    2. Step-by-step derivation
      1. associate-/l*97.4%

        \[\leadsto \color{blue}{\frac{r}{\frac{\cos \left(a + b\right)}{\sin b}}} \]
      2. remove-double-neg97.4%

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

        \[\leadsto \frac{r}{\frac{\cos \left(a + b\right)}{-\color{blue}{\sin \left(-b\right)}}} \]
      4. neg-mul-197.4%

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

        \[\leadsto \frac{r}{\color{blue}{\frac{\frac{\cos \left(a + b\right)}{-1}}{\sin \left(-b\right)}}} \]
      6. associate-/l*97.5%

        \[\leadsto \color{blue}{\frac{r \cdot \sin \left(-b\right)}{\frac{\cos \left(a + b\right)}{-1}}} \]
      7. *-commutative97.5%

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

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

        \[\leadsto \color{blue}{\frac{\sin \left(-b\right) \cdot -1}{\cos \left(a + b\right)}} \cdot r \]
      10. sin-neg97.5%

        \[\leadsto \frac{\color{blue}{\left(-\sin b\right)} \cdot -1}{\cos \left(a + b\right)} \cdot r \]
      11. distribute-lft-neg-in97.5%

        \[\leadsto \frac{\color{blue}{-\sin b \cdot -1}}{\cos \left(a + b\right)} \cdot r \]
      12. distribute-rgt-neg-in97.5%

        \[\leadsto \frac{\color{blue}{\sin b \cdot \left(--1\right)}}{\cos \left(a + b\right)} \cdot r \]
      13. associate-/l*97.5%

        \[\leadsto \color{blue}{\frac{\sin b}{\frac{\cos \left(a + b\right)}{--1}}} \cdot r \]
      14. metadata-eval97.5%

        \[\leadsto \frac{\sin b}{\frac{\cos \left(a + b\right)}{\color{blue}{1}}} \cdot r \]
      15. /-rgt-identity97.5%

        \[\leadsto \frac{\sin b}{\color{blue}{\cos \left(a + b\right)}} \cdot r \]
      16. +-commutative97.5%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -0.1 \lor \neg \left(b \leq 3.8 \cdot 10^{-8}\right):\\ \;\;\;\;r \cdot \tan b\\ \mathbf{else}:\\ \;\;\;\;\frac{r \cdot b}{\cos a}\\ \end{array} \]

Alternative 10: 60.1% accurate, 2.0× speedup?

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

\\
r \cdot \tan b
\end{array}
Derivation
  1. Initial program 73.8%

    \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
  2. Step-by-step derivation
    1. associate-/l*73.7%

      \[\leadsto \color{blue}{\frac{r}{\frac{\cos \left(a + b\right)}{\sin b}}} \]
    2. remove-double-neg73.7%

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

      \[\leadsto \frac{r}{\frac{\cos \left(a + b\right)}{-\color{blue}{\sin \left(-b\right)}}} \]
    4. neg-mul-173.7%

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

      \[\leadsto \frac{r}{\color{blue}{\frac{\frac{\cos \left(a + b\right)}{-1}}{\sin \left(-b\right)}}} \]
    6. associate-/l*73.8%

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

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

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

      \[\leadsto \color{blue}{\frac{\sin \left(-b\right) \cdot -1}{\cos \left(a + b\right)}} \cdot r \]
    10. sin-neg73.8%

      \[\leadsto \frac{\color{blue}{\left(-\sin b\right)} \cdot -1}{\cos \left(a + b\right)} \cdot r \]
    11. distribute-lft-neg-in73.8%

      \[\leadsto \frac{\color{blue}{-\sin b \cdot -1}}{\cos \left(a + b\right)} \cdot r \]
    12. distribute-rgt-neg-in73.8%

      \[\leadsto \frac{\color{blue}{\sin b \cdot \left(--1\right)}}{\cos \left(a + b\right)} \cdot r \]
    13. associate-/l*73.8%

      \[\leadsto \color{blue}{\frac{\sin b}{\frac{\cos \left(a + b\right)}{--1}}} \cdot r \]
    14. metadata-eval73.8%

      \[\leadsto \frac{\sin b}{\frac{\cos \left(a + b\right)}{\color{blue}{1}}} \cdot r \]
    15. /-rgt-identity73.8%

      \[\leadsto \frac{\sin b}{\color{blue}{\cos \left(a + b\right)}} \cdot r \]
    16. +-commutative73.8%

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

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

    \[\leadsto \frac{\sin b}{\color{blue}{\cos b}} \cdot r \]
  5. Step-by-step derivation
    1. tan-quot57.2%

      \[\leadsto \color{blue}{\tan b} \cdot r \]
    2. expm1-log1p-u49.6%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\tan b\right)\right)} \cdot r \]
    3. expm1-udef34.0%

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\tan b\right)} - 1\right)} \cdot r \]
  6. Applied egg-rr34.0%

    \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\tan b\right)} - 1\right)} \cdot r \]
  7. Step-by-step derivation
    1. expm1-def49.6%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\tan b\right)\right)} \cdot r \]
    2. expm1-log1p57.2%

      \[\leadsto \color{blue}{\tan b} \cdot r \]
  8. Simplified57.2%

    \[\leadsto \color{blue}{\tan b} \cdot r \]
  9. Final simplification57.2%

    \[\leadsto r \cdot \tan b \]

Alternative 11: 34.3% accurate, 69.0× speedup?

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

\\
r \cdot b
\end{array}
Derivation
  1. Initial program 73.8%

    \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
  2. Step-by-step derivation
    1. associate-/l*73.7%

      \[\leadsto \color{blue}{\frac{r}{\frac{\cos \left(a + b\right)}{\sin b}}} \]
    2. remove-double-neg73.7%

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

      \[\leadsto \frac{r}{\frac{\cos \left(a + b\right)}{-\color{blue}{\sin \left(-b\right)}}} \]
    4. neg-mul-173.7%

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

      \[\leadsto \frac{r}{\color{blue}{\frac{\frac{\cos \left(a + b\right)}{-1}}{\sin \left(-b\right)}}} \]
    6. associate-/l*73.8%

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

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

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

      \[\leadsto \color{blue}{\frac{\sin \left(-b\right) \cdot -1}{\cos \left(a + b\right)}} \cdot r \]
    10. sin-neg73.8%

      \[\leadsto \frac{\color{blue}{\left(-\sin b\right)} \cdot -1}{\cos \left(a + b\right)} \cdot r \]
    11. distribute-lft-neg-in73.8%

      \[\leadsto \frac{\color{blue}{-\sin b \cdot -1}}{\cos \left(a + b\right)} \cdot r \]
    12. distribute-rgt-neg-in73.8%

      \[\leadsto \frac{\color{blue}{\sin b \cdot \left(--1\right)}}{\cos \left(a + b\right)} \cdot r \]
    13. associate-/l*73.8%

      \[\leadsto \color{blue}{\frac{\sin b}{\frac{\cos \left(a + b\right)}{--1}}} \cdot r \]
    14. metadata-eval73.8%

      \[\leadsto \frac{\sin b}{\frac{\cos \left(a + b\right)}{\color{blue}{1}}} \cdot r \]
    15. /-rgt-identity73.8%

      \[\leadsto \frac{\sin b}{\color{blue}{\cos \left(a + b\right)}} \cdot r \]
    16. +-commutative73.8%

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

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

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

    \[\leadsto \color{blue}{b \cdot r} \]
  6. Step-by-step derivation
    1. *-commutative32.2%

      \[\leadsto \color{blue}{r \cdot b} \]
  7. Simplified32.2%

    \[\leadsto \color{blue}{r \cdot b} \]
  8. Final simplification32.2%

    \[\leadsto r \cdot b \]

Reproduce

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