rsin A (should all be same)

Percentage Accurate: 76.2% → 99.5%
Time: 13.0s
Alternatives: 14
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 14 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 76.2% accurate, 1.0× speedup?

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

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

Alternative 1: 99.5% accurate, 0.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(b\right), \mathsf{cos.f64}\left(a\right), \left(\sin b \cdot \left(\mathsf{neg}\left(\sin a\right)\right)\right)\right)\right) \]
    2. distribute-rgt-neg-outN/A

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

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

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

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

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

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

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

Alternative 2: 99.4% accurate, 0.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 76.3% accurate, 0.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(b\right), \mathsf{cos.f64}\left(a\right), \left(\sin b \cdot \left(\mathsf{neg}\left(\sin a\right)\right)\right)\right)\right) \]
    2. distribute-rgt-neg-outN/A

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \left(\frac{\cos \left(b + a\right) \cdot \left(\cos b \cdot \cos a - \left(\mathsf{neg}\left(\sin b\right)\right) \cdot \sin a\right)}{\cos b \cdot \cos a + \sin b \cdot \sin a}\right)\right) \]
    8. cancel-sign-subN/A

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

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

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

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

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

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

Alternative 4: 75.8% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{r}{\frac{\cos b}{\sin b}}\\
\mathbf{if}\;b \leq -240000:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;b \leq 2.15 \cdot 10^{-6}:\\
\;\;\;\;\frac{r \cdot \sin b}{\cos a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -2.4e5 or 2.15000000000000017e-6 < b

    1. Initial program 55.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.4e5 < b < 2.15000000000000017e-6

    1. Initial program 98.0%

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 75.8% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{r}{\frac{\cos b}{\sin b}}\\
\mathbf{if}\;b \leq -240000:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;b \leq 2.4 \cdot 10^{-6}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -2.4e5 or 2.3999999999999999e-6 < b

    1. Initial program 55.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.4e5 < b < 2.3999999999999999e-6

    1. Initial program 98.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 76.2% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 54.5% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(\mathsf{cos.f64}\left(a\right), \mathsf{sin.f64}\left(\color{blue}{b}\right)\right)\right) \]
  9. Simplified52.9%

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

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

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

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

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

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

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

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

Alternative 8: 55.0% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
t_0 := r \cdot \sin b\\
\mathbf{if}\;b \leq -1.12 \cdot 10^{+14}:\\
\;\;\;\;t\_0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -1.12e14 or 0.47999999999999998 < b

    1. Initial program 54.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.12e14 < b < 0.47999999999999998

    1. Initial program 97.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 55.0% accurate, 1.7× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -2.7e12 or 0.47999999999999998 < b

    1. Initial program 54.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.7e12 < b < 0.47999999999999998

    1. Initial program 97.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 54.9% accurate, 1.8× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -3.1e5 or 3200 < b

    1. Initial program 55.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.1e5 < b < 3200

    1. Initial program 96.7%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, b\right), \mathsf{cos.f64}\left(\color{blue}{\mathsf{+.f64}\left(b, a\right)}\right)\right) \]
    7. Simplified95.7%

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

Alternative 11: 54.9% accurate, 1.8× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -2.5e5 or 13.5 < b

    1. Initial program 55.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.5e5 < b < 13.5

    1. Initial program 96.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 54.9% accurate, 1.8× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -3.1e5 or 13.5 < b

    1. Initial program 55.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.1e5 < b < 13.5

    1. Initial program 96.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 38.4% accurate, 2.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{/.f64}\left(r, \mathsf{/.f64}\left(\mathsf{cos.f64}\left(a\right), \mathsf{sin.f64}\left(\color{blue}{b}\right)\right)\right) \]
  9. Simplified52.9%

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

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

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

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

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

Alternative 14: 34.1% accurate, 69.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto r \cdot \color{blue}{b} \]
    2. *-lowering-*.f6434.6%

      \[\leadsto \mathsf{*.f64}\left(r, \color{blue}{b}\right) \]
  10. Simplified34.6%

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

Reproduce

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