rsin A (should all be same)

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

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

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

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

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

      \[\leadsto \frac{r \cdot \sin b}{\color{blue}{\cos b \cdot \cos a - \sin b \cdot \sin a}} \]
    2. cancel-sign-sub-inv99.5%

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

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

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

Alternative 2: 99.5% accurate, 0.4× speedup?

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

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

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

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

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

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

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

Alternative 3: 99.5% accurate, 0.4× speedup?

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

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

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

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

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

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

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

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

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

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

Alternative 4: 77.6% accurate, 0.7× speedup?

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

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

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

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

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

      \[\leadsto \frac{r \cdot \sin b}{\color{blue}{\cos b \cdot \cos a - \sin b \cdot \sin a}} \]
    2. cancel-sign-sub-inv99.5%

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

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

    \[\leadsto \frac{r \cdot \sin b}{\color{blue}{\mathsf{fma}\left(\cos b, \cos a, \left(-\sin b\right) \cdot \sin a\right)}} \]
  7. Step-by-step derivation
    1. add-sqr-sqrt44.7%

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

      \[\leadsto \frac{r \cdot \sin b}{\mathsf{fma}\left(\cos b, \cos a, \color{blue}{\sqrt{\left(-\sin b\right) \cdot \left(-\sin b\right)}} \cdot \sin a\right)} \]
    3. sqr-neg84.6%

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

      \[\leadsto \frac{r \cdot \sin b}{\mathsf{fma}\left(\cos b, \cos a, \color{blue}{\left(\sqrt{\sin b} \cdot \sqrt{\sin b}\right)} \cdot \sin a\right)} \]
    5. add-sqr-sqrt71.4%

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

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

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

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

      \[\leadsto \frac{r \cdot \sin b}{\mathsf{fma}\left(\cos b, \cos a, \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)} \]
    10. sqrt-unprod72.7%

      \[\leadsto \frac{r \cdot \sin b}{\mathsf{fma}\left(\cos b, \cos a, \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)} \]
    11. sqr-neg72.7%

      \[\leadsto \frac{r \cdot \sin b}{\mathsf{fma}\left(\cos b, \cos a, \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)} \]
    12. sqrt-unprod32.5%

      \[\leadsto \frac{r \cdot \sin b}{\mathsf{fma}\left(\cos b, \cos a, \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)} \]
    13. add-sqr-sqrt73.6%

      \[\leadsto \frac{r \cdot \sin b}{\mathsf{fma}\left(\cos b, \cos a, \frac{\cos b \cdot \cos a + \color{blue}{\left(-\sin b\right)} \cdot \sin a}{2} - \frac{\cos \left(b + a\right)}{2}\right)} \]
    14. cancel-sign-sub-inv73.6%

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

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

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

      \[\leadsto \frac{r \cdot \sin b}{\mathsf{fma}\left(\cos b, \cos a, \color{blue}{0}\right)} \]
  10. Simplified72.9%

    \[\leadsto \frac{r \cdot \sin b}{\mathsf{fma}\left(\cos b, \cos a, \color{blue}{0}\right)} \]
  11. Step-by-step derivation
    1. fma-undefine72.9%

      \[\leadsto \frac{r \cdot \sin b}{\color{blue}{\cos b \cdot \cos a + 0}} \]
    2. +-rgt-identity72.9%

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

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

Alternative 5: 77.6% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \sin b \cdot \frac{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(sin(b) * Float64(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[Sin[b], $MachinePrecision] * N[(r / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

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

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

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

      \[\leadsto \frac{r \cdot \sin b}{\color{blue}{\cos b \cdot \cos a - \sin b \cdot \sin a}} \]
    2. cancel-sign-sub-inv99.5%

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

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

    \[\leadsto \frac{r \cdot \sin b}{\color{blue}{\mathsf{fma}\left(\cos b, \cos a, \left(-\sin b\right) \cdot \sin a\right)}} \]
  7. Step-by-step derivation
    1. add-sqr-sqrt44.7%

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

      \[\leadsto \frac{r \cdot \sin b}{\mathsf{fma}\left(\cos b, \cos a, \color{blue}{\sqrt{\left(-\sin b\right) \cdot \left(-\sin b\right)}} \cdot \sin a\right)} \]
    3. sqr-neg84.6%

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

      \[\leadsto \frac{r \cdot \sin b}{\mathsf{fma}\left(\cos b, \cos a, \color{blue}{\left(\sqrt{\sin b} \cdot \sqrt{\sin b}\right)} \cdot \sin a\right)} \]
    5. add-sqr-sqrt71.4%

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

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

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

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

      \[\leadsto \frac{r \cdot \sin b}{\mathsf{fma}\left(\cos b, \cos a, \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)} \]
    10. sqrt-unprod72.7%

      \[\leadsto \frac{r \cdot \sin b}{\mathsf{fma}\left(\cos b, \cos a, \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)} \]
    11. sqr-neg72.7%

      \[\leadsto \frac{r \cdot \sin b}{\mathsf{fma}\left(\cos b, \cos a, \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)} \]
    12. sqrt-unprod32.5%

      \[\leadsto \frac{r \cdot \sin b}{\mathsf{fma}\left(\cos b, \cos a, \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)} \]
    13. add-sqr-sqrt73.6%

      \[\leadsto \frac{r \cdot \sin b}{\mathsf{fma}\left(\cos b, \cos a, \frac{\cos b \cdot \cos a + \color{blue}{\left(-\sin b\right)} \cdot \sin a}{2} - \frac{\cos \left(b + a\right)}{2}\right)} \]
    14. cancel-sign-sub-inv73.6%

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

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

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

      \[\leadsto \frac{r \cdot \sin b}{\mathsf{fma}\left(\cos b, \cos a, \color{blue}{0}\right)} \]
  10. Simplified72.9%

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

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

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

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

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

      \[\leadsto \sin b \cdot \frac{r}{\color{blue}{\cos a \cdot \cos b}} \]
  13. Simplified72.8%

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

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

Alternative 6: 76.5% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -5.50000000000000033e-4 or 0.52000000000000002 < b

    1. Initial program 46.8%

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

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

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

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

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

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

      \[\leadsto \frac{r \cdot \sin b}{\color{blue}{\mathsf{fma}\left(\cos b, \cos a, \left(-\sin b\right) \cdot \sin a\right)}} \]
    7. Step-by-step derivation
      1. frac-2neg99.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{r}{\frac{\color{blue}{\cos \left(b - a\right)}}{-\sin b}} \]
      13. add-sqr-sqrt3.4%

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

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

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

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

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

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

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

    if -5.50000000000000033e-4 < b < 0.52000000000000002

    1. Initial program 97.7%

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

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

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

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

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

Alternative 7: 76.5% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -5.99999999999999947e-4 or 0.52000000000000002 < b

    1. Initial program 46.8%

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

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

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

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

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

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

      \[\leadsto \frac{r \cdot \sin b}{\color{blue}{\mathsf{fma}\left(\cos b, \cos a, \left(-\sin b\right) \cdot \sin a\right)}} \]
    7. Step-by-step derivation
      1. expm1-log1p-u99.3%

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

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

      \[\leadsto \frac{r \cdot \sin b}{\mathsf{fma}\left(\cos b, \color{blue}{e^{\mathsf{log1p}\left(\cos a\right)} - 1}, \left(-\sin b\right) \cdot \sin a\right)} \]
    9. Step-by-step derivation
      1. expm1-define99.3%

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

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

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

        \[\leadsto \frac{\color{blue}{\sin b \cdot r}}{\cos b} \]
      2. *-lft-identity48.1%

        \[\leadsto \frac{\sin b \cdot r}{\color{blue}{1 \cdot \cos b}} \]
      3. times-frac48.1%

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

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

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

    if -5.99999999999999947e-4 < b < 0.52000000000000002

    1. Initial program 97.7%

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

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

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

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

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

Alternative 8: 76.5% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -5.50000000000000033e-4 or 0.52000000000000002 < b

    1. Initial program 46.8%

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

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

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

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

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

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

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

    if -5.50000000000000033e-4 < b < 0.52000000000000002

    1. Initial program 97.7%

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

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

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

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

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

Alternative 9: 76.4% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 49.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{r}{\frac{\color{blue}{\cos b \cdot \cos a - \sin b \cdot \sin a}}{-\sin b}} \]
      4. fma-neg2.4%

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

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

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

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

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

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

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

        \[\leadsto \frac{r}{\frac{\cos b \cdot \cos a + \color{blue}{\sin b} \cdot \sin a}{-\sin b}} \]
      12. cos-diff6.6%

        \[\leadsto \frac{r}{\frac{\color{blue}{\cos \left(b - a\right)}}{-\sin b}} \]
      13. add-sqr-sqrt3.6%

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

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

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

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

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

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

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

    if -6.4999999999999997e-4 < b < 0.52000000000000002

    1. Initial program 97.7%

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

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

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

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

    if 0.52000000000000002 < b

    1. Initial program 44.6%

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

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

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

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

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

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

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

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

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

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

Alternative 10: 76.6% accurate, 1.0× speedup?

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

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

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

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

Alternative 11: 76.6% 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 71.7%

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

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

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

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

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

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

Alternative 12: 76.6% 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 71.7%

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

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

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

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

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

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

Alternative 13: 55.4% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

Alternative 14: 53.4% accurate, 1.9× speedup?

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

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

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


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

    1. Initial program 82.8%

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

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

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

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

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

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

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

    if 3450 < b

    1. Initial program 43.9%

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

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

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

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

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

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

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

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

      \[\leadsto {\left(\sqrt[3]{r}\right)}^{2} \cdot \left(\sqrt[3]{r} \cdot \frac{\sin b}{\color{blue}{\cos a}}\right) \]
    8. Taylor expanded in a around 0 11.0%

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

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

Alternative 15: 53.4% accurate, 1.9× speedup?

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

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

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


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

    1. Initial program 82.8%

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

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

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

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

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

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

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

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

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

    if 3450 < b

    1. Initial program 43.9%

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

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

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

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

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

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

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

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

      \[\leadsto {\left(\sqrt[3]{r}\right)}^{2} \cdot \left(\sqrt[3]{r} \cdot \frac{\sin b}{\color{blue}{\cos a}}\right) \]
    8. Taylor expanded in a around 0 11.0%

      \[\leadsto \color{blue}{r \cdot \sin b} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 16: 39.1% accurate, 2.0× speedup?

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

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

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

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

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

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

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

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

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

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

    \[\leadsto {\left(\sqrt[3]{r}\right)}^{2} \cdot \left(\sqrt[3]{r} \cdot \frac{\sin b}{\color{blue}{\cos a}}\right) \]
  8. Taylor expanded in a around 0 37.0%

    \[\leadsto \color{blue}{r \cdot \sin b} \]
  9. Add Preprocessing

Alternative 17: 35.1% accurate, 69.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{b \cdot r} \]
  9. Step-by-step derivation
    1. *-commutative33.6%

      \[\leadsto \color{blue}{r \cdot b} \]
  10. Simplified33.6%

    \[\leadsto \color{blue}{r \cdot b} \]
  11. Add Preprocessing

Reproduce

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