| Alternative 1 | |
|---|---|
| Error | 0.8 |
| Cost | 7232 |
\[\frac{e \cdot \left(\sin v \cdot \left(1 - e\right)\right)}{1 - e \cdot e}
\]
(FPCore (e v) :precision binary64 (/ (* e (sin v)) (+ 1.0 (* e (cos v)))))
(FPCore (e v) :precision binary64 (* e (/ (sin v) (+ 1.0 (* (cos v) e)))))
double code(double e, double v) {
return (e * sin(v)) / (1.0 + (e * cos(v)));
}
double code(double e, double v) {
return e * (sin(v) / (1.0 + (cos(v) * e)));
}
real(8) function code(e, v)
real(8), intent (in) :: e
real(8), intent (in) :: v
code = (e * sin(v)) / (1.0d0 + (e * cos(v)))
end function
real(8) function code(e, v)
real(8), intent (in) :: e
real(8), intent (in) :: v
code = e * (sin(v) / (1.0d0 + (cos(v) * e)))
end function
public static double code(double e, double v) {
return (e * Math.sin(v)) / (1.0 + (e * Math.cos(v)));
}
public static double code(double e, double v) {
return e * (Math.sin(v) / (1.0 + (Math.cos(v) * e)));
}
def code(e, v): return (e * math.sin(v)) / (1.0 + (e * math.cos(v)))
def code(e, v): return e * (math.sin(v) / (1.0 + (math.cos(v) * e)))
function code(e, v) return Float64(Float64(e * sin(v)) / Float64(1.0 + Float64(e * cos(v)))) end
function code(e, v) return Float64(e * Float64(sin(v) / Float64(1.0 + Float64(cos(v) * e)))) end
function tmp = code(e, v) tmp = (e * sin(v)) / (1.0 + (e * cos(v))); end
function tmp = code(e, v) tmp = e * (sin(v) / (1.0 + (cos(v) * e))); end
code[e_, v_] := N[(N[(e * N[Sin[v], $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(e * N[Cos[v], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[e_, v_] := N[(e * N[(N[Sin[v], $MachinePrecision] / N[(1.0 + N[(N[Cos[v], $MachinePrecision] * e), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{e \cdot \sin v}{1 + e \cdot \cos v}
e \cdot \frac{\sin v}{1 + \cos v \cdot e}
Results
Initial program 0.1
Simplified0.1
[Start]0.1 | \[ \frac{e \cdot \sin v}{1 + e \cdot \cos v}
\] |
|---|---|
associate-*r/ [<=]0.1 | \[ \color{blue}{e \cdot \frac{\sin v}{1 + e \cdot \cos v}}
\] |
*-commutative [<=]0.1 | \[ \color{blue}{\frac{\sin v}{1 + e \cdot \cos v} \cdot e}
\] |
+-commutative [=>]0.1 | \[ \frac{\sin v}{\color{blue}{e \cdot \cos v + 1}} \cdot e
\] |
fma-def [=>]0.1 | \[ \frac{\sin v}{\color{blue}{\mathsf{fma}\left(e, \cos v, 1\right)}} \cdot e
\] |
Taylor expanded in v around inf 0.1
Final simplification0.1
| Alternative 1 | |
|---|---|
| Error | 0.8 |
| Cost | 7232 |
| Alternative 2 | |
|---|---|
| Error | 1.1 |
| Cost | 6848 |
| Alternative 3 | |
|---|---|
| Error | 0.9 |
| Cost | 6848 |
| Alternative 4 | |
|---|---|
| Error | 1.4 |
| Cost | 6592 |
| Alternative 5 | |
|---|---|
| Error | 30.1 |
| Cost | 1344 |
| Alternative 6 | |
|---|---|
| Error | 30.7 |
| Cost | 576 |
| Alternative 7 | |
|---|---|
| Error | 30.8 |
| Cost | 448 |
| Alternative 8 | |
|---|---|
| Error | 31.4 |
| Cost | 192 |
| Alternative 9 | |
|---|---|
| Error | 61.1 |
| Cost | 64 |
herbie shell --seed 2023056
(FPCore (e v)
:name "Trigonometry A"
:precision binary64
:pre (and (<= 0.0 e) (<= e 1.0))
(/ (* e (sin v)) (+ 1.0 (* e (cos v)))))