rsin B (should all be same)

Percentage Accurate: 76.7% → 99.5%
Time: 14.7s
Alternatives: 11
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 11 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.7% 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.4× speedup?

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

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

    \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. cos-sumN/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos a \cdot \cos b - \sin a \cdot \sin b}} \]
    2. sub-negN/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos a \cdot \cos b + \left(\mathsf{neg}\left(\sin a \cdot \sin b\right)\right)}} \]
    3. +-commutativeN/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\left(\mathsf{neg}\left(\sin a \cdot \sin b\right)\right) + \cos a \cdot \cos b}} \]
    4. *-commutativeN/A

      \[\leadsto r \cdot \frac{\sin b}{\left(\mathsf{neg}\left(\color{blue}{\sin b \cdot \sin a}\right)\right) + \cos a \cdot \cos b} \]
    5. distribute-lft-neg-inN/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\left(\mathsf{neg}\left(\sin b\right)\right) \cdot \sin a} + \cos a \cdot \cos b} \]
    6. accelerator-lowering-fma.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(\sin b\right), \sin a, \cos a \cdot \cos b\right)}} \]
    7. neg-sub0N/A

      \[\leadsto r \cdot \frac{\sin b}{\mathsf{fma}\left(\color{blue}{0 - \sin b}, \sin a, \cos a \cdot \cos b\right)} \]
    8. --lowering--.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\mathsf{fma}\left(\color{blue}{0 - \sin b}, \sin a, \cos a \cdot \cos b\right)} \]
    9. sin-lowering-sin.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\mathsf{fma}\left(0 - \color{blue}{\sin b}, \sin a, \cos a \cdot \cos b\right)} \]
    10. sin-lowering-sin.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\mathsf{fma}\left(0 - \sin b, \color{blue}{\sin a}, \cos a \cdot \cos b\right)} \]
    11. *-lowering-*.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\mathsf{fma}\left(0 - \sin b, \sin a, \color{blue}{\cos a \cdot \cos b}\right)} \]
    12. cos-lowering-cos.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\mathsf{fma}\left(0 - \sin b, \sin a, \color{blue}{\cos a} \cdot \cos b\right)} \]
    13. cos-lowering-cos.f6499.5

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

    \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\mathsf{fma}\left(0 - \sin b, \sin a, \cos a \cdot \cos b\right)}} \]
  5. Step-by-step derivation
    1. sub0-negN/A

      \[\leadsto r \cdot \frac{\sin b}{\mathsf{fma}\left(\color{blue}{\mathsf{neg}\left(\sin b\right)}, \sin a, \cos a \cdot \cos b\right)} \]
    2. neg-lowering-neg.f64N/A

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

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

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

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

Alternative 2: 76.2% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\sin b}{\cos \left(b + a\right)}\\ t_1 := r \cdot \tan b\\ \mathbf{if}\;t\_0 \leq -0.025:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 0.0015:\\ \;\;\;\;b \cdot \frac{r}{\cos a}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (r a b)
 :precision binary64
 (let* ((t_0 (/ (sin b) (cos (+ b a)))) (t_1 (* r (tan b))))
   (if (<= t_0 -0.025) t_1 (if (<= t_0 0.0015) (* b (/ r (cos a))) t_1))))
double code(double r, double a, double b) {
	double t_0 = sin(b) / cos((b + a));
	double t_1 = r * tan(b);
	double tmp;
	if (t_0 <= -0.025) {
		tmp = t_1;
	} else if (t_0 <= 0.0015) {
		tmp = b * (r / cos(a));
	} else {
		tmp = t_1;
	}
	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) :: t_1
    real(8) :: tmp
    t_0 = sin(b) / cos((b + a))
    t_1 = r * tan(b)
    if (t_0 <= (-0.025d0)) then
        tmp = t_1
    else if (t_0 <= 0.0015d0) then
        tmp = b * (r / cos(a))
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double r, double a, double b) {
	double t_0 = Math.sin(b) / Math.cos((b + a));
	double t_1 = r * Math.tan(b);
	double tmp;
	if (t_0 <= -0.025) {
		tmp = t_1;
	} else if (t_0 <= 0.0015) {
		tmp = b * (r / Math.cos(a));
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(r, a, b):
	t_0 = math.sin(b) / math.cos((b + a))
	t_1 = r * math.tan(b)
	tmp = 0
	if t_0 <= -0.025:
		tmp = t_1
	elif t_0 <= 0.0015:
		tmp = b * (r / math.cos(a))
	else:
		tmp = t_1
	return tmp
function code(r, a, b)
	t_0 = Float64(sin(b) / cos(Float64(b + a)))
	t_1 = Float64(r * tan(b))
	tmp = 0.0
	if (t_0 <= -0.025)
		tmp = t_1;
	elseif (t_0 <= 0.0015)
		tmp = Float64(b * Float64(r / cos(a)));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(r, a, b)
	t_0 = sin(b) / cos((b + a));
	t_1 = r * tan(b);
	tmp = 0.0;
	if (t_0 <= -0.025)
		tmp = t_1;
	elseif (t_0 <= 0.0015)
		tmp = b * (r / cos(a));
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[Sin[b], $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.025], t$95$1, If[LessEqual[t$95$0, 0.0015], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\sin b}{\cos \left(b + a\right)}\\
t_1 := r \cdot \tan b\\
\mathbf{if}\;t\_0 \leq -0.025:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_0 \leq 0.0015:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < -0.025000000000000001 or 0.0015 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b)))

    1. Initial program 50.6%

      \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-numN/A

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{r}}{\cos \left(a + b\right)} \cdot \sin b \]
      8. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{r}{\cos \left(a + b\right)}} \cdot \sin b \]
      9. cos-lowering-cos.f64N/A

        \[\leadsto \frac{r}{\color{blue}{\cos \left(a + b\right)}} \cdot \sin b \]
      10. +-commutativeN/A

        \[\leadsto \frac{r}{\cos \color{blue}{\left(b + a\right)}} \cdot \sin b \]
      11. +-lowering-+.f64N/A

        \[\leadsto \frac{r}{\cos \color{blue}{\left(b + a\right)}} \cdot \sin b \]
      12. sin-lowering-sin.f6450.7

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

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

      \[\leadsto \color{blue}{\frac{r}{\cos b}} \cdot \sin b \]
    6. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{r}{\cos b}} \cdot \sin b \]
      2. cos-lowering-cos.f6451.3

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

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

        \[\leadsto \color{blue}{\frac{r \cdot \sin b}{\cos b}} \]
      2. associate-/l*N/A

        \[\leadsto \color{blue}{r \cdot \frac{\sin b}{\cos b}} \]
      3. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{r \cdot \frac{\sin b}{\cos b}} \]
      4. quot-tanN/A

        \[\leadsto r \cdot \color{blue}{\tan b} \]
      5. tan-lowering-tan.f6451.4

        \[\leadsto r \cdot \color{blue}{\tan b} \]
    9. Applied egg-rr51.4%

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

    if -0.025000000000000001 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < 0.0015

    1. Initial program 97.6%

      \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in b around 0

      \[\leadsto \color{blue}{\frac{b \cdot r}{\cos a}} \]
    4. Step-by-step derivation
      1. associate-/l*N/A

        \[\leadsto \color{blue}{b \cdot \frac{r}{\cos a}} \]
      2. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{b \cdot \frac{r}{\cos a}} \]
      3. /-lowering-/.f64N/A

        \[\leadsto b \cdot \color{blue}{\frac{r}{\cos a}} \]
      4. cos-lowering-cos.f6497.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin b}{\cos \left(b + a\right)} \leq -0.025:\\ \;\;\;\;r \cdot \tan b\\ \mathbf{elif}\;\frac{\sin b}{\cos \left(b + a\right)} \leq 0.0015:\\ \;\;\;\;b \cdot \frac{r}{\cos a}\\ \mathbf{else}:\\ \;\;\;\;r \cdot \tan b\\ \end{array} \]
  5. Add Preprocessing

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 74.1%

    \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. cos-sumN/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos a \cdot \cos b - \sin a \cdot \sin b}} \]
    2. --lowering--.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos a \cdot \cos b - \sin a \cdot \sin b}} \]
    3. *-lowering-*.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos a \cdot \cos b} - \sin a \cdot \sin b} \]
    4. cos-lowering-cos.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos a} \cdot \cos b - \sin a \cdot \sin b} \]
    5. cos-lowering-cos.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\cos a \cdot \color{blue}{\cos b} - \sin a \cdot \sin b} \]
    6. *-commutativeN/A

      \[\leadsto r \cdot \frac{\sin b}{\cos a \cdot \cos b - \color{blue}{\sin b \cdot \sin a}} \]
    7. *-lowering-*.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\cos a \cdot \cos b - \color{blue}{\sin b \cdot \sin a}} \]
    8. sin-lowering-sin.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\cos a \cdot \cos b - \color{blue}{\sin b} \cdot \sin a} \]
    9. sin-lowering-sin.f6499.5

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

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

Alternative 4: 76.7% accurate, 0.9× speedup?

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

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

    \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. clear-numN/A

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{r}}{\cos \left(a + b\right)} \cdot \sin b \]
    8. /-lowering-/.f64N/A

      \[\leadsto \color{blue}{\frac{r}{\cos \left(a + b\right)}} \cdot \sin b \]
    9. cos-lowering-cos.f64N/A

      \[\leadsto \frac{r}{\color{blue}{\cos \left(a + b\right)}} \cdot \sin b \]
    10. +-commutativeN/A

      \[\leadsto \frac{r}{\cos \color{blue}{\left(b + a\right)}} \cdot \sin b \]
    11. +-lowering-+.f64N/A

      \[\leadsto \frac{r}{\cos \color{blue}{\left(b + a\right)}} \cdot \sin b \]
    12. sin-lowering-sin.f6474.1

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

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

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

      \[\leadsto \frac{r}{\cos \color{blue}{\left(\frac{a \cdot a - b \cdot b}{a - b}\right)}} \cdot \sin b \]
    3. frac-2negN/A

      \[\leadsto \frac{r}{\cos \color{blue}{\left(\frac{\mathsf{neg}\left(\left(a \cdot a - b \cdot b\right)\right)}{\mathsf{neg}\left(\left(a - b\right)\right)}\right)}} \cdot \sin b \]
    4. difference-of-squaresN/A

      \[\leadsto \frac{r}{\cos \left(\frac{\mathsf{neg}\left(\color{blue}{\left(a + b\right) \cdot \left(a - b\right)}\right)}{\mathsf{neg}\left(\left(a - b\right)\right)}\right)} \cdot \sin b \]
    5. +-commutativeN/A

      \[\leadsto \frac{r}{\cos \left(\frac{\mathsf{neg}\left(\color{blue}{\left(b + a\right)} \cdot \left(a - b\right)\right)}{\mathsf{neg}\left(\left(a - b\right)\right)}\right)} \cdot \sin b \]
    6. *-commutativeN/A

      \[\leadsto \frac{r}{\cos \left(\frac{\mathsf{neg}\left(\color{blue}{\left(a - b\right) \cdot \left(b + a\right)}\right)}{\mathsf{neg}\left(\left(a - b\right)\right)}\right)} \cdot \sin b \]
    7. distribute-lft-neg-inN/A

      \[\leadsto \frac{r}{\cos \left(\frac{\color{blue}{\left(\mathsf{neg}\left(\left(a - b\right)\right)\right) \cdot \left(b + a\right)}}{\mathsf{neg}\left(\left(a - b\right)\right)}\right)} \cdot \sin b \]
    8. sub0-negN/A

      \[\leadsto \frac{r}{\cos \left(\frac{\color{blue}{\left(0 - \left(a - b\right)\right)} \cdot \left(b + a\right)}{\mathsf{neg}\left(\left(a - b\right)\right)}\right)} \cdot \sin b \]
    9. neg-mul-1N/A

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

      \[\leadsto \frac{r}{\cos \color{blue}{\left(\frac{0 - \left(a - b\right)}{-1} \cdot \frac{b + a}{a - b}\right)}} \cdot \sin b \]
    11. *-lowering-*.f64N/A

      \[\leadsto \frac{r}{\cos \color{blue}{\left(\frac{0 - \left(a - b\right)}{-1} \cdot \frac{b + a}{a - b}\right)}} \cdot \sin b \]
    12. /-lowering-/.f64N/A

      \[\leadsto \frac{r}{\cos \left(\color{blue}{\frac{0 - \left(a - b\right)}{-1}} \cdot \frac{b + a}{a - b}\right)} \cdot \sin b \]
    13. associate--r-N/A

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

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

      \[\leadsto \frac{r}{\cos \left(\frac{b + \color{blue}{\left(\mathsf{neg}\left(a\right)\right)}}{-1} \cdot \frac{b + a}{a - b}\right)} \cdot \sin b \]
    16. sub-negN/A

      \[\leadsto \frac{r}{\cos \left(\frac{\color{blue}{b - a}}{-1} \cdot \frac{b + a}{a - b}\right)} \cdot \sin b \]
    17. --lowering--.f64N/A

      \[\leadsto \frac{r}{\cos \left(\frac{\color{blue}{b - a}}{-1} \cdot \frac{b + a}{a - b}\right)} \cdot \sin b \]
    18. /-lowering-/.f64N/A

      \[\leadsto \frac{r}{\cos \left(\frac{b - a}{-1} \cdot \color{blue}{\frac{b + a}{a - b}}\right)} \cdot \sin b \]
    19. +-lowering-+.f64N/A

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

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

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

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

Alternative 5: 76.7% accurate, 0.9× speedup?

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

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

    \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. flip-+N/A

      \[\leadsto r \cdot \frac{\sin b}{\cos \color{blue}{\left(\frac{a \cdot a - b \cdot b}{a - b}\right)}} \]
    2. frac-2negN/A

      \[\leadsto r \cdot \frac{\sin b}{\cos \color{blue}{\left(\frac{\mathsf{neg}\left(\left(a \cdot a - b \cdot b\right)\right)}{\mathsf{neg}\left(\left(a - b\right)\right)}\right)}} \]
    3. distribute-frac-negN/A

      \[\leadsto r \cdot \frac{\sin b}{\cos \color{blue}{\left(\mathsf{neg}\left(\frac{a \cdot a - b \cdot b}{\mathsf{neg}\left(\left(a - b\right)\right)}\right)\right)}} \]
    4. cos-negN/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos \left(\frac{a \cdot a - b \cdot b}{\mathsf{neg}\left(\left(a - b\right)\right)}\right)}} \]
    5. cos-lowering-cos.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos \left(\frac{a \cdot a - b \cdot b}{\mathsf{neg}\left(\left(a - b\right)\right)}\right)}} \]
    6. /-lowering-/.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\cos \color{blue}{\left(\frac{a \cdot a - b \cdot b}{\mathsf{neg}\left(\left(a - b\right)\right)}\right)}} \]
    7. difference-of-squaresN/A

      \[\leadsto r \cdot \frac{\sin b}{\cos \left(\frac{\color{blue}{\left(a + b\right) \cdot \left(a - b\right)}}{\mathsf{neg}\left(\left(a - b\right)\right)}\right)} \]
    8. *-lowering-*.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\cos \left(\frac{\color{blue}{\left(a + b\right) \cdot \left(a - b\right)}}{\mathsf{neg}\left(\left(a - b\right)\right)}\right)} \]
    9. +-commutativeN/A

      \[\leadsto r \cdot \frac{\sin b}{\cos \left(\frac{\color{blue}{\left(b + a\right)} \cdot \left(a - b\right)}{\mathsf{neg}\left(\left(a - b\right)\right)}\right)} \]
    10. +-lowering-+.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\cos \left(\frac{\color{blue}{\left(b + a\right)} \cdot \left(a - b\right)}{\mathsf{neg}\left(\left(a - b\right)\right)}\right)} \]
    11. --lowering--.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\cos \left(\frac{\left(b + a\right) \cdot \color{blue}{\left(a - b\right)}}{\mathsf{neg}\left(\left(a - b\right)\right)}\right)} \]
    12. neg-sub0N/A

      \[\leadsto r \cdot \frac{\sin b}{\cos \left(\frac{\left(b + a\right) \cdot \left(a - b\right)}{\color{blue}{0 - \left(a - b\right)}}\right)} \]
    13. --lowering--.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\cos \left(\frac{\left(b + a\right) \cdot \left(a - b\right)}{\color{blue}{0 - \left(a - b\right)}}\right)} \]
    14. --lowering--.f6448.4

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

    \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos \left(\frac{\left(b + a\right) \cdot \left(a - b\right)}{0 - \left(a - b\right)}\right)}} \]
  5. Step-by-step derivation
    1. *-commutativeN/A

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

      \[\leadsto r \cdot \frac{\sin b}{\cos \color{blue}{\left(\left(a - b\right) \cdot \frac{b + a}{0 - \left(a - b\right)}\right)}} \]
    3. *-lowering-*.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\cos \color{blue}{\left(\left(a - b\right) \cdot \frac{b + a}{0 - \left(a - b\right)}\right)}} \]
    4. --lowering--.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\cos \left(\color{blue}{\left(a - b\right)} \cdot \frac{b + a}{0 - \left(a - b\right)}\right)} \]
    5. /-lowering-/.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\cos \left(\left(a - b\right) \cdot \color{blue}{\frac{b + a}{0 - \left(a - b\right)}}\right)} \]
    6. +-lowering-+.f64N/A

      \[\leadsto r \cdot \frac{\sin b}{\cos \left(\left(a - b\right) \cdot \frac{\color{blue}{b + a}}{0 - \left(a - b\right)}\right)} \]
    7. associate--r-N/A

      \[\leadsto r \cdot \frac{\sin b}{\cos \left(\left(a - b\right) \cdot \frac{b + a}{\color{blue}{\left(0 - a\right) + b}}\right)} \]
    8. +-commutativeN/A

      \[\leadsto r \cdot \frac{\sin b}{\cos \left(\left(a - b\right) \cdot \frac{b + a}{\color{blue}{b + \left(0 - a\right)}}\right)} \]
    9. sub0-negN/A

      \[\leadsto r \cdot \frac{\sin b}{\cos \left(\left(a - b\right) \cdot \frac{b + a}{b + \color{blue}{\left(\mathsf{neg}\left(a\right)\right)}}\right)} \]
    10. sub-negN/A

      \[\leadsto r \cdot \frac{\sin b}{\cos \left(\left(a - b\right) \cdot \frac{b + a}{\color{blue}{b - a}}\right)} \]
    11. --lowering--.f6474.4

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

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

Alternative 6: 76.7% 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 74.1%

    \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. clear-numN/A

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{r}}{\cos \left(a + b\right)} \cdot \sin b \]
    8. /-lowering-/.f64N/A

      \[\leadsto \color{blue}{\frac{r}{\cos \left(a + b\right)}} \cdot \sin b \]
    9. cos-lowering-cos.f64N/A

      \[\leadsto \frac{r}{\color{blue}{\cos \left(a + b\right)}} \cdot \sin b \]
    10. +-commutativeN/A

      \[\leadsto \frac{r}{\cos \color{blue}{\left(b + a\right)}} \cdot \sin b \]
    11. +-lowering-+.f64N/A

      \[\leadsto \frac{r}{\cos \color{blue}{\left(b + a\right)}} \cdot \sin b \]
    12. sin-lowering-sin.f6474.1

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

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

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

Alternative 7: 76.7% 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 74.1%

    \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
  2. Add Preprocessing
  3. Final simplification74.1%

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

Alternative 8: 76.6% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := r \cdot \tan b\\ \mathbf{if}\;b \leq -0.076:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;b \leq 0.032:\\ \;\;\;\;r \cdot \frac{b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b, b \cdot \mathsf{fma}\left(b \cdot b, -0.0001984126984126984, 0.008333333333333333\right), -0.16666666666666666\right), 1\right)}{\cos \left(b + a\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{1}{t\_0}}\\ \end{array} \end{array} \]
(FPCore (r a b)
 :precision binary64
 (let* ((t_0 (* r (tan b))))
   (if (<= b -0.076)
     t_0
     (if (<= b 0.032)
       (*
        r
        (/
         (*
          b
          (fma
           (* b b)
           (fma
            b
            (* b (fma (* b b) -0.0001984126984126984 0.008333333333333333))
            -0.16666666666666666)
           1.0))
         (cos (+ b a))))
       (/ 1.0 (/ 1.0 t_0))))))
double code(double r, double a, double b) {
	double t_0 = r * tan(b);
	double tmp;
	if (b <= -0.076) {
		tmp = t_0;
	} else if (b <= 0.032) {
		tmp = r * ((b * fma((b * b), fma(b, (b * fma((b * b), -0.0001984126984126984, 0.008333333333333333)), -0.16666666666666666), 1.0)) / cos((b + a)));
	} else {
		tmp = 1.0 / (1.0 / t_0);
	}
	return tmp;
}
function code(r, a, b)
	t_0 = Float64(r * tan(b))
	tmp = 0.0
	if (b <= -0.076)
		tmp = t_0;
	elseif (b <= 0.032)
		tmp = Float64(r * Float64(Float64(b * fma(Float64(b * b), fma(b, Float64(b * fma(Float64(b * b), -0.0001984126984126984, 0.008333333333333333)), -0.16666666666666666), 1.0)) / cos(Float64(b + a))));
	else
		tmp = Float64(1.0 / Float64(1.0 / t_0));
	end
	return tmp
end
code[r_, a_, b_] := Block[{t$95$0 = N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -0.076], t$95$0, If[LessEqual[b, 0.032], N[(r * N[(N[(b * N[(N[(b * b), $MachinePrecision] * N[(b * N[(b * N[(N[(b * b), $MachinePrecision] * -0.0001984126984126984 + 0.008333333333333333), $MachinePrecision]), $MachinePrecision] + -0.16666666666666666), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := r \cdot \tan b\\
\mathbf{if}\;b \leq -0.076:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;b \leq 0.032:\\
\;\;\;\;r \cdot \frac{b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b, b \cdot \mathsf{fma}\left(b \cdot b, -0.0001984126984126984, 0.008333333333333333\right), -0.16666666666666666\right), 1\right)}{\cos \left(b + a\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{1}{t\_0}}\\


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

    1. Initial program 56.6%

      \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-numN/A

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{r}}{\cos \left(a + b\right)} \cdot \sin b \]
      8. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{r}{\cos \left(a + b\right)}} \cdot \sin b \]
      9. cos-lowering-cos.f64N/A

        \[\leadsto \frac{r}{\color{blue}{\cos \left(a + b\right)}} \cdot \sin b \]
      10. +-commutativeN/A

        \[\leadsto \frac{r}{\cos \color{blue}{\left(b + a\right)}} \cdot \sin b \]
      11. +-lowering-+.f64N/A

        \[\leadsto \frac{r}{\cos \color{blue}{\left(b + a\right)}} \cdot \sin b \]
      12. sin-lowering-sin.f6456.7

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

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

      \[\leadsto \color{blue}{\frac{r}{\cos b}} \cdot \sin b \]
    6. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{r}{\cos b}} \cdot \sin b \]
      2. cos-lowering-cos.f6458.2

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

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

        \[\leadsto \color{blue}{\frac{r \cdot \sin b}{\cos b}} \]
      2. associate-/l*N/A

        \[\leadsto \color{blue}{r \cdot \frac{\sin b}{\cos b}} \]
      3. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{r \cdot \frac{\sin b}{\cos b}} \]
      4. quot-tanN/A

        \[\leadsto r \cdot \color{blue}{\tan b} \]
      5. tan-lowering-tan.f6458.2

        \[\leadsto r \cdot \color{blue}{\tan b} \]
    9. Applied egg-rr58.2%

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

    if -0.0759999999999999981 < b < 0.032000000000000001

    1. Initial program 97.6%

      \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in b around 0

      \[\leadsto r \cdot \frac{\color{blue}{b \cdot \left(1 + {b}^{2} \cdot \left({b}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}\right) - \frac{1}{6}\right)\right)}}{\cos \left(a + b\right)} \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto r \cdot \frac{\color{blue}{b \cdot \left(1 + {b}^{2} \cdot \left({b}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}\right) - \frac{1}{6}\right)\right)}}{\cos \left(a + b\right)} \]
      2. +-commutativeN/A

        \[\leadsto r \cdot \frac{b \cdot \color{blue}{\left({b}^{2} \cdot \left({b}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}\right) - \frac{1}{6}\right) + 1\right)}}{\cos \left(a + b\right)} \]
      3. accelerator-lowering-fma.f64N/A

        \[\leadsto r \cdot \frac{b \cdot \color{blue}{\mathsf{fma}\left({b}^{2}, {b}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}\right) - \frac{1}{6}, 1\right)}}{\cos \left(a + b\right)} \]
      4. unpow2N/A

        \[\leadsto r \cdot \frac{b \cdot \mathsf{fma}\left(\color{blue}{b \cdot b}, {b}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}\right) - \frac{1}{6}, 1\right)}{\cos \left(a + b\right)} \]
      5. *-lowering-*.f64N/A

        \[\leadsto r \cdot \frac{b \cdot \mathsf{fma}\left(\color{blue}{b \cdot b}, {b}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}\right) - \frac{1}{6}, 1\right)}{\cos \left(a + b\right)} \]
      6. sub-negN/A

        \[\leadsto r \cdot \frac{b \cdot \mathsf{fma}\left(b \cdot b, \color{blue}{{b}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}\right) + \left(\mathsf{neg}\left(\frac{1}{6}\right)\right)}, 1\right)}{\cos \left(a + b\right)} \]
      7. unpow2N/A

        \[\leadsto r \cdot \frac{b \cdot \mathsf{fma}\left(b \cdot b, \color{blue}{\left(b \cdot b\right)} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}\right) + \left(\mathsf{neg}\left(\frac{1}{6}\right)\right), 1\right)}{\cos \left(a + b\right)} \]
      8. associate-*l*N/A

        \[\leadsto r \cdot \frac{b \cdot \mathsf{fma}\left(b \cdot b, \color{blue}{b \cdot \left(b \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}\right)\right)} + \left(\mathsf{neg}\left(\frac{1}{6}\right)\right), 1\right)}{\cos \left(a + b\right)} \]
      9. *-commutativeN/A

        \[\leadsto r \cdot \frac{b \cdot \mathsf{fma}\left(b \cdot b, b \cdot \color{blue}{\left(\left(\frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}\right) \cdot b\right)} + \left(\mathsf{neg}\left(\frac{1}{6}\right)\right), 1\right)}{\cos \left(a + b\right)} \]
      10. metadata-evalN/A

        \[\leadsto r \cdot \frac{b \cdot \mathsf{fma}\left(b \cdot b, b \cdot \left(\left(\frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}\right) \cdot b\right) + \color{blue}{\frac{-1}{6}}, 1\right)}{\cos \left(a + b\right)} \]
      11. accelerator-lowering-fma.f64N/A

        \[\leadsto r \cdot \frac{b \cdot \mathsf{fma}\left(b \cdot b, \color{blue}{\mathsf{fma}\left(b, \left(\frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}\right) \cdot b, \frac{-1}{6}\right)}, 1\right)}{\cos \left(a + b\right)} \]
      12. *-commutativeN/A

        \[\leadsto r \cdot \frac{b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b, \color{blue}{b \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}\right)}, \frac{-1}{6}\right), 1\right)}{\cos \left(a + b\right)} \]
      13. *-lowering-*.f64N/A

        \[\leadsto r \cdot \frac{b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b, \color{blue}{b \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}\right)}, \frac{-1}{6}\right), 1\right)}{\cos \left(a + b\right)} \]
      14. +-commutativeN/A

        \[\leadsto r \cdot \frac{b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b, b \cdot \color{blue}{\left(\frac{-1}{5040} \cdot {b}^{2} + \frac{1}{120}\right)}, \frac{-1}{6}\right), 1\right)}{\cos \left(a + b\right)} \]
      15. *-commutativeN/A

        \[\leadsto r \cdot \frac{b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b, b \cdot \left(\color{blue}{{b}^{2} \cdot \frac{-1}{5040}} + \frac{1}{120}\right), \frac{-1}{6}\right), 1\right)}{\cos \left(a + b\right)} \]
      16. accelerator-lowering-fma.f64N/A

        \[\leadsto r \cdot \frac{b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b, b \cdot \color{blue}{\mathsf{fma}\left({b}^{2}, \frac{-1}{5040}, \frac{1}{120}\right)}, \frac{-1}{6}\right), 1\right)}{\cos \left(a + b\right)} \]
      17. unpow2N/A

        \[\leadsto r \cdot \frac{b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b, b \cdot \mathsf{fma}\left(\color{blue}{b \cdot b}, \frac{-1}{5040}, \frac{1}{120}\right), \frac{-1}{6}\right), 1\right)}{\cos \left(a + b\right)} \]
      18. *-lowering-*.f6497.6

        \[\leadsto r \cdot \frac{b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b, b \cdot \mathsf{fma}\left(\color{blue}{b \cdot b}, -0.0001984126984126984, 0.008333333333333333\right), -0.16666666666666666\right), 1\right)}{\cos \left(a + b\right)} \]
    5. Simplified97.6%

      \[\leadsto r \cdot \frac{\color{blue}{b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b, b \cdot \mathsf{fma}\left(b \cdot b, -0.0001984126984126984, 0.008333333333333333\right), -0.16666666666666666\right), 1\right)}}{\cos \left(a + b\right)} \]

    if 0.032000000000000001 < b

    1. Initial program 42.9%

      \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-numN/A

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{r}}{\cos \left(a + b\right)} \cdot \sin b \]
      8. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{r}{\cos \left(a + b\right)}} \cdot \sin b \]
      9. cos-lowering-cos.f64N/A

        \[\leadsto \frac{r}{\color{blue}{\cos \left(a + b\right)}} \cdot \sin b \]
      10. +-commutativeN/A

        \[\leadsto \frac{r}{\cos \color{blue}{\left(b + a\right)}} \cdot \sin b \]
      11. +-lowering-+.f64N/A

        \[\leadsto \frac{r}{\cos \color{blue}{\left(b + a\right)}} \cdot \sin b \]
      12. sin-lowering-sin.f6442.9

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

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

      \[\leadsto \color{blue}{\frac{r}{\cos b}} \cdot \sin b \]
    6. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{r}{\cos b}} \cdot \sin b \]
      2. cos-lowering-cos.f6442.6

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

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

        \[\leadsto \color{blue}{\frac{r \cdot \sin b}{\cos b}} \]
      2. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{\sin b \cdot r}}{\cos b} \]
      3. clear-numN/A

        \[\leadsto \color{blue}{\frac{1}{\frac{\cos b}{\sin b \cdot r}}} \]
      4. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{1}{\frac{\cos b}{\sin b \cdot r}}} \]
      5. clear-numN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{\sin b \cdot r}{\cos b}}}} \]
      6. *-commutativeN/A

        \[\leadsto \frac{1}{\frac{1}{\frac{\color{blue}{r \cdot \sin b}}{\cos b}}} \]
      7. associate-*l/N/A

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{\frac{r}{\cos b} \cdot \sin b}}} \]
      8. /-lowering-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{r}{\cos b} \cdot \sin b}}} \]
      9. associate-*l/N/A

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{\frac{r \cdot \sin b}{\cos b}}}} \]
      10. associate-/l*N/A

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{r \cdot \frac{\sin b}{\cos b}}}} \]
      11. *-lowering-*.f64N/A

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{r \cdot \frac{\sin b}{\cos b}}}} \]
      12. quot-tanN/A

        \[\leadsto \frac{1}{\frac{1}{r \cdot \color{blue}{\tan b}}} \]
      13. tan-lowering-tan.f6442.7

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -0.076:\\ \;\;\;\;r \cdot \tan b\\ \mathbf{elif}\;b \leq 0.032:\\ \;\;\;\;r \cdot \frac{b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b, b \cdot \mathsf{fma}\left(b \cdot b, -0.0001984126984126984, 0.008333333333333333\right), -0.16666666666666666\right), 1\right)}{\cos \left(b + a\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{1}{r \cdot \tan b}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 76.6% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := r \cdot \tan b\\ \mathbf{if}\;b \leq -0.0305:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;b \leq 0.029:\\ \;\;\;\;r \cdot \frac{b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b \cdot b, 0.008333333333333333, -0.16666666666666666\right), 1\right)}{\cos \left(b + a\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{1}{t\_0}}\\ \end{array} \end{array} \]
(FPCore (r a b)
 :precision binary64
 (let* ((t_0 (* r (tan b))))
   (if (<= b -0.0305)
     t_0
     (if (<= b 0.029)
       (*
        r
        (/
         (*
          b
          (fma
           (* b b)
           (fma (* b b) 0.008333333333333333 -0.16666666666666666)
           1.0))
         (cos (+ b a))))
       (/ 1.0 (/ 1.0 t_0))))))
double code(double r, double a, double b) {
	double t_0 = r * tan(b);
	double tmp;
	if (b <= -0.0305) {
		tmp = t_0;
	} else if (b <= 0.029) {
		tmp = r * ((b * fma((b * b), fma((b * b), 0.008333333333333333, -0.16666666666666666), 1.0)) / cos((b + a)));
	} else {
		tmp = 1.0 / (1.0 / t_0);
	}
	return tmp;
}
function code(r, a, b)
	t_0 = Float64(r * tan(b))
	tmp = 0.0
	if (b <= -0.0305)
		tmp = t_0;
	elseif (b <= 0.029)
		tmp = Float64(r * Float64(Float64(b * fma(Float64(b * b), fma(Float64(b * b), 0.008333333333333333, -0.16666666666666666), 1.0)) / cos(Float64(b + a))));
	else
		tmp = Float64(1.0 / Float64(1.0 / t_0));
	end
	return tmp
end
code[r_, a_, b_] := Block[{t$95$0 = N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -0.0305], t$95$0, If[LessEqual[b, 0.029], N[(r * N[(N[(b * N[(N[(b * b), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] * 0.008333333333333333 + -0.16666666666666666), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := r \cdot \tan b\\
\mathbf{if}\;b \leq -0.0305:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;b \leq 0.029:\\
\;\;\;\;r \cdot \frac{b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b \cdot b, 0.008333333333333333, -0.16666666666666666\right), 1\right)}{\cos \left(b + a\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{1}{t\_0}}\\


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

    1. Initial program 56.6%

      \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-numN/A

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{r}}{\cos \left(a + b\right)} \cdot \sin b \]
      8. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{r}{\cos \left(a + b\right)}} \cdot \sin b \]
      9. cos-lowering-cos.f64N/A

        \[\leadsto \frac{r}{\color{blue}{\cos \left(a + b\right)}} \cdot \sin b \]
      10. +-commutativeN/A

        \[\leadsto \frac{r}{\cos \color{blue}{\left(b + a\right)}} \cdot \sin b \]
      11. +-lowering-+.f64N/A

        \[\leadsto \frac{r}{\cos \color{blue}{\left(b + a\right)}} \cdot \sin b \]
      12. sin-lowering-sin.f6456.7

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

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

      \[\leadsto \color{blue}{\frac{r}{\cos b}} \cdot \sin b \]
    6. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{r}{\cos b}} \cdot \sin b \]
      2. cos-lowering-cos.f6458.2

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

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

        \[\leadsto \color{blue}{\frac{r \cdot \sin b}{\cos b}} \]
      2. associate-/l*N/A

        \[\leadsto \color{blue}{r \cdot \frac{\sin b}{\cos b}} \]
      3. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{r \cdot \frac{\sin b}{\cos b}} \]
      4. quot-tanN/A

        \[\leadsto r \cdot \color{blue}{\tan b} \]
      5. tan-lowering-tan.f6458.2

        \[\leadsto r \cdot \color{blue}{\tan b} \]
    9. Applied egg-rr58.2%

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

    if -0.030499999999999999 < b < 0.0290000000000000015

    1. Initial program 97.6%

      \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in b around 0

      \[\leadsto r \cdot \frac{\color{blue}{b \cdot \left(1 + {b}^{2} \cdot \left(\frac{1}{120} \cdot {b}^{2} - \frac{1}{6}\right)\right)}}{\cos \left(a + b\right)} \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto r \cdot \frac{\color{blue}{b \cdot \left(1 + {b}^{2} \cdot \left(\frac{1}{120} \cdot {b}^{2} - \frac{1}{6}\right)\right)}}{\cos \left(a + b\right)} \]
      2. +-commutativeN/A

        \[\leadsto r \cdot \frac{b \cdot \color{blue}{\left({b}^{2} \cdot \left(\frac{1}{120} \cdot {b}^{2} - \frac{1}{6}\right) + 1\right)}}{\cos \left(a + b\right)} \]
      3. accelerator-lowering-fma.f64N/A

        \[\leadsto r \cdot \frac{b \cdot \color{blue}{\mathsf{fma}\left({b}^{2}, \frac{1}{120} \cdot {b}^{2} - \frac{1}{6}, 1\right)}}{\cos \left(a + b\right)} \]
      4. unpow2N/A

        \[\leadsto r \cdot \frac{b \cdot \mathsf{fma}\left(\color{blue}{b \cdot b}, \frac{1}{120} \cdot {b}^{2} - \frac{1}{6}, 1\right)}{\cos \left(a + b\right)} \]
      5. *-lowering-*.f64N/A

        \[\leadsto r \cdot \frac{b \cdot \mathsf{fma}\left(\color{blue}{b \cdot b}, \frac{1}{120} \cdot {b}^{2} - \frac{1}{6}, 1\right)}{\cos \left(a + b\right)} \]
      6. sub-negN/A

        \[\leadsto r \cdot \frac{b \cdot \mathsf{fma}\left(b \cdot b, \color{blue}{\frac{1}{120} \cdot {b}^{2} + \left(\mathsf{neg}\left(\frac{1}{6}\right)\right)}, 1\right)}{\cos \left(a + b\right)} \]
      7. *-commutativeN/A

        \[\leadsto r \cdot \frac{b \cdot \mathsf{fma}\left(b \cdot b, \color{blue}{{b}^{2} \cdot \frac{1}{120}} + \left(\mathsf{neg}\left(\frac{1}{6}\right)\right), 1\right)}{\cos \left(a + b\right)} \]
      8. metadata-evalN/A

        \[\leadsto r \cdot \frac{b \cdot \mathsf{fma}\left(b \cdot b, {b}^{2} \cdot \frac{1}{120} + \color{blue}{\frac{-1}{6}}, 1\right)}{\cos \left(a + b\right)} \]
      9. accelerator-lowering-fma.f64N/A

        \[\leadsto r \cdot \frac{b \cdot \mathsf{fma}\left(b \cdot b, \color{blue}{\mathsf{fma}\left({b}^{2}, \frac{1}{120}, \frac{-1}{6}\right)}, 1\right)}{\cos \left(a + b\right)} \]
      10. unpow2N/A

        \[\leadsto r \cdot \frac{b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(\color{blue}{b \cdot b}, \frac{1}{120}, \frac{-1}{6}\right), 1\right)}{\cos \left(a + b\right)} \]
      11. *-lowering-*.f6497.6

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

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

    if 0.0290000000000000015 < b

    1. Initial program 42.9%

      \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-numN/A

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{r}}{\cos \left(a + b\right)} \cdot \sin b \]
      8. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{r}{\cos \left(a + b\right)}} \cdot \sin b \]
      9. cos-lowering-cos.f64N/A

        \[\leadsto \frac{r}{\color{blue}{\cos \left(a + b\right)}} \cdot \sin b \]
      10. +-commutativeN/A

        \[\leadsto \frac{r}{\cos \color{blue}{\left(b + a\right)}} \cdot \sin b \]
      11. +-lowering-+.f64N/A

        \[\leadsto \frac{r}{\cos \color{blue}{\left(b + a\right)}} \cdot \sin b \]
      12. sin-lowering-sin.f6442.9

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

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

      \[\leadsto \color{blue}{\frac{r}{\cos b}} \cdot \sin b \]
    6. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{r}{\cos b}} \cdot \sin b \]
      2. cos-lowering-cos.f6442.6

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

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

        \[\leadsto \color{blue}{\frac{r \cdot \sin b}{\cos b}} \]
      2. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{\sin b \cdot r}}{\cos b} \]
      3. clear-numN/A

        \[\leadsto \color{blue}{\frac{1}{\frac{\cos b}{\sin b \cdot r}}} \]
      4. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{1}{\frac{\cos b}{\sin b \cdot r}}} \]
      5. clear-numN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{\sin b \cdot r}{\cos b}}}} \]
      6. *-commutativeN/A

        \[\leadsto \frac{1}{\frac{1}{\frac{\color{blue}{r \cdot \sin b}}{\cos b}}} \]
      7. associate-*l/N/A

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{\frac{r}{\cos b} \cdot \sin b}}} \]
      8. /-lowering-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{r}{\cos b} \cdot \sin b}}} \]
      9. associate-*l/N/A

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{\frac{r \cdot \sin b}{\cos b}}}} \]
      10. associate-/l*N/A

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{r \cdot \frac{\sin b}{\cos b}}}} \]
      11. *-lowering-*.f64N/A

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{r \cdot \frac{\sin b}{\cos b}}}} \]
      12. quot-tanN/A

        \[\leadsto \frac{1}{\frac{1}{r \cdot \color{blue}{\tan b}}} \]
      13. tan-lowering-tan.f6442.7

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -0.0305:\\ \;\;\;\;r \cdot \tan b\\ \mathbf{elif}\;b \leq 0.029:\\ \;\;\;\;r \cdot \frac{b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b \cdot b, 0.008333333333333333, -0.16666666666666666\right), 1\right)}{\cos \left(b + a\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{1}{r \cdot \tan b}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 60.2% accurate, 2.1× speedup?

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

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

    \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. clear-numN/A

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{r}}{\cos \left(a + b\right)} \cdot \sin b \]
    8. /-lowering-/.f64N/A

      \[\leadsto \color{blue}{\frac{r}{\cos \left(a + b\right)}} \cdot \sin b \]
    9. cos-lowering-cos.f64N/A

      \[\leadsto \frac{r}{\color{blue}{\cos \left(a + b\right)}} \cdot \sin b \]
    10. +-commutativeN/A

      \[\leadsto \frac{r}{\cos \color{blue}{\left(b + a\right)}} \cdot \sin b \]
    11. +-lowering-+.f64N/A

      \[\leadsto \frac{r}{\cos \color{blue}{\left(b + a\right)}} \cdot \sin b \]
    12. sin-lowering-sin.f6474.1

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

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

    \[\leadsto \color{blue}{\frac{r}{\cos b}} \cdot \sin b \]
  6. Step-by-step derivation
    1. /-lowering-/.f64N/A

      \[\leadsto \color{blue}{\frac{r}{\cos b}} \cdot \sin b \]
    2. cos-lowering-cos.f6459.2

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

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

      \[\leadsto \color{blue}{\frac{r \cdot \sin b}{\cos b}} \]
    2. associate-/l*N/A

      \[\leadsto \color{blue}{r \cdot \frac{\sin b}{\cos b}} \]
    3. *-lowering-*.f64N/A

      \[\leadsto \color{blue}{r \cdot \frac{\sin b}{\cos b}} \]
    4. quot-tanN/A

      \[\leadsto r \cdot \color{blue}{\tan b} \]
    5. tan-lowering-tan.f6459.2

      \[\leadsto r \cdot \color{blue}{\tan b} \]
  9. Applied egg-rr59.2%

    \[\leadsto \color{blue}{r \cdot \tan b} \]
  10. Add Preprocessing

Alternative 11: 35.0% accurate, 36.7× 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 74.1%

    \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
  2. Add Preprocessing
  3. Taylor expanded in b around 0

    \[\leadsto \color{blue}{\frac{b \cdot r}{\cos a}} \]
  4. Step-by-step derivation
    1. associate-/l*N/A

      \[\leadsto \color{blue}{b \cdot \frac{r}{\cos a}} \]
    2. *-lowering-*.f64N/A

      \[\leadsto \color{blue}{b \cdot \frac{r}{\cos a}} \]
    3. /-lowering-/.f64N/A

      \[\leadsto b \cdot \color{blue}{\frac{r}{\cos a}} \]
    4. cos-lowering-cos.f6451.2

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

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

    \[\leadsto b \cdot \color{blue}{r} \]
  7. Step-by-step derivation
    1. Simplified36.0%

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

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

    Reproduce

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