rsin A (should all be same)

Percentage Accurate: 76.7% → 99.5%
Time: 15.3s
Alternatives: 15
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 15 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.7% accurate, 1.0× speedup?

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

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

Alternative 1: 99.5% accurate, 0.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{r}{\color{blue}{\cos a \cdot \cos b} - \sin b \cdot \sin a} \cdot \sin b \]
    3. cancel-sign-sub-invN/A

      \[\leadsto \frac{r}{\color{blue}{\cos a \cdot \cos b + \left(\mathsf{neg}\left(\sin b\right)\right) \cdot \sin a}} \cdot \sin b \]
    4. sub0-negN/A

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{r}{\mathsf{fma}\left(\color{blue}{\mathsf{neg}\left(\sin b\right)}, \sin a, \cos a \cdot \cos b\right)} \cdot \sin b \]
    3. sin-lowering-sin.f6499.6

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

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

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

Alternative 2: 99.5% accurate, 0.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{r}{\cos a \cdot \cos b - \color{blue}{\sin b} \cdot \sin a} \cdot \sin b \]
    9. sin-lowering-sin.f6499.5

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

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

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

Alternative 3: 76.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -0.076:\\ \;\;\;\;\sin b \cdot \frac{r}{\cos b}\\ \mathbf{elif}\;b \leq 0.07:\\ \;\;\;\;r \cdot \frac{b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b, b \cdot \mathsf{fma}\left(b \cdot b, -0.0001984126984126984, 0.008333333333333333\right), -0.16666666666666666\right), 1\right)}{\cos \left(b + a\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{r \cdot \sin b}{\cos b}\\ \end{array} \end{array} \]
(FPCore (r a b)
 :precision binary64
 (if (<= b -0.076)
   (* (sin b) (/ r (cos b)))
   (if (<= b 0.07)
     (*
      r
      (/
       (*
        b
        (fma
         (* b b)
         (fma
          b
          (* b (fma (* b b) -0.0001984126984126984 0.008333333333333333))
          -0.16666666666666666)
         1.0))
       (cos (+ b a))))
     (/ (* r (sin b)) (cos b)))))
double code(double r, double a, double b) {
	double tmp;
	if (b <= -0.076) {
		tmp = sin(b) * (r / cos(b));
	} else if (b <= 0.07) {
		tmp = r * ((b * fma((b * b), fma(b, (b * fma((b * b), -0.0001984126984126984, 0.008333333333333333)), -0.16666666666666666), 1.0)) / cos((b + a)));
	} else {
		tmp = (r * sin(b)) / cos(b);
	}
	return tmp;
}
function code(r, a, b)
	tmp = 0.0
	if (b <= -0.076)
		tmp = Float64(sin(b) * Float64(r / cos(b)));
	elseif (b <= 0.07)
		tmp = Float64(r * Float64(Float64(b * fma(Float64(b * b), fma(b, Float64(b * fma(Float64(b * b), -0.0001984126984126984, 0.008333333333333333)), -0.16666666666666666), 1.0)) / cos(Float64(b + a))));
	else
		tmp = Float64(Float64(r * sin(b)) / cos(b));
	end
	return tmp
end
code[r_, a_, b_] := If[LessEqual[b, -0.076], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 0.07], N[(r * N[(N[(b * N[(N[(b * b), $MachinePrecision] * N[(b * N[(b * N[(N[(b * b), $MachinePrecision] * -0.0001984126984126984 + 0.008333333333333333), $MachinePrecision]), $MachinePrecision] + -0.16666666666666666), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;b \leq 0.07:\\
\;\;\;\;r \cdot \frac{b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b, b \cdot \mathsf{fma}\left(b \cdot b, -0.0001984126984126984, 0.008333333333333333\right), -0.16666666666666666\right), 1\right)}{\cos \left(b + a\right)}\\

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


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

    1. Initial program 56.6%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{r}{\cos b}} \cdot \sin b \]
      2. cos-lowering-cos.f6458.2

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

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

    if -0.0759999999999999981 < b < 0.070000000000000007

    1. Initial program 97.5%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{r \cdot \sin b}{\mathsf{fma}\left(0 - \sin b, \sin a, \color{blue}{\cos a} \cdot \cos b\right)} \]
      13. cos-lowering-cos.f6499.8

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{r \cdot \left(b \cdot \mathsf{fma}\left(b \cdot b, \color{blue}{\mathsf{fma}\left({b}^{2}, \frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}, \frac{-1}{6}\right)}, 1\right)\right)}{\mathsf{fma}\left(0 - \sin b, \sin a, \cos a \cdot \cos b\right)} \]
      9. unpow2N/A

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

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

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

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

        \[\leadsto \frac{r \cdot \left(b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b \cdot b, \color{blue}{\mathsf{fma}\left({b}^{2}, \frac{-1}{5040}, \frac{1}{120}\right)}, \frac{-1}{6}\right), 1\right)\right)}{\mathsf{fma}\left(0 - \sin b, \sin a, \cos a \cdot \cos b\right)} \]
      14. unpow2N/A

        \[\leadsto \frac{r \cdot \left(b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(\color{blue}{b \cdot b}, \frac{-1}{5040}, \frac{1}{120}\right), \frac{-1}{6}\right), 1\right)\right)}{\mathsf{fma}\left(0 - \sin b, \sin a, \cos a \cdot \cos b\right)} \]
      15. *-lowering-*.f6499.8

        \[\leadsto \frac{r \cdot \left(b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(\color{blue}{b \cdot b}, -0.0001984126984126984, 0.008333333333333333\right), -0.16666666666666666\right), 1\right)\right)}{\mathsf{fma}\left(0 - \sin b, \sin a, \cos a \cdot \cos b\right)} \]
    7. Simplified99.8%

      \[\leadsto \frac{r \cdot \color{blue}{\left(b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b \cdot b, -0.0001984126984126984, 0.008333333333333333\right), -0.16666666666666666\right), 1\right)\right)}}{\mathsf{fma}\left(0 - \sin b, \sin a, \cos a \cdot \cos b\right)} \]
    8. Step-by-step derivation
      1. associate-/l*N/A

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

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

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

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

    if 0.070000000000000007 < b

    1. Initial program 41.9%

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

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

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

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

        \[\leadsto \frac{r \cdot \color{blue}{\sin b}}{\cos b} \]
      4. cos-lowering-cos.f6441.7

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

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

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

Alternative 4: 76.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin b \cdot \frac{r}{\cos b}\\ \mathbf{if}\;b \leq -0.235:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;b \leq 0.095:\\ \;\;\;\;r \cdot \frac{b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b, b \cdot \mathsf{fma}\left(b \cdot b, -0.0001984126984126984, 0.008333333333333333\right), -0.16666666666666666\right), 1\right)}{\cos \left(b + a\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (r a b)
 :precision binary64
 (let* ((t_0 (* (sin b) (/ r (cos b)))))
   (if (<= b -0.235)
     t_0
     (if (<= b 0.095)
       (*
        r
        (/
         (*
          b
          (fma
           (* b b)
           (fma
            b
            (* b (fma (* b b) -0.0001984126984126984 0.008333333333333333))
            -0.16666666666666666)
           1.0))
         (cos (+ b a))))
       t_0))))
double code(double r, double a, double b) {
	double t_0 = sin(b) * (r / cos(b));
	double tmp;
	if (b <= -0.235) {
		tmp = t_0;
	} else if (b <= 0.095) {
		tmp = r * ((b * fma((b * b), fma(b, (b * fma((b * b), -0.0001984126984126984, 0.008333333333333333)), -0.16666666666666666), 1.0)) / cos((b + a)));
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(r, a, b)
	t_0 = Float64(sin(b) * Float64(r / cos(b)))
	tmp = 0.0
	if (b <= -0.235)
		tmp = t_0;
	elseif (b <= 0.095)
		tmp = Float64(r * Float64(Float64(b * fma(Float64(b * b), fma(b, Float64(b * fma(Float64(b * b), -0.0001984126984126984, 0.008333333333333333)), -0.16666666666666666), 1.0)) / cos(Float64(b + a))));
	else
		tmp = t_0;
	end
	return tmp
end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -0.235], t$95$0, If[LessEqual[b, 0.095], N[(r * N[(N[(b * N[(N[(b * b), $MachinePrecision] * N[(b * N[(b * N[(N[(b * b), $MachinePrecision] * -0.0001984126984126984 + 0.008333333333333333), $MachinePrecision]), $MachinePrecision] + -0.16666666666666666), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}

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

\mathbf{elif}\;b \leq 0.095:\\
\;\;\;\;r \cdot \frac{b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b, b \cdot \mathsf{fma}\left(b \cdot b, -0.0001984126984126984, 0.008333333333333333\right), -0.16666666666666666\right), 1\right)}{\cos \left(b + a\right)}\\

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


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

    1. Initial program 49.9%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{r}{\cos b}} \cdot \sin b \]
      2. cos-lowering-cos.f6450.6

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

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

    if -0.23499999999999999 < b < 0.095000000000000001

    1. Initial program 97.5%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{r \cdot \sin b}{\mathsf{fma}\left(0 - \sin b, \sin a, \color{blue}{\cos a} \cdot \cos b\right)} \]
      13. cos-lowering-cos.f6499.8

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{r \cdot \left(b \cdot \mathsf{fma}\left(b \cdot b, \color{blue}{\mathsf{fma}\left({b}^{2}, \frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}, \frac{-1}{6}\right)}, 1\right)\right)}{\mathsf{fma}\left(0 - \sin b, \sin a, \cos a \cdot \cos b\right)} \]
      9. unpow2N/A

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

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

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

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

        \[\leadsto \frac{r \cdot \left(b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b \cdot b, \color{blue}{\mathsf{fma}\left({b}^{2}, \frac{-1}{5040}, \frac{1}{120}\right)}, \frac{-1}{6}\right), 1\right)\right)}{\mathsf{fma}\left(0 - \sin b, \sin a, \cos a \cdot \cos b\right)} \]
      14. unpow2N/A

        \[\leadsto \frac{r \cdot \left(b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(\color{blue}{b \cdot b}, \frac{-1}{5040}, \frac{1}{120}\right), \frac{-1}{6}\right), 1\right)\right)}{\mathsf{fma}\left(0 - \sin b, \sin a, \cos a \cdot \cos b\right)} \]
      15. *-lowering-*.f6499.8

        \[\leadsto \frac{r \cdot \left(b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(\color{blue}{b \cdot b}, -0.0001984126984126984, 0.008333333333333333\right), -0.16666666666666666\right), 1\right)\right)}{\mathsf{fma}\left(0 - \sin b, \sin a, \cos a \cdot \cos b\right)} \]
    7. Simplified99.8%

      \[\leadsto \frac{r \cdot \color{blue}{\left(b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b \cdot b, -0.0001984126984126984, 0.008333333333333333\right), -0.16666666666666666\right), 1\right)\right)}}{\mathsf{fma}\left(0 - \sin b, \sin a, \cos a \cdot \cos b\right)} \]
    8. Step-by-step derivation
      1. associate-/l*N/A

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

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

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

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

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

Alternative 5: 76.7% 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 74.1%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 55.2% 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 74.1%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{r}{\cos a}} \cdot \sin b \]
    2. cos-lowering-cos.f6454.6

      \[\leadsto \frac{r}{\color{blue}{\cos a}} \cdot \sin b \]
  7. Simplified54.6%

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

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

Alternative 7: 55.7% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := r \cdot \sin b\\ \mathbf{if}\;b \leq -5.2:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;b \leq 0.69:\\ \;\;\;\;r \cdot \frac{b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b, b \cdot \mathsf{fma}\left(b \cdot b, -0.0001984126984126984, 0.008333333333333333\right), -0.16666666666666666\right), 1\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 -5.2)
     t_0
     (if (<= b 0.69)
       (*
        r
        (/
         (*
          b
          (fma
           (* b b)
           (fma
            b
            (* b (fma (* b b) -0.0001984126984126984 0.008333333333333333))
            -0.16666666666666666)
           1.0))
         (cos (+ b a))))
       t_0))))
double code(double r, double a, double b) {
	double t_0 = r * sin(b);
	double tmp;
	if (b <= -5.2) {
		tmp = t_0;
	} else if (b <= 0.69) {
		tmp = r * ((b * fma((b * b), fma(b, (b * fma((b * b), -0.0001984126984126984, 0.008333333333333333)), -0.16666666666666666), 1.0)) / 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 <= -5.2)
		tmp = t_0;
	elseif (b <= 0.69)
		tmp = Float64(r * Float64(Float64(b * fma(Float64(b * b), fma(b, Float64(b * fma(Float64(b * b), -0.0001984126984126984, 0.008333333333333333)), -0.16666666666666666), 1.0)) / cos(Float64(b + a))));
	else
		tmp = t_0;
	end
	return tmp
end
code[r_, a_, b_] := Block[{t$95$0 = N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -5.2], t$95$0, If[LessEqual[b, 0.69], N[(r * N[(N[(b * N[(N[(b * b), $MachinePrecision] * N[(b * N[(b * N[(N[(b * b), $MachinePrecision] * -0.0001984126984126984 + 0.008333333333333333), $MachinePrecision]), $MachinePrecision] + -0.16666666666666666), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}

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

\mathbf{elif}\;b \leq 0.69:\\
\;\;\;\;r \cdot \frac{b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b, b \cdot \mathsf{fma}\left(b \cdot b, -0.0001984126984126984, 0.008333333333333333\right), -0.16666666666666666\right), 1\right)}{\cos \left(b + a\right)}\\

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


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

    1. Initial program 49.5%

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

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

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

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

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

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

        \[\leadsto \frac{r \cdot \sin b}{\cos a - \color{blue}{b \cdot \sin a}} \]
      6. sin-lowering-sin.f646.5

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

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

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

        \[\leadsto \color{blue}{r \cdot \sin b} \]
      2. sin-lowering-sin.f6411.4

        \[\leadsto r \cdot \color{blue}{\sin b} \]
    8. Simplified11.4%

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

    if -5.20000000000000018 < b < 0.68999999999999995

    1. Initial program 97.5%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{r \cdot \sin b}{\mathsf{fma}\left(0 - \sin b, \sin a, \color{blue}{\cos a} \cdot \cos b\right)} \]
      13. cos-lowering-cos.f6499.8

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{r \cdot \left(b \cdot \mathsf{fma}\left(b \cdot b, \color{blue}{\mathsf{fma}\left({b}^{2}, \frac{1}{120} + \frac{-1}{5040} \cdot {b}^{2}, \frac{-1}{6}\right)}, 1\right)\right)}{\mathsf{fma}\left(0 - \sin b, \sin a, \cos a \cdot \cos b\right)} \]
      9. unpow2N/A

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

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

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

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

        \[\leadsto \frac{r \cdot \left(b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b \cdot b, \color{blue}{\mathsf{fma}\left({b}^{2}, \frac{-1}{5040}, \frac{1}{120}\right)}, \frac{-1}{6}\right), 1\right)\right)}{\mathsf{fma}\left(0 - \sin b, \sin a, \cos a \cdot \cos b\right)} \]
      14. unpow2N/A

        \[\leadsto \frac{r \cdot \left(b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(\color{blue}{b \cdot b}, \frac{-1}{5040}, \frac{1}{120}\right), \frac{-1}{6}\right), 1\right)\right)}{\mathsf{fma}\left(0 - \sin b, \sin a, \cos a \cdot \cos b\right)} \]
      15. *-lowering-*.f6499.5

        \[\leadsto \frac{r \cdot \left(b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(\color{blue}{b \cdot b}, -0.0001984126984126984, 0.008333333333333333\right), -0.16666666666666666\right), 1\right)\right)}{\mathsf{fma}\left(0 - \sin b, \sin a, \cos a \cdot \cos b\right)} \]
    7. Simplified99.5%

      \[\leadsto \frac{r \cdot \color{blue}{\left(b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b \cdot b, -0.0001984126984126984, 0.008333333333333333\right), -0.16666666666666666\right), 1\right)\right)}}{\mathsf{fma}\left(0 - \sin b, \sin a, \cos a \cdot \cos b\right)} \]
    8. Step-by-step derivation
      1. associate-/l*N/A

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

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

        \[\leadsto \color{blue}{\frac{b \cdot \left(\left(b \cdot b\right) \cdot \left(\left(b \cdot b\right) \cdot \left(\left(b \cdot b\right) \cdot \frac{-1}{5040} + \frac{1}{120}\right) + \frac{-1}{6}\right) + 1\right)}{\left(0 - \sin b\right) \cdot \sin a + \cos a \cdot \cos b} \cdot r} \]
    9. Applied egg-rr97.4%

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

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

Alternative 8: 55.7% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := r \cdot \sin b\\ \mathbf{if}\;b \leq -4.6:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;b \leq 0.69:\\ \;\;\;\;\frac{r}{\cos \left(b + a\right)} \cdot \left(b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b \cdot b, -0.0001984126984126984, 0.008333333333333333\right), -0.16666666666666666\right), 1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (r a b)
 :precision binary64
 (let* ((t_0 (* r (sin b))))
   (if (<= b -4.6)
     t_0
     (if (<= b 0.69)
       (*
        (/ r (cos (+ b a)))
        (*
         b
         (fma
          (* b b)
          (fma
           (* b b)
           (fma (* b b) -0.0001984126984126984 0.008333333333333333)
           -0.16666666666666666)
          1.0)))
       t_0))))
double code(double r, double a, double b) {
	double t_0 = r * sin(b);
	double tmp;
	if (b <= -4.6) {
		tmp = t_0;
	} else if (b <= 0.69) {
		tmp = (r / cos((b + a))) * (b * fma((b * b), fma((b * b), fma((b * b), -0.0001984126984126984, 0.008333333333333333), -0.16666666666666666), 1.0));
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(r, a, b)
	t_0 = Float64(r * sin(b))
	tmp = 0.0
	if (b <= -4.6)
		tmp = t_0;
	elseif (b <= 0.69)
		tmp = Float64(Float64(r / cos(Float64(b + a))) * Float64(b * fma(Float64(b * b), fma(Float64(b * b), fma(Float64(b * b), -0.0001984126984126984, 0.008333333333333333), -0.16666666666666666), 1.0)));
	else
		tmp = t_0;
	end
	return tmp
end
code[r_, a_, b_] := Block[{t$95$0 = N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -4.6], t$95$0, If[LessEqual[b, 0.69], N[(N[(r / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(b * N[(N[(b * b), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] * -0.0001984126984126984 + 0.008333333333333333), $MachinePrecision] + -0.16666666666666666), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}

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

\mathbf{elif}\;b \leq 0.69:\\
\;\;\;\;\frac{r}{\cos \left(b + a\right)} \cdot \left(b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b \cdot b, -0.0001984126984126984, 0.008333333333333333\right), -0.16666666666666666\right), 1\right)\right)\\

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


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

    1. Initial program 49.5%

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

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

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

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

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

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

        \[\leadsto \frac{r \cdot \sin b}{\cos a - \color{blue}{b \cdot \sin a}} \]
      6. sin-lowering-sin.f646.5

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

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

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

        \[\leadsto \color{blue}{r \cdot \sin b} \]
      2. sin-lowering-sin.f6411.4

        \[\leadsto r \cdot \color{blue}{\sin b} \]
    8. Simplified11.4%

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

    if -4.5999999999999996 < b < 0.68999999999999995

    1. Initial program 97.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{r}{\cos \left(b + a\right)} \cdot \left(b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(\color{blue}{b \cdot b}, \frac{-1}{5040}, \frac{1}{120}\right), \frac{-1}{6}\right), 1\right)\right) \]
      15. *-lowering-*.f6497.4

        \[\leadsto \frac{r}{\cos \left(b + a\right)} \cdot \left(b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(\color{blue}{b \cdot b}, -0.0001984126984126984, 0.008333333333333333\right), -0.16666666666666666\right), 1\right)\right) \]
    7. Simplified97.4%

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

Alternative 9: 55.7% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := r \cdot \sin b\\ \mathbf{if}\;b \leq -4.2:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;b \leq 0.69:\\ \;\;\;\;r \cdot \frac{b \cdot \mathsf{fma}\left(b, b \cdot \mathsf{fma}\left(b \cdot b, 0.008333333333333333, -0.16666666666666666\right), 1\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 -4.2)
     t_0
     (if (<= b 0.69)
       (*
        r
        (/
         (*
          b
          (fma
           b
           (* b (fma (* b b) 0.008333333333333333 -0.16666666666666666))
           1.0))
         (cos (+ b a))))
       t_0))))
double code(double r, double a, double b) {
	double t_0 = r * sin(b);
	double tmp;
	if (b <= -4.2) {
		tmp = t_0;
	} else if (b <= 0.69) {
		tmp = r * ((b * fma(b, (b * fma((b * b), 0.008333333333333333, -0.16666666666666666)), 1.0)) / 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 <= -4.2)
		tmp = t_0;
	elseif (b <= 0.69)
		tmp = Float64(r * Float64(Float64(b * fma(b, Float64(b * fma(Float64(b * b), 0.008333333333333333, -0.16666666666666666)), 1.0)) / cos(Float64(b + a))));
	else
		tmp = t_0;
	end
	return tmp
end
code[r_, a_, b_] := Block[{t$95$0 = N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -4.2], t$95$0, If[LessEqual[b, 0.69], N[(r * N[(N[(b * N[(b * N[(b * N[(N[(b * b), $MachinePrecision] * 0.008333333333333333 + -0.16666666666666666), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}

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

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

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


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

    1. Initial program 49.5%

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

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

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

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

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

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

        \[\leadsto \frac{r \cdot \sin b}{\cos a - \color{blue}{b \cdot \sin a}} \]
      6. sin-lowering-sin.f646.5

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

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

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

        \[\leadsto \color{blue}{r \cdot \sin b} \]
      2. sin-lowering-sin.f6411.4

        \[\leadsto r \cdot \color{blue}{\sin b} \]
    8. Simplified11.4%

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

    if -4.20000000000000018 < b < 0.68999999999999995

    1. Initial program 97.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{r}{\cos \left(b + a\right)} \cdot \left(b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b, \color{blue}{b \cdot \frac{1}{120}}, \frac{-1}{6}\right), 1\right)\right) \]
      14. *-lowering-*.f6497.2

        \[\leadsto \frac{r}{\cos \left(b + a\right)} \cdot \left(b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b, \color{blue}{b \cdot 0.008333333333333333}, -0.16666666666666666\right), 1\right)\right) \]
    7. Simplified97.2%

      \[\leadsto \frac{r}{\cos \left(b + a\right)} \cdot \color{blue}{\left(b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b, b \cdot 0.008333333333333333, -0.16666666666666666\right), 1\right)\right)} \]
    8. Step-by-step derivation
      1. associate-*l/N/A

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto r \cdot \frac{b \cdot \mathsf{fma}\left(b, b \cdot \mathsf{fma}\left(b \cdot b, \frac{1}{120}, \frac{-1}{6}\right), 1\right)}{\color{blue}{\cos \left(b + a\right)}} \]
      13. +-lowering-+.f6497.2

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

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

Alternative 10: 55.7% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := r \cdot \sin b\\ \mathbf{if}\;b \leq -3.5:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;b \leq 0.69:\\ \;\;\;\;\frac{r}{\cos \left(b + a\right)} \cdot \left(b \cdot \mathsf{fma}\left(b, b \cdot -0.16666666666666666, 1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (r a b)
 :precision binary64
 (let* ((t_0 (* r (sin b))))
   (if (<= b -3.5)
     t_0
     (if (<= b 0.69)
       (* (/ r (cos (+ b a))) (* b (fma b (* b -0.16666666666666666) 1.0)))
       t_0))))
double code(double r, double a, double b) {
	double t_0 = r * sin(b);
	double tmp;
	if (b <= -3.5) {
		tmp = t_0;
	} else if (b <= 0.69) {
		tmp = (r / cos((b + a))) * (b * fma(b, (b * -0.16666666666666666), 1.0));
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(r, a, b)
	t_0 = Float64(r * sin(b))
	tmp = 0.0
	if (b <= -3.5)
		tmp = t_0;
	elseif (b <= 0.69)
		tmp = Float64(Float64(r / cos(Float64(b + a))) * Float64(b * fma(b, Float64(b * -0.16666666666666666), 1.0)));
	else
		tmp = t_0;
	end
	return tmp
end
code[r_, a_, b_] := Block[{t$95$0 = N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -3.5], t$95$0, If[LessEqual[b, 0.69], N[(N[(r / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(b * N[(b * N[(b * -0.16666666666666666), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}

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

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

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


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

    1. Initial program 49.5%

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

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

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

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

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

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

        \[\leadsto \frac{r \cdot \sin b}{\cos a - \color{blue}{b \cdot \sin a}} \]
      6. sin-lowering-sin.f646.5

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

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

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

        \[\leadsto \color{blue}{r \cdot \sin b} \]
      2. sin-lowering-sin.f6411.4

        \[\leadsto r \cdot \color{blue}{\sin b} \]
    8. Simplified11.4%

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

    if -3.5 < b < 0.68999999999999995

    1. Initial program 97.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{r}{\cos \left(b + a\right)} \cdot \left(b \cdot \mathsf{fma}\left(b, \color{blue}{b \cdot \frac{-1}{6}}, 1\right)\right) \]
      9. *-lowering-*.f6496.8

        \[\leadsto \frac{r}{\cos \left(b + a\right)} \cdot \left(b \cdot \mathsf{fma}\left(b, \color{blue}{b \cdot -0.16666666666666666}, 1\right)\right) \]
    7. Simplified96.8%

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

Alternative 11: 53.4% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.5:\\
\;\;\;\;r \cdot \sin b\\

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


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

    1. Initial program 56.0%

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

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

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

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

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

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

        \[\leadsto \frac{r \cdot \sin b}{\cos a - \color{blue}{b \cdot \sin a}} \]
      6. sin-lowering-sin.f646.5

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

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

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

        \[\leadsto \color{blue}{r \cdot \sin b} \]
      2. sin-lowering-sin.f6412.2

        \[\leadsto r \cdot \color{blue}{\sin b} \]
    8. Simplified12.2%

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

    if -4.5 < b

    1. Initial program 80.5%

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

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

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

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

        \[\leadsto \frac{\color{blue}{r \cdot b}}{\cos a} \]
      4. cos-lowering-cos.f6468.0

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

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

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

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

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

        \[\leadsto b \cdot \color{blue}{\frac{r}{\cos a}} \]
      5. cos-lowering-cos.f6468.1

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

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

Alternative 12: 39.1% accurate, 2.1× 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 74.1%

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

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

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

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

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

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

      \[\leadsto \frac{r \cdot \sin b}{\cos a - \color{blue}{b \cdot \sin a}} \]
    6. sin-lowering-sin.f6453.0

      \[\leadsto \frac{r \cdot \sin b}{\cos a - b \cdot \color{blue}{\sin a}} \]
  5. Simplified53.0%

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

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

      \[\leadsto \color{blue}{r \cdot \sin b} \]
    2. sin-lowering-sin.f6439.5

      \[\leadsto r \cdot \color{blue}{\sin b} \]
  8. Simplified39.5%

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

Alternative 13: 35.4% accurate, 6.7× speedup?

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

\\
b \cdot \left(r \cdot \frac{1}{\mathsf{fma}\left(b, b \cdot -0.5, 1\right)}\right)
\end{array}
Derivation
  1. Initial program 74.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{r \cdot \sin b}{\mathsf{fma}\left(b, \mathsf{fma}\left(b, \cos a \cdot \frac{-1}{2}, 0\right) - \color{blue}{\sin a}, \cos a\right)} \]
    13. cos-lowering-cos.f6452.5

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

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

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

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

      \[\leadsto \color{blue}{\frac{b \cdot r}{1 + \frac{-1}{2} \cdot {b}^{2}}} \]
    3. Step-by-step derivation
      1. associate-/l*N/A

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

        \[\leadsto \color{blue}{b \cdot \frac{r}{1 + \frac{-1}{2} \cdot {b}^{2}}} \]
      3. /-lowering-/.f64N/A

        \[\leadsto b \cdot \color{blue}{\frac{r}{1 + \frac{-1}{2} \cdot {b}^{2}}} \]
      4. +-commutativeN/A

        \[\leadsto b \cdot \frac{r}{\color{blue}{\frac{-1}{2} \cdot {b}^{2} + 1}} \]
      5. *-commutativeN/A

        \[\leadsto b \cdot \frac{r}{\color{blue}{{b}^{2} \cdot \frac{-1}{2}} + 1} \]
      6. unpow2N/A

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

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

        \[\leadsto b \cdot \frac{r}{b \cdot \color{blue}{\left(\frac{-1}{2} \cdot b\right)} + 1} \]
      9. accelerator-lowering-fma.f64N/A

        \[\leadsto b \cdot \frac{r}{\color{blue}{\mathsf{fma}\left(b, \frac{-1}{2} \cdot b, 1\right)}} \]
      10. *-commutativeN/A

        \[\leadsto b \cdot \frac{r}{\mathsf{fma}\left(b, \color{blue}{b \cdot \frac{-1}{2}}, 1\right)} \]
      11. *-lowering-*.f6436.1

        \[\leadsto b \cdot \frac{r}{\mathsf{fma}\left(b, \color{blue}{b \cdot -0.5}, 1\right)} \]
    4. Simplified36.1%

      \[\leadsto \color{blue}{b \cdot \frac{r}{\mathsf{fma}\left(b, b \cdot -0.5, 1\right)}} \]
    5. Step-by-step derivation
      1. clear-numN/A

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

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

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

        \[\leadsto b \cdot \left(\color{blue}{\frac{1}{b \cdot \left(b \cdot \frac{-1}{2}\right) + 1}} \cdot r\right) \]
      5. accelerator-lowering-fma.f64N/A

        \[\leadsto b \cdot \left(\frac{1}{\color{blue}{\mathsf{fma}\left(b, b \cdot \frac{-1}{2}, 1\right)}} \cdot r\right) \]
      6. *-lowering-*.f6436.1

        \[\leadsto b \cdot \left(\frac{1}{\mathsf{fma}\left(b, \color{blue}{b \cdot -0.5}, 1\right)} \cdot r\right) \]
    6. Applied egg-rr36.1%

      \[\leadsto b \cdot \color{blue}{\left(\frac{1}{\mathsf{fma}\left(b, b \cdot -0.5, 1\right)} \cdot r\right)} \]
    7. Final simplification36.1%

      \[\leadsto b \cdot \left(r \cdot \frac{1}{\mathsf{fma}\left(b, b \cdot -0.5, 1\right)}\right) \]
    8. Add Preprocessing

    Alternative 14: 35.4% accurate, 7.9× speedup?

    \[\begin{array}{l} \\ b \cdot \frac{r}{\mathsf{fma}\left(b, b \cdot -0.5, 1\right)} \end{array} \]
    (FPCore (r a b) :precision binary64 (* b (/ r (fma b (* b -0.5) 1.0))))
    double code(double r, double a, double b) {
    	return b * (r / fma(b, (b * -0.5), 1.0));
    }
    
    function code(r, a, b)
    	return Float64(b * Float64(r / fma(b, Float64(b * -0.5), 1.0)))
    end
    
    code[r_, a_, b_] := N[(b * N[(r / N[(b * N[(b * -0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    b \cdot \frac{r}{\mathsf{fma}\left(b, b \cdot -0.5, 1\right)}
    \end{array}
    
    Derivation
    1. Initial program 74.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{r \cdot \sin b}{\mathsf{fma}\left(b, \mathsf{fma}\left(b, \cos a \cdot \frac{-1}{2}, 0\right) - \color{blue}{\sin a}, \cos a\right)} \]
      13. cos-lowering-cos.f6452.5

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

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

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

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

        \[\leadsto \color{blue}{\frac{b \cdot r}{1 + \frac{-1}{2} \cdot {b}^{2}}} \]
      3. Step-by-step derivation
        1. associate-/l*N/A

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

          \[\leadsto \color{blue}{b \cdot \frac{r}{1 + \frac{-1}{2} \cdot {b}^{2}}} \]
        3. /-lowering-/.f64N/A

          \[\leadsto b \cdot \color{blue}{\frac{r}{1 + \frac{-1}{2} \cdot {b}^{2}}} \]
        4. +-commutativeN/A

          \[\leadsto b \cdot \frac{r}{\color{blue}{\frac{-1}{2} \cdot {b}^{2} + 1}} \]
        5. *-commutativeN/A

          \[\leadsto b \cdot \frac{r}{\color{blue}{{b}^{2} \cdot \frac{-1}{2}} + 1} \]
        6. unpow2N/A

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

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

          \[\leadsto b \cdot \frac{r}{b \cdot \color{blue}{\left(\frac{-1}{2} \cdot b\right)} + 1} \]
        9. accelerator-lowering-fma.f64N/A

          \[\leadsto b \cdot \frac{r}{\color{blue}{\mathsf{fma}\left(b, \frac{-1}{2} \cdot b, 1\right)}} \]
        10. *-commutativeN/A

          \[\leadsto b \cdot \frac{r}{\mathsf{fma}\left(b, \color{blue}{b \cdot \frac{-1}{2}}, 1\right)} \]
        11. *-lowering-*.f6436.1

          \[\leadsto b \cdot \frac{r}{\mathsf{fma}\left(b, \color{blue}{b \cdot -0.5}, 1\right)} \]
      4. Simplified36.1%

        \[\leadsto \color{blue}{b \cdot \frac{r}{\mathsf{fma}\left(b, b \cdot -0.5, 1\right)}} \]
      5. Add Preprocessing

      Alternative 15: 35.0% accurate, 36.7× 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 74.1%

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

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

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

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

          \[\leadsto \frac{\color{blue}{r \cdot b}}{\cos a} \]
        4. cos-lowering-cos.f6451.2

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

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

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

          \[\leadsto \color{blue}{r \cdot b} \]
        2. *-lowering-*.f6436.0

          \[\leadsto \color{blue}{r \cdot b} \]
      8. Simplified36.0%

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

      Reproduce

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