rsin B (should all be same)

Percentage Accurate: 76.9% → 99.5%
Time: 15.8s
Alternatives: 22
Speedup: 1.0×

Specification

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

\\
r \cdot \frac{\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 22 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.9% accurate, 1.0× speedup?

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

\\
r \cdot \frac{\sin b}{\cos \left(a + b\right)}
\end{array}

Alternative 1: 99.5% accurate, 0.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(b\right), r\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(a\right), \mathsf{cos.f64}\left(b\right)\right)\right)\right) \]
  9. Applied egg-rr99.6%

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

Alternative 2: 99.5% accurate, 0.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 99.5% accurate, 0.4× speedup?

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

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

    \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. clear-numN/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \sin b\right) \]
    11. +-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) \]
    12. sin-lowering-sin.f6477.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) \]
  4. Applied egg-rr77.5%

    \[\leadsto \color{blue}{\frac{r}{\cos \left(b + a\right)} \cdot \sin b} \]
  5. 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. *-commutativeN/A

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(a\right), \mathsf{cos.f64}\left(b\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) \]
  6. Applied egg-rr99.5%

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

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

Alternative 4: 99.5% accurate, 0.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 76.5% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -4.2 \cdot 10^{-6}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\

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

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


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

    1. Initial program 57.1%

      \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-numN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \sin b\right) \]
      11. +-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) \]
      12. sin-lowering-sin.f6457.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) \]
    4. Applied egg-rr57.3%

      \[\leadsto \color{blue}{\frac{r}{\cos \left(b + a\right)} \cdot \sin b} \]
    5. 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) \]
    6. 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.f6459.2%

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

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

    if -4.1999999999999996e-6 < a < 1650

    1. Initial program 98.0%

      \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in a around 0

      \[\leadsto \color{blue}{\frac{r \cdot \sin b}{\cos b}} \]
    4. 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.f6497.8%

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

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

    if 1650 < a

    1. Initial program 54.0%

      \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in b around 0

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

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

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

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

Alternative 6: 76.5% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -3.65 \cdot 10^{-6}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\

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

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


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

    1. Initial program 57.1%

      \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-numN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \sin b\right) \]
      11. +-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) \]
      12. sin-lowering-sin.f6457.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) \]
    4. Applied egg-rr57.3%

      \[\leadsto \color{blue}{\frac{r}{\cos \left(b + a\right)} \cdot \sin b} \]
    5. 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) \]
    6. 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.f6459.2%

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

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

    if -3.65000000000000021e-6 < a < 1650

    1. Initial program 98.0%

      \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-numN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \sin b\right) \]
      11. +-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) \]
      12. 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) \]
    4. Applied egg-rr98.0%

      \[\leadsto \color{blue}{\frac{r}{\cos \left(b + a\right)} \cdot \sin b} \]
    5. 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) \]
    6. 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.f6497.8%

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

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

    if 1650 < a

    1. Initial program 54.0%

      \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in b around 0

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

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

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

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

Alternative 7: 76.5% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -4.2 \cdot 10^{-6}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\

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

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


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

    1. Initial program 57.1%

      \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-numN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \sin b\right) \]
      11. +-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) \]
      12. sin-lowering-sin.f6457.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) \]
    4. Applied egg-rr57.3%

      \[\leadsto \color{blue}{\frac{r}{\cos \left(b + a\right)} \cdot \sin b} \]
    5. 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) \]
    6. 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.f6459.2%

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

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

    if -4.1999999999999996e-6 < a < 1650

    1. Initial program 98.0%

      \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in a around 0

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

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

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

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

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

    if 1650 < a

    1. Initial program 54.0%

      \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in b around 0

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

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

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

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

Alternative 8: 76.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := r \cdot \frac{\sin b}{\cos a}\\ \mathbf{if}\;a \leq -4.2 \cdot 10^{-6}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;a \leq 1650:\\ \;\;\;\;r \cdot \frac{\sin b}{\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 -4.2e-6) t_0 (if (<= a 1650.0) (* r (/ (sin b) (cos b))) t_0))))
double code(double r, double a, double b) {
	double t_0 = r * (sin(b) / cos(a));
	double tmp;
	if (a <= -4.2e-6) {
		tmp = t_0;
	} else if (a <= 1650.0) {
		tmp = r * (sin(b) / 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 <= (-4.2d-6)) then
        tmp = t_0
    else if (a <= 1650.0d0) then
        tmp = r * (sin(b) / 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 <= -4.2e-6) {
		tmp = t_0;
	} else if (a <= 1650.0) {
		tmp = r * (Math.sin(b) / 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 <= -4.2e-6:
		tmp = t_0
	elif a <= 1650.0:
		tmp = r * (math.sin(b) / 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 <= -4.2e-6)
		tmp = t_0;
	elseif (a <= 1650.0)
		tmp = Float64(r * Float64(sin(b) / 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 <= -4.2e-6)
		tmp = t_0;
	elseif (a <= 1650.0)
		tmp = r * (sin(b) / 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, -4.2e-6], t$95$0, If[LessEqual[a, 1650.0], N[(r * N[(N[Sin[b], $MachinePrecision] / 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 -4.2 \cdot 10^{-6}:\\
\;\;\;\;t\_0\\

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

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


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

    1. Initial program 55.6%

      \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in b around 0

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

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

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

    if -4.1999999999999996e-6 < a < 1650

    1. Initial program 98.0%

      \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in a around 0

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

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

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

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

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

Alternative 9: 76.8% accurate, 1.0× speedup?

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

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

    \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. clear-numN/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \sin b\right) \]
    11. +-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) \]
    12. sin-lowering-sin.f6477.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) \]
  4. Applied egg-rr77.5%

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

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\left(\left(b \cdot b - a \cdot a\right) \cdot \frac{1}{b - a}\right)\right)\right), \mathsf{sin.f64}\left(b\right)\right) \]
    3. difference-of-squaresN/A

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\left(\frac{\left(b + a\right) \cdot \left(b - a\right)}{b - a}\right)\right)\right), \mathsf{sin.f64}\left(b\right)\right) \]
    3. *-rgt-identityN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\left(\frac{\left(b + a\right) \cdot \left(b - a\right)}{\left(b - a\right) \cdot 1}\right)\right)\right), \mathsf{sin.f64}\left(b\right)\right) \]
    4. times-fracN/A

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

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

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

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

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

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

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

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

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

Alternative 10: 76.9% accurate, 1.0× speedup?

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

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

    \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. associate-*r/N/A

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

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \sin b\right), \cos \color{blue}{\left(a + b\right)}\right) \]
    4. 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) \]
    5. 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) \]
    6. +-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) \]
    7. +-lowering-+.f6477.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) \]
  4. Applied egg-rr77.5%

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

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

Alternative 11: 76.8% accurate, 1.0× speedup?

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

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

    \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. clear-numN/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \sin b\right) \]
    11. +-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) \]
    12. sin-lowering-sin.f6477.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) \]
  4. Applied egg-rr77.5%

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

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

Alternative 12: 76.9% accurate, 1.0× speedup?

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

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

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

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

Alternative 13: 55.0% accurate, 1.0× speedup?

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

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

    \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
  2. Add Preprocessing
  3. Taylor expanded in b around 0

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

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

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

Alternative 14: 55.3% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin b \cdot r\\ \mathbf{if}\;b \leq -4.4:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;b \leq 3700:\\ \;\;\;\;\frac{r}{\cos \left(b + a\right)} \cdot \left(b \cdot \left(1 + b \cdot \left(b \cdot \left(-0.16666666666666666 + \left(b \cdot b\right) \cdot 0.008333333333333333\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (r a b)
 :precision binary64
 (let* ((t_0 (* (sin b) r)))
   (if (<= b -4.4)
     t_0
     (if (<= b 3700.0)
       (*
        (/ r (cos (+ b a)))
        (*
         b
         (+
          1.0
          (*
           b
           (* b (+ -0.16666666666666666 (* (* b b) 0.008333333333333333)))))))
       t_0))))
double code(double r, double a, double b) {
	double t_0 = sin(b) * r;
	double tmp;
	if (b <= -4.4) {
		tmp = t_0;
	} else if (b <= 3700.0) {
		tmp = (r / cos((b + a))) * (b * (1.0 + (b * (b * (-0.16666666666666666 + ((b * b) * 0.008333333333333333))))));
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(r, a, b)
    real(8), intent (in) :: r
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sin(b) * r
    if (b <= (-4.4d0)) then
        tmp = t_0
    else if (b <= 3700.0d0) then
        tmp = (r / cos((b + a))) * (b * (1.0d0 + (b * (b * ((-0.16666666666666666d0) + ((b * b) * 0.008333333333333333d0))))))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double r, double a, double b) {
	double t_0 = Math.sin(b) * r;
	double tmp;
	if (b <= -4.4) {
		tmp = t_0;
	} else if (b <= 3700.0) {
		tmp = (r / Math.cos((b + a))) * (b * (1.0 + (b * (b * (-0.16666666666666666 + ((b * b) * 0.008333333333333333))))));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(r, a, b):
	t_0 = math.sin(b) * r
	tmp = 0
	if b <= -4.4:
		tmp = t_0
	elif b <= 3700.0:
		tmp = (r / math.cos((b + a))) * (b * (1.0 + (b * (b * (-0.16666666666666666 + ((b * b) * 0.008333333333333333))))))
	else:
		tmp = t_0
	return tmp
function code(r, a, b)
	t_0 = Float64(sin(b) * r)
	tmp = 0.0
	if (b <= -4.4)
		tmp = t_0;
	elseif (b <= 3700.0)
		tmp = Float64(Float64(r / cos(Float64(b + a))) * Float64(b * Float64(1.0 + Float64(b * Float64(b * Float64(-0.16666666666666666 + Float64(Float64(b * b) * 0.008333333333333333)))))));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(r, a, b)
	t_0 = sin(b) * r;
	tmp = 0.0;
	if (b <= -4.4)
		tmp = t_0;
	elseif (b <= 3700.0)
		tmp = (r / cos((b + a))) * (b * (1.0 + (b * (b * (-0.16666666666666666 + ((b * b) * 0.008333333333333333))))));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision]}, If[LessEqual[b, -4.4], t$95$0, If[LessEqual[b, 3700.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[(N[(b * b), $MachinePrecision] * 0.008333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin b \cdot r\\
\mathbf{if}\;b \leq -4.4:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;b \leq 3700:\\
\;\;\;\;\frac{r}{\cos \left(b + a\right)} \cdot \left(b \cdot \left(1 + b \cdot \left(b \cdot \left(-0.16666666666666666 + \left(b \cdot b\right) \cdot 0.008333333333333333\right)\right)\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -4.4000000000000004 or 3700 < b

    1. Initial program 56.9%

      \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-numN/A

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

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

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

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

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

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

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

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

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

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

        \[\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) \]
    4. Applied egg-rr56.9%

      \[\leadsto \color{blue}{\frac{r}{\cos \left(b + a\right)} \cdot \sin b} \]
    5. 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) \]
    6. 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.f6412.9%

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

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

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

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

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

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

    if -4.4000000000000004 < b < 3700

    1. Initial program 98.6%

      \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-numN/A

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

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

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

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

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

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

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

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

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

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

        \[\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) \]
    4. Applied egg-rr98.6%

      \[\leadsto \color{blue}{\frac{r}{\cos \left(b + a\right)} \cdot \sin b} \]
    5. 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) \]
    6. 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. *-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(\left({b}^{2}\right), \color{blue}{\frac{1}{120}}\right)\right)\right)\right)\right)\right)\right) \]
      13. 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}, \mathsf{*.f64}\left(\left(b \cdot b\right), \frac{1}{120}\right)\right)\right)\right)\right)\right)\right) \]
      14. *-lowering-*.f6498.0%

        \[\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(\mathsf{*.f64}\left(b, b\right), \frac{1}{120}\right)\right)\right)\right)\right)\right)\right) \]
    7. Simplified98.0%

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

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

Alternative 15: 55.3% accurate, 1.6× speedup?

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

\\
\begin{array}{l}
t_0 := \sin b \cdot r\\
\mathbf{if}\;b \leq -7:\\
\;\;\;\;t\_0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -7 or 10 < b

    1. Initial program 56.9%

      \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-numN/A

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

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

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

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

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

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

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

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

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

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

        \[\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) \]
    4. Applied egg-rr56.9%

      \[\leadsto \color{blue}{\frac{r}{\cos \left(b + a\right)} \cdot \sin b} \]
    5. 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) \]
    6. 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.f6412.9%

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

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

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

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

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

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

    if -7 < b < 10

    1. Initial program 98.6%

      \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in b around 0

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(r, \mathsf{/.f64}\left(\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 \frac{1}{120}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(a, b\right)\right)\right)\right) \]
      11. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(r, \mathsf{/.f64}\left(\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), \frac{1}{120}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(a, b\right)\right)\right)\right) \]
      12. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(r, \mathsf{/.f64}\left(\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), \frac{1}{120}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(a, b\right)\right)\right)\right) \]
      13. *-lowering-*.f6497.9%

        \[\leadsto \mathsf{*.f64}\left(r, \mathsf{/.f64}\left(\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), \frac{1}{120}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{+.f64}\left(a, b\right)\right)\right)\right) \]
    5. Simplified97.9%

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

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

Alternative 16: 55.2% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
t_0 := \sin b \cdot r\\
\mathbf{if}\;b \leq -1950:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;b \leq 3200000:\\
\;\;\;\;\frac{r}{\cos \left(b + a\right)} \cdot \left(b \cdot \left(1 + -0.16666666666666666 \cdot \left(b \cdot b\right)\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -1950 or 3.2e6 < b

    1. Initial program 56.1%

      \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-numN/A

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

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

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

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

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

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

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

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

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

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

        \[\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) \]
    4. Applied egg-rr56.2%

      \[\leadsto \color{blue}{\frac{r}{\cos \left(b + a\right)} \cdot \sin b} \]
    5. 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) \]
    6. 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.f6413.0%

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

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

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

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

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

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

    if -1950 < b < 3.2e6

    1. Initial program 98.4%

      \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-numN/A

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

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

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

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

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

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

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

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

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

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

        \[\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) \]
    4. Applied egg-rr98.4%

      \[\leadsto \color{blue}{\frac{r}{\cos \left(b + a\right)} \cdot \sin b} \]
    5. 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) \]
    6. 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. *-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(\frac{-1}{6}, \color{blue}{\left({b}^{2}\right)}\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, \mathsf{*.f64}\left(\frac{-1}{6}, \left(b \cdot \color{blue}{b}\right)\right)\right)\right)\right) \]
      5. *-lowering-*.f6495.7%

        \[\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(\frac{-1}{6}, \mathsf{*.f64}\left(b, \color{blue}{b}\right)\right)\right)\right)\right) \]
    7. Simplified95.7%

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

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

Alternative 17: 55.3% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
t_0 := \sin b \cdot r\\
\mathbf{if}\;b \leq -500:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;b \leq 1800000:\\
\;\;\;\;r \cdot \frac{b \cdot \left(1 + b \cdot \left(b \cdot -0.16666666666666666\right)\right)}{\cos \left(b + a\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -500 or 1.8e6 < b

    1. Initial program 56.1%

      \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-numN/A

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

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

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

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

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

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

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

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

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

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

        \[\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) \]
    4. Applied egg-rr56.2%

      \[\leadsto \color{blue}{\frac{r}{\cos \left(b + a\right)} \cdot \sin b} \]
    5. 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) \]
    6. 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.f6413.0%

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

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

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

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

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

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

    if -500 < b < 1.8e6

    1. Initial program 98.4%

      \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in b around 0

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

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

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

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

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

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

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

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

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

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

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

Alternative 18: 55.1% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
t_0 := \sin b \cdot r\\
\mathbf{if}\;b \leq -0.95:\\
\;\;\;\;t\_0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -0.94999999999999996 or 17.5 < b

    1. Initial program 56.9%

      \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-numN/A

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

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

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

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

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

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

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

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

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

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

        \[\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) \]
    4. Applied egg-rr56.9%

      \[\leadsto \color{blue}{\frac{r}{\cos \left(b + a\right)} \cdot \sin b} \]
    5. 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) \]
    6. 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.f6412.9%

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

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

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

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

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

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

    if -0.94999999999999996 < b < 17.5

    1. Initial program 98.6%

      \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-numN/A

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

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

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

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

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

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

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

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

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

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

        \[\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) \]
    4. Applied egg-rr98.6%

      \[\leadsto \color{blue}{\frac{r}{\cos \left(b + a\right)} \cdot \sin b} \]
    5. 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}{b}\right) \]
    6. Step-by-step derivation
      1. Simplified97.4%

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

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

    Alternative 19: 55.2% accurate, 1.8× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin b \cdot r\\ \mathbf{if}\;b \leq -4.2:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;b \leq 330:\\ \;\;\;\;r \cdot \frac{b}{\cos \left(b + a\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
    (FPCore (r a b)
     :precision binary64
     (let* ((t_0 (* (sin b) r)))
       (if (<= b -4.2) t_0 (if (<= b 330.0) (* r (/ b (cos (+ b a)))) t_0))))
    double code(double r, double a, double b) {
    	double t_0 = sin(b) * r;
    	double tmp;
    	if (b <= -4.2) {
    		tmp = t_0;
    	} else if (b <= 330.0) {
    		tmp = r * (b / cos((b + a)));
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    real(8) function code(r, a, b)
        real(8), intent (in) :: r
        real(8), intent (in) :: a
        real(8), intent (in) :: b
        real(8) :: t_0
        real(8) :: tmp
        t_0 = sin(b) * r
        if (b <= (-4.2d0)) then
            tmp = t_0
        else if (b <= 330.0d0) then
            tmp = r * (b / cos((b + a)))
        else
            tmp = t_0
        end if
        code = tmp
    end function
    
    public static double code(double r, double a, double b) {
    	double t_0 = Math.sin(b) * r;
    	double tmp;
    	if (b <= -4.2) {
    		tmp = t_0;
    	} else if (b <= 330.0) {
    		tmp = r * (b / Math.cos((b + a)));
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    def code(r, a, b):
    	t_0 = math.sin(b) * r
    	tmp = 0
    	if b <= -4.2:
    		tmp = t_0
    	elif b <= 330.0:
    		tmp = r * (b / math.cos((b + a)))
    	else:
    		tmp = t_0
    	return tmp
    
    function code(r, a, b)
    	t_0 = Float64(sin(b) * r)
    	tmp = 0.0
    	if (b <= -4.2)
    		tmp = t_0;
    	elseif (b <= 330.0)
    		tmp = Float64(r * Float64(b / cos(Float64(b + a))));
    	else
    		tmp = t_0;
    	end
    	return tmp
    end
    
    function tmp_2 = code(r, a, b)
    	t_0 = sin(b) * r;
    	tmp = 0.0;
    	if (b <= -4.2)
    		tmp = t_0;
    	elseif (b <= 330.0)
    		tmp = r * (b / cos((b + a)));
    	else
    		tmp = t_0;
    	end
    	tmp_2 = tmp;
    end
    
    code[r_, a_, b_] := Block[{t$95$0 = N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision]}, If[LessEqual[b, -4.2], t$95$0, If[LessEqual[b, 330.0], N[(r * N[(b / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \sin b \cdot r\\
    \mathbf{if}\;b \leq -4.2:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;b \leq 330:\\
    \;\;\;\;r \cdot \frac{b}{\cos \left(b + a\right)}\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if b < -4.20000000000000018 or 330 < b

      1. Initial program 56.9%

        \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. clear-numN/A

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

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

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

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

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

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

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

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

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

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

          \[\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) \]
      4. Applied egg-rr56.9%

        \[\leadsto \color{blue}{\frac{r}{\cos \left(b + a\right)} \cdot \sin b} \]
      5. 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) \]
      6. 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.f6412.9%

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

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

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

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

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

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

      if -4.20000000000000018 < b < 330

      1. Initial program 98.6%

        \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
      2. Add Preprocessing
      3. Taylor expanded in b around 0

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

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

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

      Alternative 20: 55.1% accurate, 1.8× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin b \cdot r\\ \mathbf{if}\;b \leq -4.7:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;b \leq 2020000:\\ \;\;\;\;b \cdot \frac{r}{\cos a}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
      (FPCore (r a b)
       :precision binary64
       (let* ((t_0 (* (sin b) r)))
         (if (<= b -4.7) t_0 (if (<= b 2020000.0) (* b (/ r (cos a))) t_0))))
      double code(double r, double a, double b) {
      	double t_0 = sin(b) * r;
      	double tmp;
      	if (b <= -4.7) {
      		tmp = t_0;
      	} else if (b <= 2020000.0) {
      		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 = sin(b) * r
          if (b <= (-4.7d0)) then
              tmp = t_0
          else if (b <= 2020000.0d0) 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 = Math.sin(b) * r;
      	double tmp;
      	if (b <= -4.7) {
      		tmp = t_0;
      	} else if (b <= 2020000.0) {
      		tmp = b * (r / Math.cos(a));
      	} else {
      		tmp = t_0;
      	}
      	return tmp;
      }
      
      def code(r, a, b):
      	t_0 = math.sin(b) * r
      	tmp = 0
      	if b <= -4.7:
      		tmp = t_0
      	elif b <= 2020000.0:
      		tmp = b * (r / math.cos(a))
      	else:
      		tmp = t_0
      	return tmp
      
      function code(r, a, b)
      	t_0 = Float64(sin(b) * r)
      	tmp = 0.0
      	if (b <= -4.7)
      		tmp = t_0;
      	elseif (b <= 2020000.0)
      		tmp = Float64(b * Float64(r / cos(a)));
      	else
      		tmp = t_0;
      	end
      	return tmp
      end
      
      function tmp_2 = code(r, a, b)
      	t_0 = sin(b) * r;
      	tmp = 0.0;
      	if (b <= -4.7)
      		tmp = t_0;
      	elseif (b <= 2020000.0)
      		tmp = b * (r / cos(a));
      	else
      		tmp = t_0;
      	end
      	tmp_2 = tmp;
      end
      
      code[r_, a_, b_] := Block[{t$95$0 = N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision]}, If[LessEqual[b, -4.7], t$95$0, If[LessEqual[b, 2020000.0], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := \sin b \cdot r\\
      \mathbf{if}\;b \leq -4.7:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;b \leq 2020000:\\
      \;\;\;\;b \cdot \frac{r}{\cos a}\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_0\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if b < -4.70000000000000018 or 2.02e6 < b

        1. Initial program 56.8%

          \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
        2. Add Preprocessing
        3. Step-by-step derivation
          1. clear-numN/A

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \sin b\right) \]
          11. +-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) \]
          12. sin-lowering-sin.f6456.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) \]
        4. Applied egg-rr56.8%

          \[\leadsto \color{blue}{\frac{r}{\cos \left(b + a\right)} \cdot \sin b} \]
        5. 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) \]
        6. 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.f6412.9%

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

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

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

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

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

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

        if -4.70000000000000018 < b < 2.02e6

        1. Initial program 98.4%

          \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
        2. Add Preprocessing
        3. Taylor expanded in b around 0

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

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

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

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

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

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

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

      Alternative 21: 38.6% accurate, 2.0× speedup?

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

        \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. clear-numN/A

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(r, \mathsf{cos.f64}\left(\left(b + a\right)\right)\right), \sin b\right) \]
        11. +-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) \]
        12. sin-lowering-sin.f6477.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) \]
      4. Applied egg-rr77.5%

        \[\leadsto \color{blue}{\frac{r}{\cos \left(b + a\right)} \cdot \sin b} \]
      5. 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) \]
      6. 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.4%

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

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

        \[\leadsto \color{blue}{r \cdot \sin b} \]
      9. 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) \]
      10. Simplified37.2%

        \[\leadsto \color{blue}{r \cdot \sin b} \]
      11. Final simplification37.2%

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

      Alternative 22: 34.6% accurate, 69.0× speedup?

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

        \[r \cdot \frac{\sin b}{\cos \left(a + b\right)} \]
      2. Add Preprocessing
      3. Taylor expanded in b around 0

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

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

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

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

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

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

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

          \[\leadsto \mathsf{*.f64}\left(b, \color{blue}{r}\right) \]
      8. Simplified32.9%

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

      Reproduce

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