rsin A (should all be same)

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

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

    \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
  2. Step-by-step derivation
    1. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
    2. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
    3. sin-lowering-sin.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
    4. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
    5. +-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
    6. +-lowering-+.f6478.5%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
  3. Simplified78.5%

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \left(\cos b \cdot \cos a - \color{blue}{\sin b \cdot \sin a}\right)\right) \]
    2. sub-negN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \left(\cos b \cdot \cos a + \color{blue}{\left(\mathsf{neg}\left(\sin b \cdot \sin a\right)\right)}\right)\right) \]
    3. +-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \left(\left(\mathsf{neg}\left(\sin b \cdot \sin a\right)\right) + \color{blue}{\cos b \cdot \cos a}\right)\right) \]
    4. distribute-lft-neg-inN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \left(\left(\mathsf{neg}\left(\sin b\right)\right) \cdot \sin a + \color{blue}{\cos b} \cdot \cos a\right)\right) \]
    5. fma-defineN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \left(\mathsf{fma}\left(\mathsf{neg}\left(\sin b\right), \color{blue}{\sin a}, \cos b \cdot \cos a\right)\right)\right) \]
    6. fma-lowering-fma.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{fma.f64}\left(\left(\mathsf{neg}\left(\sin b\right)\right), \color{blue}{\sin a}, \left(\cos b \cdot \cos a\right)\right)\right) \]
    7. neg-sub0N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{fma.f64}\left(\left(0 - \sin b\right), \sin \color{blue}{a}, \left(\cos b \cdot \cos a\right)\right)\right) \]
    8. --lowering--.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(0, \sin b\right), \sin \color{blue}{a}, \left(\cos b \cdot \cos a\right)\right)\right) \]
    9. sin-lowering-sin.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{sin.f64}\left(b\right)\right), \sin a, \left(\cos b \cdot \cos a\right)\right)\right) \]
    10. sin-lowering-sin.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{sin.f64}\left(b\right)\right), \mathsf{sin.f64}\left(a\right), \left(\cos b \cdot \cos a\right)\right)\right) \]
    11. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{sin.f64}\left(b\right)\right), \mathsf{sin.f64}\left(a\right), \mathsf{*.f64}\left(\cos b, \cos a\right)\right)\right) \]
    12. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{sin.f64}\left(b\right)\right), \mathsf{sin.f64}\left(a\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(b\right), \cos a\right)\right)\right) \]
    13. cos-lowering-cos.f6499.6%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{sin.f64}\left(b\right)\right), \mathsf{sin.f64}\left(a\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(b\right), \mathsf{cos.f64}\left(a\right)\right)\right)\right) \]
  6. Applied egg-rr99.6%

    \[\leadsto \frac{r \cdot \sin b}{\color{blue}{\mathsf{fma}\left(0 - \sin b, \sin a, \cos b \cdot \cos a\right)}} \]
  7. Step-by-step derivation
    1. remove-double-divN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(0, \left(\frac{1}{\frac{1}{\sin b}}\right)\right), \mathsf{sin.f64}\left(a\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(b\right), \mathsf{cos.f64}\left(a\right)\right)\right)\right) \]
    2. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{/.f64}\left(1, \left(\frac{1}{\sin b}\right)\right)\right), \mathsf{sin.f64}\left(a\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(b\right), \mathsf{cos.f64}\left(a\right)\right)\right)\right) \]
    3. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \sin b\right)\right)\right), \mathsf{sin.f64}\left(a\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(b\right), \mathsf{cos.f64}\left(a\right)\right)\right)\right) \]
    4. sin-lowering-sin.f6499.6%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right), \mathsf{sin.f64}\left(a\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(b\right), \mathsf{cos.f64}\left(a\right)\right)\right)\right) \]
  8. Applied egg-rr99.6%

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{fma.f64}\left(\left(\mathsf{neg}\left(\frac{1}{\frac{1}{\sin b}}\right)\right), \mathsf{sin.f64}\left(\color{blue}{a}\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(b\right), \mathsf{cos.f64}\left(a\right)\right)\right)\right) \]
    2. remove-double-divN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{fma.f64}\left(\left(\mathsf{neg}\left(\sin b\right)\right), \mathsf{sin.f64}\left(a\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(b\right), \mathsf{cos.f64}\left(a\right)\right)\right)\right) \]
    3. neg-lowering-neg.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{fma.f64}\left(\mathsf{neg.f64}\left(\sin b\right), \mathsf{sin.f64}\left(\color{blue}{a}\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(b\right), \mathsf{cos.f64}\left(a\right)\right)\right)\right) \]
    4. sin-lowering-sin.f6499.6%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{fma.f64}\left(\mathsf{neg.f64}\left(\mathsf{sin.f64}\left(b\right)\right), \mathsf{sin.f64}\left(a\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(b\right), \mathsf{cos.f64}\left(a\right)\right)\right)\right) \]
  10. Applied egg-rr99.6%

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

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

    \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
  2. Step-by-step derivation
    1. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
    2. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
    3. sin-lowering-sin.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
    4. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
    5. +-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
    6. +-lowering-+.f6478.5%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
  3. Simplified78.5%

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \left(\cos b \cdot \cos a - \color{blue}{\sin b \cdot \sin a}\right)\right) \]
    2. --lowering--.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{\_.f64}\left(\left(\cos b \cdot \cos a\right), \color{blue}{\left(\sin b \cdot \sin a\right)}\right)\right) \]
    3. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\cos b, \cos a\right), \left(\color{blue}{\sin b} \cdot \sin a\right)\right)\right) \]
    4. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(b\right), \cos a\right), \left(\sin \color{blue}{b} \cdot \sin a\right)\right)\right) \]
    5. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(b\right), \mathsf{cos.f64}\left(a\right)\right), \left(\sin b \cdot \sin a\right)\right)\right) \]
    6. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(b\right), \mathsf{cos.f64}\left(a\right)\right), \mathsf{*.f64}\left(\sin b, \color{blue}{\sin a}\right)\right)\right) \]
    7. sin-lowering-sin.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(b\right), \mathsf{cos.f64}\left(a\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(b\right), \sin \color{blue}{a}\right)\right)\right) \]
    8. sin-lowering-sin.f6499.6%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(b\right), \mathsf{cos.f64}\left(a\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(b\right), \mathsf{sin.f64}\left(a\right)\right)\right)\right) \]
  6. Applied egg-rr99.6%

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

Alternative 3: 99.4% accurate, 0.4× speedup?

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

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

    \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
  2. Step-by-step derivation
    1. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
    2. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
    3. sin-lowering-sin.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
    4. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
    5. +-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
    6. +-lowering-+.f6478.5%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
  3. Simplified78.5%

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

      \[\leadsto \frac{r}{\cos \left(b + a\right)} \cdot \color{blue}{\sin b} \]
    2. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\left(\frac{r}{\cos \left(b + a\right)}\right), \color{blue}{\sin b}\right) \]
    3. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \cos \left(b + a\right)\right), \sin \color{blue}{b}\right) \]
    4. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \sin b\right) \]
    5. +-lowering-+.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \sin b\right) \]
    6. sin-lowering-sin.f6478.5%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{sin.f64}\left(b\right)\right) \]
  6. Applied egg-rr78.5%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \left(\cos b \cdot \cos a - \sin b \cdot \sin a\right)\right), \mathsf{sin.f64}\left(b\right)\right) \]
    2. --lowering--.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{\_.f64}\left(\left(\cos b \cdot \cos a\right), \left(\sin b \cdot \sin a\right)\right)\right), \mathsf{sin.f64}\left(b\right)\right) \]
    3. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\cos b, \cos a\right), \left(\sin b \cdot \sin a\right)\right)\right), \mathsf{sin.f64}\left(b\right)\right) \]
    4. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(b\right), \cos a\right), \left(\sin b \cdot \sin a\right)\right)\right), \mathsf{sin.f64}\left(b\right)\right) \]
    5. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(b\right), \mathsf{cos.f64}\left(a\right)\right), \left(\sin b \cdot \sin a\right)\right)\right), \mathsf{sin.f64}\left(b\right)\right) \]
    6. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(b\right), \mathsf{cos.f64}\left(a\right)\right), \mathsf{*.f64}\left(\sin b, \sin a\right)\right)\right), \mathsf{sin.f64}\left(b\right)\right) \]
    7. sin-lowering-sin.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(b\right), \mathsf{cos.f64}\left(a\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(b\right), \sin a\right)\right)\right), \mathsf{sin.f64}\left(b\right)\right) \]
    8. sin-lowering-sin.f6499.5%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(b\right), \mathsf{cos.f64}\left(a\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(b\right), \mathsf{sin.f64}\left(a\right)\right)\right)\right), \mathsf{sin.f64}\left(b\right)\right) \]
  8. Applied egg-rr99.5%

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

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

Alternative 4: 75.8% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;a \leq 2.3 \cdot 10^{+15}:\\
\;\;\;\;\frac{t\_0}{\cos b}\\

\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{\cos a}\\


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

    1. Initial program 59.8%

      \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
    2. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
      3. sin-lowering-sin.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
      4. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
      5. +-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
      6. +-lowering-+.f6459.8%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
    3. Simplified59.8%

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

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

        \[\leadsto \frac{r}{\color{blue}{\frac{\cos \left(b + a\right)}{\sin b}}} \]
      3. *-lft-identityN/A

        \[\leadsto \frac{1 \cdot r}{\frac{\color{blue}{\cos \left(b + a\right)}}{\sin b}} \]
      4. div-invN/A

        \[\leadsto \frac{1 \cdot r}{\cos \left(b + a\right) \cdot \color{blue}{\frac{1}{\sin b}}} \]
      5. times-fracN/A

        \[\leadsto \frac{1}{\cos \left(b + a\right)} \cdot \color{blue}{\frac{r}{\frac{1}{\sin b}}} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{\cos \left(b + a\right)}\right), \color{blue}{\left(\frac{r}{\frac{1}{\sin b}}\right)}\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \cos \left(b + a\right)\right), \left(\frac{\color{blue}{r}}{\frac{1}{\sin b}}\right)\right) \]
      8. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
      9. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
      10. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \color{blue}{\left(\frac{1}{\sin b}\right)}\right)\right) \]
      11. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \color{blue}{\sin b}\right)\right)\right) \]
      12. sin-lowering-sin.f6459.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
    6. Applied egg-rr59.7%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \color{blue}{\cos a}\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
    8. Step-by-step derivation
      1. cos-lowering-cos.f6459.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(a\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
    9. Simplified59.0%

      \[\leadsto \frac{1}{\color{blue}{\cos a}} \cdot \frac{r}{\frac{1}{\sin b}} \]
    10. Step-by-step derivation
      1. clear-numN/A

        \[\leadsto \frac{1}{\cos a} \cdot \frac{1}{\color{blue}{\frac{\frac{1}{\sin b}}{r}}} \]
      2. un-div-invN/A

        \[\leadsto \frac{\frac{1}{\cos a}}{\color{blue}{\frac{\frac{1}{\sin b}}{r}}} \]
      3. associate-/r/N/A

        \[\leadsto \frac{\frac{1}{\cos a}}{\frac{1}{\sin b}} \cdot \color{blue}{r} \]
      4. div-invN/A

        \[\leadsto \frac{1 \cdot \frac{1}{\cos a}}{\frac{1}{\sin b}} \cdot r \]
      5. associate-*l/N/A

        \[\leadsto \left(\frac{1}{\frac{1}{\sin b}} \cdot \frac{1}{\cos a}\right) \cdot r \]
      6. remove-double-divN/A

        \[\leadsto \left(\sin b \cdot \frac{1}{\cos a}\right) \cdot r \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\sin b \cdot \frac{1}{\cos a}\right), \color{blue}{r}\right) \]
      8. un-div-invN/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{\sin b}{\cos a}\right), r\right) \]
      9. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\sin b, \cos a\right), r\right) \]
      10. sin-lowering-sin.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(b\right), \cos a\right), r\right) \]
      11. cos-lowering-cos.f6459.1%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(b\right), \mathsf{cos.f64}\left(a\right)\right), r\right) \]
    11. Applied egg-rr59.1%

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

    if -6.7999999999999999e-5 < a < 2.3e15

    1. Initial program 98.0%

      \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
    2. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
      3. sin-lowering-sin.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
      4. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
      5. +-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
      6. +-lowering-+.f6498.0%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
    3. Simplified98.0%

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

      \[\leadsto \color{blue}{\frac{r \cdot \sin b}{\cos b}} \]
    6. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos b}\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{b}\right) \]
      3. sin-lowering-sin.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos b\right) \]
      4. cos-lowering-cos.f6498.0%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(b\right)\right) \]
    7. Simplified98.0%

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

    if 2.3e15 < a

    1. Initial program 57.0%

      \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
    2. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
      3. sin-lowering-sin.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
      4. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
      5. +-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
      6. +-lowering-+.f6457.0%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \color{blue}{\cos a}\right) \]
    6. Step-by-step derivation
      1. cos-lowering-cos.f6456.6%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(a\right)\right) \]
    7. Simplified56.6%

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

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

Alternative 5: 75.8% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;a \leq 2.3 \cdot 10^{+15}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\

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


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

    1. Initial program 59.8%

      \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
    2. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
      3. sin-lowering-sin.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
      4. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
      5. +-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
      6. +-lowering-+.f6459.8%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
    3. Simplified59.8%

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

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

        \[\leadsto \frac{r}{\color{blue}{\frac{\cos \left(b + a\right)}{\sin b}}} \]
      3. *-lft-identityN/A

        \[\leadsto \frac{1 \cdot r}{\frac{\color{blue}{\cos \left(b + a\right)}}{\sin b}} \]
      4. div-invN/A

        \[\leadsto \frac{1 \cdot r}{\cos \left(b + a\right) \cdot \color{blue}{\frac{1}{\sin b}}} \]
      5. times-fracN/A

        \[\leadsto \frac{1}{\cos \left(b + a\right)} \cdot \color{blue}{\frac{r}{\frac{1}{\sin b}}} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{\cos \left(b + a\right)}\right), \color{blue}{\left(\frac{r}{\frac{1}{\sin b}}\right)}\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \cos \left(b + a\right)\right), \left(\frac{\color{blue}{r}}{\frac{1}{\sin b}}\right)\right) \]
      8. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
      9. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
      10. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \color{blue}{\left(\frac{1}{\sin b}\right)}\right)\right) \]
      11. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \color{blue}{\sin b}\right)\right)\right) \]
      12. sin-lowering-sin.f6459.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
    6. Applied egg-rr59.7%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \color{blue}{\cos a}\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
    8. Step-by-step derivation
      1. cos-lowering-cos.f6459.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(a\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
    9. Simplified59.0%

      \[\leadsto \frac{1}{\color{blue}{\cos a}} \cdot \frac{r}{\frac{1}{\sin b}} \]
    10. Step-by-step derivation
      1. clear-numN/A

        \[\leadsto \frac{1}{\cos a} \cdot \frac{1}{\color{blue}{\frac{\frac{1}{\sin b}}{r}}} \]
      2. un-div-invN/A

        \[\leadsto \frac{\frac{1}{\cos a}}{\color{blue}{\frac{\frac{1}{\sin b}}{r}}} \]
      3. associate-/r/N/A

        \[\leadsto \frac{\frac{1}{\cos a}}{\frac{1}{\sin b}} \cdot \color{blue}{r} \]
      4. div-invN/A

        \[\leadsto \frac{1 \cdot \frac{1}{\cos a}}{\frac{1}{\sin b}} \cdot r \]
      5. associate-*l/N/A

        \[\leadsto \left(\frac{1}{\frac{1}{\sin b}} \cdot \frac{1}{\cos a}\right) \cdot r \]
      6. remove-double-divN/A

        \[\leadsto \left(\sin b \cdot \frac{1}{\cos a}\right) \cdot r \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\sin b \cdot \frac{1}{\cos a}\right), \color{blue}{r}\right) \]
      8. un-div-invN/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{\sin b}{\cos a}\right), r\right) \]
      9. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\sin b, \cos a\right), r\right) \]
      10. sin-lowering-sin.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(b\right), \cos a\right), r\right) \]
      11. cos-lowering-cos.f6459.1%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(b\right), \mathsf{cos.f64}\left(a\right)\right), r\right) \]
    11. Applied egg-rr59.1%

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

    if -2.34999999999999993e-4 < a < 2.3e15

    1. Initial program 98.0%

      \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
    2. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
      3. sin-lowering-sin.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
      4. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
      5. +-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
      6. +-lowering-+.f6498.0%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
    3. Simplified98.0%

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

        \[\leadsto \frac{r}{\cos \left(b + a\right)} \cdot \color{blue}{\sin b} \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{r}{\cos \left(b + a\right)}\right), \color{blue}{\sin b}\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \cos \left(b + a\right)\right), \sin \color{blue}{b}\right) \]
      4. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \sin b\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \sin b\right) \]
      6. sin-lowering-sin.f6498.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{sin.f64}\left(b\right)\right) \]
    6. Applied egg-rr98.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(\frac{r}{\cos b}\right)}, \mathsf{sin.f64}\left(b\right)\right) \]
    8. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \cos b\right), \mathsf{sin.f64}\left(\color{blue}{b}\right)\right) \]
      2. cos-lowering-cos.f6498.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(b\right)\right), \mathsf{sin.f64}\left(b\right)\right) \]
    9. Simplified98.0%

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

    if 2.3e15 < a

    1. Initial program 57.0%

      \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
    2. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
      3. sin-lowering-sin.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
      4. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
      5. +-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
      6. +-lowering-+.f6457.0%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \color{blue}{\cos a}\right) \]
    6. Step-by-step derivation
      1. cos-lowering-cos.f6456.6%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(a\right)\right) \]
    7. Simplified56.6%

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

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

Alternative 6: 75.8% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;a \leq 2.3 \cdot 10^{+15}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\

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


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

    1. Initial program 59.8%

      \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
    2. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
      3. sin-lowering-sin.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
      4. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
      5. +-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
      6. +-lowering-+.f6459.8%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
    3. Simplified59.8%

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

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

        \[\leadsto \frac{r}{\color{blue}{\frac{\cos \left(b + a\right)}{\sin b}}} \]
      3. *-lft-identityN/A

        \[\leadsto \frac{1 \cdot r}{\frac{\color{blue}{\cos \left(b + a\right)}}{\sin b}} \]
      4. div-invN/A

        \[\leadsto \frac{1 \cdot r}{\cos \left(b + a\right) \cdot \color{blue}{\frac{1}{\sin b}}} \]
      5. times-fracN/A

        \[\leadsto \frac{1}{\cos \left(b + a\right)} \cdot \color{blue}{\frac{r}{\frac{1}{\sin b}}} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{\cos \left(b + a\right)}\right), \color{blue}{\left(\frac{r}{\frac{1}{\sin b}}\right)}\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \cos \left(b + a\right)\right), \left(\frac{\color{blue}{r}}{\frac{1}{\sin b}}\right)\right) \]
      8. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
      9. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
      10. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \color{blue}{\left(\frac{1}{\sin b}\right)}\right)\right) \]
      11. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \color{blue}{\sin b}\right)\right)\right) \]
      12. sin-lowering-sin.f6459.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
    6. Applied egg-rr59.7%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \color{blue}{\cos a}\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
    8. Step-by-step derivation
      1. cos-lowering-cos.f6459.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(a\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
    9. Simplified59.0%

      \[\leadsto \frac{1}{\color{blue}{\cos a}} \cdot \frac{r}{\frac{1}{\sin b}} \]
    10. Step-by-step derivation
      1. clear-numN/A

        \[\leadsto \frac{1}{\cos a} \cdot \frac{1}{\color{blue}{\frac{\frac{1}{\sin b}}{r}}} \]
      2. un-div-invN/A

        \[\leadsto \frac{\frac{1}{\cos a}}{\color{blue}{\frac{\frac{1}{\sin b}}{r}}} \]
      3. associate-/r/N/A

        \[\leadsto \frac{\frac{1}{\cos a}}{\frac{1}{\sin b}} \cdot \color{blue}{r} \]
      4. div-invN/A

        \[\leadsto \frac{1 \cdot \frac{1}{\cos a}}{\frac{1}{\sin b}} \cdot r \]
      5. associate-*l/N/A

        \[\leadsto \left(\frac{1}{\frac{1}{\sin b}} \cdot \frac{1}{\cos a}\right) \cdot r \]
      6. remove-double-divN/A

        \[\leadsto \left(\sin b \cdot \frac{1}{\cos a}\right) \cdot r \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\sin b \cdot \frac{1}{\cos a}\right), \color{blue}{r}\right) \]
      8. un-div-invN/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{\sin b}{\cos a}\right), r\right) \]
      9. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\sin b, \cos a\right), r\right) \]
      10. sin-lowering-sin.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(b\right), \cos a\right), r\right) \]
      11. cos-lowering-cos.f6459.1%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(b\right), \mathsf{cos.f64}\left(a\right)\right), r\right) \]
    11. Applied egg-rr59.1%

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

    if -1.55e-4 < a < 2.3e15

    1. Initial program 98.0%

      \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
    2. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
      3. sin-lowering-sin.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
      4. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
      5. +-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
      6. +-lowering-+.f6498.0%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
    3. Simplified98.0%

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

        \[\leadsto \frac{r}{\cos \left(b + a\right)} \cdot \color{blue}{\sin b} \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{r}{\cos \left(b + a\right)}\right), \color{blue}{\sin b}\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \cos \left(b + a\right)\right), \sin \color{blue}{b}\right) \]
      4. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \sin b\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \sin b\right) \]
      6. sin-lowering-sin.f6498.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{sin.f64}\left(b\right)\right) \]
    6. Applied egg-rr98.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(\frac{r}{\cos b}\right)}, \mathsf{sin.f64}\left(b\right)\right) \]
    8. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \cos b\right), \mathsf{sin.f64}\left(\color{blue}{b}\right)\right) \]
      2. cos-lowering-cos.f6498.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(b\right)\right), \mathsf{sin.f64}\left(b\right)\right) \]
    9. Simplified98.0%

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

    if 2.3e15 < a

    1. Initial program 57.0%

      \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
    2. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
      3. sin-lowering-sin.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
      4. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
      5. +-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
      6. +-lowering-+.f6457.0%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
    3. Simplified57.0%

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

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

        \[\leadsto \frac{r}{\color{blue}{\frac{\cos \left(b + a\right)}{\sin b}}} \]
      3. *-lft-identityN/A

        \[\leadsto \frac{1 \cdot r}{\frac{\color{blue}{\cos \left(b + a\right)}}{\sin b}} \]
      4. div-invN/A

        \[\leadsto \frac{1 \cdot r}{\cos \left(b + a\right) \cdot \color{blue}{\frac{1}{\sin b}}} \]
      5. times-fracN/A

        \[\leadsto \frac{1}{\cos \left(b + a\right)} \cdot \color{blue}{\frac{r}{\frac{1}{\sin b}}} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{\cos \left(b + a\right)}\right), \color{blue}{\left(\frac{r}{\frac{1}{\sin b}}\right)}\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \cos \left(b + a\right)\right), \left(\frac{\color{blue}{r}}{\frac{1}{\sin b}}\right)\right) \]
      8. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
      9. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
      10. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \color{blue}{\left(\frac{1}{\sin b}\right)}\right)\right) \]
      11. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \color{blue}{\sin b}\right)\right)\right) \]
      12. sin-lowering-sin.f6456.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
    6. Applied egg-rr56.8%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \color{blue}{\cos a}\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
    8. Step-by-step derivation
      1. cos-lowering-cos.f6456.5%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(a\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
    9. Simplified56.5%

      \[\leadsto \frac{1}{\color{blue}{\cos a}} \cdot \frac{r}{\frac{1}{\sin b}} \]
    10. Step-by-step derivation
      1. frac-timesN/A

        \[\leadsto \frac{1 \cdot r}{\color{blue}{\cos a \cdot \frac{1}{\sin b}}} \]
      2. *-lft-identityN/A

        \[\leadsto \frac{r}{\color{blue}{\cos a} \cdot \frac{1}{\sin b}} \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(r, \color{blue}{\left(\cos a \cdot \frac{1}{\sin b}\right)}\right) \]
      4. un-div-invN/A

        \[\leadsto \mathsf{/.f64}\left(r, \left(\frac{\cos a}{\color{blue}{\sin b}}\right)\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(\cos a, \color{blue}{\sin b}\right)\right) \]
      6. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(\mathsf{cos.f64}\left(a\right), \sin \color{blue}{b}\right)\right) \]
      7. sin-lowering-sin.f6456.6%

        \[\leadsto \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(\mathsf{cos.f64}\left(a\right), \mathsf{sin.f64}\left(b\right)\right)\right) \]
    11. Applied egg-rr56.6%

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

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

Alternative 7: 75.7% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := r \cdot \frac{\sin b}{\cos a}\\
\mathbf{if}\;a \leq -7.5 \cdot 10^{-6}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;a \leq 2.3 \cdot 10^{+15}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -7.50000000000000019e-6 or 2.3e15 < a

    1. Initial program 58.4%

      \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
    2. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
      3. sin-lowering-sin.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
      4. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
      5. +-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
      6. +-lowering-+.f6458.4%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
    3. Simplified58.4%

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

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

        \[\leadsto \frac{r}{\color{blue}{\frac{\cos \left(b + a\right)}{\sin b}}} \]
      3. *-lft-identityN/A

        \[\leadsto \frac{1 \cdot r}{\frac{\color{blue}{\cos \left(b + a\right)}}{\sin b}} \]
      4. div-invN/A

        \[\leadsto \frac{1 \cdot r}{\cos \left(b + a\right) \cdot \color{blue}{\frac{1}{\sin b}}} \]
      5. times-fracN/A

        \[\leadsto \frac{1}{\cos \left(b + a\right)} \cdot \color{blue}{\frac{r}{\frac{1}{\sin b}}} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{\cos \left(b + a\right)}\right), \color{blue}{\left(\frac{r}{\frac{1}{\sin b}}\right)}\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \cos \left(b + a\right)\right), \left(\frac{\color{blue}{r}}{\frac{1}{\sin b}}\right)\right) \]
      8. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
      9. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
      10. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \color{blue}{\left(\frac{1}{\sin b}\right)}\right)\right) \]
      11. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \color{blue}{\sin b}\right)\right)\right) \]
      12. sin-lowering-sin.f6458.3%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
    6. Applied egg-rr58.3%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \color{blue}{\cos a}\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
    8. Step-by-step derivation
      1. cos-lowering-cos.f6457.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(a\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
    9. Simplified57.8%

      \[\leadsto \frac{1}{\color{blue}{\cos a}} \cdot \frac{r}{\frac{1}{\sin b}} \]
    10. Step-by-step derivation
      1. clear-numN/A

        \[\leadsto \frac{1}{\cos a} \cdot \frac{1}{\color{blue}{\frac{\frac{1}{\sin b}}{r}}} \]
      2. un-div-invN/A

        \[\leadsto \frac{\frac{1}{\cos a}}{\color{blue}{\frac{\frac{1}{\sin b}}{r}}} \]
      3. associate-/r/N/A

        \[\leadsto \frac{\frac{1}{\cos a}}{\frac{1}{\sin b}} \cdot \color{blue}{r} \]
      4. div-invN/A

        \[\leadsto \frac{1 \cdot \frac{1}{\cos a}}{\frac{1}{\sin b}} \cdot r \]
      5. associate-*l/N/A

        \[\leadsto \left(\frac{1}{\frac{1}{\sin b}} \cdot \frac{1}{\cos a}\right) \cdot r \]
      6. remove-double-divN/A

        \[\leadsto \left(\sin b \cdot \frac{1}{\cos a}\right) \cdot r \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\sin b \cdot \frac{1}{\cos a}\right), \color{blue}{r}\right) \]
      8. un-div-invN/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{\sin b}{\cos a}\right), r\right) \]
      9. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\sin b, \cos a\right), r\right) \]
      10. sin-lowering-sin.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(b\right), \cos a\right), r\right) \]
      11. cos-lowering-cos.f6457.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(b\right), \mathsf{cos.f64}\left(a\right)\right), r\right) \]
    11. Applied egg-rr57.8%

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

    if -7.50000000000000019e-6 < a < 2.3e15

    1. Initial program 98.0%

      \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
    2. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
      3. sin-lowering-sin.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
      4. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
      5. +-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
      6. +-lowering-+.f6498.0%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
    3. Simplified98.0%

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

        \[\leadsto \frac{r}{\cos \left(b + a\right)} \cdot \color{blue}{\sin b} \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{r}{\cos \left(b + a\right)}\right), \color{blue}{\sin b}\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \cos \left(b + a\right)\right), \sin \color{blue}{b}\right) \]
      4. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \sin b\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \sin b\right) \]
      6. sin-lowering-sin.f6498.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{sin.f64}\left(b\right)\right) \]
    6. Applied egg-rr98.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(\frac{r}{\cos b}\right)}, \mathsf{sin.f64}\left(b\right)\right) \]
    8. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \cos b\right), \mathsf{sin.f64}\left(\color{blue}{b}\right)\right) \]
      2. cos-lowering-cos.f6498.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(b\right)\right), \mathsf{sin.f64}\left(b\right)\right) \]
    9. Simplified98.0%

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

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

Alternative 8: 75.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin b \cdot \frac{r}{\cos a}\\ \mathbf{if}\;a \leq -3.8 \cdot 10^{-5}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;a \leq 2.3 \cdot 10^{+15}:\\ \;\;\;\;\sin b \cdot \frac{r}{\cos b}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (r a b)
 :precision binary64
 (let* ((t_0 (* (sin b) (/ r (cos a)))))
   (if (<= a -3.8e-5) t_0 (if (<= a 2.3e+15) (* (sin b) (/ r (cos b))) t_0))))
double code(double r, double a, double b) {
	double t_0 = sin(b) * (r / cos(a));
	double tmp;
	if (a <= -3.8e-5) {
		tmp = t_0;
	} else if (a <= 2.3e+15) {
		tmp = sin(b) * (r / cos(b));
	} 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 / cos(a))
    if (a <= (-3.8d-5)) then
        tmp = t_0
    else if (a <= 2.3d+15) then
        tmp = sin(b) * (r / cos(b))
    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 / Math.cos(a));
	double tmp;
	if (a <= -3.8e-5) {
		tmp = t_0;
	} else if (a <= 2.3e+15) {
		tmp = Math.sin(b) * (r / Math.cos(b));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(r, a, b):
	t_0 = math.sin(b) * (r / math.cos(a))
	tmp = 0
	if a <= -3.8e-5:
		tmp = t_0
	elif a <= 2.3e+15:
		tmp = math.sin(b) * (r / math.cos(b))
	else:
		tmp = t_0
	return tmp
function code(r, a, b)
	t_0 = Float64(sin(b) * Float64(r / cos(a)))
	tmp = 0.0
	if (a <= -3.8e-5)
		tmp = t_0;
	elseif (a <= 2.3e+15)
		tmp = Float64(sin(b) * Float64(r / cos(b)));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(r, a, b)
	t_0 = sin(b) * (r / cos(a));
	tmp = 0.0;
	if (a <= -3.8e-5)
		tmp = t_0;
	elseif (a <= 2.3e+15)
		tmp = sin(b) * (r / cos(b));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -3.8e-5], t$95$0, If[LessEqual[a, 2.3e+15], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin b \cdot \frac{r}{\cos a}\\
\mathbf{if}\;a \leq -3.8 \cdot 10^{-5}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;a \leq 2.3 \cdot 10^{+15}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -3.8000000000000002e-5 or 2.3e15 < a

    1. Initial program 58.4%

      \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
    2. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
      3. sin-lowering-sin.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
      4. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
      5. +-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
      6. +-lowering-+.f6458.4%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
    3. Simplified58.4%

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

        \[\leadsto \frac{r}{\cos \left(b + a\right)} \cdot \color{blue}{\sin b} \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{r}{\cos \left(b + a\right)}\right), \color{blue}{\sin b}\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \cos \left(b + a\right)\right), \sin \color{blue}{b}\right) \]
      4. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \sin b\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \sin b\right) \]
      6. sin-lowering-sin.f6458.3%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{sin.f64}\left(b\right)\right) \]
    6. Applied egg-rr58.3%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(\frac{r}{\cos a}\right)}, \mathsf{sin.f64}\left(b\right)\right) \]
    8. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \cos a\right), \mathsf{sin.f64}\left(\color{blue}{b}\right)\right) \]
      2. cos-lowering-cos.f6457.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(a\right)\right), \mathsf{sin.f64}\left(b\right)\right) \]
    9. Simplified57.8%

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

    if -3.8000000000000002e-5 < a < 2.3e15

    1. Initial program 98.0%

      \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
    2. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
      3. sin-lowering-sin.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
      4. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
      5. +-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
      6. +-lowering-+.f6498.0%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
    3. Simplified98.0%

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

        \[\leadsto \frac{r}{\cos \left(b + a\right)} \cdot \color{blue}{\sin b} \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{r}{\cos \left(b + a\right)}\right), \color{blue}{\sin b}\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \cos \left(b + a\right)\right), \sin \color{blue}{b}\right) \]
      4. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \sin b\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \sin b\right) \]
      6. sin-lowering-sin.f6498.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{sin.f64}\left(b\right)\right) \]
    6. Applied egg-rr98.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(\frac{r}{\cos b}\right)}, \mathsf{sin.f64}\left(b\right)\right) \]
    8. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \cos b\right), \mathsf{sin.f64}\left(\color{blue}{b}\right)\right) \]
      2. cos-lowering-cos.f6498.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(b\right)\right), \mathsf{sin.f64}\left(b\right)\right) \]
    9. Simplified98.0%

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

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

Alternative 9: 76.5% 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 78.5%

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

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

Alternative 10: 76.5% 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 78.5%

    \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
  2. Step-by-step derivation
    1. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
    2. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
    3. sin-lowering-sin.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
    4. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
    5. +-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
    6. +-lowering-+.f6478.5%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
  3. Simplified78.5%

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

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

      \[\leadsto \frac{\sin b}{\cos \left(b + a\right)} \cdot \color{blue}{r} \]
    3. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\left(\frac{\sin b}{\cos \left(b + a\right)}\right), \color{blue}{r}\right) \]
    4. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\sin b, \cos \left(b + a\right)\right), r\right) \]
    5. sin-lowering-sin.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(b\right), \cos \left(b + a\right)\right), r\right) \]
    6. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(b\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), r\right) \]
    7. +-lowering-+.f6478.5%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(b\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), r\right) \]
  6. Applied egg-rr78.5%

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

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

Alternative 11: 76.5% accurate, 1.0× speedup?

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

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

    \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
  2. Step-by-step derivation
    1. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
    2. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
    3. sin-lowering-sin.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
    4. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
    5. +-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
    6. +-lowering-+.f6478.5%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
  3. Simplified78.5%

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

      \[\leadsto \frac{r}{\cos \left(b + a\right)} \cdot \color{blue}{\sin b} \]
    2. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\left(\frac{r}{\cos \left(b + a\right)}\right), \color{blue}{\sin b}\right) \]
    3. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \cos \left(b + a\right)\right), \sin \color{blue}{b}\right) \]
    4. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \sin b\right) \]
    5. +-lowering-+.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \sin b\right) \]
    6. sin-lowering-sin.f6478.5%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{sin.f64}\left(b\right)\right) \]
  6. Applied egg-rr78.5%

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

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

Alternative 12: 54.9% accurate, 1.0× speedup?

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

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

    \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
  2. Step-by-step derivation
    1. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
    2. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
    3. sin-lowering-sin.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
    4. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
    5. +-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
    6. +-lowering-+.f6478.5%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
  3. Simplified78.5%

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

      \[\leadsto \frac{r}{\cos \left(b + a\right)} \cdot \color{blue}{\sin b} \]
    2. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\left(\frac{r}{\cos \left(b + a\right)}\right), \color{blue}{\sin b}\right) \]
    3. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \cos \left(b + a\right)\right), \sin \color{blue}{b}\right) \]
    4. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \sin b\right) \]
    5. +-lowering-+.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \sin b\right) \]
    6. sin-lowering-sin.f6478.5%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{sin.f64}\left(b\right)\right) \]
  6. Applied egg-rr78.5%

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

    \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(\frac{r}{\cos a}\right)}, \mathsf{sin.f64}\left(b\right)\right) \]
  8. Step-by-step derivation
    1. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \cos a\right), \mathsf{sin.f64}\left(\color{blue}{b}\right)\right) \]
    2. cos-lowering-cos.f6454.0%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(a\right)\right), \mathsf{sin.f64}\left(b\right)\right) \]
  9. Simplified54.0%

    \[\leadsto \color{blue}{\frac{r}{\cos a}} \cdot \sin b \]
  10. Final simplification54.0%

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

Alternative 13: 55.3% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -9 \cdot 10^{+27}:\\
\;\;\;\;r \cdot \sin b\\

\mathbf{elif}\;b \leq 3.8 \cdot 10^{+25}:\\
\;\;\;\;\frac{r \cdot \left(b \cdot \left(1 + \left(b \cdot b\right) \cdot \left(-0.16666666666666666 + \left(b \cdot b\right) \cdot \left(0.008333333333333333 + \left(b \cdot b\right) \cdot -0.0001984126984126984\right)\right)\right)\right)}{\cos \left(b + a\right)}\\

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


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

    1. Initial program 60.1%

      \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
    2. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
      3. sin-lowering-sin.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
      4. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
      5. +-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
      6. +-lowering-+.f6460.1%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
    3. Simplified60.1%

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

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

        \[\leadsto \frac{r}{\color{blue}{\frac{\cos \left(b + a\right)}{\sin b}}} \]
      3. *-lft-identityN/A

        \[\leadsto \frac{1 \cdot r}{\frac{\color{blue}{\cos \left(b + a\right)}}{\sin b}} \]
      4. div-invN/A

        \[\leadsto \frac{1 \cdot r}{\cos \left(b + a\right) \cdot \color{blue}{\frac{1}{\sin b}}} \]
      5. times-fracN/A

        \[\leadsto \frac{1}{\cos \left(b + a\right)} \cdot \color{blue}{\frac{r}{\frac{1}{\sin b}}} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{\cos \left(b + a\right)}\right), \color{blue}{\left(\frac{r}{\frac{1}{\sin b}}\right)}\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \cos \left(b + a\right)\right), \left(\frac{\color{blue}{r}}{\frac{1}{\sin b}}\right)\right) \]
      8. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
      9. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
      10. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \color{blue}{\left(\frac{1}{\sin b}\right)}\right)\right) \]
      11. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \color{blue}{\sin b}\right)\right)\right) \]
      12. sin-lowering-sin.f6460.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
    6. Applied egg-rr60.0%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \color{blue}{\cos a}\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
    8. Step-by-step derivation
      1. cos-lowering-cos.f6410.2%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(a\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
    9. Simplified10.2%

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

      \[\leadsto \color{blue}{r \cdot \sin b} \]
    11. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(r, \color{blue}{\sin b}\right) \]
      2. sin-lowering-sin.f6410.5%

        \[\leadsto \mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right) \]
    12. Simplified10.5%

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

    if -8.9999999999999998e27 < b < 3.8e25

    1. Initial program 97.9%

      \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
    2. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
      3. sin-lowering-sin.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
      4. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
      5. +-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
      6. +-lowering-+.f6497.9%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
    3. Simplified97.9%

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \color{blue}{\left(b \cdot \left(1 + {b}^{2} \cdot \left({b}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}\right) - \frac{1}{6}\right)\right)\right)}\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
    6. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{*.f64}\left(b, \left(1 + {b}^{2} \cdot \left({b}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}\right) - \frac{1}{6}\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, \color{blue}{a}\right)\right)\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \left({b}^{2} \cdot \left({b}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}\right) - \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left({b}^{2}\right), \left({b}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}\right) - \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
      4. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left(b \cdot b\right), \left({b}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}\right) - \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \left({b}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}\right) - \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
      6. sub-negN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \left({b}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}\right) + \left(\mathsf{neg}\left(\frac{1}{6}\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
      7. metadata-evalN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \left({b}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}\right) + \frac{-1}{6}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
      8. +-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \left(\frac{-1}{6} + {b}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
      9. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \mathsf{+.f64}\left(\frac{-1}{6}, \left({b}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \mathsf{+.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(\left({b}^{2}\right), \left(\frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
      11. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \mathsf{+.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(\left(b \cdot b\right), \left(\frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \mathsf{+.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \left(\frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
      13. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \mathsf{+.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \mathsf{+.f64}\left(\frac{1}{120}, \left(\frac{-1}{5040} \cdot {b}^{2}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
      14. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \mathsf{+.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \mathsf{+.f64}\left(\frac{1}{120}, \left({b}^{2} \cdot \frac{-1}{5040}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \mathsf{+.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \mathsf{+.f64}\left(\frac{1}{120}, \mathsf{*.f64}\left(\left({b}^{2}\right), \frac{-1}{5040}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
      16. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \mathsf{+.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \mathsf{+.f64}\left(\frac{1}{120}, \mathsf{*.f64}\left(\left(b \cdot b\right), \frac{-1}{5040}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
      17. *-lowering-*.f6493.8%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \mathsf{+.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \mathsf{+.f64}\left(\frac{1}{120}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \frac{-1}{5040}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
    7. Simplified93.8%

      \[\leadsto \frac{r \cdot \color{blue}{\left(b \cdot \left(1 + \left(b \cdot b\right) \cdot \left(-0.16666666666666666 + \left(b \cdot b\right) \cdot \left(0.008333333333333333 + \left(b \cdot b\right) \cdot -0.0001984126984126984\right)\right)\right)\right)}}{\cos \left(b + a\right)} \]

    if 3.8e25 < b

    1. Initial program 54.0%

      \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
    2. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
      3. sin-lowering-sin.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
      4. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
      5. +-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
      6. +-lowering-+.f6454.0%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
    3. Simplified54.0%

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

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

        \[\leadsto \frac{r}{\color{blue}{\frac{\cos \left(b + a\right)}{\sin b}}} \]
      3. *-lft-identityN/A

        \[\leadsto \frac{1 \cdot r}{\frac{\color{blue}{\cos \left(b + a\right)}}{\sin b}} \]
      4. div-invN/A

        \[\leadsto \frac{1 \cdot r}{\cos \left(b + a\right) \cdot \color{blue}{\frac{1}{\sin b}}} \]
      5. times-fracN/A

        \[\leadsto \frac{1}{\cos \left(b + a\right)} \cdot \color{blue}{\frac{r}{\frac{1}{\sin b}}} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{\cos \left(b + a\right)}\right), \color{blue}{\left(\frac{r}{\frac{1}{\sin b}}\right)}\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \cos \left(b + a\right)\right), \left(\frac{\color{blue}{r}}{\frac{1}{\sin b}}\right)\right) \]
      8. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
      9. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
      10. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \color{blue}{\left(\frac{1}{\sin b}\right)}\right)\right) \]
      11. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \color{blue}{\sin b}\right)\right)\right) \]
      12. sin-lowering-sin.f6453.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
    6. Applied egg-rr53.8%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \color{blue}{\cos a}\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
    8. Step-by-step derivation
      1. cos-lowering-cos.f6411.4%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(a\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
    9. Simplified11.4%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{1}, \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
    11. Step-by-step derivation
      1. Simplified10.9%

        \[\leadsto \color{blue}{1} \cdot \frac{r}{\frac{1}{\sin b}} \]
    12. Recombined 3 regimes into one program.
    13. Final simplification54.5%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -9 \cdot 10^{+27}:\\ \;\;\;\;r \cdot \sin b\\ \mathbf{elif}\;b \leq 3.8 \cdot 10^{+25}:\\ \;\;\;\;\frac{r \cdot \left(b \cdot \left(1 + \left(b \cdot b\right) \cdot \left(-0.16666666666666666 + \left(b \cdot b\right) \cdot \left(0.008333333333333333 + \left(b \cdot b\right) \cdot -0.0001984126984126984\right)\right)\right)\right)}{\cos \left(b + a\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{r}{\frac{1}{\sin b}}\\ \end{array} \]
    14. Add Preprocessing

    Alternative 14: 55.4% accurate, 1.6× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -2 \cdot 10^{+17}:\\ \;\;\;\;r \cdot \sin b\\ \mathbf{elif}\;b \leq 15.5:\\ \;\;\;\;\frac{b \cdot \left(r + \left(b \cdot b\right) \cdot \left(r \cdot \left(-0.16666666666666666 + \left(b \cdot b\right) \cdot 0.008333333333333333\right)\right)\right)}{\cos \left(b + a\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{r}{\frac{1}{\sin b}}\\ \end{array} \end{array} \]
    (FPCore (r a b)
     :precision binary64
     (if (<= b -2e+17)
       (* r (sin b))
       (if (<= b 15.5)
         (/
          (*
           b
           (+
            r
            (*
             (* b b)
             (* r (+ -0.16666666666666666 (* (* b b) 0.008333333333333333))))))
          (cos (+ b a)))
         (/ r (/ 1.0 (sin b))))))
    double code(double r, double a, double b) {
    	double tmp;
    	if (b <= -2e+17) {
    		tmp = r * sin(b);
    	} else if (b <= 15.5) {
    		tmp = (b * (r + ((b * b) * (r * (-0.16666666666666666 + ((b * b) * 0.008333333333333333)))))) / cos((b + a));
    	} else {
    		tmp = r / (1.0 / 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 <= (-2d+17)) then
            tmp = r * sin(b)
        else if (b <= 15.5d0) then
            tmp = (b * (r + ((b * b) * (r * ((-0.16666666666666666d0) + ((b * b) * 0.008333333333333333d0)))))) / cos((b + a))
        else
            tmp = r / (1.0d0 / sin(b))
        end if
        code = tmp
    end function
    
    public static double code(double r, double a, double b) {
    	double tmp;
    	if (b <= -2e+17) {
    		tmp = r * Math.sin(b);
    	} else if (b <= 15.5) {
    		tmp = (b * (r + ((b * b) * (r * (-0.16666666666666666 + ((b * b) * 0.008333333333333333)))))) / Math.cos((b + a));
    	} else {
    		tmp = r / (1.0 / Math.sin(b));
    	}
    	return tmp;
    }
    
    def code(r, a, b):
    	tmp = 0
    	if b <= -2e+17:
    		tmp = r * math.sin(b)
    	elif b <= 15.5:
    		tmp = (b * (r + ((b * b) * (r * (-0.16666666666666666 + ((b * b) * 0.008333333333333333)))))) / math.cos((b + a))
    	else:
    		tmp = r / (1.0 / math.sin(b))
    	return tmp
    
    function code(r, a, b)
    	tmp = 0.0
    	if (b <= -2e+17)
    		tmp = Float64(r * sin(b));
    	elseif (b <= 15.5)
    		tmp = Float64(Float64(b * Float64(r + Float64(Float64(b * b) * Float64(r * Float64(-0.16666666666666666 + Float64(Float64(b * b) * 0.008333333333333333)))))) / cos(Float64(b + a)));
    	else
    		tmp = Float64(r / Float64(1.0 / sin(b)));
    	end
    	return tmp
    end
    
    function tmp_2 = code(r, a, b)
    	tmp = 0.0;
    	if (b <= -2e+17)
    		tmp = r * sin(b);
    	elseif (b <= 15.5)
    		tmp = (b * (r + ((b * b) * (r * (-0.16666666666666666 + ((b * b) * 0.008333333333333333)))))) / cos((b + a));
    	else
    		tmp = r / (1.0 / sin(b));
    	end
    	tmp_2 = tmp;
    end
    
    code[r_, a_, b_] := If[LessEqual[b, -2e+17], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 15.5], N[(N[(b * N[(r + N[(N[(b * b), $MachinePrecision] * N[(r * N[(-0.16666666666666666 + N[(N[(b * b), $MachinePrecision] * 0.008333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(r / N[(1.0 / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;b \leq -2 \cdot 10^{+17}:\\
    \;\;\;\;r \cdot \sin b\\
    
    \mathbf{elif}\;b \leq 15.5:\\
    \;\;\;\;\frac{b \cdot \left(r + \left(b \cdot b\right) \cdot \left(r \cdot \left(-0.16666666666666666 + \left(b \cdot b\right) \cdot 0.008333333333333333\right)\right)\right)}{\cos \left(b + a\right)}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{r}{\frac{1}{\sin b}}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if b < -2e17

      1. Initial program 60.8%

        \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
      2. Step-by-step derivation
        1. /-lowering-/.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
        2. *-lowering-*.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
        3. sin-lowering-sin.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
        4. cos-lowering-cos.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
        5. +-commutativeN/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
        6. +-lowering-+.f6460.8%

          \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
      3. Simplified60.8%

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

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

          \[\leadsto \frac{r}{\color{blue}{\frac{\cos \left(b + a\right)}{\sin b}}} \]
        3. *-lft-identityN/A

          \[\leadsto \frac{1 \cdot r}{\frac{\color{blue}{\cos \left(b + a\right)}}{\sin b}} \]
        4. div-invN/A

          \[\leadsto \frac{1 \cdot r}{\cos \left(b + a\right) \cdot \color{blue}{\frac{1}{\sin b}}} \]
        5. times-fracN/A

          \[\leadsto \frac{1}{\cos \left(b + a\right)} \cdot \color{blue}{\frac{r}{\frac{1}{\sin b}}} \]
        6. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{\cos \left(b + a\right)}\right), \color{blue}{\left(\frac{r}{\frac{1}{\sin b}}\right)}\right) \]
        7. /-lowering-/.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \cos \left(b + a\right)\right), \left(\frac{\color{blue}{r}}{\frac{1}{\sin b}}\right)\right) \]
        8. cos-lowering-cos.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
        9. +-lowering-+.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
        10. /-lowering-/.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \color{blue}{\left(\frac{1}{\sin b}\right)}\right)\right) \]
        11. /-lowering-/.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \color{blue}{\sin b}\right)\right)\right) \]
        12. sin-lowering-sin.f6460.6%

          \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
      6. Applied egg-rr60.6%

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \color{blue}{\cos a}\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
      8. Step-by-step derivation
        1. cos-lowering-cos.f6410.0%

          \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(a\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
      9. Simplified10.0%

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

        \[\leadsto \color{blue}{r \cdot \sin b} \]
      11. Step-by-step derivation
        1. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(r, \color{blue}{\sin b}\right) \]
        2. sin-lowering-sin.f6410.4%

          \[\leadsto \mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right) \]
      12. Simplified10.4%

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

      if -2e17 < b < 15.5

      1. Initial program 98.4%

        \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
      2. Step-by-step derivation
        1. /-lowering-/.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
        2. *-lowering-*.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
        3. sin-lowering-sin.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
        4. cos-lowering-cos.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
        5. +-commutativeN/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
        6. +-lowering-+.f6498.4%

          \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
      3. Simplified98.4%

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

        \[\leadsto \mathsf{/.f64}\left(\color{blue}{\left(b \cdot \left(r + {b}^{2} \cdot \left(\frac{-1}{6} \cdot r + \frac{1}{120} \cdot \left({b}^{2} \cdot r\right)\right)\right)\right)}, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
      6. Step-by-step derivation
        1. *-lowering-*.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(b, \left(r + {b}^{2} \cdot \left(\frac{-1}{6} \cdot r + \frac{1}{120} \cdot \left({b}^{2} \cdot r\right)\right)\right)\right), \mathsf{cos.f64}\left(\color{blue}{\mathsf{+.f64}\left(b, a\right)}\right)\right) \]
        2. +-lowering-+.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(b, \mathsf{+.f64}\left(r, \left({b}^{2} \cdot \left(\frac{-1}{6} \cdot r + \frac{1}{120} \cdot \left({b}^{2} \cdot r\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, \color{blue}{a}\right)\right)\right) \]
        3. *-lowering-*.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(b, \mathsf{+.f64}\left(r, \mathsf{*.f64}\left(\left({b}^{2}\right), \left(\frac{-1}{6} \cdot r + \frac{1}{120} \cdot \left({b}^{2} \cdot r\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
        4. unpow2N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(b, \mathsf{+.f64}\left(r, \mathsf{*.f64}\left(\left(b \cdot b\right), \left(\frac{-1}{6} \cdot r + \frac{1}{120} \cdot \left({b}^{2} \cdot r\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
        5. *-lowering-*.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(b, \mathsf{+.f64}\left(r, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \left(\frac{-1}{6} \cdot r + \frac{1}{120} \cdot \left({b}^{2} \cdot r\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
        6. associate-*r*N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(b, \mathsf{+.f64}\left(r, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \left(\frac{-1}{6} \cdot r + \left(\frac{1}{120} \cdot {b}^{2}\right) \cdot r\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
        7. distribute-rgt-outN/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(b, \mathsf{+.f64}\left(r, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \left(r \cdot \left(\frac{-1}{6} + \frac{1}{120} \cdot {b}^{2}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
        8. +-commutativeN/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(b, \mathsf{+.f64}\left(r, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \left(r \cdot \left(\frac{1}{120} \cdot {b}^{2} + \frac{-1}{6}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
        9. metadata-evalN/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(b, \mathsf{+.f64}\left(r, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \left(r \cdot \left(\frac{1}{120} \cdot {b}^{2} + \left(\mathsf{neg}\left(\frac{1}{6}\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
        10. sub-negN/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(b, \mathsf{+.f64}\left(r, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \left(r \cdot \left(\frac{1}{120} \cdot {b}^{2} - \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
        11. *-lowering-*.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(b, \mathsf{+.f64}\left(r, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \mathsf{*.f64}\left(r, \left(\frac{1}{120} \cdot {b}^{2} - \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
        12. sub-negN/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(b, \mathsf{+.f64}\left(r, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \mathsf{*.f64}\left(r, \left(\frac{1}{120} \cdot {b}^{2} + \left(\mathsf{neg}\left(\frac{1}{6}\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
        13. metadata-evalN/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(b, \mathsf{+.f64}\left(r, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \mathsf{*.f64}\left(r, \left(\frac{1}{120} \cdot {b}^{2} + \frac{-1}{6}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
        14. +-commutativeN/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(b, \mathsf{+.f64}\left(r, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \mathsf{*.f64}\left(r, \left(\frac{-1}{6} + \frac{1}{120} \cdot {b}^{2}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
        15. +-lowering-+.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(b, \mathsf{+.f64}\left(r, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \mathsf{*.f64}\left(r, \mathsf{+.f64}\left(\frac{-1}{6}, \left(\frac{1}{120} \cdot {b}^{2}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
        16. *-commutativeN/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(b, \mathsf{+.f64}\left(r, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \mathsf{*.f64}\left(r, \mathsf{+.f64}\left(\frac{-1}{6}, \left({b}^{2} \cdot \frac{1}{120}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
        17. *-lowering-*.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(b, \mathsf{+.f64}\left(r, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \mathsf{*.f64}\left(r, \mathsf{+.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(\left({b}^{2}\right), \frac{1}{120}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
        18. unpow2N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(b, \mathsf{+.f64}\left(r, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \mathsf{*.f64}\left(r, \mathsf{+.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(\left(b \cdot b\right), \frac{1}{120}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
        19. *-lowering-*.f6495.7%

          \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(b, \mathsf{+.f64}\left(r, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \mathsf{*.f64}\left(r, \mathsf{+.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(b, b\right), \frac{1}{120}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
      7. Simplified95.7%

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

      if 15.5 < b

      1. Initial program 54.2%

        \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
      2. Step-by-step derivation
        1. /-lowering-/.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
        2. *-lowering-*.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
        3. sin-lowering-sin.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
        4. cos-lowering-cos.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
        5. +-commutativeN/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
        6. +-lowering-+.f6454.2%

          \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
      3. Simplified54.2%

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

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

          \[\leadsto \frac{r}{\color{blue}{\frac{\cos \left(b + a\right)}{\sin b}}} \]
        3. *-lft-identityN/A

          \[\leadsto \frac{1 \cdot r}{\frac{\color{blue}{\cos \left(b + a\right)}}{\sin b}} \]
        4. div-invN/A

          \[\leadsto \frac{1 \cdot r}{\cos \left(b + a\right) \cdot \color{blue}{\frac{1}{\sin b}}} \]
        5. times-fracN/A

          \[\leadsto \frac{1}{\cos \left(b + a\right)} \cdot \color{blue}{\frac{r}{\frac{1}{\sin b}}} \]
        6. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{\cos \left(b + a\right)}\right), \color{blue}{\left(\frac{r}{\frac{1}{\sin b}}\right)}\right) \]
        7. /-lowering-/.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \cos \left(b + a\right)\right), \left(\frac{\color{blue}{r}}{\frac{1}{\sin b}}\right)\right) \]
        8. cos-lowering-cos.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
        9. +-lowering-+.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
        10. /-lowering-/.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \color{blue}{\left(\frac{1}{\sin b}\right)}\right)\right) \]
        11. /-lowering-/.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \color{blue}{\sin b}\right)\right)\right) \]
        12. sin-lowering-sin.f6454.0%

          \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
      6. Applied egg-rr54.0%

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \color{blue}{\cos a}\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
      8. Step-by-step derivation
        1. cos-lowering-cos.f6411.5%

          \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(a\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
      9. Simplified11.5%

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

        \[\leadsto \mathsf{*.f64}\left(\color{blue}{1}, \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
      11. Step-by-step derivation
        1. Simplified10.6%

          \[\leadsto \color{blue}{1} \cdot \frac{r}{\frac{1}{\sin b}} \]
      12. Recombined 3 regimes into one program.
      13. Final simplification54.4%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -2 \cdot 10^{+17}:\\ \;\;\;\;r \cdot \sin b\\ \mathbf{elif}\;b \leq 15.5:\\ \;\;\;\;\frac{b \cdot \left(r + \left(b \cdot b\right) \cdot \left(r \cdot \left(-0.16666666666666666 + \left(b \cdot b\right) \cdot 0.008333333333333333\right)\right)\right)}{\cos \left(b + a\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{r}{\frac{1}{\sin b}}\\ \end{array} \]
      14. Add Preprocessing

      Alternative 15: 55.4% accurate, 1.6× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -8.5 \cdot 10^{+16}:\\ \;\;\;\;r \cdot \sin b\\ \mathbf{elif}\;b \leq 11:\\ \;\;\;\;\frac{r}{\cos \left(b + a\right)} \cdot \left(b \cdot \left(1 + b \cdot \left(b \cdot \left(-0.16666666666666666 + b \cdot \left(b \cdot 0.008333333333333333\right)\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{r}{\frac{1}{\sin b}}\\ \end{array} \end{array} \]
      (FPCore (r a b)
       :precision binary64
       (if (<= b -8.5e+16)
         (* r (sin b))
         (if (<= b 11.0)
           (*
            (/ r (cos (+ b a)))
            (*
             b
             (+
              1.0
              (*
               b
               (* b (+ -0.16666666666666666 (* b (* b 0.008333333333333333))))))))
           (/ r (/ 1.0 (sin b))))))
      double code(double r, double a, double b) {
      	double tmp;
      	if (b <= -8.5e+16) {
      		tmp = r * sin(b);
      	} else if (b <= 11.0) {
      		tmp = (r / cos((b + a))) * (b * (1.0 + (b * (b * (-0.16666666666666666 + (b * (b * 0.008333333333333333)))))));
      	} else {
      		tmp = r / (1.0 / 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 <= (-8.5d+16)) then
              tmp = r * sin(b)
          else if (b <= 11.0d0) then
              tmp = (r / cos((b + a))) * (b * (1.0d0 + (b * (b * ((-0.16666666666666666d0) + (b * (b * 0.008333333333333333d0)))))))
          else
              tmp = r / (1.0d0 / sin(b))
          end if
          code = tmp
      end function
      
      public static double code(double r, double a, double b) {
      	double tmp;
      	if (b <= -8.5e+16) {
      		tmp = r * Math.sin(b);
      	} else if (b <= 11.0) {
      		tmp = (r / Math.cos((b + a))) * (b * (1.0 + (b * (b * (-0.16666666666666666 + (b * (b * 0.008333333333333333)))))));
      	} else {
      		tmp = r / (1.0 / Math.sin(b));
      	}
      	return tmp;
      }
      
      def code(r, a, b):
      	tmp = 0
      	if b <= -8.5e+16:
      		tmp = r * math.sin(b)
      	elif b <= 11.0:
      		tmp = (r / math.cos((b + a))) * (b * (1.0 + (b * (b * (-0.16666666666666666 + (b * (b * 0.008333333333333333)))))))
      	else:
      		tmp = r / (1.0 / math.sin(b))
      	return tmp
      
      function code(r, a, b)
      	tmp = 0.0
      	if (b <= -8.5e+16)
      		tmp = Float64(r * sin(b));
      	elseif (b <= 11.0)
      		tmp = Float64(Float64(r / cos(Float64(b + a))) * Float64(b * Float64(1.0 + Float64(b * Float64(b * Float64(-0.16666666666666666 + Float64(b * Float64(b * 0.008333333333333333))))))));
      	else
      		tmp = Float64(r / Float64(1.0 / sin(b)));
      	end
      	return tmp
      end
      
      function tmp_2 = code(r, a, b)
      	tmp = 0.0;
      	if (b <= -8.5e+16)
      		tmp = r * sin(b);
      	elseif (b <= 11.0)
      		tmp = (r / cos((b + a))) * (b * (1.0 + (b * (b * (-0.16666666666666666 + (b * (b * 0.008333333333333333)))))));
      	else
      		tmp = r / (1.0 / sin(b));
      	end
      	tmp_2 = tmp;
      end
      
      code[r_, a_, b_] := If[LessEqual[b, -8.5e+16], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 11.0], N[(N[(r / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(b * N[(1.0 + N[(b * N[(b * N[(-0.16666666666666666 + N[(b * N[(b * 0.008333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r / N[(1.0 / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;b \leq -8.5 \cdot 10^{+16}:\\
      \;\;\;\;r \cdot \sin b\\
      
      \mathbf{elif}\;b \leq 11:\\
      \;\;\;\;\frac{r}{\cos \left(b + a\right)} \cdot \left(b \cdot \left(1 + b \cdot \left(b \cdot \left(-0.16666666666666666 + b \cdot \left(b \cdot 0.008333333333333333\right)\right)\right)\right)\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{r}{\frac{1}{\sin b}}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if b < -8.5e16

        1. Initial program 60.8%

          \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
        2. Step-by-step derivation
          1. /-lowering-/.f64N/A

            \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
          2. *-lowering-*.f64N/A

            \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
          3. sin-lowering-sin.f64N/A

            \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
          4. cos-lowering-cos.f64N/A

            \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
          5. +-commutativeN/A

            \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
          6. +-lowering-+.f6460.8%

            \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
        3. Simplified60.8%

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

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

            \[\leadsto \frac{r}{\color{blue}{\frac{\cos \left(b + a\right)}{\sin b}}} \]
          3. *-lft-identityN/A

            \[\leadsto \frac{1 \cdot r}{\frac{\color{blue}{\cos \left(b + a\right)}}{\sin b}} \]
          4. div-invN/A

            \[\leadsto \frac{1 \cdot r}{\cos \left(b + a\right) \cdot \color{blue}{\frac{1}{\sin b}}} \]
          5. times-fracN/A

            \[\leadsto \frac{1}{\cos \left(b + a\right)} \cdot \color{blue}{\frac{r}{\frac{1}{\sin b}}} \]
          6. *-lowering-*.f64N/A

            \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{\cos \left(b + a\right)}\right), \color{blue}{\left(\frac{r}{\frac{1}{\sin b}}\right)}\right) \]
          7. /-lowering-/.f64N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \cos \left(b + a\right)\right), \left(\frac{\color{blue}{r}}{\frac{1}{\sin b}}\right)\right) \]
          8. cos-lowering-cos.f64N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
          9. +-lowering-+.f64N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
          10. /-lowering-/.f64N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \color{blue}{\left(\frac{1}{\sin b}\right)}\right)\right) \]
          11. /-lowering-/.f64N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \color{blue}{\sin b}\right)\right)\right) \]
          12. sin-lowering-sin.f6460.6%

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
        6. Applied egg-rr60.6%

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

          \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \color{blue}{\cos a}\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
        8. Step-by-step derivation
          1. cos-lowering-cos.f6410.0%

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(a\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
        9. Simplified10.0%

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

          \[\leadsto \color{blue}{r \cdot \sin b} \]
        11. Step-by-step derivation
          1. *-lowering-*.f64N/A

            \[\leadsto \mathsf{*.f64}\left(r, \color{blue}{\sin b}\right) \]
          2. sin-lowering-sin.f6410.4%

            \[\leadsto \mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right) \]
        12. Simplified10.4%

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

        if -8.5e16 < b < 11

        1. Initial program 98.4%

          \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
        2. Step-by-step derivation
          1. /-lowering-/.f64N/A

            \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
          2. *-lowering-*.f64N/A

            \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
          3. sin-lowering-sin.f64N/A

            \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
          4. cos-lowering-cos.f64N/A

            \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
          5. +-commutativeN/A

            \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
          6. +-lowering-+.f6498.4%

            \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
        3. Simplified98.4%

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

            \[\leadsto \frac{r}{\cos \left(b + a\right)} \cdot \color{blue}{\sin b} \]
          2. *-lowering-*.f64N/A

            \[\leadsto \mathsf{*.f64}\left(\left(\frac{r}{\cos \left(b + a\right)}\right), \color{blue}{\sin b}\right) \]
          3. /-lowering-/.f64N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \cos \left(b + a\right)\right), \sin \color{blue}{b}\right) \]
          4. cos-lowering-cos.f64N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \sin b\right) \]
          5. +-lowering-+.f64N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \sin b\right) \]
          6. sin-lowering-sin.f6498.3%

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{sin.f64}\left(b\right)\right) \]
        6. Applied egg-rr98.3%

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

          \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \color{blue}{\left(b \cdot \left(1 + {b}^{2} \cdot \left(\frac{1}{120} \cdot {b}^{2} - \frac{1}{6}\right)\right)\right)}\right) \]
        8. Step-by-step derivation
          1. *-lowering-*.f64N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{*.f64}\left(b, \color{blue}{\left(1 + {b}^{2} \cdot \left(\frac{1}{120} \cdot {b}^{2} - \frac{1}{6}\right)\right)}\right)\right) \]
          2. +-lowering-+.f64N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \color{blue}{\left({b}^{2} \cdot \left(\frac{1}{120} \cdot {b}^{2} - \frac{1}{6}\right)\right)}\right)\right)\right) \]
          3. unpow2N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \left(\left(b \cdot b\right) \cdot \left(\color{blue}{\frac{1}{120} \cdot {b}^{2}} - \frac{1}{6}\right)\right)\right)\right)\right) \]
          4. associate-*l*N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \left(b \cdot \color{blue}{\left(b \cdot \left(\frac{1}{120} \cdot {b}^{2} - \frac{1}{6}\right)\right)}\right)\right)\right)\right) \]
          5. *-lowering-*.f64N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(b, \color{blue}{\left(b \cdot \left(\frac{1}{120} \cdot {b}^{2} - \frac{1}{6}\right)\right)}\right)\right)\right)\right) \]
          6. *-lowering-*.f64N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(b, \mathsf{*.f64}\left(b, \color{blue}{\left(\frac{1}{120} \cdot {b}^{2} - \frac{1}{6}\right)}\right)\right)\right)\right)\right) \]
          7. sub-negN/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(b, \mathsf{*.f64}\left(b, \left(\frac{1}{120} \cdot {b}^{2} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{6}\right)\right)}\right)\right)\right)\right)\right)\right) \]
          8. metadata-evalN/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(b, \mathsf{*.f64}\left(b, \left(\frac{1}{120} \cdot {b}^{2} + \frac{-1}{6}\right)\right)\right)\right)\right)\right) \]
          9. +-commutativeN/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(b, \mathsf{*.f64}\left(b, \left(\frac{-1}{6} + \color{blue}{\frac{1}{120} \cdot {b}^{2}}\right)\right)\right)\right)\right)\right) \]
          10. +-lowering-+.f64N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(b, \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(\frac{-1}{6}, \color{blue}{\left(\frac{1}{120} \cdot {b}^{2}\right)}\right)\right)\right)\right)\right)\right) \]
          11. *-commutativeN/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(b, \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(\frac{-1}{6}, \left({b}^{2} \cdot \color{blue}{\frac{1}{120}}\right)\right)\right)\right)\right)\right)\right) \]
          12. unpow2N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(b, \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(\frac{-1}{6}, \left(\left(b \cdot b\right) \cdot \frac{1}{120}\right)\right)\right)\right)\right)\right)\right) \]
          13. associate-*l*N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(b, \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(\frac{-1}{6}, \left(b \cdot \color{blue}{\left(b \cdot \frac{1}{120}\right)}\right)\right)\right)\right)\right)\right)\right) \]
          14. *-commutativeN/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(b, \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(\frac{-1}{6}, \left(b \cdot \left(\frac{1}{120} \cdot \color{blue}{b}\right)\right)\right)\right)\right)\right)\right)\right) \]
          15. *-lowering-*.f64N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(b, \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(b, \color{blue}{\left(\frac{1}{120} \cdot b\right)}\right)\right)\right)\right)\right)\right)\right) \]
          16. *-commutativeN/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(b, \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(b, \left(b \cdot \color{blue}{\frac{1}{120}}\right)\right)\right)\right)\right)\right)\right)\right) \]
          17. *-lowering-*.f6495.6%

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(b, \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(b, \mathsf{*.f64}\left(b, \color{blue}{\frac{1}{120}}\right)\right)\right)\right)\right)\right)\right)\right) \]
        9. Simplified95.6%

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

        if 11 < b

        1. Initial program 54.2%

          \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
        2. Step-by-step derivation
          1. /-lowering-/.f64N/A

            \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
          2. *-lowering-*.f64N/A

            \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
          3. sin-lowering-sin.f64N/A

            \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
          4. cos-lowering-cos.f64N/A

            \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
          5. +-commutativeN/A

            \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
          6. +-lowering-+.f6454.2%

            \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
        3. Simplified54.2%

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

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

            \[\leadsto \frac{r}{\color{blue}{\frac{\cos \left(b + a\right)}{\sin b}}} \]
          3. *-lft-identityN/A

            \[\leadsto \frac{1 \cdot r}{\frac{\color{blue}{\cos \left(b + a\right)}}{\sin b}} \]
          4. div-invN/A

            \[\leadsto \frac{1 \cdot r}{\cos \left(b + a\right) \cdot \color{blue}{\frac{1}{\sin b}}} \]
          5. times-fracN/A

            \[\leadsto \frac{1}{\cos \left(b + a\right)} \cdot \color{blue}{\frac{r}{\frac{1}{\sin b}}} \]
          6. *-lowering-*.f64N/A

            \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{\cos \left(b + a\right)}\right), \color{blue}{\left(\frac{r}{\frac{1}{\sin b}}\right)}\right) \]
          7. /-lowering-/.f64N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \cos \left(b + a\right)\right), \left(\frac{\color{blue}{r}}{\frac{1}{\sin b}}\right)\right) \]
          8. cos-lowering-cos.f64N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
          9. +-lowering-+.f64N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
          10. /-lowering-/.f64N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \color{blue}{\left(\frac{1}{\sin b}\right)}\right)\right) \]
          11. /-lowering-/.f64N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \color{blue}{\sin b}\right)\right)\right) \]
          12. sin-lowering-sin.f6454.0%

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
        6. Applied egg-rr54.0%

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

          \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \color{blue}{\cos a}\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
        8. Step-by-step derivation
          1. cos-lowering-cos.f6411.5%

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(a\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
        9. Simplified11.5%

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

          \[\leadsto \mathsf{*.f64}\left(\color{blue}{1}, \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
        11. Step-by-step derivation
          1. Simplified10.6%

            \[\leadsto \color{blue}{1} \cdot \frac{r}{\frac{1}{\sin b}} \]
        12. Recombined 3 regimes into one program.
        13. Final simplification54.4%

          \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -8.5 \cdot 10^{+16}:\\ \;\;\;\;r \cdot \sin b\\ \mathbf{elif}\;b \leq 11:\\ \;\;\;\;\frac{r}{\cos \left(b + a\right)} \cdot \left(b \cdot \left(1 + b \cdot \left(b \cdot \left(-0.16666666666666666 + b \cdot \left(b \cdot 0.008333333333333333\right)\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{r}{\frac{1}{\sin b}}\\ \end{array} \]
        14. Add Preprocessing

        Alternative 16: 55.2% accurate, 1.7× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -9 \cdot 10^{+27}:\\ \;\;\;\;r \cdot \sin b\\ \mathbf{elif}\;b \leq 3.8 \cdot 10^{+25}:\\ \;\;\;\;\frac{\left(1 + b \cdot \left(b \cdot -0.16666666666666666\right)\right) \cdot \left(r \cdot b\right)}{\cos \left(b + a\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{r}{\frac{1}{\sin b}}\\ \end{array} \end{array} \]
        (FPCore (r a b)
         :precision binary64
         (if (<= b -9e+27)
           (* r (sin b))
           (if (<= b 3.8e+25)
             (/ (* (+ 1.0 (* b (* b -0.16666666666666666))) (* r b)) (cos (+ b a)))
             (/ r (/ 1.0 (sin b))))))
        double code(double r, double a, double b) {
        	double tmp;
        	if (b <= -9e+27) {
        		tmp = r * sin(b);
        	} else if (b <= 3.8e+25) {
        		tmp = ((1.0 + (b * (b * -0.16666666666666666))) * (r * b)) / cos((b + a));
        	} else {
        		tmp = r / (1.0 / 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 <= (-9d+27)) then
                tmp = r * sin(b)
            else if (b <= 3.8d+25) then
                tmp = ((1.0d0 + (b * (b * (-0.16666666666666666d0)))) * (r * b)) / cos((b + a))
            else
                tmp = r / (1.0d0 / sin(b))
            end if
            code = tmp
        end function
        
        public static double code(double r, double a, double b) {
        	double tmp;
        	if (b <= -9e+27) {
        		tmp = r * Math.sin(b);
        	} else if (b <= 3.8e+25) {
        		tmp = ((1.0 + (b * (b * -0.16666666666666666))) * (r * b)) / Math.cos((b + a));
        	} else {
        		tmp = r / (1.0 / Math.sin(b));
        	}
        	return tmp;
        }
        
        def code(r, a, b):
        	tmp = 0
        	if b <= -9e+27:
        		tmp = r * math.sin(b)
        	elif b <= 3.8e+25:
        		tmp = ((1.0 + (b * (b * -0.16666666666666666))) * (r * b)) / math.cos((b + a))
        	else:
        		tmp = r / (1.0 / math.sin(b))
        	return tmp
        
        function code(r, a, b)
        	tmp = 0.0
        	if (b <= -9e+27)
        		tmp = Float64(r * sin(b));
        	elseif (b <= 3.8e+25)
        		tmp = Float64(Float64(Float64(1.0 + Float64(b * Float64(b * -0.16666666666666666))) * Float64(r * b)) / cos(Float64(b + a)));
        	else
        		tmp = Float64(r / Float64(1.0 / sin(b)));
        	end
        	return tmp
        end
        
        function tmp_2 = code(r, a, b)
        	tmp = 0.0;
        	if (b <= -9e+27)
        		tmp = r * sin(b);
        	elseif (b <= 3.8e+25)
        		tmp = ((1.0 + (b * (b * -0.16666666666666666))) * (r * b)) / cos((b + a));
        	else
        		tmp = r / (1.0 / sin(b));
        	end
        	tmp_2 = tmp;
        end
        
        code[r_, a_, b_] := If[LessEqual[b, -9e+27], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.8e+25], N[(N[(N[(1.0 + N[(b * N[(b * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(r * b), $MachinePrecision]), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(r / N[(1.0 / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;b \leq -9 \cdot 10^{+27}:\\
        \;\;\;\;r \cdot \sin b\\
        
        \mathbf{elif}\;b \leq 3.8 \cdot 10^{+25}:\\
        \;\;\;\;\frac{\left(1 + b \cdot \left(b \cdot -0.16666666666666666\right)\right) \cdot \left(r \cdot b\right)}{\cos \left(b + a\right)}\\
        
        \mathbf{else}:\\
        \;\;\;\;\frac{r}{\frac{1}{\sin b}}\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if b < -8.9999999999999998e27

          1. Initial program 60.1%

            \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
          2. Step-by-step derivation
            1. /-lowering-/.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
            2. *-lowering-*.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
            3. sin-lowering-sin.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
            4. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
            5. +-commutativeN/A

              \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
            6. +-lowering-+.f6460.1%

              \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
          3. Simplified60.1%

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

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

              \[\leadsto \frac{r}{\color{blue}{\frac{\cos \left(b + a\right)}{\sin b}}} \]
            3. *-lft-identityN/A

              \[\leadsto \frac{1 \cdot r}{\frac{\color{blue}{\cos \left(b + a\right)}}{\sin b}} \]
            4. div-invN/A

              \[\leadsto \frac{1 \cdot r}{\cos \left(b + a\right) \cdot \color{blue}{\frac{1}{\sin b}}} \]
            5. times-fracN/A

              \[\leadsto \frac{1}{\cos \left(b + a\right)} \cdot \color{blue}{\frac{r}{\frac{1}{\sin b}}} \]
            6. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{\cos \left(b + a\right)}\right), \color{blue}{\left(\frac{r}{\frac{1}{\sin b}}\right)}\right) \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \cos \left(b + a\right)\right), \left(\frac{\color{blue}{r}}{\frac{1}{\sin b}}\right)\right) \]
            8. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
            9. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
            10. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \color{blue}{\left(\frac{1}{\sin b}\right)}\right)\right) \]
            11. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \color{blue}{\sin b}\right)\right)\right) \]
            12. sin-lowering-sin.f6460.0%

              \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
          6. Applied egg-rr60.0%

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

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \color{blue}{\cos a}\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
          8. Step-by-step derivation
            1. cos-lowering-cos.f6410.2%

              \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(a\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
          9. Simplified10.2%

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

            \[\leadsto \color{blue}{r \cdot \sin b} \]
          11. Step-by-step derivation
            1. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(r, \color{blue}{\sin b}\right) \]
            2. sin-lowering-sin.f6410.5%

              \[\leadsto \mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right) \]
          12. Simplified10.5%

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

          if -8.9999999999999998e27 < b < 3.8e25

          1. Initial program 97.9%

            \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
          2. Step-by-step derivation
            1. /-lowering-/.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
            2. *-lowering-*.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
            3. sin-lowering-sin.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
            4. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
            5. +-commutativeN/A

              \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
            6. +-lowering-+.f6497.9%

              \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
          3. Simplified97.9%

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

            \[\leadsto \mathsf{/.f64}\left(\color{blue}{\left(b \cdot \left(r + \frac{-1}{6} \cdot \left({b}^{2} \cdot r\right)\right)\right)}, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
          6. Step-by-step derivation
            1. +-commutativeN/A

              \[\leadsto \mathsf{/.f64}\left(\left(b \cdot \left(\frac{-1}{6} \cdot \left({b}^{2} \cdot r\right) + r\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, \color{blue}{a}\right)\right)\right) \]
            2. *-commutativeN/A

              \[\leadsto \mathsf{/.f64}\left(\left(b \cdot \left(\left({b}^{2} \cdot r\right) \cdot \frac{-1}{6} + r\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
            3. associate-*r*N/A

              \[\leadsto \mathsf{/.f64}\left(\left(b \cdot \left({b}^{2} \cdot \left(r \cdot \frac{-1}{6}\right) + r\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
            4. *-commutativeN/A

              \[\leadsto \mathsf{/.f64}\left(\left(b \cdot \left({b}^{2} \cdot \left(\frac{-1}{6} \cdot r\right) + r\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
            5. distribute-rgt-inN/A

              \[\leadsto \mathsf{/.f64}\left(\left(\left({b}^{2} \cdot \left(\frac{-1}{6} \cdot r\right)\right) \cdot b + r \cdot b\right), \mathsf{cos.f64}\left(\color{blue}{\mathsf{+.f64}\left(b, a\right)}\right)\right) \]
            6. *-commutativeN/A

              \[\leadsto \mathsf{/.f64}\left(\left(\left({b}^{2} \cdot \left(\frac{-1}{6} \cdot r\right)\right) \cdot b + b \cdot r\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, \color{blue}{a}\right)\right)\right) \]
            7. associate-*r*N/A

              \[\leadsto \mathsf{/.f64}\left(\left(\left(\left({b}^{2} \cdot \frac{-1}{6}\right) \cdot r\right) \cdot b + b \cdot r\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
            8. *-commutativeN/A

              \[\leadsto \mathsf{/.f64}\left(\left(\left(\left(\frac{-1}{6} \cdot {b}^{2}\right) \cdot r\right) \cdot b + b \cdot r\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
            9. associate-*l*N/A

              \[\leadsto \mathsf{/.f64}\left(\left(\left(\frac{-1}{6} \cdot {b}^{2}\right) \cdot \left(r \cdot b\right) + b \cdot r\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(\color{blue}{b}, a\right)\right)\right) \]
            10. *-commutativeN/A

              \[\leadsto \mathsf{/.f64}\left(\left(\left(\frac{-1}{6} \cdot {b}^{2}\right) \cdot \left(b \cdot r\right) + b \cdot r\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
            11. distribute-lft1-inN/A

              \[\leadsto \mathsf{/.f64}\left(\left(\left(\frac{-1}{6} \cdot {b}^{2} + 1\right) \cdot \left(b \cdot r\right)\right), \mathsf{cos.f64}\left(\color{blue}{\mathsf{+.f64}\left(b, a\right)}\right)\right) \]
            12. +-commutativeN/A

              \[\leadsto \mathsf{/.f64}\left(\left(\left(1 + \frac{-1}{6} \cdot {b}^{2}\right) \cdot \left(b \cdot r\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(\color{blue}{b}, a\right)\right)\right) \]
            13. *-lowering-*.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(1 + \frac{-1}{6} \cdot {b}^{2}\right), \left(b \cdot r\right)\right), \mathsf{cos.f64}\left(\color{blue}{\mathsf{+.f64}\left(b, a\right)}\right)\right) \]
            14. +-lowering-+.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(\frac{-1}{6} \cdot {b}^{2}\right)\right), \left(b \cdot r\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(\color{blue}{b}, a\right)\right)\right) \]
            15. unpow2N/A

              \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(\frac{-1}{6} \cdot \left(b \cdot b\right)\right)\right), \left(b \cdot r\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
            16. associate-*r*N/A

              \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(\left(\frac{-1}{6} \cdot b\right) \cdot b\right)\right), \left(b \cdot r\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
            17. *-commutativeN/A

              \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(b \cdot \left(\frac{-1}{6} \cdot b\right)\right)\right), \left(b \cdot r\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
            18. *-lowering-*.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(b, \left(\frac{-1}{6} \cdot b\right)\right)\right), \left(b \cdot r\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
            19. *-commutativeN/A

              \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(b, \left(b \cdot \frac{-1}{6}\right)\right)\right), \left(b \cdot r\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
            20. *-lowering-*.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(b, \mathsf{*.f64}\left(b, \frac{-1}{6}\right)\right)\right), \left(b \cdot r\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
            21. *-commutativeN/A

              \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(b, \mathsf{*.f64}\left(b, \frac{-1}{6}\right)\right)\right), \left(r \cdot b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, \color{blue}{a}\right)\right)\right) \]
            22. *-lowering-*.f6493.3%

              \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(b, \mathsf{*.f64}\left(b, \frac{-1}{6}\right)\right)\right), \mathsf{*.f64}\left(r, b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, \color{blue}{a}\right)\right)\right) \]
          7. Simplified93.3%

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

          if 3.8e25 < b

          1. Initial program 54.0%

            \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
          2. Step-by-step derivation
            1. /-lowering-/.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
            2. *-lowering-*.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
            3. sin-lowering-sin.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
            4. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
            5. +-commutativeN/A

              \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
            6. +-lowering-+.f6454.0%

              \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
          3. Simplified54.0%

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

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

              \[\leadsto \frac{r}{\color{blue}{\frac{\cos \left(b + a\right)}{\sin b}}} \]
            3. *-lft-identityN/A

              \[\leadsto \frac{1 \cdot r}{\frac{\color{blue}{\cos \left(b + a\right)}}{\sin b}} \]
            4. div-invN/A

              \[\leadsto \frac{1 \cdot r}{\cos \left(b + a\right) \cdot \color{blue}{\frac{1}{\sin b}}} \]
            5. times-fracN/A

              \[\leadsto \frac{1}{\cos \left(b + a\right)} \cdot \color{blue}{\frac{r}{\frac{1}{\sin b}}} \]
            6. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{\cos \left(b + a\right)}\right), \color{blue}{\left(\frac{r}{\frac{1}{\sin b}}\right)}\right) \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \cos \left(b + a\right)\right), \left(\frac{\color{blue}{r}}{\frac{1}{\sin b}}\right)\right) \]
            8. cos-lowering-cos.f64N/A

              \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
            9. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
            10. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \color{blue}{\left(\frac{1}{\sin b}\right)}\right)\right) \]
            11. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \color{blue}{\sin b}\right)\right)\right) \]
            12. sin-lowering-sin.f6453.8%

              \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
          6. Applied egg-rr53.8%

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

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \color{blue}{\cos a}\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
          8. Step-by-step derivation
            1. cos-lowering-cos.f6411.4%

              \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(a\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
          9. Simplified11.4%

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

            \[\leadsto \mathsf{*.f64}\left(\color{blue}{1}, \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
          11. Step-by-step derivation
            1. Simplified10.9%

              \[\leadsto \color{blue}{1} \cdot \frac{r}{\frac{1}{\sin b}} \]
          12. Recombined 3 regimes into one program.
          13. Final simplification54.3%

            \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -9 \cdot 10^{+27}:\\ \;\;\;\;r \cdot \sin b\\ \mathbf{elif}\;b \leq 3.8 \cdot 10^{+25}:\\ \;\;\;\;\frac{\left(1 + b \cdot \left(b \cdot -0.16666666666666666\right)\right) \cdot \left(r \cdot b\right)}{\cos \left(b + a\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{r}{\frac{1}{\sin b}}\\ \end{array} \]
          14. Add Preprocessing

          Alternative 17: 55.2% accurate, 1.7× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -9 \cdot 10^{+27}:\\ \;\;\;\;r \cdot \sin b\\ \mathbf{elif}\;b \leq 3.8 \cdot 10^{+25}:\\ \;\;\;\;\frac{r \cdot \left(b \cdot \left(1 + b \cdot \left(b \cdot -0.16666666666666666\right)\right)\right)}{\cos \left(b + a\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{r}{\frac{1}{\sin b}}\\ \end{array} \end{array} \]
          (FPCore (r a b)
           :precision binary64
           (if (<= b -9e+27)
             (* r (sin b))
             (if (<= b 3.8e+25)
               (/ (* r (* b (+ 1.0 (* b (* b -0.16666666666666666))))) (cos (+ b a)))
               (/ r (/ 1.0 (sin b))))))
          double code(double r, double a, double b) {
          	double tmp;
          	if (b <= -9e+27) {
          		tmp = r * sin(b);
          	} else if (b <= 3.8e+25) {
          		tmp = (r * (b * (1.0 + (b * (b * -0.16666666666666666))))) / cos((b + a));
          	} else {
          		tmp = r / (1.0 / 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 <= (-9d+27)) then
                  tmp = r * sin(b)
              else if (b <= 3.8d+25) then
                  tmp = (r * (b * (1.0d0 + (b * (b * (-0.16666666666666666d0)))))) / cos((b + a))
              else
                  tmp = r / (1.0d0 / sin(b))
              end if
              code = tmp
          end function
          
          public static double code(double r, double a, double b) {
          	double tmp;
          	if (b <= -9e+27) {
          		tmp = r * Math.sin(b);
          	} else if (b <= 3.8e+25) {
          		tmp = (r * (b * (1.0 + (b * (b * -0.16666666666666666))))) / Math.cos((b + a));
          	} else {
          		tmp = r / (1.0 / Math.sin(b));
          	}
          	return tmp;
          }
          
          def code(r, a, b):
          	tmp = 0
          	if b <= -9e+27:
          		tmp = r * math.sin(b)
          	elif b <= 3.8e+25:
          		tmp = (r * (b * (1.0 + (b * (b * -0.16666666666666666))))) / math.cos((b + a))
          	else:
          		tmp = r / (1.0 / math.sin(b))
          	return tmp
          
          function code(r, a, b)
          	tmp = 0.0
          	if (b <= -9e+27)
          		tmp = Float64(r * sin(b));
          	elseif (b <= 3.8e+25)
          		tmp = Float64(Float64(r * Float64(b * Float64(1.0 + Float64(b * Float64(b * -0.16666666666666666))))) / cos(Float64(b + a)));
          	else
          		tmp = Float64(r / Float64(1.0 / sin(b)));
          	end
          	return tmp
          end
          
          function tmp_2 = code(r, a, b)
          	tmp = 0.0;
          	if (b <= -9e+27)
          		tmp = r * sin(b);
          	elseif (b <= 3.8e+25)
          		tmp = (r * (b * (1.0 + (b * (b * -0.16666666666666666))))) / cos((b + a));
          	else
          		tmp = r / (1.0 / sin(b));
          	end
          	tmp_2 = tmp;
          end
          
          code[r_, a_, b_] := If[LessEqual[b, -9e+27], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.8e+25], N[(N[(r * N[(b * N[(1.0 + N[(b * N[(b * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(r / N[(1.0 / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;b \leq -9 \cdot 10^{+27}:\\
          \;\;\;\;r \cdot \sin b\\
          
          \mathbf{elif}\;b \leq 3.8 \cdot 10^{+25}:\\
          \;\;\;\;\frac{r \cdot \left(b \cdot \left(1 + b \cdot \left(b \cdot -0.16666666666666666\right)\right)\right)}{\cos \left(b + a\right)}\\
          
          \mathbf{else}:\\
          \;\;\;\;\frac{r}{\frac{1}{\sin b}}\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if b < -8.9999999999999998e27

            1. Initial program 60.1%

              \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
            2. Step-by-step derivation
              1. /-lowering-/.f64N/A

                \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
              2. *-lowering-*.f64N/A

                \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
              3. sin-lowering-sin.f64N/A

                \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
              4. cos-lowering-cos.f64N/A

                \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
              5. +-commutativeN/A

                \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
              6. +-lowering-+.f6460.1%

                \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
            3. Simplified60.1%

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

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

                \[\leadsto \frac{r}{\color{blue}{\frac{\cos \left(b + a\right)}{\sin b}}} \]
              3. *-lft-identityN/A

                \[\leadsto \frac{1 \cdot r}{\frac{\color{blue}{\cos \left(b + a\right)}}{\sin b}} \]
              4. div-invN/A

                \[\leadsto \frac{1 \cdot r}{\cos \left(b + a\right) \cdot \color{blue}{\frac{1}{\sin b}}} \]
              5. times-fracN/A

                \[\leadsto \frac{1}{\cos \left(b + a\right)} \cdot \color{blue}{\frac{r}{\frac{1}{\sin b}}} \]
              6. *-lowering-*.f64N/A

                \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{\cos \left(b + a\right)}\right), \color{blue}{\left(\frac{r}{\frac{1}{\sin b}}\right)}\right) \]
              7. /-lowering-/.f64N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \cos \left(b + a\right)\right), \left(\frac{\color{blue}{r}}{\frac{1}{\sin b}}\right)\right) \]
              8. cos-lowering-cos.f64N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
              9. +-lowering-+.f64N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
              10. /-lowering-/.f64N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \color{blue}{\left(\frac{1}{\sin b}\right)}\right)\right) \]
              11. /-lowering-/.f64N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \color{blue}{\sin b}\right)\right)\right) \]
              12. sin-lowering-sin.f6460.0%

                \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
            6. Applied egg-rr60.0%

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

              \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \color{blue}{\cos a}\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
            8. Step-by-step derivation
              1. cos-lowering-cos.f6410.2%

                \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(a\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
            9. Simplified10.2%

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

              \[\leadsto \color{blue}{r \cdot \sin b} \]
            11. Step-by-step derivation
              1. *-lowering-*.f64N/A

                \[\leadsto \mathsf{*.f64}\left(r, \color{blue}{\sin b}\right) \]
              2. sin-lowering-sin.f6410.5%

                \[\leadsto \mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right) \]
            12. Simplified10.5%

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

            if -8.9999999999999998e27 < b < 3.8e25

            1. Initial program 97.9%

              \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
            2. Step-by-step derivation
              1. /-lowering-/.f64N/A

                \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
              2. *-lowering-*.f64N/A

                \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
              3. sin-lowering-sin.f64N/A

                \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
              4. cos-lowering-cos.f64N/A

                \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
              5. +-commutativeN/A

                \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
              6. +-lowering-+.f6497.9%

                \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
            3. Simplified97.9%

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

              \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \color{blue}{\left(b \cdot \left(1 + \frac{-1}{6} \cdot {b}^{2}\right)\right)}\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
            6. Step-by-step derivation
              1. *-lowering-*.f64N/A

                \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{*.f64}\left(b, \left(1 + \frac{-1}{6} \cdot {b}^{2}\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, \color{blue}{a}\right)\right)\right) \]
              2. +-lowering-+.f64N/A

                \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \left(\frac{-1}{6} \cdot {b}^{2}\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
              3. unpow2N/A

                \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \left(\frac{-1}{6} \cdot \left(b \cdot b\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
              4. associate-*r*N/A

                \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \left(\left(\frac{-1}{6} \cdot b\right) \cdot b\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
              5. *-commutativeN/A

                \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \left(b \cdot \left(\frac{-1}{6} \cdot b\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
              6. *-lowering-*.f64N/A

                \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(b, \left(\frac{-1}{6} \cdot b\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
              7. *-commutativeN/A

                \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(b, \left(b \cdot \frac{-1}{6}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
              8. *-lowering-*.f6493.3%

                \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(b, \mathsf{*.f64}\left(b, \frac{-1}{6}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
            7. Simplified93.3%

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

            if 3.8e25 < b

            1. Initial program 54.0%

              \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
            2. Step-by-step derivation
              1. /-lowering-/.f64N/A

                \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
              2. *-lowering-*.f64N/A

                \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
              3. sin-lowering-sin.f64N/A

                \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
              4. cos-lowering-cos.f64N/A

                \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
              5. +-commutativeN/A

                \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
              6. +-lowering-+.f6454.0%

                \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
            3. Simplified54.0%

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

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

                \[\leadsto \frac{r}{\color{blue}{\frac{\cos \left(b + a\right)}{\sin b}}} \]
              3. *-lft-identityN/A

                \[\leadsto \frac{1 \cdot r}{\frac{\color{blue}{\cos \left(b + a\right)}}{\sin b}} \]
              4. div-invN/A

                \[\leadsto \frac{1 \cdot r}{\cos \left(b + a\right) \cdot \color{blue}{\frac{1}{\sin b}}} \]
              5. times-fracN/A

                \[\leadsto \frac{1}{\cos \left(b + a\right)} \cdot \color{blue}{\frac{r}{\frac{1}{\sin b}}} \]
              6. *-lowering-*.f64N/A

                \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{\cos \left(b + a\right)}\right), \color{blue}{\left(\frac{r}{\frac{1}{\sin b}}\right)}\right) \]
              7. /-lowering-/.f64N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \cos \left(b + a\right)\right), \left(\frac{\color{blue}{r}}{\frac{1}{\sin b}}\right)\right) \]
              8. cos-lowering-cos.f64N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
              9. +-lowering-+.f64N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
              10. /-lowering-/.f64N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \color{blue}{\left(\frac{1}{\sin b}\right)}\right)\right) \]
              11. /-lowering-/.f64N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \color{blue}{\sin b}\right)\right)\right) \]
              12. sin-lowering-sin.f6453.8%

                \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
            6. Applied egg-rr53.8%

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

              \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \color{blue}{\cos a}\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
            8. Step-by-step derivation
              1. cos-lowering-cos.f6411.4%

                \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(a\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
            9. Simplified11.4%

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

              \[\leadsto \mathsf{*.f64}\left(\color{blue}{1}, \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
            11. Step-by-step derivation
              1. Simplified10.9%

                \[\leadsto \color{blue}{1} \cdot \frac{r}{\frac{1}{\sin b}} \]
            12. Recombined 3 regimes into one program.
            13. Final simplification54.3%

              \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -9 \cdot 10^{+27}:\\ \;\;\;\;r \cdot \sin b\\ \mathbf{elif}\;b \leq 3.8 \cdot 10^{+25}:\\ \;\;\;\;\frac{r \cdot \left(b \cdot \left(1 + b \cdot \left(b \cdot -0.16666666666666666\right)\right)\right)}{\cos \left(b + a\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{r}{\frac{1}{\sin b}}\\ \end{array} \]
            14. Add Preprocessing

            Alternative 18: 55.2% accurate, 1.7× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -1 \cdot 10^{+28}:\\ \;\;\;\;r \cdot \sin b\\ \mathbf{elif}\;b \leq 4 \cdot 10^{+25}:\\ \;\;\;\;\frac{r}{\cos \left(b + a\right)} \cdot \left(b \cdot \left(1 + b \cdot \left(b \cdot -0.16666666666666666\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{r}{\frac{1}{\sin b}}\\ \end{array} \end{array} \]
            (FPCore (r a b)
             :precision binary64
             (if (<= b -1e+28)
               (* r (sin b))
               (if (<= b 4e+25)
                 (* (/ r (cos (+ b a))) (* b (+ 1.0 (* b (* b -0.16666666666666666)))))
                 (/ r (/ 1.0 (sin b))))))
            double code(double r, double a, double b) {
            	double tmp;
            	if (b <= -1e+28) {
            		tmp = r * sin(b);
            	} else if (b <= 4e+25) {
            		tmp = (r / cos((b + a))) * (b * (1.0 + (b * (b * -0.16666666666666666))));
            	} else {
            		tmp = r / (1.0 / 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 <= (-1d+28)) then
                    tmp = r * sin(b)
                else if (b <= 4d+25) then
                    tmp = (r / cos((b + a))) * (b * (1.0d0 + (b * (b * (-0.16666666666666666d0)))))
                else
                    tmp = r / (1.0d0 / sin(b))
                end if
                code = tmp
            end function
            
            public static double code(double r, double a, double b) {
            	double tmp;
            	if (b <= -1e+28) {
            		tmp = r * Math.sin(b);
            	} else if (b <= 4e+25) {
            		tmp = (r / Math.cos((b + a))) * (b * (1.0 + (b * (b * -0.16666666666666666))));
            	} else {
            		tmp = r / (1.0 / Math.sin(b));
            	}
            	return tmp;
            }
            
            def code(r, a, b):
            	tmp = 0
            	if b <= -1e+28:
            		tmp = r * math.sin(b)
            	elif b <= 4e+25:
            		tmp = (r / math.cos((b + a))) * (b * (1.0 + (b * (b * -0.16666666666666666))))
            	else:
            		tmp = r / (1.0 / math.sin(b))
            	return tmp
            
            function code(r, a, b)
            	tmp = 0.0
            	if (b <= -1e+28)
            		tmp = Float64(r * sin(b));
            	elseif (b <= 4e+25)
            		tmp = Float64(Float64(r / cos(Float64(b + a))) * Float64(b * Float64(1.0 + Float64(b * Float64(b * -0.16666666666666666)))));
            	else
            		tmp = Float64(r / Float64(1.0 / sin(b)));
            	end
            	return tmp
            end
            
            function tmp_2 = code(r, a, b)
            	tmp = 0.0;
            	if (b <= -1e+28)
            		tmp = r * sin(b);
            	elseif (b <= 4e+25)
            		tmp = (r / cos((b + a))) * (b * (1.0 + (b * (b * -0.16666666666666666))));
            	else
            		tmp = r / (1.0 / sin(b));
            	end
            	tmp_2 = tmp;
            end
            
            code[r_, a_, b_] := If[LessEqual[b, -1e+28], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4e+25], N[(N[(r / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(b * N[(1.0 + N[(b * N[(b * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r / N[(1.0 / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;b \leq -1 \cdot 10^{+28}:\\
            \;\;\;\;r \cdot \sin b\\
            
            \mathbf{elif}\;b \leq 4 \cdot 10^{+25}:\\
            \;\;\;\;\frac{r}{\cos \left(b + a\right)} \cdot \left(b \cdot \left(1 + b \cdot \left(b \cdot -0.16666666666666666\right)\right)\right)\\
            
            \mathbf{else}:\\
            \;\;\;\;\frac{r}{\frac{1}{\sin b}}\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 3 regimes
            2. if b < -9.99999999999999958e27

              1. Initial program 60.1%

                \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
              2. Step-by-step derivation
                1. /-lowering-/.f64N/A

                  \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
                2. *-lowering-*.f64N/A

                  \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
                3. sin-lowering-sin.f64N/A

                  \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
                4. cos-lowering-cos.f64N/A

                  \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
                5. +-commutativeN/A

                  \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
                6. +-lowering-+.f6460.1%

                  \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
              3. Simplified60.1%

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

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

                  \[\leadsto \frac{r}{\color{blue}{\frac{\cos \left(b + a\right)}{\sin b}}} \]
                3. *-lft-identityN/A

                  \[\leadsto \frac{1 \cdot r}{\frac{\color{blue}{\cos \left(b + a\right)}}{\sin b}} \]
                4. div-invN/A

                  \[\leadsto \frac{1 \cdot r}{\cos \left(b + a\right) \cdot \color{blue}{\frac{1}{\sin b}}} \]
                5. times-fracN/A

                  \[\leadsto \frac{1}{\cos \left(b + a\right)} \cdot \color{blue}{\frac{r}{\frac{1}{\sin b}}} \]
                6. *-lowering-*.f64N/A

                  \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{\cos \left(b + a\right)}\right), \color{blue}{\left(\frac{r}{\frac{1}{\sin b}}\right)}\right) \]
                7. /-lowering-/.f64N/A

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \cos \left(b + a\right)\right), \left(\frac{\color{blue}{r}}{\frac{1}{\sin b}}\right)\right) \]
                8. cos-lowering-cos.f64N/A

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
                9. +-lowering-+.f64N/A

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
                10. /-lowering-/.f64N/A

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \color{blue}{\left(\frac{1}{\sin b}\right)}\right)\right) \]
                11. /-lowering-/.f64N/A

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \color{blue}{\sin b}\right)\right)\right) \]
                12. sin-lowering-sin.f6460.0%

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
              6. Applied egg-rr60.0%

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

                \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \color{blue}{\cos a}\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
              8. Step-by-step derivation
                1. cos-lowering-cos.f6410.2%

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(a\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
              9. Simplified10.2%

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

                \[\leadsto \color{blue}{r \cdot \sin b} \]
              11. Step-by-step derivation
                1. *-lowering-*.f64N/A

                  \[\leadsto \mathsf{*.f64}\left(r, \color{blue}{\sin b}\right) \]
                2. sin-lowering-sin.f6410.5%

                  \[\leadsto \mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right) \]
              12. Simplified10.5%

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

              if -9.99999999999999958e27 < b < 4.00000000000000036e25

              1. Initial program 97.9%

                \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
              2. Step-by-step derivation
                1. /-lowering-/.f64N/A

                  \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
                2. *-lowering-*.f64N/A

                  \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
                3. sin-lowering-sin.f64N/A

                  \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
                4. cos-lowering-cos.f64N/A

                  \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
                5. +-commutativeN/A

                  \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
                6. +-lowering-+.f6497.9%

                  \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
              3. Simplified97.9%

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

                  \[\leadsto \frac{r}{\cos \left(b + a\right)} \cdot \color{blue}{\sin b} \]
                2. *-lowering-*.f64N/A

                  \[\leadsto \mathsf{*.f64}\left(\left(\frac{r}{\cos \left(b + a\right)}\right), \color{blue}{\sin b}\right) \]
                3. /-lowering-/.f64N/A

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \cos \left(b + a\right)\right), \sin \color{blue}{b}\right) \]
                4. cos-lowering-cos.f64N/A

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \sin b\right) \]
                5. +-lowering-+.f64N/A

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \sin b\right) \]
                6. sin-lowering-sin.f6497.8%

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{sin.f64}\left(b\right)\right) \]
              6. Applied egg-rr97.8%

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

                \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \color{blue}{\left(b \cdot \left(1 + \frac{-1}{6} \cdot {b}^{2}\right)\right)}\right) \]
              8. Step-by-step derivation
                1. *-lowering-*.f64N/A

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{*.f64}\left(b, \color{blue}{\left(1 + \frac{-1}{6} \cdot {b}^{2}\right)}\right)\right) \]
                2. +-lowering-+.f64N/A

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{6} \cdot {b}^{2}\right)}\right)\right)\right) \]
                3. *-commutativeN/A

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \left({b}^{2} \cdot \color{blue}{\frac{-1}{6}}\right)\right)\right)\right) \]
                4. unpow2N/A

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \left(\left(b \cdot b\right) \cdot \frac{-1}{6}\right)\right)\right)\right) \]
                5. associate-*l*N/A

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \left(b \cdot \color{blue}{\left(b \cdot \frac{-1}{6}\right)}\right)\right)\right)\right) \]
                6. *-commutativeN/A

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \left(b \cdot \left(\frac{-1}{6} \cdot \color{blue}{b}\right)\right)\right)\right)\right) \]
                7. *-lowering-*.f64N/A

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(b, \color{blue}{\left(\frac{-1}{6} \cdot b\right)}\right)\right)\right)\right) \]
                8. *-commutativeN/A

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(b, \left(b \cdot \color{blue}{\frac{-1}{6}}\right)\right)\right)\right)\right) \]
                9. *-lowering-*.f6493.2%

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{*.f64}\left(b, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(b, \mathsf{*.f64}\left(b, \color{blue}{\frac{-1}{6}}\right)\right)\right)\right)\right) \]
              9. Simplified93.2%

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

              if 4.00000000000000036e25 < b

              1. Initial program 54.0%

                \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
              2. Step-by-step derivation
                1. /-lowering-/.f64N/A

                  \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
                2. *-lowering-*.f64N/A

                  \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
                3. sin-lowering-sin.f64N/A

                  \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
                4. cos-lowering-cos.f64N/A

                  \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
                5. +-commutativeN/A

                  \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
                6. +-lowering-+.f6454.0%

                  \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
              3. Simplified54.0%

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

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

                  \[\leadsto \frac{r}{\color{blue}{\frac{\cos \left(b + a\right)}{\sin b}}} \]
                3. *-lft-identityN/A

                  \[\leadsto \frac{1 \cdot r}{\frac{\color{blue}{\cos \left(b + a\right)}}{\sin b}} \]
                4. div-invN/A

                  \[\leadsto \frac{1 \cdot r}{\cos \left(b + a\right) \cdot \color{blue}{\frac{1}{\sin b}}} \]
                5. times-fracN/A

                  \[\leadsto \frac{1}{\cos \left(b + a\right)} \cdot \color{blue}{\frac{r}{\frac{1}{\sin b}}} \]
                6. *-lowering-*.f64N/A

                  \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{\cos \left(b + a\right)}\right), \color{blue}{\left(\frac{r}{\frac{1}{\sin b}}\right)}\right) \]
                7. /-lowering-/.f64N/A

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \cos \left(b + a\right)\right), \left(\frac{\color{blue}{r}}{\frac{1}{\sin b}}\right)\right) \]
                8. cos-lowering-cos.f64N/A

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
                9. +-lowering-+.f64N/A

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
                10. /-lowering-/.f64N/A

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \color{blue}{\left(\frac{1}{\sin b}\right)}\right)\right) \]
                11. /-lowering-/.f64N/A

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \color{blue}{\sin b}\right)\right)\right) \]
                12. sin-lowering-sin.f6453.8%

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
              6. Applied egg-rr53.8%

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

                \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \color{blue}{\cos a}\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
              8. Step-by-step derivation
                1. cos-lowering-cos.f6411.4%

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(a\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
              9. Simplified11.4%

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

                \[\leadsto \mathsf{*.f64}\left(\color{blue}{1}, \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
              11. Step-by-step derivation
                1. Simplified10.9%

                  \[\leadsto \color{blue}{1} \cdot \frac{r}{\frac{1}{\sin b}} \]
              12. Recombined 3 regimes into one program.
              13. Final simplification54.2%

                \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -1 \cdot 10^{+28}:\\ \;\;\;\;r \cdot \sin b\\ \mathbf{elif}\;b \leq 4 \cdot 10^{+25}:\\ \;\;\;\;\frac{r}{\cos \left(b + a\right)} \cdot \left(b \cdot \left(1 + b \cdot \left(b \cdot -0.16666666666666666\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{r}{\frac{1}{\sin b}}\\ \end{array} \]
              14. Add Preprocessing

              Alternative 19: 55.0% accurate, 1.8× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -9 \cdot 10^{+27}:\\ \;\;\;\;r \cdot \sin b\\ \mathbf{elif}\;b \leq 4 \cdot 10^{+25}:\\ \;\;\;\;\frac{r \cdot b}{\cos a}\\ \mathbf{else}:\\ \;\;\;\;\frac{r}{\frac{1}{\sin b}}\\ \end{array} \end{array} \]
              (FPCore (r a b)
               :precision binary64
               (if (<= b -9e+27)
                 (* r (sin b))
                 (if (<= b 4e+25) (/ (* r b) (cos a)) (/ r (/ 1.0 (sin b))))))
              double code(double r, double a, double b) {
              	double tmp;
              	if (b <= -9e+27) {
              		tmp = r * sin(b);
              	} else if (b <= 4e+25) {
              		tmp = (r * b) / cos(a);
              	} else {
              		tmp = r / (1.0 / 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 <= (-9d+27)) then
                      tmp = r * sin(b)
                  else if (b <= 4d+25) then
                      tmp = (r * b) / cos(a)
                  else
                      tmp = r / (1.0d0 / sin(b))
                  end if
                  code = tmp
              end function
              
              public static double code(double r, double a, double b) {
              	double tmp;
              	if (b <= -9e+27) {
              		tmp = r * Math.sin(b);
              	} else if (b <= 4e+25) {
              		tmp = (r * b) / Math.cos(a);
              	} else {
              		tmp = r / (1.0 / Math.sin(b));
              	}
              	return tmp;
              }
              
              def code(r, a, b):
              	tmp = 0
              	if b <= -9e+27:
              		tmp = r * math.sin(b)
              	elif b <= 4e+25:
              		tmp = (r * b) / math.cos(a)
              	else:
              		tmp = r / (1.0 / math.sin(b))
              	return tmp
              
              function code(r, a, b)
              	tmp = 0.0
              	if (b <= -9e+27)
              		tmp = Float64(r * sin(b));
              	elseif (b <= 4e+25)
              		tmp = Float64(Float64(r * b) / cos(a));
              	else
              		tmp = Float64(r / Float64(1.0 / sin(b)));
              	end
              	return tmp
              end
              
              function tmp_2 = code(r, a, b)
              	tmp = 0.0;
              	if (b <= -9e+27)
              		tmp = r * sin(b);
              	elseif (b <= 4e+25)
              		tmp = (r * b) / cos(a);
              	else
              		tmp = r / (1.0 / sin(b));
              	end
              	tmp_2 = tmp;
              end
              
              code[r_, a_, b_] := If[LessEqual[b, -9e+27], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4e+25], N[(N[(r * b), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], N[(r / N[(1.0 / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              \mathbf{if}\;b \leq -9 \cdot 10^{+27}:\\
              \;\;\;\;r \cdot \sin b\\
              
              \mathbf{elif}\;b \leq 4 \cdot 10^{+25}:\\
              \;\;\;\;\frac{r \cdot b}{\cos a}\\
              
              \mathbf{else}:\\
              \;\;\;\;\frac{r}{\frac{1}{\sin b}}\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 3 regimes
              2. if b < -8.9999999999999998e27

                1. Initial program 60.1%

                  \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
                2. Step-by-step derivation
                  1. /-lowering-/.f64N/A

                    \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
                  2. *-lowering-*.f64N/A

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
                  3. sin-lowering-sin.f64N/A

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
                  4. cos-lowering-cos.f64N/A

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
                  5. +-commutativeN/A

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
                  6. +-lowering-+.f6460.1%

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
                3. Simplified60.1%

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

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

                    \[\leadsto \frac{r}{\color{blue}{\frac{\cos \left(b + a\right)}{\sin b}}} \]
                  3. *-lft-identityN/A

                    \[\leadsto \frac{1 \cdot r}{\frac{\color{blue}{\cos \left(b + a\right)}}{\sin b}} \]
                  4. div-invN/A

                    \[\leadsto \frac{1 \cdot r}{\cos \left(b + a\right) \cdot \color{blue}{\frac{1}{\sin b}}} \]
                  5. times-fracN/A

                    \[\leadsto \frac{1}{\cos \left(b + a\right)} \cdot \color{blue}{\frac{r}{\frac{1}{\sin b}}} \]
                  6. *-lowering-*.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{\cos \left(b + a\right)}\right), \color{blue}{\left(\frac{r}{\frac{1}{\sin b}}\right)}\right) \]
                  7. /-lowering-/.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \cos \left(b + a\right)\right), \left(\frac{\color{blue}{r}}{\frac{1}{\sin b}}\right)\right) \]
                  8. cos-lowering-cos.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
                  9. +-lowering-+.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
                  10. /-lowering-/.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \color{blue}{\left(\frac{1}{\sin b}\right)}\right)\right) \]
                  11. /-lowering-/.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \color{blue}{\sin b}\right)\right)\right) \]
                  12. sin-lowering-sin.f6460.0%

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
                6. Applied egg-rr60.0%

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

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \color{blue}{\cos a}\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
                8. Step-by-step derivation
                  1. cos-lowering-cos.f6410.2%

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(a\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
                9. Simplified10.2%

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

                  \[\leadsto \color{blue}{r \cdot \sin b} \]
                11. Step-by-step derivation
                  1. *-lowering-*.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(r, \color{blue}{\sin b}\right) \]
                  2. sin-lowering-sin.f6410.5%

                    \[\leadsto \mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right) \]
                12. Simplified10.5%

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

                if -8.9999999999999998e27 < b < 4.00000000000000036e25

                1. Initial program 97.9%

                  \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
                2. Step-by-step derivation
                  1. /-lowering-/.f64N/A

                    \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
                  2. *-lowering-*.f64N/A

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
                  3. sin-lowering-sin.f64N/A

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
                  4. cos-lowering-cos.f64N/A

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
                  5. +-commutativeN/A

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
                  6. +-lowering-+.f6497.9%

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
                3. Simplified97.9%

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

                  \[\leadsto \color{blue}{\frac{b \cdot r}{\cos a}} \]
                6. Step-by-step derivation
                  1. /-lowering-/.f64N/A

                    \[\leadsto \mathsf{/.f64}\left(\left(b \cdot r\right), \color{blue}{\cos a}\right) \]
                  2. *-commutativeN/A

                    \[\leadsto \mathsf{/.f64}\left(\left(r \cdot b\right), \cos \color{blue}{a}\right) \]
                  3. *-lowering-*.f64N/A

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, b\right), \cos \color{blue}{a}\right) \]
                  4. cos-lowering-cos.f6492.9%

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, b\right), \mathsf{cos.f64}\left(a\right)\right) \]
                7. Simplified92.9%

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

                if 4.00000000000000036e25 < b

                1. Initial program 54.0%

                  \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
                2. Step-by-step derivation
                  1. /-lowering-/.f64N/A

                    \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
                  2. *-lowering-*.f64N/A

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
                  3. sin-lowering-sin.f64N/A

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
                  4. cos-lowering-cos.f64N/A

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
                  5. +-commutativeN/A

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
                  6. +-lowering-+.f6454.0%

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
                3. Simplified54.0%

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

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

                    \[\leadsto \frac{r}{\color{blue}{\frac{\cos \left(b + a\right)}{\sin b}}} \]
                  3. *-lft-identityN/A

                    \[\leadsto \frac{1 \cdot r}{\frac{\color{blue}{\cos \left(b + a\right)}}{\sin b}} \]
                  4. div-invN/A

                    \[\leadsto \frac{1 \cdot r}{\cos \left(b + a\right) \cdot \color{blue}{\frac{1}{\sin b}}} \]
                  5. times-fracN/A

                    \[\leadsto \frac{1}{\cos \left(b + a\right)} \cdot \color{blue}{\frac{r}{\frac{1}{\sin b}}} \]
                  6. *-lowering-*.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{\cos \left(b + a\right)}\right), \color{blue}{\left(\frac{r}{\frac{1}{\sin b}}\right)}\right) \]
                  7. /-lowering-/.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \cos \left(b + a\right)\right), \left(\frac{\color{blue}{r}}{\frac{1}{\sin b}}\right)\right) \]
                  8. cos-lowering-cos.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
                  9. +-lowering-+.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
                  10. /-lowering-/.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \color{blue}{\left(\frac{1}{\sin b}\right)}\right)\right) \]
                  11. /-lowering-/.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \color{blue}{\sin b}\right)\right)\right) \]
                  12. sin-lowering-sin.f6453.8%

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
                6. Applied egg-rr53.8%

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

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \color{blue}{\cos a}\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
                8. Step-by-step derivation
                  1. cos-lowering-cos.f6411.4%

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(a\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
                9. Simplified11.4%

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

                  \[\leadsto \mathsf{*.f64}\left(\color{blue}{1}, \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
                11. Step-by-step derivation
                  1. Simplified10.9%

                    \[\leadsto \color{blue}{1} \cdot \frac{r}{\frac{1}{\sin b}} \]
                12. Recombined 3 regimes into one program.
                13. Final simplification54.0%

                  \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -9 \cdot 10^{+27}:\\ \;\;\;\;r \cdot \sin b\\ \mathbf{elif}\;b \leq 4 \cdot 10^{+25}:\\ \;\;\;\;\frac{r \cdot b}{\cos a}\\ \mathbf{else}:\\ \;\;\;\;\frac{r}{\frac{1}{\sin b}}\\ \end{array} \]
                14. Add Preprocessing

                Alternative 20: 55.0% accurate, 1.8× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} t_0 := r \cdot \sin b\\ \mathbf{if}\;b \leq -4 \cdot 10^{+28}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;b \leq 4 \cdot 10^{+25}:\\ \;\;\;\;\frac{r \cdot b}{\cos a}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                (FPCore (r a b)
                 :precision binary64
                 (let* ((t_0 (* r (sin b))))
                   (if (<= b -4e+28) t_0 (if (<= b 4e+25) (/ (* r b) (cos a)) t_0))))
                double code(double r, double a, double b) {
                	double t_0 = r * sin(b);
                	double tmp;
                	if (b <= -4e+28) {
                		tmp = t_0;
                	} else if (b <= 4e+25) {
                		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 = r * sin(b)
                    if (b <= (-4d+28)) then
                        tmp = t_0
                    else if (b <= 4d+25) 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 = r * Math.sin(b);
                	double tmp;
                	if (b <= -4e+28) {
                		tmp = t_0;
                	} else if (b <= 4e+25) {
                		tmp = (r * b) / Math.cos(a);
                	} else {
                		tmp = t_0;
                	}
                	return tmp;
                }
                
                def code(r, a, b):
                	t_0 = r * math.sin(b)
                	tmp = 0
                	if b <= -4e+28:
                		tmp = t_0
                	elif b <= 4e+25:
                		tmp = (r * b) / math.cos(a)
                	else:
                		tmp = t_0
                	return tmp
                
                function code(r, a, b)
                	t_0 = Float64(r * sin(b))
                	tmp = 0.0
                	if (b <= -4e+28)
                		tmp = t_0;
                	elseif (b <= 4e+25)
                		tmp = Float64(Float64(r * b) / cos(a));
                	else
                		tmp = t_0;
                	end
                	return tmp
                end
                
                function tmp_2 = code(r, a, b)
                	t_0 = r * sin(b);
                	tmp = 0.0;
                	if (b <= -4e+28)
                		tmp = t_0;
                	elseif (b <= 4e+25)
                		tmp = (r * b) / cos(a);
                	else
                		tmp = t_0;
                	end
                	tmp_2 = tmp;
                end
                
                code[r_, a_, b_] := Block[{t$95$0 = N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -4e+28], t$95$0, If[LessEqual[b, 4e+25], N[(N[(r * b), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], t$95$0]]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                t_0 := r \cdot \sin b\\
                \mathbf{if}\;b \leq -4 \cdot 10^{+28}:\\
                \;\;\;\;t\_0\\
                
                \mathbf{elif}\;b \leq 4 \cdot 10^{+25}:\\
                \;\;\;\;\frac{r \cdot b}{\cos a}\\
                
                \mathbf{else}:\\
                \;\;\;\;t\_0\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if b < -3.99999999999999983e28 or 4.00000000000000036e25 < b

                  1. Initial program 57.0%

                    \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
                  2. Step-by-step derivation
                    1. /-lowering-/.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
                    2. *-lowering-*.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
                    3. sin-lowering-sin.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
                    4. cos-lowering-cos.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
                    5. +-commutativeN/A

                      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
                    6. +-lowering-+.f6457.0%

                      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
                  3. Simplified57.0%

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

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

                      \[\leadsto \frac{r}{\color{blue}{\frac{\cos \left(b + a\right)}{\sin b}}} \]
                    3. *-lft-identityN/A

                      \[\leadsto \frac{1 \cdot r}{\frac{\color{blue}{\cos \left(b + a\right)}}{\sin b}} \]
                    4. div-invN/A

                      \[\leadsto \frac{1 \cdot r}{\cos \left(b + a\right) \cdot \color{blue}{\frac{1}{\sin b}}} \]
                    5. times-fracN/A

                      \[\leadsto \frac{1}{\cos \left(b + a\right)} \cdot \color{blue}{\frac{r}{\frac{1}{\sin b}}} \]
                    6. *-lowering-*.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{\cos \left(b + a\right)}\right), \color{blue}{\left(\frac{r}{\frac{1}{\sin b}}\right)}\right) \]
                    7. /-lowering-/.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \cos \left(b + a\right)\right), \left(\frac{\color{blue}{r}}{\frac{1}{\sin b}}\right)\right) \]
                    8. cos-lowering-cos.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
                    9. +-lowering-+.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
                    10. /-lowering-/.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \color{blue}{\left(\frac{1}{\sin b}\right)}\right)\right) \]
                    11. /-lowering-/.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \color{blue}{\sin b}\right)\right)\right) \]
                    12. sin-lowering-sin.f6456.8%

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
                  6. Applied egg-rr56.8%

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

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \color{blue}{\cos a}\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
                  8. Step-by-step derivation
                    1. cos-lowering-cos.f6410.8%

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(a\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
                  9. Simplified10.8%

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

                    \[\leadsto \color{blue}{r \cdot \sin b} \]
                  11. Step-by-step derivation
                    1. *-lowering-*.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(r, \color{blue}{\sin b}\right) \]
                    2. sin-lowering-sin.f6410.7%

                      \[\leadsto \mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right) \]
                  12. Simplified10.7%

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

                  if -3.99999999999999983e28 < b < 4.00000000000000036e25

                  1. Initial program 97.9%

                    \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
                  2. Step-by-step derivation
                    1. /-lowering-/.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
                    2. *-lowering-*.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
                    3. sin-lowering-sin.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
                    4. cos-lowering-cos.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
                    5. +-commutativeN/A

                      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
                    6. +-lowering-+.f6497.9%

                      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
                  3. Simplified97.9%

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

                    \[\leadsto \color{blue}{\frac{b \cdot r}{\cos a}} \]
                  6. Step-by-step derivation
                    1. /-lowering-/.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(\left(b \cdot r\right), \color{blue}{\cos a}\right) \]
                    2. *-commutativeN/A

                      \[\leadsto \mathsf{/.f64}\left(\left(r \cdot b\right), \cos \color{blue}{a}\right) \]
                    3. *-lowering-*.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, b\right), \cos \color{blue}{a}\right) \]
                    4. cos-lowering-cos.f6492.9%

                      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, b\right), \mathsf{cos.f64}\left(a\right)\right) \]
                  7. Simplified92.9%

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

                Alternative 21: 55.0% accurate, 1.8× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} t_0 := r \cdot \sin b\\ \mathbf{if}\;b \leq -4 \cdot 10^{+28}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;b \leq 4 \cdot 10^{+25}:\\ \;\;\;\;b \cdot \frac{r}{\cos a}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                (FPCore (r a b)
                 :precision binary64
                 (let* ((t_0 (* r (sin b))))
                   (if (<= b -4e+28) t_0 (if (<= b 4e+25) (* b (/ r (cos a))) t_0))))
                double code(double r, double a, double b) {
                	double t_0 = r * sin(b);
                	double tmp;
                	if (b <= -4e+28) {
                		tmp = t_0;
                	} else if (b <= 4e+25) {
                		tmp = b * (r / 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 = r * sin(b)
                    if (b <= (-4d+28)) then
                        tmp = t_0
                    else if (b <= 4d+25) then
                        tmp = b * (r / 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 = r * Math.sin(b);
                	double tmp;
                	if (b <= -4e+28) {
                		tmp = t_0;
                	} else if (b <= 4e+25) {
                		tmp = b * (r / Math.cos(a));
                	} else {
                		tmp = t_0;
                	}
                	return tmp;
                }
                
                def code(r, a, b):
                	t_0 = r * math.sin(b)
                	tmp = 0
                	if b <= -4e+28:
                		tmp = t_0
                	elif b <= 4e+25:
                		tmp = b * (r / math.cos(a))
                	else:
                		tmp = t_0
                	return tmp
                
                function code(r, a, b)
                	t_0 = Float64(r * sin(b))
                	tmp = 0.0
                	if (b <= -4e+28)
                		tmp = t_0;
                	elseif (b <= 4e+25)
                		tmp = Float64(b * Float64(r / cos(a)));
                	else
                		tmp = t_0;
                	end
                	return tmp
                end
                
                function tmp_2 = code(r, a, b)
                	t_0 = r * sin(b);
                	tmp = 0.0;
                	if (b <= -4e+28)
                		tmp = t_0;
                	elseif (b <= 4e+25)
                		tmp = b * (r / cos(a));
                	else
                		tmp = t_0;
                	end
                	tmp_2 = tmp;
                end
                
                code[r_, a_, b_] := Block[{t$95$0 = N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -4e+28], t$95$0, If[LessEqual[b, 4e+25], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                t_0 := r \cdot \sin b\\
                \mathbf{if}\;b \leq -4 \cdot 10^{+28}:\\
                \;\;\;\;t\_0\\
                
                \mathbf{elif}\;b \leq 4 \cdot 10^{+25}:\\
                \;\;\;\;b \cdot \frac{r}{\cos a}\\
                
                \mathbf{else}:\\
                \;\;\;\;t\_0\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if b < -3.99999999999999983e28 or 4.00000000000000036e25 < b

                  1. Initial program 57.0%

                    \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
                  2. Step-by-step derivation
                    1. /-lowering-/.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
                    2. *-lowering-*.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
                    3. sin-lowering-sin.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
                    4. cos-lowering-cos.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
                    5. +-commutativeN/A

                      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
                    6. +-lowering-+.f6457.0%

                      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
                  3. Simplified57.0%

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

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

                      \[\leadsto \frac{r}{\color{blue}{\frac{\cos \left(b + a\right)}{\sin b}}} \]
                    3. *-lft-identityN/A

                      \[\leadsto \frac{1 \cdot r}{\frac{\color{blue}{\cos \left(b + a\right)}}{\sin b}} \]
                    4. div-invN/A

                      \[\leadsto \frac{1 \cdot r}{\cos \left(b + a\right) \cdot \color{blue}{\frac{1}{\sin b}}} \]
                    5. times-fracN/A

                      \[\leadsto \frac{1}{\cos \left(b + a\right)} \cdot \color{blue}{\frac{r}{\frac{1}{\sin b}}} \]
                    6. *-lowering-*.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{\cos \left(b + a\right)}\right), \color{blue}{\left(\frac{r}{\frac{1}{\sin b}}\right)}\right) \]
                    7. /-lowering-/.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \cos \left(b + a\right)\right), \left(\frac{\color{blue}{r}}{\frac{1}{\sin b}}\right)\right) \]
                    8. cos-lowering-cos.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
                    9. +-lowering-+.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
                    10. /-lowering-/.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \color{blue}{\left(\frac{1}{\sin b}\right)}\right)\right) \]
                    11. /-lowering-/.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \color{blue}{\sin b}\right)\right)\right) \]
                    12. sin-lowering-sin.f6456.8%

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
                  6. Applied egg-rr56.8%

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

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \color{blue}{\cos a}\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
                  8. Step-by-step derivation
                    1. cos-lowering-cos.f6410.8%

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(a\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
                  9. Simplified10.8%

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

                    \[\leadsto \color{blue}{r \cdot \sin b} \]
                  11. Step-by-step derivation
                    1. *-lowering-*.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(r, \color{blue}{\sin b}\right) \]
                    2. sin-lowering-sin.f6410.7%

                      \[\leadsto \mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right) \]
                  12. Simplified10.7%

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

                  if -3.99999999999999983e28 < b < 4.00000000000000036e25

                  1. Initial program 97.9%

                    \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
                  2. Step-by-step derivation
                    1. /-lowering-/.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
                    2. *-lowering-*.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
                    3. sin-lowering-sin.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
                    4. cos-lowering-cos.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
                    5. +-commutativeN/A

                      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
                    6. +-lowering-+.f6497.9%

                      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
                  3. Simplified97.9%

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

                    \[\leadsto \color{blue}{\frac{b \cdot r}{\cos a}} \]
                  6. Step-by-step derivation
                    1. /-lowering-/.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(\left(b \cdot r\right), \color{blue}{\cos a}\right) \]
                    2. *-commutativeN/A

                      \[\leadsto \mathsf{/.f64}\left(\left(r \cdot b\right), \cos \color{blue}{a}\right) \]
                    3. *-lowering-*.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, b\right), \cos \color{blue}{a}\right) \]
                    4. cos-lowering-cos.f6492.9%

                      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, b\right), \mathsf{cos.f64}\left(a\right)\right) \]
                  7. Simplified92.9%

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

                      \[\leadsto \frac{r}{\cos a} \cdot \color{blue}{b} \]
                    2. *-lowering-*.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(\left(\frac{r}{\cos a}\right), \color{blue}{b}\right) \]
                    3. /-lowering-/.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \cos a\right), b\right) \]
                    4. cos-lowering-cos.f6492.8%

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(a\right)\right), b\right) \]
                  9. Applied egg-rr92.8%

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

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

                Alternative 22: 39.2% 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 78.5%

                  \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
                2. Step-by-step derivation
                  1. /-lowering-/.f64N/A

                    \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
                  2. *-lowering-*.f64N/A

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
                  3. sin-lowering-sin.f64N/A

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
                  4. cos-lowering-cos.f64N/A

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
                  5. +-commutativeN/A

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
                  6. +-lowering-+.f6478.5%

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
                3. Simplified78.5%

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

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

                    \[\leadsto \frac{r}{\color{blue}{\frac{\cos \left(b + a\right)}{\sin b}}} \]
                  3. *-lft-identityN/A

                    \[\leadsto \frac{1 \cdot r}{\frac{\color{blue}{\cos \left(b + a\right)}}{\sin b}} \]
                  4. div-invN/A

                    \[\leadsto \frac{1 \cdot r}{\cos \left(b + a\right) \cdot \color{blue}{\frac{1}{\sin b}}} \]
                  5. times-fracN/A

                    \[\leadsto \frac{1}{\cos \left(b + a\right)} \cdot \color{blue}{\frac{r}{\frac{1}{\sin b}}} \]
                  6. *-lowering-*.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{\cos \left(b + a\right)}\right), \color{blue}{\left(\frac{r}{\frac{1}{\sin b}}\right)}\right) \]
                  7. /-lowering-/.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \cos \left(b + a\right)\right), \left(\frac{\color{blue}{r}}{\frac{1}{\sin b}}\right)\right) \]
                  8. cos-lowering-cos.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
                  9. +-lowering-+.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \left(\frac{r}{\frac{1}{\sin b}}\right)\right) \]
                  10. /-lowering-/.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \color{blue}{\left(\frac{1}{\sin b}\right)}\right)\right) \]
                  11. /-lowering-/.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \color{blue}{\sin b}\right)\right)\right) \]
                  12. sin-lowering-sin.f6478.3%

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
                6. Applied egg-rr78.3%

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

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \color{blue}{\cos a}\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
                8. Step-by-step derivation
                  1. cos-lowering-cos.f6453.9%

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(a\right)\right), \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(b\right)\right)\right)\right) \]
                9. Simplified53.9%

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

                  \[\leadsto \color{blue}{r \cdot \sin b} \]
                11. Step-by-step derivation
                  1. *-lowering-*.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(r, \color{blue}{\sin b}\right) \]
                  2. sin-lowering-sin.f6437.2%

                    \[\leadsto \mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right) \]
                12. Simplified37.2%

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

                Alternative 23: 34.9% 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 78.5%

                  \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
                2. Step-by-step derivation
                  1. /-lowering-/.f64N/A

                    \[\leadsto \mathsf{/.f64}\left(\left(r \cdot \sin b\right), \color{blue}{\cos \left(a + b\right)}\right) \]
                  2. *-lowering-*.f64N/A

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
                  3. sin-lowering-sin.f64N/A

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \cos \left(a + \color{blue}{b}\right)\right) \]
                  4. cos-lowering-cos.f64N/A

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(a + b\right)\right)\right) \]
                  5. +-commutativeN/A

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\left(b + a\right)\right)\right) \]
                  6. +-lowering-+.f6478.5%

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(b, a\right)\right)\right) \]
                3. Simplified78.5%

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

                  \[\leadsto \color{blue}{\frac{b \cdot r}{\cos a}} \]
                6. Step-by-step derivation
                  1. /-lowering-/.f64N/A

                    \[\leadsto \mathsf{/.f64}\left(\left(b \cdot r\right), \color{blue}{\cos a}\right) \]
                  2. *-commutativeN/A

                    \[\leadsto \mathsf{/.f64}\left(\left(r \cdot b\right), \cos \color{blue}{a}\right) \]
                  3. *-lowering-*.f64N/A

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, b\right), \cos \color{blue}{a}\right) \]
                  4. cos-lowering-cos.f6450.7%

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, b\right), \mathsf{cos.f64}\left(a\right)\right) \]
                7. Simplified50.7%

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

                  \[\leadsto \color{blue}{b \cdot r} \]
                9. Step-by-step derivation
                  1. *-commutativeN/A

                    \[\leadsto r \cdot \color{blue}{b} \]
                  2. *-lowering-*.f6433.9%

                    \[\leadsto \mathsf{*.f64}\left(r, \color{blue}{b}\right) \]
                10. Simplified33.9%

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

                Reproduce

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