rsin A (should all be same)

Percentage Accurate: 77.0% → 99.5%
Time: 12.3s
Alternatives: 12
Speedup: 0.4×

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

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

Initial Program: 77.0% accurate, 1.0× speedup?

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

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

Alternative 1: 99.5% accurate, 0.3× speedup?

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.5% accurate, 0.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 99.5% accurate, 0.4× speedup?

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

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

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

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

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

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

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

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

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

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

Alternative 4: 99.5% accurate, 0.4× speedup?

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

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

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

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

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

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

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

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

Alternative 5: 76.7% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -8 \cdot 10^{-7}:\\
\;\;\;\;r \cdot \tan b\\

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

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


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

    1. Initial program 55.9%

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

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

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

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

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

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

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

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

        \[\leadsto \left(e^{\mathsf{log1p}\left(\color{blue}{\tan b}\right)} - 1\right) \cdot r \]
    6. Applied egg-rr45.5%

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\tan b\right)} - 1\right)} \cdot r \]
    7. Step-by-step derivation
      1. expm1-def46.4%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\tan b\right)\right)} \cdot r \]
      2. expm1-log1p55.4%

        \[\leadsto \color{blue}{\tan b} \cdot r \]
    8. Simplified55.4%

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

    if -7.9999999999999996e-7 < b < 1.74999999999999997e-6

    1. Initial program 99.2%

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

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

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

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

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

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

    if 1.74999999999999997e-6 < b

    1. Initial program 43.4%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{r}{\frac{\cos b}{\sin b}}} \]
      4. clear-num44.8%

        \[\leadsto \frac{r}{\color{blue}{\frac{1}{\frac{\sin b}{\cos b}}}} \]
      5. quot-tan44.9%

        \[\leadsto \frac{r}{\frac{1}{\color{blue}{\tan b}}} \]
    6. Applied egg-rr44.9%

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

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

Alternative 6: 77.0% 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 75.2%

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

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

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

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

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

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

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

Alternative 7: 77.0% 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 75.2%

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

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

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

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

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

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

Alternative 8: 76.7% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.32 \cdot 10^{-6} \lor \neg \left(b \leq 1.75 \cdot 10^{-6}\right):\\
\;\;\;\;r \cdot \tan b\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -1.3200000000000001e-6 or 1.74999999999999997e-6 < b

    1. Initial program 49.3%

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

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

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

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

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

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

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

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

        \[\leadsto \left(e^{\mathsf{log1p}\left(\color{blue}{\tan b}\right)} - 1\right) \cdot r \]
    6. Applied egg-rr38.8%

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

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\tan b\right)\right)} \cdot r \]
      2. expm1-log1p49.8%

        \[\leadsto \color{blue}{\tan b} \cdot r \]
    8. Simplified49.8%

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

    if -1.3200000000000001e-6 < b < 1.74999999999999997e-6

    1. Initial program 99.2%

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

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

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

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

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

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

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

Alternative 9: 76.7% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.32 \cdot 10^{-6}:\\
\;\;\;\;r \cdot \tan b\\

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

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


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

    1. Initial program 55.9%

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

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

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

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

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

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

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

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

        \[\leadsto \left(e^{\mathsf{log1p}\left(\color{blue}{\tan b}\right)} - 1\right) \cdot r \]
    6. Applied egg-rr45.5%

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\tan b\right)} - 1\right)} \cdot r \]
    7. Step-by-step derivation
      1. expm1-def46.4%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\tan b\right)\right)} \cdot r \]
      2. expm1-log1p55.4%

        \[\leadsto \color{blue}{\tan b} \cdot r \]
    8. Simplified55.4%

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

    if -1.3200000000000001e-6 < b < 1.74999999999999997e-6

    1. Initial program 99.2%

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

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

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

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

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

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

    if 1.74999999999999997e-6 < b

    1. Initial program 43.4%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{r}{\frac{\cos b}{\sin b}}} \]
      4. clear-num44.8%

        \[\leadsto \frac{r}{\color{blue}{\frac{1}{\frac{\sin b}{\cos b}}}} \]
      5. quot-tan44.9%

        \[\leadsto \frac{r}{\frac{1}{\color{blue}{\tan b}}} \]
    6. Applied egg-rr44.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -1.32 \cdot 10^{-6}:\\ \;\;\;\;r \cdot \tan b\\ \mathbf{elif}\;b \leq 1.75 \cdot 10^{-6}:\\ \;\;\;\;r \cdot \frac{b}{\cos a}\\ \mathbf{else}:\\ \;\;\;\;\frac{r}{\frac{1}{\tan b}}\\ \end{array} \]

Alternative 10: 60.6% accurate, 2.0× 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 75.2%

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

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

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

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

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

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

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

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

      \[\leadsto \left(e^{\mathsf{log1p}\left(\color{blue}{\tan b}\right)} - 1\right) \cdot r \]
  6. Applied egg-rr31.3%

    \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\tan b\right)} - 1\right)} \cdot r \]
  7. Step-by-step derivation
    1. expm1-def53.2%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\tan b\right)\right)} \cdot r \]
    2. expm1-log1p58.1%

      \[\leadsto \color{blue}{\tan b} \cdot r \]
  8. Simplified58.1%

    \[\leadsto \color{blue}{\tan b} \cdot r \]
  9. Final simplification58.1%

    \[\leadsto r \cdot \tan b \]

Alternative 11: 35.3% accurate, 23.0× speedup?

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

\\
\frac{r}{b \cdot -0.3333333333333333 + \frac{1}{b}}
\end{array}
Derivation
  1. Initial program 75.2%

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

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

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

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

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

      \[\leadsto \frac{r}{\color{blue}{\mathsf{fma}\left(b, -0.5 \cdot \cos a - -0.16666666666666666 \cdot \cos a, -1 \cdot \sin a + \frac{\cos a}{b}\right)}} \]
    2. distribute-rgt-out--55.2%

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{r}{-0.3333333333333333 \cdot b + \frac{1}{b}}} \]
  8. Final simplification37.4%

    \[\leadsto \frac{r}{b \cdot -0.3333333333333333 + \frac{1}{b}} \]

Alternative 12: 34.9% accurate, 69.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto r \cdot b \]

Reproduce

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