rsin A (should all be same)

Percentage Accurate: 76.3% → 99.5%
Time: 13.5s
Alternatives: 9
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 9 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.3% accurate, 1.0× speedup?

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

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

Alternative 1: 99.5% accurate, 0.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(r, \mathsf{sin.f64}\left(b\right)\right), \mathsf{fma.f64}\left(\mathsf{cos.f64}\left(b\right), \mathsf{cos.f64}\left(a\right), \left(\sin b \cdot \left(0 - \sin a\right)\right)\right)\right) \]
    5. sub0-negN/A

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

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

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

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

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

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

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

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

Alternative 2: 99.5% accurate, 0.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 99.5% accurate, 0.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 76.1% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{-6}:\\
\;\;\;\;r \cdot \tan b\\

\mathbf{elif}\;b \leq 6.8 \cdot 10^{-9}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\

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


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

    1. Initial program 53.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(r, \tan b\right) \]
      5. tan-lowering-tan.f6454.7%

        \[\leadsto \mathsf{*.f64}\left(r, \mathsf{tan.f64}\left(b\right)\right) \]
    11. Applied egg-rr54.7%

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

    if -1.99999999999999991e-6 < b < 6.7999999999999997e-9

    1. Initial program 99.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.7999999999999997e-9 < b

    1. Initial program 65.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 76.3% accurate, 1.0× speedup?

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

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

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

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

Alternative 6: 76.3% 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 80.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 76.1% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
t_0 := r \cdot \tan b\\
\mathbf{if}\;b \leq -1.1 \cdot 10^{-6}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;b \leq 6.8 \cdot 10^{-9}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -1.1000000000000001e-6 or 6.7999999999999997e-9 < b

    1. Initial program 59.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(r, \tan b\right) \]
      5. tan-lowering-tan.f6460.3%

        \[\leadsto \mathsf{*.f64}\left(r, \mathsf{tan.f64}\left(b\right)\right) \]
    11. Applied egg-rr60.3%

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

    if -1.1000000000000001e-6 < b < 6.7999999999999997e-9

    1. Initial program 99.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 59.9% accurate, 2.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(r, \tan b\right) \]
    5. tan-lowering-tan.f6463.7%

      \[\leadsto \mathsf{*.f64}\left(r, \mathsf{tan.f64}\left(b\right)\right) \]
  11. Applied egg-rr63.7%

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

Alternative 9: 34.9% accurate, 69.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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