?

Average Error: 15.0 → 0.4
Time: 13.9s
Precision: binary64
Cost: 19648

?

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

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 15.0

    \[\frac{r \cdot \sin b}{\cos \left(a + b\right)} \]
  2. Simplified15.1

    \[\leadsto \color{blue}{\frac{r}{\frac{\cos \left(b + a\right)}{\sin b}}} \]
    Proof

    [Start]15.0

    \[ \frac{r \cdot \sin b}{\cos \left(a + b\right)} \]

    associate-/l* [=>]15.1

    \[ \color{blue}{\frac{r}{\frac{\cos \left(a + b\right)}{\sin b}}} \]

    +-commutative [=>]15.1

    \[ \frac{r}{\frac{\cos \color{blue}{\left(b + a\right)}}{\sin b}} \]
  3. Applied egg-rr0.4

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

    \[\leadsto \frac{r}{\color{blue}{\mathsf{fma}\left(\frac{\cos b}{\sin b}, \cos a, -\sin a\right)}} \]
    Proof

    [Start]0.4

    \[ \frac{r}{\frac{1}{\sin b} \cdot \left(\cos b \cdot \cos a\right) + \frac{1}{\sin b} \cdot \left(\left(-\sin b\right) \cdot \sin a\right)} \]

    distribute-lft-neg-in [<=]0.4

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

    associate-*l/ [=>]0.4

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

    *-lft-identity [=>]0.4

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

    associate-*l/ [<=]0.4

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

    fma-def [=>]0.4

    \[ \frac{r}{\color{blue}{\mathsf{fma}\left(\frac{\cos b}{\sin b}, \cos a, \frac{1}{\sin b} \cdot \left(-\sin b \cdot \sin a\right)\right)}} \]

    associate-*l/ [=>]0.4

    \[ \frac{r}{\mathsf{fma}\left(\frac{\cos b}{\sin b}, \cos a, \color{blue}{\frac{1 \cdot \left(-\sin b \cdot \sin a\right)}{\sin b}}\right)} \]

    *-lft-identity [=>]0.4

    \[ \frac{r}{\mathsf{fma}\left(\frac{\cos b}{\sin b}, \cos a, \frac{\color{blue}{-\sin b \cdot \sin a}}{\sin b}\right)} \]

    distribute-frac-neg [=>]0.4

    \[ \frac{r}{\mathsf{fma}\left(\frac{\cos b}{\sin b}, \cos a, \color{blue}{-\frac{\sin b \cdot \sin a}{\sin b}}\right)} \]

    associate-*l/ [<=]0.4

    \[ \frac{r}{\mathsf{fma}\left(\frac{\cos b}{\sin b}, \cos a, -\color{blue}{\frac{\sin b}{\sin b} \cdot \sin a}\right)} \]

    distribute-lft-neg-in [=>]0.4

    \[ \frac{r}{\mathsf{fma}\left(\frac{\cos b}{\sin b}, \cos a, \color{blue}{\left(-\frac{\sin b}{\sin b}\right) \cdot \sin a}\right)} \]

    *-inverses [=>]0.4

    \[ \frac{r}{\mathsf{fma}\left(\frac{\cos b}{\sin b}, \cos a, \left(-\color{blue}{1}\right) \cdot \sin a\right)} \]

    metadata-eval [=>]0.4

    \[ \frac{r}{\mathsf{fma}\left(\frac{\cos b}{\sin b}, \cos a, \color{blue}{-1} \cdot \sin a\right)} \]

    mul-1-neg [=>]0.4

    \[ \frac{r}{\mathsf{fma}\left(\frac{\cos b}{\sin b}, \cos a, \color{blue}{-\sin a}\right)} \]
  5. Applied egg-rr0.4

    \[\leadsto \frac{r}{\color{blue}{0 - \left(\sin a - \frac{\cos a}{\tan b}\right)}} \]
  6. Simplified0.4

    \[\leadsto \frac{r}{\color{blue}{\frac{\cos a}{\tan b} - \sin a}} \]
    Proof

    [Start]0.4

    \[ \frac{r}{0 - \left(\sin a - \frac{\cos a}{\tan b}\right)} \]

    associate--r- [=>]0.4

    \[ \frac{r}{\color{blue}{\left(0 - \sin a\right) + \frac{\cos a}{\tan b}}} \]

    +-commutative [=>]0.4

    \[ \frac{r}{\color{blue}{\frac{\cos a}{\tan b} + \left(0 - \sin a\right)}} \]

    sub0-neg [=>]0.4

    \[ \frac{r}{\frac{\cos a}{\tan b} + \color{blue}{\left(-\sin a\right)}} \]

    sub-neg [<=]0.4

    \[ \frac{r}{\color{blue}{\frac{\cos a}{\tan b} - \sin a}} \]
  7. Final simplification0.4

    \[\leadsto \frac{r}{\frac{\cos a}{\tan b} - \sin a} \]

Alternatives

Alternative 1
Error15.0
Cost13385
\[\begin{array}{l} \mathbf{if}\;a \leq -0.18 \lor \neg \left(a \leq 0.0016\right):\\ \;\;\;\;\sin b \cdot \frac{r}{\cos a}\\ \mathbf{else}:\\ \;\;\;\;\frac{r}{\frac{1}{\tan b} - a}\\ \end{array} \]
Alternative 2
Error15.0
Cost13384
\[\begin{array}{l} \mathbf{if}\;a \leq -0.18:\\ \;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\ \mathbf{elif}\;a \leq 0.025:\\ \;\;\;\;\frac{r}{\frac{1}{\tan b} - a}\\ \mathbf{else}:\\ \;\;\;\;\sin b \cdot \frac{r}{\cos a}\\ \end{array} \]
Alternative 3
Error15.1
Cost13248
\[\frac{r}{\cos \left(a + b\right)} \cdot \sin b \]
Alternative 4
Error16.1
Cost7113
\[\begin{array}{l} \mathbf{if}\;b \leq -2.15 \cdot 10^{-8} \lor \neg \left(b \leq 0.0024\right):\\ \;\;\;\;\frac{r}{\frac{1}{\tan b} - a}\\ \mathbf{else}:\\ \;\;\;\;b \cdot \frac{r}{\cos a}\\ \end{array} \]
Alternative 5
Error30.7
Cost6852
\[\begin{array}{l} \mathbf{if}\;b \leq 0.56:\\ \;\;\;\;b \cdot \frac{r}{\cos a}\\ \mathbf{else}:\\ \;\;\;\;r \cdot \sin b\\ \end{array} \]
Alternative 6
Error32.1
Cost6720
\[r \cdot \frac{b}{\cos a} \]
Alternative 7
Error32.2
Cost6720
\[b \cdot \frac{r}{\cos a} \]
Alternative 8
Error41.9
Cost576
\[\frac{r}{b \cdot -0.3333333333333333 + \frac{1}{b}} \]
Alternative 9
Error42.5
Cost192
\[r \cdot b \]

Error

Reproduce?

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