rsin B (should all be same)

Percentage Accurate: 76.7% → 99.5%
Time: 14.2s
Alternatives: 14
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 14 alternatives:

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

Initial Program: 76.7% accurate, 1.0× speedup?

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

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

Alternative 1: 99.5% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \frac{r \cdot \sin b}{\mathsf{fma}\left(\cos b, \cos a, -\sin b \cdot \sin a\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(-Float64(sin(b) * 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 \sin a\right)}
\end{array}
Derivation
  1. Initial program 76.3%

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

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

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

    \[\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 \sin a\right)} \]

Alternative 2: 99.4% accurate, 0.3× speedup?

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\sin b}{\frac{\cos \left(b + a\right)}{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}{\frac{\color{blue}{\mathsf{fma}\left(\cos b, \cos a, \left(-\sin b\right) \cdot \sin a\right)}}{r}} \]
  6. Final simplification99.5%

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

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

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

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

    \[\leadsto \color{blue}{r \cdot \frac{\sin b}{\cos \left(b + a\right)}} \]
  4. 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}} \]
  5. Applied egg-rr99.5%

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

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

Alternative 4: 76.4% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -4.19999999999999989e-8 or 3.40000000000000015e-10 < b

    1. Initial program 49.2%

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

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

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

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

    if -4.19999999999999989e-8 < b < 3.40000000000000015e-10

    1. Initial program 99.8%

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

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

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

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

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

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

Alternative 5: 76.4% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -4.19999999999999989e-8 or 3.40000000000000015e-10 < b

    1. Initial program 49.2%

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

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

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

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

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

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

    if -4.19999999999999989e-8 < b < 3.40000000000000015e-10

    1. Initial program 99.8%

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

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

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

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

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

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

Alternative 6: 76.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -4.2 \cdot 10^{-8}:\\ \;\;\;\;\sin b \cdot \frac{r}{\cos b}\\ \mathbf{elif}\;b \leq 3.4 \cdot 10^{-10}:\\ \;\;\;\;\frac{r \cdot b}{\cos \left(b + a\right)}\\ \mathbf{else}:\\ \;\;\;\;r \cdot \frac{\sin b}{\cos b}\\ \end{array} \end{array} \]
(FPCore (r a b)
 :precision binary64
 (if (<= b -4.2e-8)
   (* (sin b) (/ r (cos b)))
   (if (<= b 3.4e-10) (/ (* r b) (cos (+ b a))) (* r (/ (sin b) (cos b))))))
double code(double r, double a, double b) {
	double tmp;
	if (b <= -4.2e-8) {
		tmp = sin(b) * (r / cos(b));
	} else if (b <= 3.4e-10) {
		tmp = (r * b) / cos((b + 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 <= (-4.2d-8)) then
        tmp = sin(b) * (r / cos(b))
    else if (b <= 3.4d-10) then
        tmp = (r * b) / cos((b + 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 <= -4.2e-8) {
		tmp = Math.sin(b) * (r / Math.cos(b));
	} else if (b <= 3.4e-10) {
		tmp = (r * b) / Math.cos((b + a));
	} else {
		tmp = r * (Math.sin(b) / Math.cos(b));
	}
	return tmp;
}
def code(r, a, b):
	tmp = 0
	if b <= -4.2e-8:
		tmp = math.sin(b) * (r / math.cos(b))
	elif b <= 3.4e-10:
		tmp = (r * b) / math.cos((b + a))
	else:
		tmp = r * (math.sin(b) / math.cos(b))
	return tmp
function code(r, a, b)
	tmp = 0.0
	if (b <= -4.2e-8)
		tmp = Float64(sin(b) * Float64(r / cos(b)));
	elseif (b <= 3.4e-10)
		tmp = Float64(Float64(r * b) / cos(Float64(b + a)));
	else
		tmp = Float64(r * Float64(sin(b) / cos(b)));
	end
	return tmp
end
function tmp_2 = code(r, a, b)
	tmp = 0.0;
	if (b <= -4.2e-8)
		tmp = sin(b) * (r / cos(b));
	elseif (b <= 3.4e-10)
		tmp = (r * b) / cos((b + a));
	else
		tmp = r * (sin(b) / cos(b));
	end
	tmp_2 = tmp;
end
code[r_, a_, b_] := If[LessEqual[b, -4.2e-8], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.4e-10], N[(N[(r * b), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.2 \cdot 10^{-8}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\

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

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


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

    1. Initial program 55.3%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{r \cdot \sin b}{\mathsf{fma}\left(1, \cos a \cdot \cos b, -\color{blue}{\sin b \cdot \sin a}\right) + \mathsf{fma}\left(-\sin b \cdot \sin a, 1, \left(\sin b \cdot \sin a\right) \cdot 1\right)} \]
      3. distribute-lft-neg-in99.1%

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

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

        \[\leadsto \frac{r \cdot \sin b}{\mathsf{fma}\left(1, \cos a \cdot \cos b, \sin a \cdot \left(-\sin b\right)\right) + \color{blue}{\left(\left(-\sin b \cdot \sin a\right) \cdot 1 + \left(\sin b \cdot \sin a\right) \cdot 1\right)}} \]
      6. *-rgt-identity99.1%

        \[\leadsto \frac{r \cdot \sin b}{\mathsf{fma}\left(1, \cos a \cdot \cos b, \sin a \cdot \left(-\sin b\right)\right) + \left(\color{blue}{\left(-\sin b \cdot \sin a\right)} + \left(\sin b \cdot \sin a\right) \cdot 1\right)} \]
      7. distribute-lft-neg-in99.1%

        \[\leadsto \frac{r \cdot \sin b}{\mathsf{fma}\left(1, \cos a \cdot \cos b, \sin a \cdot \left(-\sin b\right)\right) + \left(\color{blue}{\left(-\sin b\right) \cdot \sin a} + \left(\sin b \cdot \sin a\right) \cdot 1\right)} \]
      8. *-rgt-identity99.1%

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

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

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

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

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

        \[\leadsto \color{blue}{\sin b \cdot \frac{r}{\cos b}} \]
    10. Simplified55.4%

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

    if -4.19999999999999989e-8 < b < 3.40000000000000015e-10

    1. Initial program 99.8%

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

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

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

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

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

    if 3.40000000000000015e-10 < b

    1. Initial program 43.2%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -4.2 \cdot 10^{-8}:\\ \;\;\;\;\sin b \cdot \frac{r}{\cos b}\\ \mathbf{elif}\;b \leq 3.4 \cdot 10^{-10}:\\ \;\;\;\;\frac{r \cdot b}{\cos \left(b + a\right)}\\ \mathbf{else}:\\ \;\;\;\;r \cdot \frac{\sin b}{\cos b}\\ \end{array} \]

Alternative 7: 53.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 3.3 \cdot 10^{-10}:\\ \;\;\;\;r \cdot \mathsf{expm1}\left(\frac{b}{\cos a}\right)\\ \mathbf{else}:\\ \;\;\;\;r \cdot \sin b\\ \end{array} \end{array} \]
(FPCore (r a b)
 :precision binary64
 (if (<= b 3.3e-10) (* r (expm1 (/ b (cos a)))) (* r (sin b))))
double code(double r, double a, double b) {
	double tmp;
	if (b <= 3.3e-10) {
		tmp = r * expm1((b / cos(a)));
	} else {
		tmp = r * sin(b);
	}
	return tmp;
}
public static double code(double r, double a, double b) {
	double tmp;
	if (b <= 3.3e-10) {
		tmp = r * Math.expm1((b / Math.cos(a)));
	} else {
		tmp = r * Math.sin(b);
	}
	return tmp;
}
def code(r, a, b):
	tmp = 0
	if b <= 3.3e-10:
		tmp = r * math.expm1((b / math.cos(a)))
	else:
		tmp = r * math.sin(b)
	return tmp
function code(r, a, b)
	tmp = 0.0
	if (b <= 3.3e-10)
		tmp = Float64(r * expm1(Float64(b / cos(a))));
	else
		tmp = Float64(r * sin(b));
	end
	return tmp
end
code[r_, a_, b_] := If[LessEqual[b, 3.3e-10], N[(r * N[(Exp[N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.3 \cdot 10^{-10}:\\
\;\;\;\;r \cdot \mathsf{expm1}\left(\frac{b}{\cos a}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 3.3e-10

    1. Initial program 86.4%

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

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

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

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

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

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

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

        \[\leadsto r \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{\cos a} \cdot \sin b\right)\right)} \]
      2. associate-*l/73.1%

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

        \[\leadsto r \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\color{blue}{\sin b}}{\cos a}\right)\right) \]
    8. Applied egg-rr73.1%

      \[\leadsto r \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin b}{\cos a}\right)\right)} \]
    9. Taylor expanded in b around 0 72.6%

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

    if 3.3e-10 < b

    1. Initial program 43.2%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 3.3 \cdot 10^{-10}:\\ \;\;\;\;r \cdot \mathsf{expm1}\left(\frac{b}{\cos a}\right)\\ \mathbf{else}:\\ \;\;\;\;r \cdot \sin b\\ \end{array} \]

Alternative 8: 76.7% accurate, 1.0× speedup?

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

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

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

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

Alternative 9: 54.7% 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 76.3%

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

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

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

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

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

Alternative 10: 54.6% accurate, 1.9× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -92 or 3.40000000000000015e-10 < b

    1. Initial program 47.9%

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

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

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

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

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

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

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

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

    if -92 < b < 3.40000000000000015e-10

    1. Initial program 99.8%

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

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

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

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

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

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

Alternative 11: 54.6% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -1.7 \lor \neg \left(b \leq 3.4 \cdot 10^{-10}\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.7) (not (<= b 3.4e-10))) (* r (sin b)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
	double tmp;
	if ((b <= -1.7) || !(b <= 3.4e-10)) {
		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.7d0)) .or. (.not. (b <= 3.4d-10))) 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.7) || !(b <= 3.4e-10)) {
		tmp = r * Math.sin(b);
	} else {
		tmp = r * (b / Math.cos(a));
	}
	return tmp;
}
def code(r, a, b):
	tmp = 0
	if (b <= -1.7) or not (b <= 3.4e-10):
		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.7) || !(b <= 3.4e-10))
		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.7) || ~((b <= 3.4e-10)))
		tmp = r * sin(b);
	else
		tmp = r * (b / cos(a));
	end
	tmp_2 = tmp;
end
code[r_, a_, b_] := If[Or[LessEqual[b, -1.7], N[Not[LessEqual[b, 3.4e-10]], $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.7 \lor \neg \left(b \leq 3.4 \cdot 10^{-10}\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.69999999999999996 or 3.40000000000000015e-10 < b

    1. Initial program 47.9%

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

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

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

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

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

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

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

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

    if -1.69999999999999996 < b < 3.40000000000000015e-10

    1. Initial program 99.8%

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

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

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

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

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

Alternative 12: 54.6% accurate, 1.9× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -35 or 3.40000000000000015e-10 < b

    1. Initial program 47.9%

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

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

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

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

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

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

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

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

    if -35 < b < 3.40000000000000015e-10

    1. Initial program 99.8%

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

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

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

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

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

Alternative 13: 38.1% 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 76.3%

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\sin b \cdot r} \]
  8. Final simplification41.7%

    \[\leadsto r \cdot \sin b \]

Alternative 14: 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 76.3%

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

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

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

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

    \[\leadsto r \cdot \color{blue}{b} \]
  6. Final simplification37.2%

    \[\leadsto r \cdot b \]

Reproduce

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