rsin A (should all be same)

Percentage Accurate: 76.3% → 99.5%
Time: 18.4s
Alternatives: 14
Speedup: 0.7×

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

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

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

Alternative 1: 99.5% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \sin b \cdot \left(-\sin a\right)\right)} \cdot 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(Float64(sin(b) / fma(cos(b), cos(a), Float64(sin(b) * Float64(-sin(a))))) * r)
end
code[r_, a_, b_] := N[(N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision] + N[(N[Sin[b], $MachinePrecision] * (-N[Sin[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * r), $MachinePrecision]
\begin{array}{l}

\\
\frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \sin b \cdot \left(-\sin a\right)\right)} \cdot r
\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. remove-double-neg77.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.5% accurate, 0.4× speedup?

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

\\
\sin b \cdot \frac{r}{\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-/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. Add Preprocessing
  5. Step-by-step derivation
    1. associate-/r/77.1%

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

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

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

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

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

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 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. remove-double-neg77.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 77.3% accurate, 0.7× speedup?

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

\\
r \cdot \frac{\sin b}{\cos b \cdot \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-/l*77.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\sin b}{\cos b \cdot \cos a - \left(\frac{\cos \left(b - a\right)}{2} - \frac{\cos b \cdot \cos a + \color{blue}{\sqrt{\sin b \cdot \sin a} \cdot \sqrt{\sin b \cdot \sin a}}}{2}\right)} \cdot r \]
    9. add-sqr-sqrt77.7%

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

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

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

      \[\leadsto \frac{\sin b}{\cos b \cdot \cos a - \color{blue}{0}} \cdot r \]
  10. Simplified78.2%

    \[\leadsto \frac{\sin b}{\cos b \cdot \cos a - \color{blue}{0}} \cdot r \]
  11. Final simplification78.2%

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

Alternative 5: 76.0% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 54.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.4999999999999996e-6 < b < 54

    1. Initial program 98.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-\color{blue}{\left(-\sin b\right)}}{\cos \left(a + b\right)} \cdot r \]
      14. remove-double-neg98.9%

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

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

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

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

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

Alternative 6: 76.0% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 59.6%

      \[\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. remove-double-neg59.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.80000000000000012e-6 < b < 54

    1. Initial program 98.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-\color{blue}{\left(-\sin b\right)}}{\cos \left(a + b\right)} \cdot r \]
      14. remove-double-neg98.9%

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

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

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

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

    if 54 < b

    1. Initial program 48.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -6.8 \cdot 10^{-6}:\\ \;\;\;\;r \cdot \frac{\sin b}{\cos b}\\ \mathbf{elif}\;b \leq 54:\\ \;\;\;\;r \cdot \frac{b}{\cos a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin b}{\frac{\cos b}{r}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 76.0% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 59.6%

      \[\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. remove-double-neg59.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.39999999999999997e-6 < b < 54

    1. Initial program 98.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-\color{blue}{\left(-\sin b\right)}}{\cos \left(a + b\right)} \cdot r \]
      14. remove-double-neg98.9%

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

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

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

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

    if 54 < b

    1. Initial program 48.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -5.4 \cdot 10^{-6}:\\ \;\;\;\;r \cdot \frac{\sin b}{\cos b}\\ \mathbf{elif}\;b \leq 54:\\ \;\;\;\;r \cdot \frac{b}{\cos a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin b \cdot r}{\cos b}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 76.3% 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. Add Preprocessing
  5. Step-by-step derivation
    1. associate-/r/77.1%

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

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

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

Alternative 9: 76.3% accurate, 1.0× speedup?

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

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

    \[\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. remove-double-neg77.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 54.9% accurate, 1.0× speedup?

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

\\
\sin b \cdot \frac{r}{\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-/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. Add Preprocessing
  5. Step-by-step derivation
    1. associate-/r/77.1%

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

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

    \[\leadsto \color{blue}{\frac{r}{\cos a}} \cdot \sin b \]
  8. Final simplification57.3%

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

Alternative 11: 54.9% 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-/l*77.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 50.9% accurate, 2.0× speedup?

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

\\
r \cdot \frac{b}{\cos a}
\end{array}
Derivation
  1. Initial program 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. remove-double-neg77.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 34.7% accurate, 23.0× speedup?

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

\\
\frac{r}{b \cdot -0.3333333333333333 + \frac{1}{b}}
\end{array}
Derivation
  1. Initial program 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. Add Preprocessing
  5. Taylor expanded in b around 0 54.1%

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

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

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

      \[\leadsto \frac{r}{\color{blue}{\left(b \cdot \left(-0.5 \cdot \cos a - -0.16666666666666666 \cdot \cos a\right) + \frac{\cos a}{b}\right) - \sin a}} \]
    4. fma-define54.1%

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

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

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

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

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

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

Alternative 14: 34.2% accurate, 69.0× speedup?

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

\\
b \cdot r
\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. remove-double-neg77.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{b} \cdot r \]
  7. Final simplification34.7%

    \[\leadsto b \cdot r \]
  8. Add Preprocessing

Reproduce

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