| Alternative 1 | |
|---|---|
| Error | 0.3 |
| Cost | 32704 |
\[\sin b \cdot \frac{r}{\cos b \cdot \cos a - \sin b \cdot \sin a}
\]
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (cos (+ a b))))
(FPCore (r a b)
:precision binary64
(*
(sin b)
(/
r
(-
(* (cos b) (* (cos a) 2.0))
(+ (* (sin b) (sin a)) (* (cos b) (cos 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 sin(b) * (r / ((cos(b) * (cos(a) * 2.0)) - ((sin(b) * sin(a)) + (cos(b) * 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 = (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 = sin(b) * (r / ((cos(b) * (cos(a) * 2.0d0)) - ((sin(b) * sin(a)) + (cos(b) * cos(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 Math.sin(b) * (r / ((Math.cos(b) * (Math.cos(a) * 2.0)) - ((Math.sin(b) * Math.sin(a)) + (Math.cos(b) * Math.cos(a)))));
}
def code(r, a, b): return (r * math.sin(b)) / math.cos((a + b))
def code(r, a, b): return math.sin(b) * (r / ((math.cos(b) * (math.cos(a) * 2.0)) - ((math.sin(b) * math.sin(a)) + (math.cos(b) * math.cos(a)))))
function code(r, a, b) return Float64(Float64(r * sin(b)) / cos(Float64(a + b))) end
function code(r, a, b) return Float64(sin(b) * Float64(r / Float64(Float64(cos(b) * Float64(cos(a) * 2.0)) - Float64(Float64(sin(b) * sin(a)) + Float64(cos(b) * cos(a)))))) end
function tmp = code(r, a, b) tmp = (r * sin(b)) / cos((a + b)); end
function tmp = code(r, a, b) tmp = sin(b) * (r / ((cos(b) * (cos(a) * 2.0)) - ((sin(b) * sin(a)) + (cos(b) * cos(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[(N[Sin[b], $MachinePrecision] * N[(r / N[(N[(N[Cos[b], $MachinePrecision] * N[(N[Cos[a], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{r \cdot \sin b}{\cos \left(a + b\right)}
\sin b \cdot \frac{r}{\cos b \cdot \left(\cos a \cdot 2\right) - \left(\sin b \cdot \sin a + \cos b \cdot \cos a\right)}
Results
Initial program 15.5
Simplified15.5
[Start]15.5 | \[ \frac{r \cdot \sin b}{\cos \left(a + b\right)}
\] |
|---|---|
rational_best-simplify-3 [=>]15.5 | \[ \frac{r \cdot \sin b}{\cos \color{blue}{\left(b + a\right)}}
\] |
Applied egg-rr0.3
Taylor expanded in r around 0 0.3
Simplified15.5
[Start]0.3 | \[ \frac{\sin b \cdot r}{\cos a \cdot \cos b - \sin a \cdot \sin b}
\] |
|---|---|
rational_best-simplify-1 [=>]0.3 | \[ \frac{\color{blue}{r \cdot \sin b}}{\cos a \cdot \cos b - \sin a \cdot \sin b}
\] |
trig-simplify-14 [=>]15.5 | \[ \frac{r \cdot \sin b}{\color{blue}{\cos \left(a + b\right)}}
\] |
rational_best-simplify-3 [<=]15.5 | \[ \frac{r \cdot \sin b}{\cos \color{blue}{\left(b + a\right)}}
\] |
rational_best-simplify-8 [<=]15.5 | \[ \frac{r \cdot \sin b}{\color{blue}{\frac{\cos \left(b + a\right)}{1}}}
\] |
metadata-eval [<=]15.5 | \[ \frac{r \cdot \sin b}{\frac{\cos \left(b + a\right)}{\color{blue}{-1 \cdot -1}}}
\] |
rational_best-simplify-53 [<=]15.5 | \[ \frac{r \cdot \sin b}{\color{blue}{\frac{\frac{\cos \left(b + a\right)}{-1}}{-1}}}
\] |
rational_best-simplify-13 [<=]15.5 | \[ \frac{r \cdot \sin b}{\frac{\color{blue}{-\cos \left(b + a\right)}}{-1}}
\] |
rational_best-simplify-12 [=>]15.5 | \[ \frac{r \cdot \sin b}{\color{blue}{-\left(-\cos \left(b + a\right)\right)}}
\] |
rational_best-simplify-61 [<=]15.5 | \[ \color{blue}{\left(-r\right) \cdot \frac{\sin b}{-\cos \left(b + a\right)}}
\] |
rational_best-simplify-55 [=>]15.5 | \[ \color{blue}{\sin b \cdot \frac{-r}{-\cos \left(b + a\right)}}
\] |
rational_best-simplify-14 [=>]15.5 | \[ \sin b \cdot \frac{\color{blue}{0 - r}}{-\cos \left(b + a\right)}
\] |
rational_best-simplify-58 [=>]15.5 | \[ \sin b \cdot \color{blue}{\frac{r - 0}{\cos \left(b + a\right)}}
\] |
rational_best-simplify-9 [=>]15.5 | \[ \sin b \cdot \frac{\color{blue}{r}}{\cos \left(b + a\right)}
\] |
Applied egg-rr0.4
Final simplification0.4
| Alternative 1 | |
|---|---|
| Error | 0.3 |
| Cost | 32704 |
| Alternative 2 | |
|---|---|
| Error | 14.9 |
| Cost | 26496 |
| Alternative 3 | |
|---|---|
| Error | 15.6 |
| Cost | 13384 |
| Alternative 4 | |
|---|---|
| Error | 15.6 |
| Cost | 13384 |
| Alternative 5 | |
|---|---|
| Error | 15.5 |
| Cost | 13248 |
| Alternative 6 | |
|---|---|
| Error | 15.5 |
| Cost | 13248 |
| Alternative 7 | |
|---|---|
| Error | 29.2 |
| Cost | 13120 |
| Alternative 8 | |
|---|---|
| Error | 29.2 |
| Cost | 7112 |
| Alternative 9 | |
|---|---|
| Error | 29.2 |
| Cost | 6984 |
| Alternative 10 | |
|---|---|
| Error | 39.2 |
| Cost | 6592 |
| Alternative 11 | |
|---|---|
| Error | 42.1 |
| Cost | 192 |
herbie shell --seed 2023099
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))