?

Average Error: 15.3 → 15.3
Time: 26.7s
Precision: binary64
Cost: 13384

?

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

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

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Split input into 3 regimes
  2. if a < -6.99999999999999993e-4

    1. Initial program 29.2

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

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

      [Start]29.2

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

      rational.json-simplify-2 [=>]29.2

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

      rational.json-simplify-49 [=>]29.2

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

      rational.json-simplify-1 [=>]29.2

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

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

    if -6.99999999999999993e-4 < a < 0.00154999999999999995

    1. Initial program 0.6

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

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

      [Start]0.6

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

      rational.json-simplify-2 [=>]0.6

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

      rational.json-simplify-49 [=>]0.6

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

      rational.json-simplify-1 [=>]0.6

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

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

    if 0.00154999999999999995 < a

    1. Initial program 30.0

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

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

      [Start]30.0

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

      rational.json-simplify-2 [=>]30.0

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

      rational.json-simplify-49 [=>]30.0

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

      rational.json-simplify-1 [=>]30.0

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

      \[\leadsto r \cdot \frac{\sin b}{\color{blue}{\cos a}} \]
    4. Applied egg-rr30.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -0.0007:\\ \;\;\;\;r \cdot \frac{\sin b}{\cos a}\\ \mathbf{elif}\;a \leq 0.00155:\\ \;\;\;\;\frac{\sin b \cdot r}{\cos b}\\ \mathbf{else}:\\ \;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\ \end{array} \]

Alternatives

Alternative 1
Error15.3
Cost13384
\[\begin{array}{l} t_0 := r \cdot \frac{\sin b}{\cos a}\\ \mathbf{if}\;a \leq -0.000175:\\ \;\;\;\;t_0\\ \mathbf{elif}\;a \leq 0.00055:\\ \;\;\;\;r \cdot \frac{\sin b}{\cos b}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error15.3
Cost13384
\[\begin{array}{l} \mathbf{if}\;a \leq -0.00072:\\ \;\;\;\;r \cdot \frac{\sin b}{\cos a}\\ \mathbf{elif}\;a \leq 0.005:\\ \;\;\;\;r \cdot \frac{\sin b}{\cos b}\\ \mathbf{else}:\\ \;\;\;\;\sin b \cdot \frac{r}{\cos a}\\ \end{array} \]
Alternative 3
Error15.3
Cost13384
\[\begin{array}{l} \mathbf{if}\;a \leq -0.000116:\\ \;\;\;\;r \cdot \frac{\sin b}{\cos a}\\ \mathbf{elif}\;a \leq 0.00025:\\ \;\;\;\;\sin b \cdot \frac{r}{\cos b}\\ \mathbf{else}:\\ \;\;\;\;\sin b \cdot \frac{r}{\cos a}\\ \end{array} \]
Alternative 4
Error15.3
Cost13384
\[\begin{array}{l} \mathbf{if}\;a \leq -9.2 \cdot 10^{-5}:\\ \;\;\;\;r \cdot \frac{\sin b}{\cos a}\\ \mathbf{elif}\;a \leq 0.000175:\\ \;\;\;\;\sin b \cdot \frac{r}{\cos b}\\ \mathbf{else}:\\ \;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\ \end{array} \]
Alternative 5
Error15.3
Cost13248
\[\sin b \cdot \frac{r}{\cos \left(b + a\right)} \]
Alternative 6
Error15.3
Cost13248
\[r \cdot \frac{\sin b}{\cos \left(b + a\right)} \]
Alternative 7
Error29.1
Cost13120
\[r \cdot \frac{\sin b}{\cos a} \]
Alternative 8
Error29.3
Cost6984
\[\begin{array}{l} t_0 := \sin b \cdot r\\ \mathbf{if}\;b \leq -2.3 \cdot 10^{+44}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;b \leq 1.15:\\ \;\;\;\;b \cdot \frac{r}{\cos a}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 9
Error39.5
Cost6592
\[\sin b \cdot r \]
Alternative 10
Error42.4
Cost192
\[r \cdot b \]

Error

Reproduce?

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