rsin B (should all be same)

Percentage Accurate: 75.9% → 99.5%
Time: 14.5s
Alternatives: 13
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 13 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: 75.9% 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}{\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 77.1%

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

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

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

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

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

Alternative 2: 75.6% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 54.9%

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

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

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

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

    if -2.10000000000000009 < b < 0.0077000000000000002

    1. Initial program 97.7%

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

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

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

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

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

Alternative 3: 75.6% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;b \leq 0.0052:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\

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


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

    1. Initial program 56.9%

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

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

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

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

    if -2.10000000000000009 < b < 0.0051999999999999998

    1. Initial program 97.7%

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

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

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

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

    if 0.0051999999999999998 < b

    1. Initial program 52.4%

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

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

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

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

      \[\leadsto \frac{r \cdot \sin b}{\color{blue}{\cos b}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 4: 75.6% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;b \leq 0.0052:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\

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


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

    1. Initial program 56.9%

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

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

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

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

    if -2.10000000000000009 < b < 0.0051999999999999998

    1. Initial program 97.7%

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

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

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

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

    if 0.0051999999999999998 < b

    1. Initial program 52.4%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sin b \cdot \frac{r}{\cos b}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 5: 75.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{r \cdot \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(Float64(r * 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[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

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

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

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

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

Alternative 6: 75.9% 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 77.1%

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

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

Alternative 7: 54.6% 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 77.1%

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

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

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

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

Alternative 8: 54.9% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.5 \cdot 10^{+16} \lor \neg \left(b \leq 11\right):\\
\;\;\;\;r \cdot \sin b\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -4.5e16 or 11 < b

    1. Initial program 54.4%

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

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

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

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

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

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

    if -4.5e16 < b < 11

    1. Initial program 96.5%

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

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

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

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

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

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

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

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

Alternative 9: 54.8% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -460000000000 \lor \neg \left(b \leq 15.6\right):\\
\;\;\;\;r \cdot \sin b\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -4.6e11 or 15.5999999999999996 < b

    1. Initial program 54.5%

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

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

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

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

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

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

    if -4.6e11 < b < 15.5999999999999996

    1. Initial program 97.0%

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

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

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

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

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

Alternative 10: 54.8% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.22 \cdot 10^{+14} \lor \neg \left(b \leq 4.6\right):\\
\;\;\;\;r \cdot \sin b\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -1.22e14 or 4.5999999999999996 < b

    1. Initial program 54.1%

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

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

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

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

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

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

    if -1.22e14 < b < 4.5999999999999996

    1. Initial program 97.0%

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

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

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

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

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

Alternative 11: 54.8% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.22 \cdot 10^{+14} \lor \neg \left(b \leq 4.6\right):\\
\;\;\;\;r \cdot \sin b\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -1.22e14 or 4.5999999999999996 < b

    1. Initial program 54.1%

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

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

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

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

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

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

    if -1.22e14 < b < 4.5999999999999996

    1. Initial program 97.0%

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

        \[\leadsto r \cdot \frac{\sin b}{\cos \color{blue}{\left(b + a\right)}} \]
    3. Simplified97.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.8%

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

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

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

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

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

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

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

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

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

Alternative 12: 38.9% accurate, 2.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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