rsin A (should all be same)

Percentage Accurate: 76.3% → 99.5%
Time: 17.5s
Alternatives: 12
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 12 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.3% 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.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.5% accurate, 0.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\sin b}{\color{blue}{\cos b \cdot \cos a - \sin b \cdot \sin a}} \cdot r \]
  6. Final simplification99.4%

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

Alternative 3: 77.3% accurate, 0.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{r \cdot \sin b}{\cos b \cdot \cos a - \color{blue}{0}} \]
  9. Simplified75.7%

    \[\leadsto \frac{r \cdot \sin b}{\cos b \cdot \cos a - \color{blue}{0}} \]
  10. Final simplification75.7%

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

Alternative 4: 76.0% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.3 \lor \neg \left(b \leq 5.4 \cdot 10^{-5}\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -1.30000000000000004 or 5.3999999999999998e-5 < b

    1. Initial program 55.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.30000000000000004 < b < 5.3999999999999998e-5

    1. Initial program 97.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 76.0% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 49.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.30000000000000004 < b < 2.50000000000000012e-5

    1. Initial program 97.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.50000000000000012e-5 < b

    1. Initial program 63.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 76.3% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

Alternative 7: 54.6% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\sin b}{\color{blue}{\cos a}} \cdot r \]
  5. Final simplification51.3%

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

Alternative 8: 53.6% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -420000:\\ \;\;\;\;\frac{-r}{\sin a}\\ \mathbf{elif}\;b \leq 1.12:\\ \;\;\;\;r \cdot \frac{b}{\cos a}\\ \mathbf{else}:\\ \;\;\;\;\frac{r}{\frac{1}{b} - \sin a}\\ \end{array} \end{array} \]
(FPCore (r a b)
 :precision binary64
 (if (<= b -420000.0)
   (/ (- r) (sin a))
   (if (<= b 1.12) (* r (/ b (cos a))) (/ r (- (/ 1.0 b) (sin a))))))
double code(double r, double a, double b) {
	double tmp;
	if (b <= -420000.0) {
		tmp = -r / sin(a);
	} else if (b <= 1.12) {
		tmp = r * (b / cos(a));
	} else {
		tmp = r / ((1.0 / b) - 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 <= (-420000.0d0)) then
        tmp = -r / sin(a)
    else if (b <= 1.12d0) then
        tmp = r * (b / cos(a))
    else
        tmp = r / ((1.0d0 / b) - sin(a))
    end if
    code = tmp
end function
public static double code(double r, double a, double b) {
	double tmp;
	if (b <= -420000.0) {
		tmp = -r / Math.sin(a);
	} else if (b <= 1.12) {
		tmp = r * (b / Math.cos(a));
	} else {
		tmp = r / ((1.0 / b) - Math.sin(a));
	}
	return tmp;
}
def code(r, a, b):
	tmp = 0
	if b <= -420000.0:
		tmp = -r / math.sin(a)
	elif b <= 1.12:
		tmp = r * (b / math.cos(a))
	else:
		tmp = r / ((1.0 / b) - math.sin(a))
	return tmp
function code(r, a, b)
	tmp = 0.0
	if (b <= -420000.0)
		tmp = Float64(Float64(-r) / sin(a));
	elseif (b <= 1.12)
		tmp = Float64(r * Float64(b / cos(a)));
	else
		tmp = Float64(r / Float64(Float64(1.0 / b) - sin(a)));
	end
	return tmp
end
function tmp_2 = code(r, a, b)
	tmp = 0.0;
	if (b <= -420000.0)
		tmp = -r / sin(a);
	elseif (b <= 1.12)
		tmp = r * (b / cos(a));
	else
		tmp = r / ((1.0 / b) - sin(a));
	end
	tmp_2 = tmp;
end
code[r_, a_, b_] := If[LessEqual[b, -420000.0], N[((-r) / N[Sin[a], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.12], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r / N[(N[(1.0 / b), $MachinePrecision] - N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;b \leq 1.12:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\

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


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

    1. Initial program 49.1%

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

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

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

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

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

        \[\leadsto \frac{r}{\color{blue}{\frac{\cos a}{b} + -1 \cdot \sin a}} \]
      2. neg-mul-110.5%

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

        \[\leadsto \frac{r}{\color{blue}{\frac{\cos a}{b} - \sin a}} \]
    6. Simplified10.5%

      \[\leadsto \frac{r}{\color{blue}{\frac{\cos a}{b} - \sin a}} \]
    7. Taylor expanded in b around inf 10.6%

      \[\leadsto \color{blue}{-1 \cdot \frac{r}{\sin a}} \]
    8. Step-by-step derivation
      1. associate-*r/10.6%

        \[\leadsto \color{blue}{\frac{-1 \cdot r}{\sin a}} \]
      2. neg-mul-110.6%

        \[\leadsto \frac{\color{blue}{-r}}{\sin a} \]
    9. Simplified10.6%

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

    if -4.2e5 < b < 1.1200000000000001

    1. Initial program 97.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.1200000000000001 < b

    1. Initial program 63.7%

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

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

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

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

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

        \[\leadsto \frac{r}{\color{blue}{\frac{\cos a}{b} + -1 \cdot \sin a}} \]
      2. neg-mul-111.2%

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

        \[\leadsto \frac{r}{\color{blue}{\frac{\cos a}{b} - \sin a}} \]
    6. Simplified11.2%

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

      \[\leadsto \frac{r}{\color{blue}{\frac{1}{b}} - \sin a} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification50.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -420000:\\ \;\;\;\;\frac{-r}{\sin a}\\ \mathbf{elif}\;b \leq 1.12:\\ \;\;\;\;r \cdot \frac{b}{\cos a}\\ \mathbf{else}:\\ \;\;\;\;\frac{r}{\frac{1}{b} - \sin a}\\ \end{array} \]

Alternative 9: 53.6% accurate, 1.9× speedup?

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

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

\mathbf{elif}\;b \leq 2.7 \cdot 10^{+21}:\\
\;\;\;\;\frac{b \cdot r}{\cos \left(b + a\right)}\\

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


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

    1. Initial program 49.1%

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

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

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

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

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

        \[\leadsto \frac{r}{\color{blue}{\frac{\cos a}{b} + -1 \cdot \sin a}} \]
      2. neg-mul-110.5%

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

        \[\leadsto \frac{r}{\color{blue}{\frac{\cos a}{b} - \sin a}} \]
    6. Simplified10.5%

      \[\leadsto \frac{r}{\color{blue}{\frac{\cos a}{b} - \sin a}} \]
    7. Taylor expanded in b around inf 10.6%

      \[\leadsto \color{blue}{-1 \cdot \frac{r}{\sin a}} \]
    8. Step-by-step derivation
      1. associate-*r/10.6%

        \[\leadsto \color{blue}{\frac{-1 \cdot r}{\sin a}} \]
      2. neg-mul-110.6%

        \[\leadsto \frac{\color{blue}{-r}}{\sin a} \]
    9. Simplified10.6%

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

    if -3.4e5 < b < 2.7e21

    1. Initial program 97.2%

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

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

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

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

    if 2.7e21 < b

    1. Initial program 61.4%

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

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

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

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

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

        \[\leadsto \frac{r}{\color{blue}{\frac{\cos a}{b} + -1 \cdot \sin a}} \]
      2. neg-mul-111.6%

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

        \[\leadsto \frac{r}{\color{blue}{\frac{\cos a}{b} - \sin a}} \]
    6. Simplified11.6%

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

      \[\leadsto \frac{r}{\color{blue}{\frac{1}{b}} - \sin a} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification50.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -340000:\\ \;\;\;\;\frac{-r}{\sin a}\\ \mathbf{elif}\;b \leq 2.7 \cdot 10^{+21}:\\ \;\;\;\;\frac{b \cdot r}{\cos \left(b + a\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{r}{\frac{1}{b} - \sin a}\\ \end{array} \]

Alternative 10: 53.5% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -430000 \lor \neg \left(b \leq 42000000000000\right):\\
\;\;\;\;\frac{-r}{\sin a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -4.3e5 or 4.2e13 < b

    1. Initial program 55.4%

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

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

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

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

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

        \[\leadsto \frac{r}{\color{blue}{\frac{\cos a}{b} + -1 \cdot \sin a}} \]
      2. neg-mul-110.9%

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

        \[\leadsto \frac{r}{\color{blue}{\frac{\cos a}{b} - \sin a}} \]
    6. Simplified10.9%

      \[\leadsto \frac{r}{\color{blue}{\frac{\cos a}{b} - \sin a}} \]
    7. Taylor expanded in b around inf 10.7%

      \[\leadsto \color{blue}{-1 \cdot \frac{r}{\sin a}} \]
    8. Step-by-step derivation
      1. associate-*r/10.7%

        \[\leadsto \color{blue}{\frac{-1 \cdot r}{\sin a}} \]
      2. neg-mul-110.7%

        \[\leadsto \frac{\color{blue}{-r}}{\sin a} \]
    9. Simplified10.7%

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

    if -4.3e5 < b < 4.2e13

    1. Initial program 97.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -430000 \lor \neg \left(b \leq 42000000000000\right):\\ \;\;\;\;\frac{-r}{\sin a}\\ \mathbf{else}:\\ \;\;\;\;r \cdot \frac{b}{\cos a}\\ \end{array} \]

Alternative 11: 37.2% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -360000 \lor \neg \left(b \leq 1.95 \cdot 10^{-11}\right):\\
\;\;\;\;\frac{-r}{\sin a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -3.6e5 or 1.95000000000000005e-11 < b

    1. Initial program 56.2%

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

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

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

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

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

        \[\leadsto \frac{r}{\color{blue}{\frac{\cos a}{b} + -1 \cdot \sin a}} \]
      2. neg-mul-111.5%

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

        \[\leadsto \frac{r}{\color{blue}{\frac{\cos a}{b} - \sin a}} \]
    6. Simplified11.5%

      \[\leadsto \frac{r}{\color{blue}{\frac{\cos a}{b} - \sin a}} \]
    7. Taylor expanded in b around inf 10.7%

      \[\leadsto \color{blue}{-1 \cdot \frac{r}{\sin a}} \]
    8. Step-by-step derivation
      1. associate-*r/10.7%

        \[\leadsto \color{blue}{\frac{-1 \cdot r}{\sin a}} \]
      2. neg-mul-110.7%

        \[\leadsto \frac{\color{blue}{-r}}{\sin a} \]
    9. Simplified10.7%

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

    if -3.6e5 < b < 1.95000000000000005e-11

    1. Initial program 97.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -360000 \lor \neg \left(b \leq 1.95 \cdot 10^{-11}\right):\\ \;\;\;\;\frac{-r}{\sin a}\\ \mathbf{else}:\\ \;\;\;\;b \cdot r\\ \end{array} \]

Alternative 12: 34.5% accurate, 69.0× 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 75.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{b} \cdot r \]
  6. Final simplification32.3%

    \[\leadsto b \cdot r \]

Reproduce

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