rsin A (should all be same)

Percentage Accurate: 76.4% → 99.4%
Time: 17.7s
Alternatives: 18
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 18 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.4% accurate, 1.0× speedup?

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

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

Alternative 1: 99.4% accurate, 0.3× speedup?

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

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

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

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

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

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

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

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

      \[\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.4%

    \[\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.4%

      \[\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.4%

      \[\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.4%

      \[\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.4%

      \[\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.4%

      \[\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.4%

      \[\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.4%

      \[\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.4%

      \[\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.4%

      \[\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.4%

      \[\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.4%

    \[\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. Taylor expanded in r around 0 99.4%

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

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

Alternative 2: 99.5% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \frac{\sin b \cdot 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(Float64(sin(b) * r) / fma(cos(b), cos(a), Float64(sin(b) * Float64(-sin(a)))))
end
code[r_, a_, b_] := N[(N[(N[Sin[b], $MachinePrecision] * r), $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{\sin b \cdot r}{\mathsf{fma}\left(\cos b, \cos a, \sin b \cdot \left(-\sin a\right)\right)}
\end{array}
Derivation
  1. Initial program 70.2%

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

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

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

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

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

      \[\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.4%

    \[\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.4%

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

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

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

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

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

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

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

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

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

Alternative 4: 99.5% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \frac{\sin b \cdot 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(Float64(sin(b) * 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[(N[Sin[b], $MachinePrecision] * r), $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{\sin b \cdot r}{\cos a \cdot \cos b - \sin b \cdot \sin a}
\end{array}
Derivation
  1. Initial program 70.2%

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

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

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

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

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

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

Alternative 5: 77.3% accurate, 0.5× speedup?

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

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

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

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

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

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

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

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

      \[\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.4%

    \[\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.4%

      \[\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.4%

      \[\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.4%

      \[\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.4%

      \[\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.4%

      \[\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.4%

      \[\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.4%

      \[\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.4%

      \[\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.4%

      \[\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.4%

      \[\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.4%

    \[\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. Taylor expanded in r around 0 99.4%

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

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

      \[\leadsto \frac{\sin b \cdot r}{-2 \cdot \left(\sin a \cdot \sin b\right) + \color{blue}{\left(e^{\mathsf{log1p}\left(\sin a \cdot \sin b + \cos a \cdot \cos b\right)} - 1\right)}} \]
    3. +-commutative99.0%

      \[\leadsto \frac{\sin b \cdot r}{-2 \cdot \left(\sin a \cdot \sin b\right) + \left(e^{\mathsf{log1p}\left(\color{blue}{\cos a \cdot \cos b + \sin a \cdot \sin b}\right)} - 1\right)} \]
    4. cos-diff71.0%

      \[\leadsto \frac{\sin b \cdot r}{-2 \cdot \left(\sin a \cdot \sin b\right) + \left(e^{\mathsf{log1p}\left(\color{blue}{\cos \left(a - b\right)}\right)} - 1\right)} \]
  10. Applied egg-rr71.0%

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

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

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

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

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

Alternative 6: 76.1% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.0036 \lor \neg \left(b \leq 0.00245\right):\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\

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


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

    1. Initial program 47.4%

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

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

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

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

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

        \[\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.2%

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

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

        \[\leadsto \color{blue}{\sin b \cdot \frac{r}{\cos b}} \]
    8. Simplified47.7%

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

    if -0.0035999999999999999 < b < 0.0024499999999999999

    1. Initial program 98.5%

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

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

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

      \[\leadsto \frac{\color{blue}{r \cdot b}}{\cos \left(b + a\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification70.3%

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

Alternative 7: 76.4% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.0062 \lor \neg \left(a \leq 0.0027\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -0.00619999999999999978 or 0.0027000000000000001 < a

    1. Initial program 48.4%

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

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

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

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

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

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

    if -0.00619999999999999978 < a < 0.0027000000000000001

    1. Initial program 98.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 76.4% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 48.4%

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

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

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

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

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

    if -0.0560000000000000012 < a < 5.8e-4

    1. Initial program 98.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 74.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -0.0045:\\ \;\;\;\;\frac{b \cdot r}{\cos \left(b + a\right)}\\ \mathbf{elif}\;a \leq 0.03:\\ \;\;\;\;r \cdot \frac{1}{\frac{1}{\tan b} - a}\\ \mathbf{else}:\\ \;\;\;\;r \cdot \mathsf{log1p}\left(\frac{b}{\cos a}\right)\\ \end{array} \end{array} \]
(FPCore (r a b)
 :precision binary64
 (if (<= a -0.0045)
   (/ (* b r) (cos (+ b a)))
   (if (<= a 0.03)
     (* r (/ 1.0 (- (/ 1.0 (tan b)) a)))
     (* r (log1p (/ b (cos a)))))))
double code(double r, double a, double b) {
	double tmp;
	if (a <= -0.0045) {
		tmp = (b * r) / cos((b + a));
	} else if (a <= 0.03) {
		tmp = r * (1.0 / ((1.0 / tan(b)) - a));
	} else {
		tmp = r * log1p((b / cos(a)));
	}
	return tmp;
}
public static double code(double r, double a, double b) {
	double tmp;
	if (a <= -0.0045) {
		tmp = (b * r) / Math.cos((b + a));
	} else if (a <= 0.03) {
		tmp = r * (1.0 / ((1.0 / Math.tan(b)) - a));
	} else {
		tmp = r * Math.log1p((b / Math.cos(a)));
	}
	return tmp;
}
def code(r, a, b):
	tmp = 0
	if a <= -0.0045:
		tmp = (b * r) / math.cos((b + a))
	elif a <= 0.03:
		tmp = r * (1.0 / ((1.0 / math.tan(b)) - a))
	else:
		tmp = r * math.log1p((b / math.cos(a)))
	return tmp
function code(r, a, b)
	tmp = 0.0
	if (a <= -0.0045)
		tmp = Float64(Float64(b * r) / cos(Float64(b + a)));
	elseif (a <= 0.03)
		tmp = Float64(r * Float64(1.0 / Float64(Float64(1.0 / tan(b)) - a)));
	else
		tmp = Float64(r * log1p(Float64(b / cos(a))));
	end
	return tmp
end
code[r_, a_, b_] := If[LessEqual[a, -0.0045], N[(N[(b * r), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 0.03], N[(r * N[(1.0 / N[(N[(1.0 / N[Tan[b], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[Log[1 + N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.0045:\\
\;\;\;\;\frac{b \cdot r}{\cos \left(b + a\right)}\\

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

\mathbf{else}:\\
\;\;\;\;r \cdot \mathsf{log1p}\left(\frac{b}{\cos a}\right)\\


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

    1. Initial program 46.5%

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

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

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

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

    if -0.00449999999999999966 < a < 0.029999999999999999

    1. Initial program 98.2%

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.029999999999999999 < a

    1. Initial program 50.3%

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

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

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

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

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

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

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

      \[\leadsto \log \color{blue}{\left(\frac{b}{\cos a} + 1\right)} \cdot r \]
    7. Step-by-step derivation
      1. *-un-lft-identity8.6%

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

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

        \[\leadsto \left(\color{blue}{0} + \log \left(\frac{b}{\cos a} + 1\right)\right) \cdot r \]
      4. +-commutative8.6%

        \[\leadsto \left(0 + \log \color{blue}{\left(1 + \frac{b}{\cos a}\right)}\right) \cdot r \]
      5. log1p-udef46.0%

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

      \[\leadsto \color{blue}{\left(0 + \mathsf{log1p}\left(\frac{b}{\cos a}\right)\right)} \cdot r \]
    9. Step-by-step derivation
      1. +-lft-identity46.0%

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

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\frac{b}{\cos a}\right)} \cdot r \]
  3. Recombined 3 regimes into one program.
  4. Final simplification68.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -0.0045:\\ \;\;\;\;\frac{b \cdot r}{\cos \left(b + a\right)}\\ \mathbf{elif}\;a \leq 0.03:\\ \;\;\;\;r \cdot \frac{1}{\frac{1}{\tan b} - a}\\ \mathbf{else}:\\ \;\;\;\;r \cdot \mathsf{log1p}\left(\frac{b}{\cos a}\right)\\ \end{array} \]

Alternative 10: 76.4% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 46.5%

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

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

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

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

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

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

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

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

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

    if -0.00279999999999999997 < a < 0.0029

    1. Initial program 98.2%

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.0029 < a

    1. Initial program 50.3%

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

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

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

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

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

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

Alternative 11: 76.4% 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 70.2%

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

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

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

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

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

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

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

Alternative 12: 74.8% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{1}{\tan b} - a\\
\mathbf{if}\;b \leq -0.053:\\
\;\;\;\;\frac{r}{t_0}\\

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

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


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

    1. Initial program 50.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{r}{\color{blue}{\frac{1}{\tan b}} - a} \]
    10. Simplified47.0%

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

    if -0.0529999999999999985 < b < 8.20000000000000009e-5

    1. Initial program 97.9%

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

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

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

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

    if 8.20000000000000009e-5 < b

    1. Initial program 45.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 74.8% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.053 \lor \neg \left(b \leq 0.00023\right):\\
\;\;\;\;\frac{r}{\frac{1}{\tan b} - a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -0.0529999999999999985 or 2.3000000000000001e-4 < b

    1. Initial program 47.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{r}{\color{blue}{\frac{1}{\tan b}} - a} \]
    10. Simplified44.6%

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

    if -0.0529999999999999985 < b < 2.3000000000000001e-4

    1. Initial program 97.9%

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

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

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

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

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

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

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

Alternative 14: 74.8% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.053 \lor \neg \left(b \leq 0.00028\right):\\
\;\;\;\;\frac{r}{\frac{1}{\tan b} - a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -0.0529999999999999985 or 2.7999999999999998e-4 < b

    1. Initial program 47.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{r}{\color{blue}{\frac{1}{\tan b}} - a} \]
    10. Simplified44.6%

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

    if -0.0529999999999999985 < b < 2.7999999999999998e-4

    1. Initial program 97.9%

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

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

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

      \[\leadsto \frac{\color{blue}{r \cdot b}}{\cos \left(b + a\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification68.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -0.053 \lor \neg \left(b \leq 0.00028\right):\\ \;\;\;\;\frac{r}{\frac{1}{\tan b} - a}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot r}{\cos \left(b + a\right)}\\ \end{array} \]

Alternative 15: 50.8% 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 70.2%

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

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

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

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

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

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

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

Alternative 16: 50.8% accurate, 2.0× speedup?

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

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

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

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

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

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

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

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

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

Alternative 17: 34.0% accurate, 2.0× speedup?

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\log \left(1 + b\right)} \cdot r \]
  8. Step-by-step derivation
    1. log1p-def29.3%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(b\right)} \cdot r \]
  9. Simplified29.3%

    \[\leadsto \color{blue}{\mathsf{log1p}\left(b\right)} \cdot r \]
  10. Final simplification29.3%

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

Alternative 18: 34.1% accurate, 69.0× speedup?

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

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

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

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

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

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

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

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

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

    \[\leadsto b \cdot r \]

Reproduce

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