rsin A (should all be same)

Percentage Accurate: 76.6% → 99.5%
Time: 19.2s
Alternatives: 17
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 17 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.6% 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(\sin a, -\sin b, \cos a \cdot \cos b\right)} \cdot r \end{array} \]
(FPCore (r a b)
 :precision binary64
 (* (/ (sin b) (fma (sin a) (- (sin b)) (* (cos a) (cos b)))) r))
double code(double r, double a, double b) {
	return (sin(b) / fma(sin(a), -sin(b), (cos(a) * cos(b)))) * r;
}
function code(r, a, b)
	return Float64(Float64(sin(b) / fma(sin(a), Float64(-sin(b)), Float64(cos(a) * cos(b)))) * r)
end
code[r_, a_, b_] := N[(N[(N[Sin[b], $MachinePrecision] / N[(N[Sin[a], $MachinePrecision] * (-N[Sin[b], $MachinePrecision]) + N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * r), $MachinePrecision]
\begin{array}{l}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\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. sub-neg99.5%

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

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

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

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

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

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

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

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

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

Alternative 2: 99.4% accurate, 0.4× speedup?

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

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

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

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

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

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

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

      \[\leadsto \frac{r}{\color{blue}{\cos b \cdot \cos a - \sin b \cdot \sin a}} \cdot \sin b \]
  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 a \cdot \cos b - \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 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 72.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\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{r}{\color{blue}{\cos b \cdot \cos a - \sin b \cdot \sin a}} \cdot \sin b \]
  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 a \cdot \cos b - \sin b \cdot \sin a} \]
  8. Add Preprocessing

Alternative 4: 99.4% accurate, 0.4× speedup?

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{r}{\frac{\cos a \cdot \cos b - \sin a \cdot \sin b}{\sin b}}} \]
    2. *-commutative99.3%

      \[\leadsto \frac{r}{\frac{\color{blue}{\cos b \cdot \cos a} - \sin a \cdot \sin b}{\sin b}} \]
    3. *-commutative99.3%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 77.6% accurate, 0.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{r}{\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 \sin b \]
    4. add-sqr-sqrt36.6%

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

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

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

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

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

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

      \[\leadsto \frac{r}{\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 \sin b \]
    11. cos-sum73.8%

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

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

      \[\leadsto \frac{r}{\cos b \cdot \cos a - \color{blue}{0}} \cdot \sin b \]
  12. Simplified73.8%

    \[\leadsto \frac{r}{\cos b \cdot \cos a - \color{blue}{0}} \cdot \sin b \]
  13. Final simplification73.8%

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

Alternative 6: 76.3% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -0.00419999999999999974 or 1.6000000000000001 < a

    1. Initial program 49.9%

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

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

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

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

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

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

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

    if -0.00419999999999999974 < a < 1.6000000000000001

    1. Initial program 98.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{r}{\frac{\cos b}{\sin b}}} \]
      2. associate-/r/98.3%

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

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

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

Alternative 7: 76.3% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 46.3%

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

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

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

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

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

    if -0.016 < a < 1.6000000000000001

    1. Initial program 98.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{r}{\frac{\cos b}{\sin b}}} \]
      2. associate-/r/98.3%

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

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

    if 1.6000000000000001 < a

    1. Initial program 53.4%

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

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

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

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

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

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

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

Alternative 8: 76.5% 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 72.4%

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

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

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

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

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

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

Alternative 9: 54.8% 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 72.4%

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

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

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

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

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

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

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

Alternative 10: 55.1% accurate, 1.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -1.1e9 or 4.20000000000000018 < b

    1. Initial program 50.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{r}{\frac{\cos b}{\sin b}}} \]
      2. associate-/r/49.4%

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

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

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

    if -1.1e9 < b < 4.20000000000000018

    1. Initial program 95.8%

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

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

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

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

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

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

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

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

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

Alternative 11: 55.0% accurate, 1.8× speedup?

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

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

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


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

    1. Initial program 50.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{r}{\frac{\cos b}{\sin b}}} \]
      2. associate-/r/49.4%

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

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

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

    if -8.5e8 < b < 11

    1. Initial program 95.8%

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

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

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

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

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

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

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

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

Alternative 12: 55.0% accurate, 1.8× speedup?

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

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

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


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

    1. Initial program 50.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{r}{\frac{\cos b}{\sin b}}} \]
      2. associate-/r/49.4%

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

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

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

    if -9.2e8 < b < 17

    1. Initial program 95.8%

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

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

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

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

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

Alternative 13: 54.9% accurate, 1.8× speedup?

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

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

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


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

    1. Initial program 49.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{r}{\frac{\cos b}{\sin b}}} \]
      2. associate-/r/49.2%

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

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

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

    if -3.8e7 < b < 2.9e21

    1. Initial program 94.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 14: 54.9% accurate, 1.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -3.8e7 or 6.4e21 < b

    1. Initial program 49.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{r}{\frac{\cos b}{\sin b}}} \]
      2. associate-/r/49.2%

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

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

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

    if -3.8e7 < b < 6.4e21

    1. Initial program 94.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{r \cdot \frac{b}{\cos a}} \]
      2. clear-num92.5%

        \[\leadsto r \cdot \color{blue}{\frac{1}{\frac{\cos a}{b}}} \]
      3. un-div-inv92.5%

        \[\leadsto \color{blue}{\frac{r}{\frac{\cos a}{b}}} \]
    7. Applied egg-rr92.5%

      \[\leadsto \color{blue}{\frac{r}{\frac{\cos a}{b}}} \]
    8. Step-by-step derivation
      1. associate-/r/92.7%

        \[\leadsto \color{blue}{\frac{r}{\cos a} \cdot b} \]
    9. Simplified92.7%

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

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

Alternative 15: 54.9% accurate, 1.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -3.6e7 or 1.3500000000000001e22 < b

    1. Initial program 49.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{r}{\frac{\cos b}{\sin b}}} \]
      2. associate-/r/49.2%

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

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

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

    if -3.6e7 < b < 1.3500000000000001e22

    1. Initial program 94.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 16: 38.4% accurate, 2.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{r}{\frac{\cos b}{\sin b}}} \]
    2. associate-/r/56.6%

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

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

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

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

Alternative 17: 34.4% 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 72.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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