rsin B (should all be same)

Percentage Accurate: 77.5% → 99.5%
Time: 21.1s
Alternatives: 19
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 19 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.5% 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} \\ \begin{array}{l} t_0 := \sin b \cdot \sin a\\ \sin b \cdot \frac{r}{\mathsf{fma}\left(-2, t_0, \mathsf{fma}\left(\cos a, \cos b, t_0\right)\right)} \end{array} \end{array} \]
(FPCore (r a b)
 :precision binary64
 (let* ((t_0 (* (sin b) (sin a))))
   (* (sin b) (/ r (fma -2.0 t_0 (fma (cos a) (cos b) t_0))))))
double code(double r, double a, double b) {
	double t_0 = sin(b) * sin(a);
	return sin(b) * (r / fma(-2.0, t_0, fma(cos(a), cos(b), t_0)));
}
function code(r, a, b)
	t_0 = Float64(sin(b) * sin(a))
	return Float64(sin(b) * Float64(r / fma(-2.0, t_0, fma(cos(a), cos(b), t_0))))
end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]}, N[(N[Sin[b], $MachinePrecision] * N[(r / N[(-2.0 * t$95$0 + N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin b \cdot \sin a\\
\sin b \cdot \frac{r}{\mathsf{fma}\left(-2, t_0, \mathsf{fma}\left(\cos a, \cos b, t_0\right)\right)}
\end{array}
\end{array}
Derivation
  1. Initial program 78.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{r}{\color{blue}{\cos b \cdot \cos a - \sin b \cdot \sin a}} \cdot \sin b \]
    3. add-sqr-sqrt51.7%

      \[\leadsto \frac{r}{\cos b \cdot \cos a - \color{blue}{\left(\sqrt{\sin b} \cdot \sqrt{\sin b}\right)} \cdot \sin a} \cdot \sin b \]
    4. sqrt-unprod87.8%

      \[\leadsto \frac{r}{\cos b \cdot \cos a - \color{blue}{\sqrt{\sin b \cdot \sin b}} \cdot \sin a} \cdot \sin b \]
    5. sqr-neg87.8%

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

      \[\leadsto \frac{r}{\cos b \cdot \cos a - \color{blue}{\left(\sqrt{-\sin b} \cdot \sqrt{-\sin b}\right)} \cdot \sin a} \cdot \sin b \]
    7. add-sqr-sqrt78.5%

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

      \[\leadsto \frac{r}{\cos b \cdot \cos a - \color{blue}{\left(-\sin b \cdot \sin a\right)}} \cdot \sin b \]
    9. neg-mul-178.5%

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

      \[\leadsto \frac{r}{\cos b \cdot \cos a - -1 \cdot \left(\color{blue}{\left(\sqrt{\sin b} \cdot \sqrt{\sin b}\right)} \cdot \sin a\right)} \cdot \sin b \]
    11. sqrt-unprod90.1%

      \[\leadsto \frac{r}{\cos b \cdot \cos a - -1 \cdot \left(\color{blue}{\sqrt{\sin b \cdot \sin b}} \cdot \sin a\right)} \cdot \sin b \]
    12. sqr-neg90.1%

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

      \[\leadsto \frac{r}{\cos b \cdot \cos a - -1 \cdot \left(\color{blue}{\left(\sqrt{-\sin b} \cdot \sqrt{-\sin b}\right)} \cdot \sin a\right)} \cdot \sin b \]
    14. add-sqr-sqrt99.4%

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

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

    \[\leadsto \frac{r}{\color{blue}{\mathsf{fma}\left(\cos b, \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)}} \cdot \sin b \]
  8. Taylor expanded in r around 0 99.4%

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

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

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

      \[\leadsto \frac{r}{\color{blue}{\mathsf{fma}\left(-2, \sin b \cdot \sin a, \cos a \cdot \cos b - -1 \cdot \left(\sin a \cdot \sin b\right)\right)}} \cdot \sin b \]
    4. mul-1-neg99.4%

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

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

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

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

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

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

Alternative 2: 99.5% accurate, 0.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \sin b \cdot \frac{r}{\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 78.6%

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

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

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

      \[\leadsto \frac{1}{\frac{\color{blue}{\cos b \cdot \cos a - \sin b \cdot \sin a}}{r \cdot \sin b}} \]
  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.5% accurate, 0.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 78.4% accurate, 0.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{r}{\color{blue}{\cos b \cdot \cos a - \sin b \cdot \sin a}} \cdot \sin b \]
    3. add-sqr-sqrt51.7%

      \[\leadsto \frac{r}{\cos b \cdot \cos a - \color{blue}{\left(\sqrt{\sin b} \cdot \sqrt{\sin b}\right)} \cdot \sin a} \cdot \sin b \]
    4. sqrt-unprod87.8%

      \[\leadsto \frac{r}{\cos b \cdot \cos a - \color{blue}{\sqrt{\sin b \cdot \sin b}} \cdot \sin a} \cdot \sin b \]
    5. sqr-neg87.8%

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

      \[\leadsto \frac{r}{\cos b \cdot \cos a - \color{blue}{\left(\sqrt{-\sin b} \cdot \sqrt{-\sin b}\right)} \cdot \sin a} \cdot \sin b \]
    7. add-sqr-sqrt78.5%

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

      \[\leadsto \frac{r}{\cos b \cdot \cos a - \color{blue}{\left(-\sin b \cdot \sin a\right)}} \cdot \sin b \]
    9. neg-mul-178.5%

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

      \[\leadsto \frac{r}{\cos b \cdot \cos a - -1 \cdot \left(\color{blue}{\left(\sqrt{\sin b} \cdot \sqrt{\sin b}\right)} \cdot \sin a\right)} \cdot \sin b \]
    11. sqrt-unprod90.1%

      \[\leadsto \frac{r}{\cos b \cdot \cos a - -1 \cdot \left(\color{blue}{\sqrt{\sin b \cdot \sin b}} \cdot \sin a\right)} \cdot \sin b \]
    12. sqr-neg90.1%

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

      \[\leadsto \frac{r}{\cos b \cdot \cos a - -1 \cdot \left(\color{blue}{\left(\sqrt{-\sin b} \cdot \sqrt{-\sin b}\right)} \cdot \sin a\right)} \cdot \sin b \]
    14. add-sqr-sqrt99.4%

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

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

    \[\leadsto \frac{r}{\color{blue}{\mathsf{fma}\left(\cos b, \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)}} \cdot \sin b \]
  8. Taylor expanded in r around 0 99.4%

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

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

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

      \[\leadsto \frac{r}{\color{blue}{\mathsf{fma}\left(-2, \sin b \cdot \sin a, \cos a \cdot \cos b - -1 \cdot \left(\sin a \cdot \sin b\right)\right)}} \cdot \sin b \]
    4. mul-1-neg99.4%

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 78.2% accurate, 0.7× speedup?

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\frac{\color{blue}{\cos b \cdot \cos a - \sin b \cdot \sin a}}{r \cdot \sin b}} \]
  7. Applied egg-rr98.9%

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

    \[\leadsto \color{blue}{\frac{r \cdot \sin b}{\cos a \cdot \cos b - \sin a \cdot \sin b}} \]
  9. Step-by-step derivation
    1. associate-/l*99.3%

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

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

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

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

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

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

      \[\leadsto \frac{r}{\frac{\cos a \cdot \cos b - \color{blue}{0}}{\sin b}} \]
  14. Simplified79.5%

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

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

Alternative 7: 77.1% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 61.1%

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

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

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

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

    if -1.32000000000000007e-5 < b < 2.4e-14

    1. Initial program 99.7%

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

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

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

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

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

Alternative 8: 77.1% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 60.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.6000000000000001e-6 < b < 2.4e-14

    1. Initial program 99.7%

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

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

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

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

    if 2.4e-14 < b

    1. Initial program 61.5%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -7.6 \cdot 10^{-6}:\\ \;\;\;\;\sin b \cdot \frac{r}{\cos b}\\ \mathbf{elif}\;b \leq 2.4 \cdot 10^{-14}:\\ \;\;\;\;\frac{r \cdot b}{\cos a}\\ \mathbf{else}:\\ \;\;\;\;r \cdot \frac{\sin b}{\cos b}\\ \end{array} \]

Alternative 9: 77.2% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 60.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.0499999999999999e-6 < b < 4.1999999999999996e-6

    1. Initial program 99.7%

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

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

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

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

    if 4.1999999999999996e-6 < b

    1. Initial program 60.9%

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

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

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

      \[\leadsto \color{blue}{\frac{r \cdot \sin b}{\cos b}} \]
    5. Step-by-step derivation
      1. associate-/l*60.9%

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

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

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

Alternative 10: 77.2% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 60.7%

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

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

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

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

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

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

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

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

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

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

    if -9.5000000000000001e-7 < b < 5.00000000000000024e-5

    1. Initial program 99.7%

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

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

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

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

    if 5.00000000000000024e-5 < b

    1. Initial program 60.9%

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

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

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

      \[\leadsto \color{blue}{\frac{r \cdot \sin b}{\cos b}} \]
    5. Step-by-step derivation
      1. associate-/l*60.9%

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

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

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

Alternative 11: 77.5% 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 78.6%

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

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

Alternative 12: 77.5% 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 78.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 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 78.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{r}{\color{blue}{\cos b \cdot \cos a - \sin b \cdot \sin a}} \cdot \sin b \]
    3. add-sqr-sqrt51.7%

      \[\leadsto \frac{r}{\cos b \cdot \cos a - \color{blue}{\left(\sqrt{\sin b} \cdot \sqrt{\sin b}\right)} \cdot \sin a} \cdot \sin b \]
    4. sqrt-unprod87.8%

      \[\leadsto \frac{r}{\cos b \cdot \cos a - \color{blue}{\sqrt{\sin b \cdot \sin b}} \cdot \sin a} \cdot \sin b \]
    5. sqr-neg87.8%

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

      \[\leadsto \frac{r}{\cos b \cdot \cos a - \color{blue}{\left(\sqrt{-\sin b} \cdot \sqrt{-\sin b}\right)} \cdot \sin a} \cdot \sin b \]
    7. add-sqr-sqrt78.5%

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

      \[\leadsto \frac{r}{\cos b \cdot \cos a - \color{blue}{\left(-\sin b \cdot \sin a\right)}} \cdot \sin b \]
    9. neg-mul-178.5%

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

      \[\leadsto \frac{r}{\cos b \cdot \cos a - -1 \cdot \left(\color{blue}{\left(\sqrt{\sin b} \cdot \sqrt{\sin b}\right)} \cdot \sin a\right)} \cdot \sin b \]
    11. sqrt-unprod90.1%

      \[\leadsto \frac{r}{\cos b \cdot \cos a - -1 \cdot \left(\color{blue}{\sqrt{\sin b \cdot \sin b}} \cdot \sin a\right)} \cdot \sin b \]
    12. sqr-neg90.1%

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

      \[\leadsto \frac{r}{\cos b \cdot \cos a - -1 \cdot \left(\color{blue}{\left(\sqrt{-\sin b} \cdot \sqrt{-\sin b}\right)} \cdot \sin a\right)} \cdot \sin b \]
    14. add-sqr-sqrt99.4%

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

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

    \[\leadsto \frac{r}{\color{blue}{\mathsf{fma}\left(\cos b, \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)}} \cdot \sin b \]
  8. Step-by-step derivation
    1. fma-udef99.4%

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

      \[\leadsto \frac{r}{\color{blue}{\left(\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)} \cdot \sin b \]
    3. add-sqr-sqrt51.3%

      \[\leadsto \frac{r}{\left(\cos b \cdot \cos a - \color{blue}{\sqrt{\left(\sin b \cdot \sin a\right) \cdot -1} \cdot \sqrt{\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)} \cdot \sin b \]
    4. sqrt-unprod90.0%

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

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

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

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

      \[\leadsto \frac{r}{\left(\cos b \cdot \cos a - \sqrt{\color{blue}{1} \cdot \left(\left(\sin b \cdot \sin a\right) \cdot \left(\sin b \cdot \sin a\right)\right)}\right) + \mathsf{fma}\left(\sin b \cdot \sin a, -1, \left(\sin b \cdot \sin a\right) \cdot -1\right)} \cdot \sin b \]
    9. *-un-lft-identity90.0%

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

      \[\leadsto \frac{r}{\left(\cos b \cdot \cos a - \color{blue}{\sqrt{\sin b \cdot \sin a} \cdot \sqrt{\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)} \cdot \sin b \]
    11. add-sqr-sqrt80.1%

      \[\leadsto \frac{r}{\left(\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)} \cdot \sin b \]
    12. fma-udef80.1%

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

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

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

Alternative 14: 51.5% accurate, 1.0× speedup?

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

\\
r \cdot \mathsf{log1p}\left(\frac{b}{\cos a}\right)
\end{array}
Derivation
  1. Initial program 78.6%

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

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

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

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

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

    \[\leadsto r \cdot \mathsf{log1p}\left(\color{blue}{\frac{b}{\cos a}}\right) \]
  7. Final simplification49.0%

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

Alternative 15: 55.4% 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 78.6%

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

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

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

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

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

Alternative 16: 51.6% accurate, 2.0× speedup?

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

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

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

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

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

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

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

Alternative 17: 51.6% accurate, 2.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{r}{\color{blue}{\mathsf{fma}\left(\cos b, \cos a, \left(-\sin b\right) \cdot \sin a\right)}} \cdot \sin b \]
  6. Taylor expanded in b around 0 48.5%

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

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

      \[\leadsto \color{blue}{\frac{r}{\frac{\cos a}{b}}} \]
    3. associate-/r/48.5%

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

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

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

Alternative 18: 51.6% accurate, 2.0× speedup?

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

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

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

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

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

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

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

Alternative 19: 35.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 78.6%

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

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

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

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

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

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

    \[\leadsto \color{blue}{r \cdot b} \]
  8. Final simplification35.3%

    \[\leadsto r \cdot b \]

Reproduce

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