rsin B (should all be same)

Percentage Accurate: 76.6% → 99.5%
Time: 16.1s
Alternatives: 21
Speedup: 1.0×

Specification

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

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

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 21 alternatives:

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

Initial Program: 76.6% accurate, 1.0× speedup?

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

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

Alternative 1: 99.5% accurate, 0.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.5% accurate, 0.3× speedup?

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

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

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

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

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

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

      \[\leadsto \frac{r \cdot \sin b}{\color{blue}{\cos b \cdot \cos a - \sin b \cdot \sin a}} \]
    2. cancel-sign-sub-inv99.5%

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

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

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

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

Alternative 3: 99.5% accurate, 0.4× speedup?

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

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

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

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

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

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

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

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

Alternative 4: 99.4% accurate, 0.4× speedup?

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

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

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

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

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

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

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

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

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

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

Alternative 5: 99.5% accurate, 0.4× speedup?

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

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

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

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

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

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

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

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

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

Alternative 6: 76.0% accurate, 1.0× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -1.45e-5 or 1.65e10 < a

    1. Initial program 49.1%

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

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

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

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

    if -1.45e-5 < a < 1.65e10

    1. Initial program 99.1%

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

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

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

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

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

Alternative 7: 76.0% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -1.9e-6 or 1.65e10 < a

    1. Initial program 49.1%

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

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

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

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

    if -1.9e-6 < a < 1.65e10

    1. Initial program 99.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 76.0% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -1.2e-5 or 1.65e10 < a

    1. Initial program 49.1%

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

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

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

        \[\leadsto r \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin b}{\cos \left(b + a\right)}\right)\right)} \]
    5. Applied egg-rr47.1%

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

      \[\leadsto r \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin b}{\color{blue}{\cos a}}\right)\right) \]
    7. Step-by-step derivation
      1. expm1-log1p-u49.0%

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

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

        \[\leadsto \color{blue}{\frac{r}{\frac{\cos a}{\sin b}}} \]
    8. Applied egg-rr49.0%

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

    if -1.2e-5 < a < 1.65e10

    1. Initial program 99.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 76.0% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 46.3%

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

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

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

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

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

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

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

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

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

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

    if -1.45e-5 < a < 1.65e10

    1. Initial program 99.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.65e10 < a

    1. Initial program 51.2%

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

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

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

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

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

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

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

Alternative 10: 76.0% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 46.3%

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

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

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

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

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

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

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

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

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

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

    if -1.42e-5 < a < 1.65e10

    1. Initial program 99.1%

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

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

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

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

    if 1.65e10 < a

    1. Initial program 51.2%

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

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

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

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

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

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

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

Alternative 11: 76.6% accurate, 1.0× speedup?

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

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

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

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

Alternative 12: 76.6% 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 73.9%

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

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

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

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

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

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

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

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

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

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

Alternative 13: 76.6% accurate, 1.0× speedup?

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

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

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

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

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

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

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

Alternative 14: 54.6% accurate, 1.0× speedup?

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

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

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

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

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

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

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

Alternative 15: 54.7% accurate, 1.9× speedup?

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

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

\mathbf{elif}\;b \leq 9.2:\\
\;\;\;\;\frac{b}{\frac{\cos \left(b + a\right)}{r}}\\

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


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

    1. Initial program 52.5%

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

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

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

        \[\leadsto r \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin b}{\cos \left(b + a\right)}\right)\right)} \]
    5. Applied egg-rr33.1%

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

      \[\leadsto r \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin b}{\color{blue}{\cos a}}\right)\right) \]
    7. Taylor expanded in a around 0 11.3%

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

    if -1.05e8 < b < 9.1999999999999993

    1. Initial program 97.7%

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

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

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

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

      \[\leadsto r \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin b}{\cos \left(b + a\right)}\right)\right)} \]
    6. Step-by-step derivation
      1. add-sqr-sqrt77.8%

        \[\leadsto r \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin b}{\color{blue}{\sqrt{\cos \left(b + a\right)} \cdot \sqrt{\cos \left(b + a\right)}}}\right)\right) \]
      2. sqrt-unprod82.5%

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

        \[\leadsto r \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin b}{\sqrt{\color{blue}{{\cos \left(b + a\right)}^{2}}}}\right)\right) \]
    7. Applied egg-rr82.5%

      \[\leadsto r \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin b}{\color{blue}{\sqrt{{\cos \left(b + a\right)}^{2}}}}\right)\right) \]
    8. Step-by-step derivation
      1. unpow282.5%

        \[\leadsto r \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin b}{\sqrt{\color{blue}{\cos \left(b + a\right) \cdot \cos \left(b + a\right)}}}\right)\right) \]
      2. rem-sqrt-square82.5%

        \[\leadsto r \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin b}{\color{blue}{\left|\cos \left(b + a\right)\right|}}\right)\right) \]
      3. +-commutative82.5%

        \[\leadsto r \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin b}{\left|\cos \color{blue}{\left(a + b\right)}\right|}\right)\right) \]
    9. Simplified82.5%

      \[\leadsto r \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin b}{\color{blue}{\left|\cos \left(a + b\right)\right|}}\right)\right) \]
    10. Taylor expanded in b around 0 81.9%

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

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

        \[\leadsto \frac{b}{\frac{\left|\cos \color{blue}{\left(b + a\right)}\right|}{r}} \]
      3. rem-square-sqrt77.0%

        \[\leadsto \frac{b}{\frac{\left|\color{blue}{\sqrt{\cos \left(b + a\right)} \cdot \sqrt{\cos \left(b + a\right)}}\right|}{r}} \]
      4. fabs-sqr77.0%

        \[\leadsto \frac{b}{\frac{\color{blue}{\sqrt{\cos \left(b + a\right)} \cdot \sqrt{\cos \left(b + a\right)}}}{r}} \]
      5. rem-square-sqrt96.0%

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

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

    if 9.1999999999999993 < b

    1. Initial program 55.1%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\sin b}{\frac{1}{r} \cdot \color{blue}{\cos b}} \]
    7. Taylor expanded in b around 0 11.8%

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

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

Alternative 16: 54.8% accurate, 1.9× speedup?

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

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

\mathbf{elif}\;b \leq 15.6:\\
\;\;\;\;\frac{r \cdot b}{\cos \left(b + a\right)}\\

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


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

    1. Initial program 52.5%

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

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

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

        \[\leadsto r \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin b}{\cos \left(b + a\right)}\right)\right)} \]
    5. Applied egg-rr33.1%

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

      \[\leadsto r \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin b}{\color{blue}{\cos a}}\right)\right) \]
    7. Taylor expanded in a around 0 11.3%

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

    if -1.06e8 < b < 15.5999999999999996

    1. Initial program 97.7%

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

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

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

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

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

    if 15.5999999999999996 < b

    1. Initial program 55.1%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\sin b}{\frac{1}{r} \cdot \color{blue}{\cos b}} \]
    7. Taylor expanded in b around 0 11.8%

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

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

Alternative 17: 54.8% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -0.55 \lor \neg \left(b \leq 30\right):\\ \;\;\;\;r \cdot \sin b\\ \mathbf{else}:\\ \;\;\;\;r \cdot \frac{b}{\cos a}\\ \end{array} \end{array} \]
(FPCore (r a b)
 :precision binary64
 (if (or (<= b -0.55) (not (<= b 30.0))) (* r (sin b)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
	double tmp;
	if ((b <= -0.55) || !(b <= 30.0)) {
		tmp = r * sin(b);
	} else {
		tmp = r * (b / cos(a));
	}
	return tmp;
}
real(8) function code(r, a, b)
    real(8), intent (in) :: r
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: tmp
    if ((b <= (-0.55d0)) .or. (.not. (b <= 30.0d0))) then
        tmp = r * sin(b)
    else
        tmp = r * (b / cos(a))
    end if
    code = tmp
end function
public static double code(double r, double a, double b) {
	double tmp;
	if ((b <= -0.55) || !(b <= 30.0)) {
		tmp = r * Math.sin(b);
	} else {
		tmp = r * (b / Math.cos(a));
	}
	return tmp;
}
def code(r, a, b):
	tmp = 0
	if (b <= -0.55) or not (b <= 30.0):
		tmp = r * math.sin(b)
	else:
		tmp = r * (b / math.cos(a))
	return tmp
function code(r, a, b)
	tmp = 0.0
	if ((b <= -0.55) || !(b <= 30.0))
		tmp = Float64(r * sin(b));
	else
		tmp = Float64(r * Float64(b / cos(a)));
	end
	return tmp
end
function tmp_2 = code(r, a, b)
	tmp = 0.0;
	if ((b <= -0.55) || ~((b <= 30.0)))
		tmp = r * sin(b);
	else
		tmp = r * (b / cos(a));
	end
	tmp_2 = tmp;
end
code[r_, a_, b_] := If[Or[LessEqual[b, -0.55], N[Not[LessEqual[b, 30.0]], $MachinePrecision]], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.55 \lor \neg \left(b \leq 30\right):\\
\;\;\;\;r \cdot \sin b\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -0.55000000000000004 or 30 < b

    1. Initial program 53.9%

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

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

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

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

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

      \[\leadsto r \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin b}{\color{blue}{\cos a}}\right)\right) \]
    7. Taylor expanded in a around 0 11.4%

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

    if -0.55000000000000004 < b < 30

    1. Initial program 98.4%

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

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

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

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

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

Alternative 18: 54.8% accurate, 1.9× speedup?

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

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

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

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


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

    1. Initial program 52.6%

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

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

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

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

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

      \[\leadsto r \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin b}{\color{blue}{\cos a}}\right)\right) \]
    7. Taylor expanded in a around 0 11.0%

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

    if -1.15999999999999992 < b < 24

    1. Initial program 98.4%

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

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

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

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

    if 24 < b

    1. Initial program 55.1%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\sin b}{\frac{1}{r} \cdot \color{blue}{\cos b}} \]
    7. Taylor expanded in b around 0 11.8%

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

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

Alternative 19: 54.8% accurate, 1.9× speedup?

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

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

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

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


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

    1. Initial program 52.6%

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

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

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

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

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

      \[\leadsto r \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin b}{\color{blue}{\cos a}}\right)\right) \]
    7. Taylor expanded in a around 0 11.0%

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

    if -1.02 < b < 30

    1. Initial program 98.4%

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

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

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

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

    if 30 < b

    1. Initial program 55.1%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\sin b}{\frac{1}{r} \cdot \color{blue}{\cos b}} \]
    7. Taylor expanded in b around 0 11.8%

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

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

Alternative 20: 38.6% accurate, 2.0× speedup?

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

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

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

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

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

      \[\leadsto r \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin b}{\cos \left(b + a\right)}\right)\right)} \]
  5. Applied egg-rr63.9%

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

    \[\leadsto r \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin b}{\color{blue}{\cos a}}\right)\right) \]
  7. Taylor expanded in a around 0 36.2%

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

    \[\leadsto r \cdot \sin b \]

Alternative 21: 34.4% accurate, 69.0× speedup?

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

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

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

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

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

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

    \[\leadsto r \cdot \color{blue}{b} \]
  6. Final simplification31.9%

    \[\leadsto r \cdot b \]

Reproduce

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