rsin B (should all be same)

Percentage Accurate: 76.2% → 99.5%
Time: 16.6s
Alternatives: 15
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 15 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.2% 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.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 76.9% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\sin b}{\cos \left(b + a\right)}\\ \mathbf{if}\;t\_0 \leq -0.04:\\ \;\;\;\;r \cdot \frac{\sin b}{\cos b - \sin b \cdot \sin a}\\ \mathbf{else}:\\ \;\;\;\;r \cdot t\_0\\ \end{array} \end{array} \]
(FPCore (r a b)
 :precision binary64
 (let* ((t_0 (/ (sin b) (cos (+ b a)))))
   (if (<= t_0 -0.04)
     (* r (/ (sin b) (- (cos b) (* (sin b) (sin a)))))
     (* r t_0))))
double code(double r, double a, double b) {
	double t_0 = sin(b) / cos((b + a));
	double tmp;
	if (t_0 <= -0.04) {
		tmp = r * (sin(b) / (cos(b) - (sin(b) * sin(a))));
	} else {
		tmp = r * t_0;
	}
	return tmp;
}
real(8) function code(r, a, b)
    real(8), intent (in) :: r
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sin(b) / cos((b + a))
    if (t_0 <= (-0.04d0)) then
        tmp = r * (sin(b) / (cos(b) - (sin(b) * sin(a))))
    else
        tmp = r * t_0
    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 tmp;
	if (t_0 <= -0.04) {
		tmp = r * (Math.sin(b) / (Math.cos(b) - (Math.sin(b) * Math.sin(a))));
	} else {
		tmp = r * t_0;
	}
	return tmp;
}
def code(r, a, b):
	t_0 = math.sin(b) / math.cos((b + a))
	tmp = 0
	if t_0 <= -0.04:
		tmp = r * (math.sin(b) / (math.cos(b) - (math.sin(b) * math.sin(a))))
	else:
		tmp = r * t_0
	return tmp
function code(r, a, b)
	t_0 = Float64(sin(b) / cos(Float64(b + a)))
	tmp = 0.0
	if (t_0 <= -0.04)
		tmp = Float64(r * Float64(sin(b) / Float64(cos(b) - Float64(sin(b) * sin(a)))));
	else
		tmp = Float64(r * t_0);
	end
	return tmp
end
function tmp_2 = code(r, a, b)
	t_0 = sin(b) / cos((b + a));
	tmp = 0.0;
	if (t_0 <= -0.04)
		tmp = r * (sin(b) / (cos(b) - (sin(b) * sin(a))));
	else
		tmp = r * t_0;
	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]}, If[LessEqual[t$95$0, -0.04], N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * t$95$0), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;r \cdot t\_0\\


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

    1. Initial program 52.0%

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

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

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

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

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

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

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

    1. Initial program 84.9%

      \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
    2. Add Preprocessing
  3. Recombined 2 regimes into one program.
  4. Final simplification77.4%

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

Alternative 3: 99.5% accurate, 0.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 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 75.7%

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

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

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

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

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

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

Alternative 5: 75.7% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -240000 \lor \neg \left(b \leq 2.75 \cdot 10^{-11}\right):\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -2.4e5 or 2.74999999999999987e-11 < b

    1. Initial program 55.6%

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

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

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

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

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

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

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

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

    if -2.4e5 < b < 2.74999999999999987e-11

    1. Initial program 98.0%

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

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

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

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

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

Alternative 6: 75.7% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -240000 \lor \neg \left(b \leq 2.75 \cdot 10^{-11}\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -2.4e5 or 2.74999999999999987e-11 < b

    1. Initial program 55.6%

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

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

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

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

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

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

    if -2.4e5 < b < 2.74999999999999987e-11

    1. Initial program 98.0%

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

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

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

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

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

Alternative 7: 76.2% 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.7%

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

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

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

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

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

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

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

Alternative 8: 76.2% 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.7%

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

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

Alternative 9: 54.5% accurate, 1.0× speedup?

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

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

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

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

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

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

Alternative 10: 50.6% accurate, 1.9× speedup?

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

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

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

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

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

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

Alternative 11: 50.7% accurate, 2.0× speedup?

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

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

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

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

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

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

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

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

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

Alternative 12: 50.7% accurate, 2.0× speedup?

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

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

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

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

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

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

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

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

Alternative 13: 34.4% accurate, 15.9× speedup?

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{1}{\color{blue}{-1 \cdot \frac{a}{r} + \left(-0.3333333333333333 \cdot \frac{b}{r} + \frac{1}{b \cdot r}\right)}} \]
  9. Taylor expanded in a around 0 34.9%

    \[\leadsto \color{blue}{\frac{1}{-0.3333333333333333 \cdot \frac{b}{r} + \frac{1}{b \cdot r}}} \]
  10. Final simplification34.9%

    \[\leadsto \frac{1}{-0.3333333333333333 \cdot \frac{b}{r} + \frac{1}{r \cdot b}} \]
  11. Add Preprocessing

Alternative 14: 33.7% accurate, 18.8× speedup?

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

\\
\frac{r}{\left(\frac{1}{b} - b \cdot 0.3333333333333333\right) - a}
\end{array}
Derivation
  1. Initial program 75.7%

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

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

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

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

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

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

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

    \[\leadsto \frac{1}{\color{blue}{-1 \cdot \frac{a}{r} + \left(-0.3333333333333333 \cdot \frac{b}{r} + \frac{1}{b \cdot r}\right)}} \]
  9. Taylor expanded in r around -inf 34.6%

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

      \[\leadsto \color{blue}{\frac{-1 \cdot r}{\left(a + 0.3333333333333333 \cdot b\right) - \frac{1}{b}}} \]
    2. neg-mul-134.6%

      \[\leadsto \frac{\color{blue}{-r}}{\left(a + 0.3333333333333333 \cdot b\right) - \frac{1}{b}} \]
    3. associate--l+34.6%

      \[\leadsto \frac{-r}{\color{blue}{a + \left(0.3333333333333333 \cdot b - \frac{1}{b}\right)}} \]
    4. *-commutative34.6%

      \[\leadsto \frac{-r}{a + \left(\color{blue}{b \cdot 0.3333333333333333} - \frac{1}{b}\right)} \]
  11. Simplified34.6%

    \[\leadsto \color{blue}{\frac{-r}{a + \left(b \cdot 0.3333333333333333 - \frac{1}{b}\right)}} \]
  12. Final simplification34.6%

    \[\leadsto \frac{r}{\left(\frac{1}{b} - b \cdot 0.3333333333333333\right) - a} \]
  13. Add Preprocessing

Alternative 15: 34.1% 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.7%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{r \cdot b} \]
  10. Simplified34.6%

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

Reproduce

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