rsin A (should all be same)

Percentage Accurate: 76.2% → 99.5%
Time: 18.9s
Alternatives: 16
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 16 alternatives:

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

Initial Program: 76.2% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.5% accurate, 0.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 99.5% accurate, 0.4× speedup?

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

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

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

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

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

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

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

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

Alternative 4: 77.2% accurate, 0.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\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-mult77.9%

      \[\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. div-sub77.9%

      \[\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 \]
    3. cos-diff78.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 77.2% accurate, 0.7× speedup?

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

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

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

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

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

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

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

      \[\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. div-sub77.9%

      \[\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 \]
    3. cos-diff78.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 75.9% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.9 \cdot 10^{-8}:\\
\;\;\;\;r \cdot \tan b\\

\mathbf{elif}\;b \leq 4 \cdot 10^{-6}:\\
\;\;\;\;\frac{r \cdot b}{\cos a}\\

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


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

    1. Initial program 55.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin b}{\cos b}\right)\right)} \cdot r \]
      2. expm1-udef38.4%

        \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{\sin b}{\cos b}\right)} - 1\right)} \cdot r \]
      3. quot-tan38.4%

        \[\leadsto \left(e^{\mathsf{log1p}\left(\color{blue}{\tan b}\right)} - 1\right) \cdot r \]
    7. Applied egg-rr38.4%

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\tan b\right)} - 1\right)} \cdot r \]
    8. Step-by-step derivation
      1. expm1-def39.7%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\tan b\right)\right)} \cdot r \]
      2. expm1-log1p53.2%

        \[\leadsto \color{blue}{\tan b} \cdot r \]
    9. Simplified53.2%

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

    if -2.9000000000000002e-8 < b < 3.99999999999999982e-6

    1. Initial program 98.6%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(-\sin b\right)} \cdot -1}{\cos \left(a + b\right)} \cdot r \]
      11. distribute-lft-neg-in98.5%

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

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

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

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

        \[\leadsto \frac{\sin b}{\color{blue}{\cos \left(a + b\right)}} \cdot r \]
      16. +-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. Add Preprocessing
    5. Taylor expanded in b around 0 98.6%

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

    if 3.99999999999999982e-6 < b

    1. Initial program 57.1%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{r}{\cos b} \cdot \sin b} \]
    7. Applied egg-rr57.3%

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

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

Alternative 7: 76.1% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;a \leq 0.00078:\\
\;\;\;\;r \cdot \frac{1}{\frac{1}{\tan b} - a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if a < -8.4000000000000003e-4

    1. Initial program 47.7%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(-\sin b\right)} \cdot -1}{\cos \left(a + b\right)} \cdot r \]
      11. distribute-lft-neg-in47.6%

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

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

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

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

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

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

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

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

    if -8.4000000000000003e-4 < a < 7.79999999999999986e-4

    1. Initial program 99.3%

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

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

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

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

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

        \[\leadsto \frac{r}{\color{blue}{\frac{\cos b}{\sin b} + -1 \cdot a}} \]
      2. mul-1-neg99.3%

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

        \[\leadsto \frac{r}{\color{blue}{\frac{\cos b}{\sin b} - a}} \]
    7. Simplified99.3%

      \[\leadsto \frac{r}{\color{blue}{\frac{\cos b}{\sin b} - a}} \]
    8. Step-by-step derivation
      1. div-inv99.4%

        \[\leadsto \color{blue}{r \cdot \frac{1}{\frac{\cos b}{\sin b} - a}} \]
      2. clear-num99.4%

        \[\leadsto r \cdot \frac{1}{\color{blue}{\frac{1}{\frac{\sin b}{\cos b}}} - a} \]
      3. quot-tan99.4%

        \[\leadsto r \cdot \frac{1}{\frac{1}{\color{blue}{\tan b}} - a} \]
    9. Applied egg-rr99.4%

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

    if 7.79999999999999986e-4 < a

    1. Initial program 62.5%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -0.00084:\\ \;\;\;\;r \cdot \frac{\sin b}{\cos a}\\ \mathbf{elif}\;a \leq 0.00078:\\ \;\;\;\;r \cdot \frac{1}{\frac{1}{\tan b} - a}\\ \mathbf{else}:\\ \;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 76.1% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;a \leq 0.0027:\\
\;\;\;\;r \cdot \frac{1}{\frac{1}{\tan b} - a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if a < -1.85e-4

    1. Initial program 47.7%

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

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

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

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

    if -1.85e-4 < a < 0.0027000000000000001

    1. Initial program 99.3%

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

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

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

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

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

        \[\leadsto \frac{r}{\color{blue}{\frac{\cos b}{\sin b} + -1 \cdot a}} \]
      2. mul-1-neg99.3%

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

        \[\leadsto \frac{r}{\color{blue}{\frac{\cos b}{\sin b} - a}} \]
    7. Simplified99.3%

      \[\leadsto \frac{r}{\color{blue}{\frac{\cos b}{\sin b} - a}} \]
    8. Step-by-step derivation
      1. div-inv99.4%

        \[\leadsto \color{blue}{r \cdot \frac{1}{\frac{\cos b}{\sin b} - a}} \]
      2. clear-num99.4%

        \[\leadsto r \cdot \frac{1}{\color{blue}{\frac{1}{\frac{\sin b}{\cos b}}} - a} \]
      3. quot-tan99.4%

        \[\leadsto r \cdot \frac{1}{\frac{1}{\color{blue}{\tan b}} - a} \]
    9. Applied egg-rr99.4%

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

    if 0.0027000000000000001 < a

    1. Initial program 62.5%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -0.000185:\\ \;\;\;\;\frac{r \cdot \sin b}{\cos a}\\ \mathbf{elif}\;a \leq 0.0027:\\ \;\;\;\;r \cdot \frac{1}{\frac{1}{\tan b} - a}\\ \mathbf{else}:\\ \;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 76.2% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

Alternative 10: 76.2% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 75.9% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.9 \cdot 10^{-8} \lor \neg \left(b \leq 4 \cdot 10^{-6}\right):\\
\;\;\;\;r \cdot \tan b\\

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


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

    1. Initial program 56.5%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(-\sin b\right)} \cdot -1}{\cos \left(a + b\right)} \cdot r \]
      11. distribute-lft-neg-in56.5%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin b}{\cos b}\right)\right)} \cdot r \]
      2. expm1-udef40.5%

        \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{\sin b}{\cos b}\right)} - 1\right)} \cdot r \]
      3. quot-tan40.5%

        \[\leadsto \left(e^{\mathsf{log1p}\left(\color{blue}{\tan b}\right)} - 1\right) \cdot r \]
    7. Applied egg-rr40.5%

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\tan b\right)} - 1\right)} \cdot r \]
    8. Step-by-step derivation
      1. expm1-def41.5%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\tan b\right)\right)} \cdot r \]
      2. expm1-log1p55.5%

        \[\leadsto \color{blue}{\tan b} \cdot r \]
    9. Simplified55.5%

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

    if -2.9000000000000002e-8 < b < 3.99999999999999982e-6

    1. Initial program 98.6%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(-\sin b\right)} \cdot -1}{\cos \left(a + b\right)} \cdot r \]
      11. distribute-lft-neg-in98.5%

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

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

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

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

        \[\leadsto \frac{\sin b}{\color{blue}{\cos \left(a + b\right)}} \cdot r \]
      16. +-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. Add Preprocessing
    5. Taylor expanded in b around 0 98.5%

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

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

Alternative 13: 75.9% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.9 \cdot 10^{-8} \lor \neg \left(b \leq 1.15 \cdot 10^{-6}\right):\\
\;\;\;\;r \cdot \tan b\\

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


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

    1. Initial program 56.5%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(-\sin b\right)} \cdot -1}{\cos \left(a + b\right)} \cdot r \]
      11. distribute-lft-neg-in56.5%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin b}{\cos b}\right)\right)} \cdot r \]
      2. expm1-udef40.5%

        \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{\sin b}{\cos b}\right)} - 1\right)} \cdot r \]
      3. quot-tan40.5%

        \[\leadsto \left(e^{\mathsf{log1p}\left(\color{blue}{\tan b}\right)} - 1\right) \cdot r \]
    7. Applied egg-rr40.5%

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\tan b\right)} - 1\right)} \cdot r \]
    8. Step-by-step derivation
      1. expm1-def41.5%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\tan b\right)\right)} \cdot r \]
      2. expm1-log1p55.5%

        \[\leadsto \color{blue}{\tan b} \cdot r \]
    9. Simplified55.5%

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

    if -2.9000000000000002e-8 < b < 1.15e-6

    1. Initial program 98.6%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(-\sin b\right)} \cdot -1}{\cos \left(a + b\right)} \cdot r \]
      11. distribute-lft-neg-in98.5%

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

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

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

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

        \[\leadsto \frac{\sin b}{\color{blue}{\cos \left(a + b\right)}} \cdot r \]
      16. +-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. Add Preprocessing
    5. Taylor expanded in b around 0 98.6%

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

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

Alternative 14: 59.7% accurate, 2.0× speedup?

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

\\
r \cdot \tan b
\end{array}
Derivation
  1. Initial program 77.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\sin b}{\color{blue}{\cos b}} \cdot r \]
  6. Step-by-step derivation
    1. expm1-log1p-u53.2%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin b}{\cos b}\right)\right)} \cdot r \]
    2. expm1-udef35.5%

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{\sin b}{\cos b}\right)} - 1\right)} \cdot r \]
    3. quot-tan35.5%

      \[\leadsto \left(e^{\mathsf{log1p}\left(\color{blue}{\tan b}\right)} - 1\right) \cdot r \]
  7. Applied egg-rr35.5%

    \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\tan b\right)} - 1\right)} \cdot r \]
  8. Step-by-step derivation
    1. expm1-def53.2%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\tan b\right)\right)} \cdot r \]
    2. expm1-log1p60.2%

      \[\leadsto \color{blue}{\tan b} \cdot r \]
  9. Simplified60.2%

    \[\leadsto \color{blue}{\tan b} \cdot r \]
  10. Final simplification60.2%

    \[\leadsto r \cdot \tan b \]
  11. Add Preprocessing

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

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

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

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

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

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

    \[\leadsto \frac{r}{\color{blue}{-0.3333333333333333 \cdot b + \frac{1}{b}}} \]
  7. Final simplification36.0%

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

Alternative 16: 34.2% 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.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{b \cdot r} \]
  7. Step-by-step derivation
    1. *-commutative35.4%

      \[\leadsto \color{blue}{r \cdot b} \]
  8. Simplified35.4%

    \[\leadsto \color{blue}{r \cdot b} \]
  9. Final simplification35.4%

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

Reproduce

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