rsin A (should all be same)

Percentage Accurate: 77.3% → 99.5%
Time: 16.8s
Alternatives: 14
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 14 alternatives:

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

Initial Program: 77.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.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\sin b}{\color{blue}{\left(\cos b \cdot \cos a + \left(-\sin b \cdot \sin a\right)\right)} + \mathsf{fma}\left(-\sin a, \sin b, \sin a \cdot \sin b\right)} \cdot r \]
    4. associate-+l+99.5%

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

      \[\leadsto \frac{\sin b}{\cos b \cdot \cos a + \left(\left(-\color{blue}{\sin a \cdot \sin b}\right) + \mathsf{fma}\left(-\sin a, \sin b, \sin a \cdot \sin b\right)\right)} \cdot r \]
    6. distribute-rgt-neg-in99.5%

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

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

    \[\leadsto \frac{\sin b}{\color{blue}{\cos b \cdot \cos a + \left(\sin a \cdot \left(-\sin b\right) + \mathsf{fma}\left(-\sin a, \sin b, \sin b \cdot \sin a\right)\right)}} \cdot r \]
  9. Step-by-step derivation
    1. fma-def99.5%

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

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

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

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

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

Alternative 2: 99.5% accurate, 0.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 78.1% accurate, 0.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, -\color{blue}{\sin a \cdot \sin b}\right)} \cdot r \]
    3. distribute-rgt-neg-in99.5%

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

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

      \[\leadsto \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \color{blue}{\left(-\sin b\right) \cdot \sin a}\right)} \cdot r \]
    2. add-sqr-sqrt51.6%

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

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

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

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

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

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

      \[\leadsto \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \frac{\color{blue}{\left(\cos b \cdot \cos a + \sin b \cdot \sin a\right)} - \cos \left(b + a\right)}{2}\right)} \cdot r \]
    9. add-sqr-sqrt40.9%

      \[\leadsto \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \frac{\left(\cos b \cdot \cos a + \color{blue}{\left(\sqrt{\sin b} \cdot \sqrt{\sin b}\right)} \cdot \sin a\right) - \cos \left(b + a\right)}{2}\right)} \cdot r \]
    10. sqrt-unprod80.3%

      \[\leadsto \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \frac{\left(\cos b \cdot \cos a + \color{blue}{\sqrt{\sin b \cdot \sin b}} \cdot \sin a\right) - \cos \left(b + a\right)}{2}\right)} \cdot r \]
    11. sqr-neg80.3%

      \[\leadsto \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \frac{\left(\cos b \cdot \cos a + \sqrt{\color{blue}{\left(-\sin b\right) \cdot \left(-\sin b\right)}} \cdot \sin a\right) - \cos \left(b + a\right)}{2}\right)} \cdot r \]
    12. sqrt-unprod39.4%

      \[\leadsto \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \frac{\left(\cos b \cdot \cos a + \color{blue}{\left(\sqrt{-\sin b} \cdot \sqrt{-\sin b}\right)} \cdot \sin a\right) - \cos \left(b + a\right)}{2}\right)} \cdot r \]
    13. add-sqr-sqrt80.7%

      \[\leadsto \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \frac{\left(\cos b \cdot \cos a + \color{blue}{\left(-\sin b\right)} \cdot \sin a\right) - \cos \left(b + a\right)}{2}\right)} \cdot r \]
    14. cancel-sign-sub-inv80.7%

      \[\leadsto \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \frac{\color{blue}{\left(\cos b \cdot \cos a - \sin b \cdot \sin a\right)} - \cos \left(b + a\right)}{2}\right)} \cdot r \]
    15. cos-sum80.3%

      \[\leadsto \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \frac{\color{blue}{\cos \left(b + a\right)} - \cos \left(b + a\right)}{2}\right)} \cdot r \]
  10. Applied egg-rr80.3%

    \[\leadsto \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \color{blue}{\frac{\cos \left(b + a\right) - \cos \left(b + a\right)}{2}}\right)} \cdot r \]
  11. Step-by-step derivation
    1. +-inverses80.3%

      \[\leadsto \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \frac{\color{blue}{0}}{2}\right)} \cdot r \]
    2. metadata-eval80.3%

      \[\leadsto \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \color{blue}{0}\right)} \cdot r \]
  12. Simplified80.3%

    \[\leadsto \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \color{blue}{0}\right)} \cdot r \]
  13. Final simplification80.3%

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

Alternative 4: 77.1% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 63.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.00000000000000065e-5 < a < 7.5000000000000002e-4

    1. Initial program 98.9%

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

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

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

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

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

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

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

        \[\leadsto \frac{r}{\color{blue}{\frac{\cos b}{\sin b} - a}} \]
    7. Simplified99.3%

      \[\leadsto \frac{r}{\color{blue}{\frac{\cos b}{\sin b} - a}} \]
    8. Step-by-step derivation
      1. div-inv99.3%

        \[\leadsto \color{blue}{r \cdot \frac{1}{\frac{\cos b}{\sin b} - a}} \]
      2. clear-num99.3%

        \[\leadsto r \cdot \frac{1}{\color{blue}{\frac{1}{\frac{\sin b}{\cos b}}} - a} \]
      3. quot-tan99.4%

        \[\leadsto r \cdot \frac{1}{\frac{1}{\color{blue}{\tan b}} - a} \]
    9. Applied egg-rr99.4%

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

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

Alternative 5: 77.1% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;a \leq 0.0006:\\
\;\;\;\;r \cdot \frac{1}{\frac{1}{\tan b} - a}\\

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


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

    1. Initial program 68.3%

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

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

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

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

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

    if -1.85e-4 < a < 5.99999999999999947e-4

    1. Initial program 98.9%

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

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

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

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

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

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

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

        \[\leadsto \frac{r}{\color{blue}{\frac{\cos b}{\sin b} - a}} \]
    7. Simplified99.3%

      \[\leadsto \frac{r}{\color{blue}{\frac{\cos b}{\sin b} - a}} \]
    8. Step-by-step derivation
      1. div-inv99.3%

        \[\leadsto \color{blue}{r \cdot \frac{1}{\frac{\cos b}{\sin b} - a}} \]
      2. clear-num99.3%

        \[\leadsto r \cdot \frac{1}{\color{blue}{\frac{1}{\frac{\sin b}{\cos b}}} - a} \]
      3. quot-tan99.4%

        \[\leadsto r \cdot \frac{1}{\frac{1}{\color{blue}{\tan b}} - a} \]
    9. Applied egg-rr99.4%

      \[\leadsto \color{blue}{r \cdot \frac{1}{\frac{1}{\tan b} - a}} \]

    if 5.99999999999999947e-4 < 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.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -0.000185:\\ \;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\ \mathbf{elif}\;a \leq 0.0006:\\ \;\;\;\;r \cdot \frac{1}{\frac{1}{\tan b} - a}\\ \mathbf{else}:\\ \;\;\;\;r \cdot \frac{\sin b}{\cos a}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 76.4% accurate, 1.0× speedup?

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

\mathbf{elif}\;b \leq 2.3 \cdot 10^{-7}:\\
\;\;\;\;b \cdot \frac{r}{\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 < -7.6e15

    1. Initial program 49.0%

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

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

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

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

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

    if -7.6e15 < b < 2.29999999999999995e-7

    1. Initial program 97.9%

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

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

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

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

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

        \[\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/97.9%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{b}{\cos a}} \cdot r \]
    6. Step-by-step derivation
      1. *-commutative97.9%

        \[\leadsto \color{blue}{r \cdot \frac{b}{\cos a}} \]
      2. clear-num97.8%

        \[\leadsto r \cdot \color{blue}{\frac{1}{\frac{\cos a}{b}}} \]
      3. un-div-inv97.7%

        \[\leadsto \color{blue}{\frac{r}{\frac{\cos a}{b}}} \]
    7. Applied egg-rr97.7%

      \[\leadsto \color{blue}{\frac{r}{\frac{\cos a}{b}}} \]
    8. Step-by-step derivation
      1. associate-/r/97.9%

        \[\leadsto \color{blue}{\frac{r}{\cos a} \cdot b} \]
    9. Simplified97.9%

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

    if 2.29999999999999995e-7 < b

    1. Initial program 59.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 77.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 79.8%

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

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

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

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

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

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

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

Alternative 8: 74.9% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{1}{\tan b} - a\\
\mathbf{if}\;b \leq -1.6 \cdot 10^{+20}:\\
\;\;\;\;\frac{r}{t_0}\\

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

\mathbf{else}:\\
\;\;\;\;r \cdot \frac{1}{t_0}\\


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

    1. Initial program 50.7%

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

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

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

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

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

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

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

        \[\leadsto \frac{r}{\color{blue}{\frac{\cos b}{\sin b} - a}} \]
    7. Simplified48.8%

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

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{r}{\frac{\cos b}{\sin b} - a}\right)\right)} \]
      2. expm1-udef15.1%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{r}{\frac{\cos b}{\sin b} - a}\right)} - 1} \]
      3. clear-num15.1%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{r}{\color{blue}{\frac{1}{\frac{\sin b}{\cos b}}} - a}\right)} - 1 \]
      4. quot-tan15.1%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{r}{\frac{1}{\color{blue}{\tan b}} - a}\right)} - 1 \]
    9. Applied egg-rr15.1%

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

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{r}{\frac{1}{\tan b} - a}\right)\right)} \]
      2. expm1-log1p48.8%

        \[\leadsto \color{blue}{\frac{r}{\frac{1}{\tan b} - a}} \]
    11. Simplified48.8%

      \[\leadsto \color{blue}{\frac{r}{\frac{1}{\tan b} - a}} \]

    if -1.6e20 < b < 2.29999999999999995e-7

    1. Initial program 96.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{b}{\cos a}} \cdot r \]
    6. Step-by-step derivation
      1. *-commutative96.7%

        \[\leadsto \color{blue}{r \cdot \frac{b}{\cos a}} \]
      2. clear-num96.6%

        \[\leadsto r \cdot \color{blue}{\frac{1}{\frac{\cos a}{b}}} \]
      3. un-div-inv96.6%

        \[\leadsto \color{blue}{\frac{r}{\frac{\cos a}{b}}} \]
    7. Applied egg-rr96.6%

      \[\leadsto \color{blue}{\frac{r}{\frac{\cos a}{b}}} \]
    8. Step-by-step derivation
      1. associate-/r/96.8%

        \[\leadsto \color{blue}{\frac{r}{\cos a} \cdot b} \]
    9. Simplified96.8%

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

    if 2.29999999999999995e-7 < b

    1. Initial program 59.9%

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

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

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

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

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

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

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

        \[\leadsto \frac{r}{\color{blue}{\frac{\cos b}{\sin b} - a}} \]
    7. Simplified55.8%

      \[\leadsto \frac{r}{\color{blue}{\frac{\cos b}{\sin b} - a}} \]
    8. Step-by-step derivation
      1. div-inv55.7%

        \[\leadsto \color{blue}{r \cdot \frac{1}{\frac{\cos b}{\sin b} - a}} \]
      2. clear-num55.8%

        \[\leadsto r \cdot \frac{1}{\color{blue}{\frac{1}{\frac{\sin b}{\cos b}}} - a} \]
      3. quot-tan55.9%

        \[\leadsto r \cdot \frac{1}{\frac{1}{\color{blue}{\tan b}} - a} \]
    9. Applied egg-rr55.9%

      \[\leadsto \color{blue}{r \cdot \frac{1}{\frac{1}{\tan b} - a}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification78.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -1.6 \cdot 10^{+20}:\\ \;\;\;\;\frac{r}{\frac{1}{\tan b} - a}\\ \mathbf{elif}\;b \leq 2.3 \cdot 10^{-7}:\\ \;\;\;\;b \cdot \frac{r}{\cos a}\\ \mathbf{else}:\\ \;\;\;\;r \cdot \frac{1}{\frac{1}{\tan b} - a}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 74.9% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{1}{\tan b} - a\\
\mathbf{if}\;b \leq -1.6 \cdot 10^{+20}:\\
\;\;\;\;\frac{1}{\frac{t_0}{r}}\\

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

\mathbf{else}:\\
\;\;\;\;r \cdot \frac{1}{t_0}\\


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

    1. Initial program 50.7%

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

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

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

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

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

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

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

        \[\leadsto \frac{r}{\color{blue}{\frac{\cos b}{\sin b} - a}} \]
    7. Simplified48.8%

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

        \[\leadsto \color{blue}{\frac{1}{\frac{\frac{\cos b}{\sin b} - a}{r}}} \]
      2. inv-pow48.8%

        \[\leadsto \color{blue}{{\left(\frac{\frac{\cos b}{\sin b} - a}{r}\right)}^{-1}} \]
      3. clear-num48.7%

        \[\leadsto {\left(\frac{\color{blue}{\frac{1}{\frac{\sin b}{\cos b}}} - a}{r}\right)}^{-1} \]
      4. quot-tan48.9%

        \[\leadsto {\left(\frac{\frac{1}{\color{blue}{\tan b}} - a}{r}\right)}^{-1} \]
    9. Applied egg-rr48.9%

      \[\leadsto \color{blue}{{\left(\frac{\frac{1}{\tan b} - a}{r}\right)}^{-1}} \]
    10. Step-by-step derivation
      1. unpow-148.9%

        \[\leadsto \color{blue}{\frac{1}{\frac{\frac{1}{\tan b} - a}{r}}} \]
    11. Simplified48.9%

      \[\leadsto \color{blue}{\frac{1}{\frac{\frac{1}{\tan b} - a}{r}}} \]

    if -1.6e20 < b < 2.29999999999999995e-7

    1. Initial program 96.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{b}{\cos a}} \cdot r \]
    6. Step-by-step derivation
      1. *-commutative96.7%

        \[\leadsto \color{blue}{r \cdot \frac{b}{\cos a}} \]
      2. clear-num96.6%

        \[\leadsto r \cdot \color{blue}{\frac{1}{\frac{\cos a}{b}}} \]
      3. un-div-inv96.6%

        \[\leadsto \color{blue}{\frac{r}{\frac{\cos a}{b}}} \]
    7. Applied egg-rr96.6%

      \[\leadsto \color{blue}{\frac{r}{\frac{\cos a}{b}}} \]
    8. Step-by-step derivation
      1. associate-/r/96.8%

        \[\leadsto \color{blue}{\frac{r}{\cos a} \cdot b} \]
    9. Simplified96.8%

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

    if 2.29999999999999995e-7 < b

    1. Initial program 59.9%

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

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

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

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

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

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

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

        \[\leadsto \frac{r}{\color{blue}{\frac{\cos b}{\sin b} - a}} \]
    7. Simplified55.8%

      \[\leadsto \frac{r}{\color{blue}{\frac{\cos b}{\sin b} - a}} \]
    8. Step-by-step derivation
      1. div-inv55.7%

        \[\leadsto \color{blue}{r \cdot \frac{1}{\frac{\cos b}{\sin b} - a}} \]
      2. clear-num55.8%

        \[\leadsto r \cdot \frac{1}{\color{blue}{\frac{1}{\frac{\sin b}{\cos b}}} - a} \]
      3. quot-tan55.9%

        \[\leadsto r \cdot \frac{1}{\frac{1}{\color{blue}{\tan b}} - a} \]
    9. Applied egg-rr55.9%

      \[\leadsto \color{blue}{r \cdot \frac{1}{\frac{1}{\tan b} - a}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification78.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -1.6 \cdot 10^{+20}:\\ \;\;\;\;\frac{1}{\frac{\frac{1}{\tan b} - a}{r}}\\ \mathbf{elif}\;b \leq 2.3 \cdot 10^{-7}:\\ \;\;\;\;b \cdot \frac{r}{\cos a}\\ \mathbf{else}:\\ \;\;\;\;r \cdot \frac{1}{\frac{1}{\tan b} - a}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 74.9% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.6 \cdot 10^{+20} \lor \neg \left(b \leq 2.3 \cdot 10^{-7}\right):\\
\;\;\;\;\frac{r}{\frac{1}{\tan b} - a}\\

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


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

    1. Initial program 55.8%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{r}{\color{blue}{\frac{\cos b}{\sin b} - a}} \]
    8. Step-by-step derivation
      1. expm1-log1p-u31.0%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{r}{\frac{\cos b}{\sin b} - a}\right)\right)} \]
      2. expm1-udef12.9%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{r}{\frac{\cos b}{\sin b} - a}\right)} - 1} \]
      3. clear-num12.9%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{r}{\color{blue}{\frac{1}{\frac{\sin b}{\cos b}}} - a}\right)} - 1 \]
      4. quot-tan12.9%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{r}{\frac{1}{\color{blue}{\tan b}} - a}\right)} - 1 \]
    9. Applied egg-rr12.9%

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

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{r}{\frac{1}{\tan b} - a}\right)\right)} \]
      2. expm1-log1p52.7%

        \[\leadsto \color{blue}{\frac{r}{\frac{1}{\tan b} - a}} \]
    11. Simplified52.7%

      \[\leadsto \color{blue}{\frac{r}{\frac{1}{\tan b} - a}} \]

    if -1.6e20 < b < 2.29999999999999995e-7

    1. Initial program 96.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{b}{\cos a}} \cdot r \]
    6. Step-by-step derivation
      1. *-commutative96.7%

        \[\leadsto \color{blue}{r \cdot \frac{b}{\cos a}} \]
      2. clear-num96.6%

        \[\leadsto r \cdot \color{blue}{\frac{1}{\frac{\cos a}{b}}} \]
      3. un-div-inv96.6%

        \[\leadsto \color{blue}{\frac{r}{\frac{\cos a}{b}}} \]
    7. Applied egg-rr96.6%

      \[\leadsto \color{blue}{\frac{r}{\frac{\cos a}{b}}} \]
    8. Step-by-step derivation
      1. associate-/r/96.8%

        \[\leadsto \color{blue}{\frac{r}{\cos a} \cdot b} \]
    9. Simplified96.8%

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

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

Alternative 11: 56.1% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.6 \cdot 10^{+20} \lor \neg \left(b \leq 9000\right):\\
\;\;\;\;\sin b \cdot r\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -1.6e20 or 9e3 < b

    1. Initial program 54.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{r \cdot \sin b} \]
    9. Step-by-step derivation
      1. *-commutative12.9%

        \[\leadsto \color{blue}{\sin b \cdot r} \]
    10. Simplified12.9%

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

    if -1.6e20 < b < 9e3

    1. Initial program 96.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 56.1% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.6 \cdot 10^{+20} \lor \neg \left(b \leq 360000000\right):\\
\;\;\;\;\sin b \cdot r\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -1.6e20 or 3.6e8 < b

    1. Initial program 54.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{r \cdot \sin b} \]
    9. Step-by-step derivation
      1. *-commutative12.9%

        \[\leadsto \color{blue}{\sin b \cdot r} \]
    10. Simplified12.9%

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

    if -1.6e20 < b < 3.6e8

    1. Initial program 96.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{r \cdot \frac{b}{\cos a}} \]
      2. clear-num96.3%

        \[\leadsto r \cdot \color{blue}{\frac{1}{\frac{\cos a}{b}}} \]
      3. un-div-inv96.2%

        \[\leadsto \color{blue}{\frac{r}{\frac{\cos a}{b}}} \]
    7. Applied egg-rr96.2%

      \[\leadsto \color{blue}{\frac{r}{\frac{\cos a}{b}}} \]
    8. Step-by-step derivation
      1. associate-/r/96.4%

        \[\leadsto \color{blue}{\frac{r}{\cos a} \cdot b} \]
    9. Simplified96.4%

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

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

Alternative 13: 39.5% accurate, 2.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{r \cdot \sin b} \]
  9. Step-by-step derivation
    1. *-commutative42.9%

      \[\leadsto \color{blue}{\sin b \cdot r} \]
  10. Simplified42.9%

    \[\leadsto \color{blue}{\sin b \cdot r} \]
  11. Final simplification42.9%

    \[\leadsto \sin b \cdot r \]
  12. Add Preprocessing

Alternative 14: 35.4% 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 79.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{b \cdot r} \]
  7. Final simplification39.3%

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

Reproduce

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