rsin A (should all be same)

Percentage Accurate: 76.2% → 99.5%
Time: 20.7s
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.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 77.1% accurate, 0.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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 b \cdot \cos a - \sin b \cdot \sin a}{2}\right)} \cdot r \]
    5. add-sqr-sqrt53.3%

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

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

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

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

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

      \[\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 b \cdot \cos a - \sin b \cdot \sin a}{2}\right)} \cdot r \]
    11. cos-sum77.4%

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

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

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

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

    \[\leadsto \frac{\sin b}{\cos b \cdot \cos a - \color{blue}{0}} \cdot r \]
  11. Step-by-step derivation
    1. frac-2neg77.1%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sin b}{\cos b} \cdot \frac{-r}{-\cos a}} \]
  14. Simplified77.1%

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

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

Alternative 3: 77.0% accurate, 0.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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 b \cdot \cos a - \sin b \cdot \sin a}{2}\right)} \cdot r \]
    5. add-sqr-sqrt53.3%

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

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

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

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

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

      \[\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 b \cdot \cos a - \sin b \cdot \sin a}{2}\right)} \cdot r \]
    11. cos-sum77.4%

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

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

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

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

    \[\leadsto \frac{\sin b}{\cos b \cdot \cos a - \color{blue}{0}} \cdot r \]
  11. Step-by-step derivation
    1. *-commutative77.1%

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

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

      \[\leadsto \color{blue}{\frac{r}{\frac{\cos b \cdot \cos a - 0}{\sin b}}} \]
    4. --rgt-identity77.1%

      \[\leadsto \frac{r}{\frac{\color{blue}{\cos b \cdot \cos a}}{\sin b}} \]
    5. associate-/l*77.1%

      \[\leadsto \frac{r}{\color{blue}{\frac{\cos b}{\frac{\sin b}{\cos a}}}} \]
  12. Applied egg-rr77.1%

    \[\leadsto \color{blue}{\frac{r}{\frac{\cos b}{\frac{\sin b}{\cos a}}}} \]
  13. Final simplification77.1%

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

Alternative 4: 77.1% accurate, 0.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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 b \cdot \cos a - \sin b \cdot \sin a}{2}\right)} \cdot r \]
    5. add-sqr-sqrt53.3%

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

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

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

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

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

      \[\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 b \cdot \cos a - \sin b \cdot \sin a}{2}\right)} \cdot r \]
    11. cos-sum77.4%

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

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

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

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

    \[\leadsto \frac{\sin b}{\cos b \cdot \cos a - \color{blue}{0}} \cdot r \]
  11. Step-by-step derivation
    1. --rgt-identity77.1%

      \[\leadsto \frac{\sin b}{\color{blue}{\cos b \cdot \cos a}} \cdot r \]
    2. associate-*l/77.1%

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

      \[\leadsto \frac{\color{blue}{r \cdot \sin b}}{\cos b \cdot \cos a} \]
  12. Applied egg-rr77.1%

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

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

Alternative 5: 77.1% accurate, 0.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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 b \cdot \cos a - \sin b \cdot \sin a}{2}\right)} \cdot r \]
    5. add-sqr-sqrt53.3%

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

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

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

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

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

      \[\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 b \cdot \cos a - \sin b \cdot \sin a}{2}\right)} \cdot r \]
    11. cos-sum77.4%

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

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

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

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

    \[\leadsto \frac{\sin b}{\cos b \cdot \cos a - \color{blue}{0}} \cdot r \]
  11. Step-by-step derivation
    1. --rgt-identity77.1%

      \[\leadsto \frac{\sin b}{\color{blue}{\cos b \cdot \cos a}} \cdot r \]
    2. associate-*l/77.1%

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

      \[\leadsto \frac{\color{blue}{r \cdot \sin b}}{\cos b \cdot \cos a} \]
    4. associate-/r*77.1%

      \[\leadsto \color{blue}{\frac{\frac{r \cdot \sin b}{\cos b}}{\cos a}} \]
  12. Applied egg-rr77.1%

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

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

Alternative 6: 75.9% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 56.6%

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

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

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

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

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

    if -0.0064999999999999997 < a < 0.0018500000000000001

    1. Initial program 97.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 75.9% accurate, 1.0× speedup?

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

\mathbf{elif}\;a \leq 0.0018:\\
\;\;\;\;r \cdot \frac{\sin b}{\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.0064999999999999997

    1. Initial program 51.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.0064999999999999997 < a < 0.0018

    1. Initial program 97.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.0018 < a

    1. Initial program 61.9%

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

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

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

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

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

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

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

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

Alternative 8: 54.8% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.36 \cdot 10^{+14} \lor \neg \left(b \leq 3.6 \cdot 10^{+15}\right):\\
\;\;\;\;\left|\sin b \cdot r\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -1.36e14 or 3.6e15 < b

    1. Initial program 51.3%

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

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

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

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

      \[\leadsto \color{blue}{r \cdot \sin b} \]
    7. Step-by-step derivation
      1. add-sqr-sqrt5.3%

        \[\leadsto \color{blue}{\sqrt{r \cdot \sin b} \cdot \sqrt{r \cdot \sin b}} \]
      2. sqrt-unprod7.1%

        \[\leadsto \color{blue}{\sqrt{\left(r \cdot \sin b\right) \cdot \left(r \cdot \sin b\right)}} \]
      3. pow27.1%

        \[\leadsto \sqrt{\color{blue}{{\left(r \cdot \sin b\right)}^{2}}} \]
      4. *-commutative7.1%

        \[\leadsto \sqrt{{\color{blue}{\left(\sin b \cdot r\right)}}^{2}} \]
    8. Applied egg-rr7.1%

      \[\leadsto \color{blue}{\sqrt{{\left(\sin b \cdot r\right)}^{2}}} \]
    9. Step-by-step derivation
      1. unpow27.1%

        \[\leadsto \sqrt{\color{blue}{\left(\sin b \cdot r\right) \cdot \left(\sin b \cdot r\right)}} \]
      2. rem-sqrt-square11.0%

        \[\leadsto \color{blue}{\left|\sin b \cdot r\right|} \]
    10. Simplified11.0%

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

    if -1.36e14 < b < 3.6e15

    1. Initial program 95.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -1.36 \cdot 10^{+14} \lor \neg \left(b \leq 3.6 \cdot 10^{+15}\right):\\ \;\;\;\;\left|\sin b \cdot r\right|\\ \mathbf{else}:\\ \;\;\;\;r \cdot \frac{b}{\cos a}\\ \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 75.9%

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

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

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

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

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

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

    \[\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 75.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 76.0% 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 75.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\sin b}{\cos b \cdot \cos a + \color{blue}{\sqrt{\sin b \cdot \sin a} \cdot \sqrt{\sin b \cdot \sin a}}} \cdot r \]
    6. add-sqr-sqrt75.6%

      \[\leadsto \frac{\sin b}{\cos b \cdot \cos a + \color{blue}{\sin b \cdot \sin a}} \cdot r \]
    7. cos-diff76.1%

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

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

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

Alternative 12: 54.6% 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 75.9%

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

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

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

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

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

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

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

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

Alternative 13: 54.9% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -72000 \lor \neg \left(b \leq 2800000000\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 -72000.0) (not (<= b 2800000000.0)))
   (* (sin b) r)
   (* r (/ b (cos a)))))
double code(double r, double a, double b) {
	double tmp;
	if ((b <= -72000.0) || !(b <= 2800000000.0)) {
		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 <= (-72000.0d0)) .or. (.not. (b <= 2800000000.0d0))) 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 <= -72000.0) || !(b <= 2800000000.0)) {
		tmp = Math.sin(b) * r;
	} else {
		tmp = r * (b / Math.cos(a));
	}
	return tmp;
}
def code(r, a, b):
	tmp = 0
	if (b <= -72000.0) or not (b <= 2800000000.0):
		tmp = math.sin(b) * r
	else:
		tmp = r * (b / math.cos(a))
	return tmp
function code(r, a, b)
	tmp = 0.0
	if ((b <= -72000.0) || !(b <= 2800000000.0))
		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 <= -72000.0) || ~((b <= 2800000000.0)))
		tmp = sin(b) * r;
	else
		tmp = r * (b / cos(a));
	end
	tmp_2 = tmp;
end
code[r_, a_, b_] := If[Or[LessEqual[b, -72000.0], N[Not[LessEqual[b, 2800000000.0]], $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 -72000 \lor \neg \left(b \leq 2800000000\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 < -72000 or 2.8e9 < b

    1. Initial program 51.0%

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

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

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

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

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

    if -72000 < b < 2.8e9

    1. Initial program 96.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -72000 \lor \neg \left(b \leq 2800000000\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} t_0 := \sin b \cdot r\\ \mathbf{if}\;b \leq -32000:\\ \;\;\;\;\frac{1}{\frac{1}{t_0}}\\ \mathbf{elif}\;b \leq 58000000:\\ \;\;\;\;r \cdot \frac{b}{\cos a}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (r a b)
 :precision binary64
 (let* ((t_0 (* (sin b) r)))
   (if (<= b -32000.0)
     (/ 1.0 (/ 1.0 t_0))
     (if (<= b 58000000.0) (* r (/ b (cos a))) t_0))))
double code(double r, double a, double b) {
	double t_0 = sin(b) * r;
	double tmp;
	if (b <= -32000.0) {
		tmp = 1.0 / (1.0 / t_0);
	} else if (b <= 58000000.0) {
		tmp = r * (b / cos(a));
	} else {
		tmp = t_0;
	}
	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) :: t_0
    real(8) :: tmp
    t_0 = sin(b) * r
    if (b <= (-32000.0d0)) then
        tmp = 1.0d0 / (1.0d0 / t_0)
    else if (b <= 58000000.0d0) then
        tmp = r * (b / cos(a))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double r, double a, double b) {
	double t_0 = Math.sin(b) * r;
	double tmp;
	if (b <= -32000.0) {
		tmp = 1.0 / (1.0 / t_0);
	} else if (b <= 58000000.0) {
		tmp = r * (b / Math.cos(a));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(r, a, b):
	t_0 = math.sin(b) * r
	tmp = 0
	if b <= -32000.0:
		tmp = 1.0 / (1.0 / t_0)
	elif b <= 58000000.0:
		tmp = r * (b / math.cos(a))
	else:
		tmp = t_0
	return tmp
function code(r, a, b)
	t_0 = Float64(sin(b) * r)
	tmp = 0.0
	if (b <= -32000.0)
		tmp = Float64(1.0 / Float64(1.0 / t_0));
	elseif (b <= 58000000.0)
		tmp = Float64(r * Float64(b / cos(a)));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(r, a, b)
	t_0 = sin(b) * r;
	tmp = 0.0;
	if (b <= -32000.0)
		tmp = 1.0 / (1.0 / t_0);
	elseif (b <= 58000000.0)
		tmp = r * (b / cos(a));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision]}, If[LessEqual[b, -32000.0], N[(1.0 / N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 58000000.0], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin b \cdot r\\
\mathbf{if}\;b \leq -32000:\\
\;\;\;\;\frac{1}{\frac{1}{t_0}}\\

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

\mathbf{else}:\\
\;\;\;\;t_0\\


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

    1. Initial program 44.7%

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

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

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

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

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

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

        \[\leadsto {\color{blue}{\left(\frac{\frac{\cos a}{r}}{\sin b}\right)}}^{-1} \]
    7. Applied egg-rr12.3%

      \[\leadsto \color{blue}{{\left(\frac{\frac{\cos a}{r}}{\sin b}\right)}^{-1}} \]
    8. Step-by-step derivation
      1. unpow-112.3%

        \[\leadsto \color{blue}{\frac{1}{\frac{\frac{\cos a}{r}}{\sin b}}} \]
      2. associate-/l/12.3%

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

        \[\leadsto \frac{1}{\frac{\cos a}{\color{blue}{r \cdot \sin b}}} \]
    9. Simplified12.3%

      \[\leadsto \color{blue}{\frac{1}{\frac{\cos a}{r \cdot \sin b}}} \]
    10. Taylor expanded in a around 0 12.0%

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

    if -32000 < b < 5.8e7

    1. Initial program 96.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.8e7 < b

    1. Initial program 57.0%

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

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

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

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

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

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

Alternative 15: 38.8% 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 75.9%

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

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

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

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

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

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

Alternative 16: 34.6% 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 75.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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