rsin A (should all be same)

Percentage Accurate: 77.1% → 99.5%
Time: 12.5s
Alternatives: 14
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 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: 77.1% accurate, 1.0× speedup?

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

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

Alternative 1: 99.5% accurate, 0.4× speedup?

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

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

    \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
  2. Step-by-step derivation
    1. +-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. 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}} \]
  5. Applied egg-rr99.5%

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

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

Alternative 2: 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%

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

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

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

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

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

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

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

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

Alternative 3: 76.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -7.5 \lor \neg \left(b \leq 2.1 \cdot 10^{-26}\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 -7.5) (not (<= b 2.1e-26)))
   (* r (/ (sin b) (cos b)))
   (/ (* r b) (cos (+ b a)))))
double code(double r, double a, double b) {
	double tmp;
	if ((b <= -7.5) || !(b <= 2.1e-26)) {
		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 <= (-7.5d0)) .or. (.not. (b <= 2.1d-26))) 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 <= -7.5) || !(b <= 2.1e-26)) {
		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 <= -7.5) or not (b <= 2.1e-26):
		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 <= -7.5) || !(b <= 2.1e-26))
		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 <= -7.5) || ~((b <= 2.1e-26)))
		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, -7.5], N[Not[LessEqual[b, 2.1e-26]], $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 -7.5 \lor \neg \left(b \leq 2.1 \cdot 10^{-26}\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 < -7.5 or 2.10000000000000008e-26 < b

    1. Initial program 57.3%

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

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

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

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

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

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

    if -7.5 < b < 2.10000000000000008e-26

    1. Initial program 98.5%

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

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

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

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

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

Alternative 4: 76.3% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 54.5%

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

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

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

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

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

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

    if -7.5 < b < 2.10000000000000008e-26

    1. Initial program 98.5%

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

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

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

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

    if 2.10000000000000008e-26 < b

    1. Initial program 59.7%

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

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

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

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

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

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

Alternative 5: 76.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -7.5:\\ \;\;\;\;r \cdot \frac{\sin b}{\cos b}\\ \mathbf{elif}\;b \leq 2.1 \cdot 10^{-26}:\\ \;\;\;\;\frac{r \cdot b}{\cos \left(b + a\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{r \cdot \sin b}{\cos b}\\ \end{array} \end{array} \]
(FPCore (r a b)
 :precision binary64
 (if (<= b -7.5)
   (* r (/ (sin b) (cos b)))
   (if (<= b 2.1e-26) (/ (* r b) (cos (+ b a))) (/ (* r (sin b)) (cos b)))))
double code(double r, double a, double b) {
	double tmp;
	if (b <= -7.5) {
		tmp = r * (sin(b) / cos(b));
	} else if (b <= 2.1e-26) {
		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 <= (-7.5d0)) then
        tmp = r * (sin(b) / cos(b))
    else if (b <= 2.1d-26) 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 <= -7.5) {
		tmp = r * (Math.sin(b) / Math.cos(b));
	} else if (b <= 2.1e-26) {
		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 <= -7.5:
		tmp = r * (math.sin(b) / math.cos(b))
	elif b <= 2.1e-26:
		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 <= -7.5)
		tmp = Float64(r * Float64(sin(b) / cos(b)));
	elseif (b <= 2.1e-26)
		tmp = Float64(Float64(r * b) / cos(Float64(b + 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 <= -7.5)
		tmp = r * (sin(b) / cos(b));
	elseif (b <= 2.1e-26)
		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, -7.5], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.1e-26], N[(N[(r * b), $MachinePrecision] / N[Cos[N[(b + 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 -7.5:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\

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

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


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

    1. Initial program 54.5%

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

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

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

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

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

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

    if -7.5 < b < 2.10000000000000008e-26

    1. Initial program 98.5%

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

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

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

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

    if 2.10000000000000008e-26 < b

    1. Initial program 59.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 54.8% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -29000000 \lor \neg \left(b \leq 1.9 \cdot 10^{+17}\right):\\
\;\;\;\;\frac{r}{\frac{1}{b} - \sin a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -2.9e7 or 1.9e17 < b

    1. Initial program 56.0%

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

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

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

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

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

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

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

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

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

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

    if -2.9e7 < b < 1.9e17

    1. Initial program 98.5%

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

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

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

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

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

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

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

Alternative 10: 54.9% accurate, 1.9× speedup?

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

\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 < -9.5 or 6.2e19 < b

    1. Initial program 56.8%

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

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

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

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

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

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

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

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

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

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

    if -9.5 < b < 6.2e19

    1. Initial program 97.8%

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

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

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

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

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

Alternative 11: 54.7% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -10000000 \lor \neg \left(b \leq 4.2 \cdot 10^{+23}\right):\\
\;\;\;\;\frac{-r}{\sin a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -1e7 or 4.2000000000000003e23 < b

    1. Initial program 56.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{r}{\sin a}} \]
    8. Step-by-step derivation
      1. associate-*r/10.2%

        \[\leadsto \color{blue}{\frac{-1 \cdot r}{\sin a}} \]
      2. neg-mul-110.2%

        \[\leadsto \frac{\color{blue}{-r}}{\sin a} \]
    9. Simplified10.2%

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

    if -1e7 < b < 4.2000000000000003e23

    1. Initial program 97.8%

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

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

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

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

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

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

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

Alternative 12: 54.7% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -100000000 \lor \neg \left(b \leq 4.2 \cdot 10^{+23}\right):\\
\;\;\;\;\frac{-r}{\sin a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -1e8 or 4.2000000000000003e23 < b

    1. Initial program 56.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{r}{\sin a}} \]
    8. Step-by-step derivation
      1. associate-*r/10.2%

        \[\leadsto \color{blue}{\frac{-1 \cdot r}{\sin a}} \]
      2. neg-mul-110.2%

        \[\leadsto \frac{\color{blue}{-r}}{\sin a} \]
    9. Simplified10.2%

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

    if -1e8 < b < 4.2000000000000003e23

    1. Initial program 97.8%

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

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

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

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

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

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

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

Alternative 13: 38.4% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.35 \lor \neg \left(b \leq 4.2 \cdot 10^{+23}\right):\\
\;\;\;\;\frac{-r}{\sin a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -1.3500000000000001 or 4.2000000000000003e23 < b

    1. Initial program 56.2%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{r}{\sin a}} \]
    8. Step-by-step derivation
      1. associate-*r/10.3%

        \[\leadsto \color{blue}{\frac{-1 \cdot r}{\sin a}} \]
      2. neg-mul-110.3%

        \[\leadsto \frac{\color{blue}{-r}}{\sin a} \]
    9. Simplified10.3%

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

    if -1.3500000000000001 < b < 4.2000000000000003e23

    1. Initial program 98.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto r \cdot b \]

Reproduce

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