{'fraction_non_alphanumeric': 0.02756440063238166, 'fraction_numerical': 0.012554635915558448, 'mean_word_length': 4.5400309119010815, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 2, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Stream-orbit misalignment II: A new algorithm to constrain the Galactic potential

In the first of these two papers we demonstrated that assuming streams delineate orbits can lead to order one errors in potential parameters for realistic Galactic potentials. Motivated by the need for an improvement on orbit-fitting, we now present an algorithm for constraining the Galactic potential using tidal streams without assuming that streams delineate orbits. This approach is independent of the progenitor mass so is valid for all observed tidal streams. The method makes heavy use of angle-action variables and seeks the potential which recovers the expected correlations in angle space. We demonstrate that the method can correctly recover the parameters of a simple two-parameter logarithmic potential by analysing an N-body simulation of a stream. We investigate the magnitude of the errors in observational data for which the method can still recover the correct potential and compare this to current and future errors in data. The errors in the observables of individual stars for current and near future data are shown to be too large for the direct use of this method, but when the data are averaged in bins on the sky, the resulting averaged data are accurate enough to constrain correctly the potential parameters for achievable observational errors. From pseudo-data with errors comparable to those that will be furnished in the era of Gaia (20 per cent distance errors, 1.2 mas/yr proper motion errors, and 10 km/s line-of-sight velocity errors) we recover the circular velocity, V_c=220 km/s, and the flattening of the potential, q=0.9, to be V_c=223+/-10km/s and q=0.91+/-0.09.


INTRODUCTION
The study of the Galactic halo is crucial to the understanding of the dark-matter content of the Galaxy. The dynamics of halo stars reflect the shape of the Galactic potential on large scales and hence the underlying dark-matter distribution. Recent large photometric surveys have revealed many stream-like structures in the halo (Belokurov et al. 2006), which should prove useful in this respect. These tidal streams are believed to be formed by stars being stripped from their progenitor by the tidal forces of the Galactic potential. The formation of the stream reflects the underlying Galactic potential, such that the resulting structure may be used to constrain the potential.
One way of using streams to constrain the Galactic potential is to assume that a stream delineates an orbit. This assumption has been used by many authors in the development of streamfitting algorithms (Jin & Lynden-Bell 2007;Binney 2008;Eyre & Binney 2009a,b) and their application to real data (Willett et al. 2009;Koposov et al. 2010). However, not until recently was the E-mail: jason.sanders@physics.ox.ac.uk assumption that a stream delineates an orbit properly questioned by Eyre & Binney (2011). These authors demonstrated that a misalignment between the progenitor orbit and stream can lead to significant errors in the parameters of simple potentials. Sanders & Binney (xxxx, hereafter Paper I) expanded on this by discussing the misalignment in realistic Galactic potentials for real streams, and demonstrated that orbit-fitting is not valid for many known streams. In particular order-one errors in the halo parameters of a realistic Galactic potential can arise if orbit-fitting is applied to known Galactic streams. Clearly, an improvement over orbit-fitting is required, which accounts for the stream-orbit misalignment. Johnston et al. (1999) accounted for the misalignment between the stream and progenitor orbit by calculating a progenitor-massdependent energy offset at pericentre. The observed stream stars are assigned an energy in this range, and the stream is integrated backwards for a Galactic lifetime. The quality of the trial potential is assessed by the number of 'captured' particles at time t = 0. Varghese et al. (2011) developed a similar method which took into account the misalignment between the stream and progenitor orbit by correcting a proposed orbit track in real-space with a progenitormass dependent term. To fully model stream formation with limited assumptions we must turn to N-body models. Law et al. (2005), Fellhauer et al. (2006) and Law & Majewski (2010) have all employed N-body models of the tidal disruption of the Sagittarius dwarf to produce constraints on the Galactic potential. However, full searches over the entire parameter space, both potential parameters and initial cluster conditions, are very expensive as we must create a new simulation each time, and it is difficult to assess how well a given simulation fits the data. Peñarrubia et al. (2012) present an entropy-based algorithm for constraining the Galactic potential with tidal streams. Assuming the distribution function is separable in energy and position, the best-fit potential is the one which minimises the entropy of the energy distribution, or, equivalently, minimises the range of energies of the stream members. These are all valid alternatives to orbit-fitting.
Angle-action coordinates are very useful quantities in galactic dynamics, and with more and more methods for their calculation becoming available (McMillan & Binney 2008;Sanders 2012;Binney 2012) their use is becoming a practical possibility. In particular, stream formation is very simply expressed in the angle-action formalism (Tremaine 1999;Helmi & White 1999;Eyre & Binney 2011;Paper I). The structure of a tidal stream in angle-action space will only be physically correct if we have used the correct potential, regardless of whether the stream delineates an orbit or not. This formalism provides us with a route to develop a new algorithm to constrain the Galactic potential: we search for the potential which produces the correct correlations in angle-action space. In Section 2 we recap the angle-action framework of stream formation, and more closely inspect an N-body simulation to motivate and understand this formalism. In Section 3 we discuss how we can improve on orbit-fitting by exploiting the known angle-action correlations for streams and arrive at a suitable algorithm to constrain the potential. In Section 4 we test the algorithm by attempting to recover the potential from the simulation.
Due to their large distances from the Sun, observations of tidal streams have large errors. It is therefore important that any streamfitting algorithm can cope with appropriate observational errors. Some authors have tested their methods on simulated observational data with appropriate errors (Binney 2008;Eyre & Binney 2009a). In Section 5, we conclude with a full discussion of the effect of observational errors on our proposed algorithm, and compare to the errors from current and future surveys.

STREAMS IN ANGLE-ACTION SPACE
In Paper I we presented the angle-action formalism of stream formation. In this formalism streams form due to stars being on different orbits. Importantly this can lead to a misalignment, ϕ, between the stream and the underlying progenitor orbit given by where Ω0 is the frequency vector of the progenitor orbit.ê1 is the principal eigenvector of the Hessian, D, given by This misalignment only depends upon the progenitor orbit, and hence the potential, and not the progenitor mass. In Paper I we demonstrated that a non-zero misalignment angle leads to biases in the estimation of potential parameters when fitting orbits to streams. We therefore require an alternative to orbit-fitting, and the angle-action formalism provides us with a clear route.
For long narrow streams to form, the Hessian must be dominated by a single eigenvalue, λ1, with corresponding eigenvector, e1. Under this approximation both the angle and frequency differences of all the stars in the stream lie along the same straight line: In the correct potential this correlation between the angle and frequency-space structure of the stream should be apparent. Inspecting the stream in angle-action space for a trial potential should tell us whether this potential is the true potential.
In practice, the actions, angles and frequencies are difficult to calculate for a general potential. Sanders (2012) presents a method for finding actions and angles in a general axisymmetric potential by locally fitting a Stäckel potential. The Stäckel-fitting approach can be simply extended to estimate the frequencies of an orbit. We present this extension in Appendix A and there also discuss refinements to the algorithm which are appropriate for the problem in hand.

A simulation
In Paper I we introduced a range of N-body simulations to show that the angle-action formalism is mass-independent for all interesting progenitor mass scales. Before discussing the details of the proposed algorithm we briefly introduce one of these N-body stream simulations to motivate the discussion. We take the lowest mass stream from Paper I which was produced as follows: we construct a stream by evolving an N-body simulation of a King cluster on a stream-like orbit in the logarithmic potential using the code GYR-FALCON (Dehnen 2000(Dehnen , 2002. The simple two-parameter logarithmic potential is given by where Vc is the asymptotic circular speed and q is the flattening parameter. We choose Vc = 220 km s −1 and q = 0.9 which gives a good representation of the potential of the Milky Way (Koposov et al. 2010). King models (King 1966) are characterised by three free parameters: the ratio of central potential to squared-velocity parameter, W0 = Ψ0/σ 2 , the cluster mass, Mc, and a tidal limiting radius, rt. We set W0 = 2.0 and Mc = 2 × 10 4 M and seed the cluster with N = 10000 particles. Following Dehnen et al. (2004) we relate rt to the pericentric radius of the orbit, rp, via We place the cluster at the apocentre of the orbit shown in Fig. 1, which has initial conditions (R, z) = (26.0, 0.0) kpc and (U, V, W ) = (0.0, 141.8, 83.1) km s −1 . Positive U is towards the Galactic centre and positive V is in the direction of the Galactic rotation at the Sun. This orbit has rp ≈ 14 kpc, and was chosen due to its similarity to the GD-1 orbit found by Koposov et al. (2010). We evolve the simulation for t = 5 Gyr (approximately 12 radial oscillations of the progenitor) The chosen cluster model parameters along with quantities derived from these parameters are given in Table 1. Fig. 2 shows the time evolution of the angle differences between the progenitor and several particles in the simulation. Each particle oscillates in the cluster until it escapes at pericentre, after which it moves as a free particle in the Galactic potential. The slope of the particle's motion in angle-space is given by the frequency. We see that the first particles to leave have a higher frequency than those released at later times. This is because the first particles to leave require a higher energy to escape the cluster. One unexpected feature of Fig. 2 is the noise in the angle calculation when the particles are moving freely. There are small bumps in the angle difference at each orbit pericentre, which alternate in sign and increase in magnitude with time. This is due to errors introduced by the Stäckel-fitting algorithm for estimating the angles and frequencies, which we discuss later. In the right panel of Fig. 3 we show the formed stream in realspace at t = 4.27 Gyr (just after the 11th pericentric passage). Fig. 4 shows the corresponding angle-space and frequency-space structures calculated using the correct potential. We see that as predicted by equation (3) the stream stars all lie along a straight line in both angle and frequency-space. In Fig. 4 we see that the spread in frequencies in the cluster is much larger than the spread in the estimated frequencies along the progenitor orbit (given by the red line). This suggests that the Stäckel-fitting algorithm is sufficiently accurate. However, the broadening at the extremes of frequency distributions indicates that there is a systematic error present which will skew the gradient estimation. A fuller discussion of the errors is given later.     Fig. 3 into angle space and frequency space. The angles and frequencies were calculated using the true potential. The inset plots show a zoom-in of the frequency space so the orbit projections are more easily visible. In frequency-space, errors in the determination of frequencies cause the red points to form a line rather than all coincide as they should.

ALGORITHM
The N-body stream observations now provide us with a way to utilise the angle-action formalism to constrain the potential. Equation (3) states that the frequency and angle differences of all the stars in the stream must lie alongê1, and this is observed in the above N-body simulation (Fig. 4). For all the stars we can calculate the angles and frequencies and then obtain independent estimateŝ e θ 1 andê Ω 1 ofê1 by performing linear fits to the angles and frequencies. The potential closest to the Galaxy's potential is then the potential which maximisesê θ 1 ·ê Ω 1 . The present kinematics are given byê Ω 1 -it gives us the direction that stars will move in if the true potential suddenly changed to the trial potential. However,ê θ 1 gives a measure of the positions the stars have reached by moving in the true potential i.e. the history of the stars. In the true potential the current motions of stars (alongê Ω 1 ) will match the positions they have in fact reached (alongê θ 1 ). Equation (3) was derived on the assumption that the stream structure is isotropic in action-space. In Paper I we saw, in general, there are anisotropies in the action-space distribution, which cause a deviation of the frequency structure from the principal eigenvector of the Hessian. For long thin streams the Hessian must have a large principal-to-second-eigenvalue ratio. Therefore, we expect that whatever the shape of the action-space distribution, the resulting frequency-distribution will be highly elongated, although not necessarily along the principal eigenvector of the Hessian. The approach suggested here is comparing the angle and frequency distributions which should have the same principal axis in the correct potential. Therefore, the approach should be insensitive to anisotropies in action-space if we are observing long thin streams.
This approach has several clear advantages: (i) We haven't assumed that the stars in the stream delineate an orbit. (ii) The posi- Table 2. Algorithm to find the best-fit potential given stream data.
Given a set of 6D phase-space points x i we 1. pick a trial potential Φ trial , 2. calculate the angles θ i (x i , Φ trial ) and frequencies Ω i (x i , Φ trial ) using the local Stäckel-fitting algorithm, 3. fit four straight lines to the graphs of and θ φ against θz to find the gradients denoted by a 1 , a 2 , b 1 , b 2 , 4.
calculate the quantity , 5. pick a new trial potential and repeat until the angle, ψ, between the vectors is minimised.
tion of the progenitor is irrelevant. It reduces to a constant in the linear fits. (iii) We can use any subsection of the stream. (iv) The time since each star was stripped does not matter. Changing the assumed stripping time only moves stars up and down the straight line in angle space and so does not affect the linear fit. (v) Only a single calculation is required for each trial potential, whereas when orbits are fitted in real space, orbits must be generated in each potential until the best fit is found. (vi) The quality of the potential is determined solely by the degree of misalignment, so it is an unambiguous single measure of the fit. When fitting orbits, the quality of the potential is evaluated by measuring the proximity of the orbit found to the data in the 6D phase space, so an arbitrary metric must be introduced to relate position and velocity differences. However, our approach suffers from the disadvantages that (i) the angles and frequencies can only be found with full sixdimensional phase-space information, (ii) stream data are often poor and it is not clear how the errors affect the accuracy of the method, (iii) and unlike orbit fitting, we must process the data before assessing the quality of the potential, as opposed to directly checking the quality of the fits in real space.
In what follows we will assume that we have full phase-space information for all the stars in the stream, so we are not concerned with the first of these points. In Section 5 we explore how errors in the 6D data for the members of the stream affects the accuracy of the method. We summarise the above discussion into the simple algorithm presented in Table 2.

TEST
We test the algorithm of Table 2 by seeing how accurately the method recovers the chosen parameters of the potential from the N-body simulation. We examine the stream at two times -once at t = 4.02 Gyr, just after the tenth apocentric passage of the progenitor, and once at t = 4.27 Gyr, just after the subsequent pericentric passage. From these snapshots we form samples of stream stars by first removing the remnant of the progenitor and then randomly sampling 500 of the remaining ∼ 5000 stars. The real-space structures of the disrupted cluster and these samples are shown in Fig. 3.
We now use the two samples to diagnose the potential. For each trial pair of (Vc, q) we find the misalignment, ψ, between the directions of the angle difference vector and the frequency difference vector. We pick trial pairs of parameters by exploring a regular grid around the true point (Vc = 220 km s −1 , q = 0.9). Fig. 5 is a plot of the misalignment in the plane of the parameters. In the apocentric case (top panel) the global minimum occurs at Vc = 220.3 km s −1 , q = 0.899. The landscape around the minimum is quite complex. There are a series of local minima for q > 1.0. Therefore, care will be needed when searching for the minimum automatically. In the pericentric case (bottom panel) we do not recover the true potential parameters as successfully: the global minimum lies at Vc = 220.4 km s −1 , q = 0.915 and the ψ landscape is significantly more complex. Again, for q > 1.0 there are a series of local minima. Worringly, there is another deep local minimum at Vc ≈ 212 km s −1 , q ≈ 0.74. Clearly there are sources of error in the algorithm which are systematically shifting the bestfit value of q in the pericentric case. Before applying this algorithm to more realistic data sets, we must understand the cause of this systematic shift. More generally, we need a method to assess the magnitude of the systematic error in the algorithm when the underlying potential parameters are not known. In the following section we discuss the causes of the error and present a method to estimate its magnitude.

Error estimation
Even in the correct potential with perfect data the particles will not lie on exact straight lines in angle and frequency space on account of systematic errors introduced by the approximations used including the Stäckel-fitting algorithm. In the above test we have seen that this can lead to a slight misdiagnosis of the underlying potential parameters. When we include observational errors, the error ellipse obtained by resampling the random errors may not encompass the true parameters due to these systematic errors. We need to quantify the accuracy of the method even when perfect data are used. A naive error may be taken from the error in the linear regression. However, this error only takes account of the random errors and ignores any systematics. In Paper I we discussed the effects of the progenitor mass on the angle-action framework, and hence the algorithm presented in this paper. It was shown that the approach is mass-independent up to about 10 9 M . Therefore, we expect the self-gravity, the finite cluster size and the linear approximation (see equation (3)) to not affect the algorithm.
There are still two sources of systematic error in the method. The first is that the action-space structure is not perfectly isotropic. In Paper I we saw that particles are not isotropically stripped, but rather escape through the Lagrange points. This led to the entire stream structure being rotated in the angle and frequency space. Eyre & Binney (2011) showed that the action-space of a tidallydisrupted cluster has a 'bow-tie' structure. When this action-space structure is transformed into frequency space via the Hessian (see equation (3)), the broadness of the wings of the action-space distribution is still apparent at the extremes of the frequency structure. This is due to the smaller eigenvalues of the Hessian. This effect is small as we are considering a Hessian with a ratio of eigenvalues, λ1/λ2 ≈ 30. However, this effect should also be observed in the angle-space structure. As we are comparing the angle and frequency-space structures, this shouldn't have a significant impact on the implementation of the algorithm.
Second, the Stäckel-fitting algorithm introduces systematic errors. The errors depend upon the orbital phase, such that the errors in the frequency differences between the progenitor and the stream particles exhibit a characteristic beating with time. The particles which were released recently are still approximately in phase with the progenitor, whilst those at the extremes of the frequency distribution, which were released many pericentres ago, have drifted out of phase with the progenitor. Therefore, the Stäckel-fitting algorithm introduces a larger error in the frequency difference for the particles at the extremes, which leads to a broadening of the distribution at the extremes. In Appendix A2 we give a full discussion.
In conclusion, the extremes of the frequency distribution are broader, and so less reliable, than the central portion of the stream, due to systematic errors introduced by the Stäckel-fitting algorithm and anisotropies in the action-space distribution. Therefore, we es-timate the magnitude of the error in the parameters from the spread in gradients that can be obtained by considering the angle and frequency structure of different parts of the stream in the best-fit potential. Specifically, we take the error in the gradient to be the difference between this gradient and that calculated using the central particles nearest to the progenitor. We may then find a 'threshold angle', ψT , as the angle between the two particle distributions. A threshold angle may be found for both the angle-and frequencyspace distributions. However, in the simulation, the frequency distribution is the main cause of error so we only calculate a threshold angle for this distribution. This threshold angle gives an estimate of the minimum angle that we can reliably calculate. The range of valid parameters are those for which ψ < ψT , which define an error contour in the potential parameter space. Inside the error contour the angle between the frequency and angle distributions is smaller than the width of the frequency distribution.
This also helps to solve an additional problem with the algorithm. As we are blindly fitting straight lines to distributions which may not have a linear structure, there may be some data sets for which the best-fit straight lines fortuitously give a minimum in cos ψ. However, if we calculate an error contour associated with this minimum we expect the error to be very large. Therefore, we should be able to rule out this fortuitous minimum without explicit inspection.
Applying this error estimation method to the data in Fig. 4, we plot an error contour in the parameter plane, given by the thick black curve in Fig. 5. Assuming the errors in each parameter estimate are independent, we estimate the parameters in the apocentric case as Vc = (220 ± 4) km s −1 , q = (0.90 ± 0.07) in good agreement with the truth. Similarly for the pericentric case, the parameter estimates are Vc = (220 ± 3) km s −1 , q = (0.92 ± 0.04).
We have shown that we can use our algorithm to constrain the parameters of a simple potential using an error-free sample of 500 stars from a stream simulation. When the stream is observed at either apocentre or pericentre, the error contour is elongated along the q-direction. We can constrain the circular speed of the potential more accurately than the shape of the potential. The recovery of the parameters at apocentre is slightly more successful than at pericentre. However, the errors at apocentre are slightly larger.

ERRORS IN STREAM DATA
We have assumed in the above test that the input data are perfect. Obviously this check that the algorithm works in the most optimistic situation is necessary, but it does not give an indication of how the algorithm will perform on a real data set. To give a more realistic test we now add errors to the data and rerun the algorithm. We simulate an observation of the particles at t = 4.27 Gyr in the simulation from the position of the Sun (R, z) = (8.0, 0.0) kpc, which has velocity (U, V, W ) = (11.1, 232.4, 7.25) km s −1 (Schönrich et al. 2010). There is considerable uncertainty in the circular speed at the Sun (see Bovy et al. 2012 for a summary), but for a fixed solar position, the solar V is well constrained by the motion of Sgr A* (Reid & Brunthaler 2004). Therefore, in what follows, we fix the velocity of the Sun, irrespective of the choice of potential, as this more accurately simulates a realistic application of the above algorithm.
The pericentric snapshot is chosen as the GD-1 stream is currently around pericentre. At pericentre the stellar density in the stream is increased, so the overdensity is more likely to be observed. However, this effect is counteracted by the short time a stream spends around pericentre. We project the positions and velocities of the particles relative to the Sun into observable space on the sky -sky position (l, b), distance s, proper motions (µ l , µ b ) and line-of-sight velocity v || . The particles are then scattered in observable space by appropriate Gaussian errors (σ l,b , σs, σµ, σ || ) to form an 'observed' data set.
The most accurate data are obtained from streams that are closest to the Sun. For instance GD-1 lies between 8 and 12 kpc away from the Sun. Therefore when we perform the above data scattering we place the Sun as close to the centre of the stream as possible. This involves rotating the stream around the Galaxy until the centre of the stream lies at the same azimuthal angle as the Sun. This better simulates observations which could feasibly be performed.
We make 'observations' with the errors listed in Table 3, along with errors in current and future data. The data from the O2 observation are shown in Fig. 6. We now use each of these data sets to constrain the potential. We transform the data set back into the Galactocentric coordinate system, and determine the angle and frequency distributions and ψ for each trial potential. We use the Nelder Mead algorithm to find the maximum of cos ψ as a function of q and Vc. We restrict the range of parameter space explored to 0.7 < q < 1.1 and 170 km s −1 < Vc < 270 km s −1 . The initial point passed to the algorithm is the true minimum position. We estimate the error in the position of the minimum for each set of observational errors by repeating this process 100 times and finding the minimum of each data set. These points sample the distribution of the parameters given the observational errors. Using these points we can reconstruct the distribution and estimate the mean and error of the distribution. We have seen in the previous section that the systematic error estimates around pericentre are ∆Vc ∼ 3 km s −1 and ∆q ∼ 0.04. We sum these in quadrature with the estimated impact of observational error on the resulting parameter estimates.
We first explore the effects of including an observational error to each observable independently (O1). The current position errors σ l,b = 100 mas do not produce a significant change to the position of the minimum found using perfect data. Therefore, for all other observations we use a more optimistic position error of 10 mas. A distance error of ∼ 5 per cent (O1b) does not alter the estimate of the circular speed significantly but slightly decreases the estimate of q, such that it is not consistent with the truth within the quoted error. A proper-motion error of 0.21 mas yr −1 (which corresponds to a transverse velocity error of 4.7 km s −1 ( kpc mas yr −1 ) −1 × 0.21 mas yr −1 ×10 kpc ≈ 10 km s −1 ) applied independently produces a result which is consistent with the truth (O1c). An equivalent line-of-sight velocity error (O1d) shifts the minimum in the circular speed up slightly, and moves the minimum in q down significantly. The effects of errors in these three coordinates are different and probably reflect the observation geometry. We are observing at pericentre at the same azimuthal angle as the centre of the stream. Therefore the line of sight velocity around the centre of the stream (the densest part) will be very small so small errors can have a significant effect. The effect of observational errors on the Galactocentric Cartesian coordinates is also reasonably complex, particularly for the distance error which affects both the observed position and velocity of a star.
When these three errors are combined (O2) the circular speed is shifted upwards and q is recovered within the errors. Increasing the error in the proper motion (O3) shifts the circular speed upwards further and also systematically shifts the minimum in q upwards. An increase in the distance error (O4) again shifts the circular speed estimate upwards but the recovery of q is good. O5  Figure 6. Stream sample at t = 4.27 Gyr (just after 11th pericentric passage). The small blue and red points show the sample observed from the Sun with observational errors O2 given in Table 3 and the larger black points show the reduced data set produced by averaging the data in observable space on the sky with errors OA3.
shows a combination of errors which recovers the underlying potential parameters. These errors are perhaps too optimistic and unlikely to be achieved in the near future. The line of sight velocity error may be achieved by RAVE, whilst the proper motion error may be achieved by Gaia. However it is unlikely that such a small distance error will be achieved soon from either parallax measurements, or spectroscopic or photometric distances. However, if one were able to identify standard candles, such as RR Lyrae stars, in a stream, this distance error is achievable now (Drake et al. 2013). With a low-mass stream, such as GD-1, we expect very few RR Lyrae stars, so using this method may only be useful for more massive streams. Also, we require 500 observations of this quality from a tidal stream to replicate this test, which makes such a data set even more improbable. O6 shows an example of large errors. Both the circular speed and the q estimate are shifted to very large values. However, these results do not give a good indication of the parameter estimates with these errors as we are approaching the edge of the allowed range of parameters. We can still see that large errors degrade the landscape significantly so that no minimum is found within the appropriate region.
The effect of experimental errors on the position of the minimum is clearly very complex and to use this method with confidence one would need to investigate the systematics on an appropriate simulation before application to data. We see that when large errors are added, the minimum can shift away from the true parameters significantly with very small associated formal errors. The error in the location of these minima does not encompass the true parameter values. In conclusion it seems that current and near-future data could lead to limited use of this method: to use the method with confidence we require accuracy in the observables that may not be attained for many tidal streams for some while.

DATA AVERAGING IN OBSERVABLE SPACE
Despite the results of the previous section, the method could still prove relevant if slightly adjusted. The motion of the stars in a stream in real space is coherent, and the above algorithm does not utilise this fact. This additional information may be exploited by first binning in real space. The stream is essentially a one dimensional structure regardless of whether it delineates an orbit or not. Therefore binning along the stream is valid even when the stream does not delineate the orbit. We form bins along the stream and estimate the observables at the centre of the bin by the average of the observables of the stars in the bin. One of the advantages of the above routine is that the linear regression in angle-space and frequency-space beats down the random errors in the estimated angles and frequencies. Averaging the data in observable space on the sky provides an alternative method for reducing the random errors, which for large observational errors is probably the preferable technique. Indeed, when analysing the GD-1 stream Koposov et al. (2010) mitigate the problem of large errors by binning and averaging the data along the stream in observable space to obtain a handful of much more accurate data points -the proper-motion errors for instance can be reduced by a factor of five.
When large observational errors are added, particles can be scattered to very high actions. Sanders (2012) showed that the systematic errors in the angle-action variables increases with the actions. Therefore larger observational errors will also introduce larger systematic errors. In the extreme case, observational errors can make orbits unbound 1 . These orbits have infinite actions and must be ignored when performing the linear regression in angleand frequency-space. Averaging data in observable space should remove these issues as we will have a data set which spans a smaller range in actions.
Unfortunately, averaging in observable space results in a smaller number of data points with which to perform the linear regression. In the above examples we have used 500 data points which provides a very tight linear regression. However, even just a handful of data points should provide a good estimate of the gradient.
Here we explore the results of observational data averaging for three observations listed in Table 3. We bin the 'observed' data in each observational coordinate using ten equally populated bins in Galactic longitude, l. The bins are sufficiently small for the stream to be approximately linear in each subspace for each bin so averaging within a bin works well. This procedure reduces the error in the input coordinates by a factor of ∼ 1/ √ 50 ≈ 0.14. After transforming back to the Galactocentric Cartesian coordinates, we perform the algorithm on the averaged data to find the best combination of potential parameters. We then repeat the scattering and binning process 100 times to estimate the error. In Fig. 6 we plot the binned data for the observation OA3.
We can see from Table 3 that averaging in observable space produces superior results. First the systematic shifts in the minima are removed, and we recover an average for the parameters which is close to the truth, particularly for q. The average position of the minimum does not depend as sensitively on the magnitude of the observational errors (compare OA1 and OA2). If we compare O4 Table 3. Observational errors used to make observations of the stream near pericentre at t = 4.27 Gyr, along with the estimates of the potential parameters (Vc, q) using the stream-fitting algorithm outlined in this paper. σ l,b is the observational error in the sky position, σs/s the fractional distance error, σµ the proper motion error, and σ || the line-of-sight velocity error. The O# observations use all 500 stars in the stream sample to determine the potential parameters whilst the OA# observations bin the observational data in 10 bins on the sky and average before performing the algorithm. The O4M and OA3M observations use a simulation which uses a progenitor cluster which is ten times more massive, but uses the same observational errors as O4 and OA3 respectively. The final two columns give the deviation in standard deviations between the found parameters and the true parameters. At the bottom of the table we show current and future observational errors for comparison. SEGUE data taken from Pier et al. (2003), Jurić et al. (2008), Munn et al. (2004) and Yanny et al. (2009). RAVE data taken from Siebert et al. (2011) and Burnett et al. (2011) (RAVE uses position data from 2MASS, Skrutskie et al. 2006). Pan-STARRS data taken from Kaiser et al. (2002) and Magnier et al. (2008). LSST data taken from Ivezić et al. (2008) for an r = 22 star. LEGUE (LAMOST Experiment for Galactic Understanding and Exploration) data taken from Deng et al. (2012) (LAMOST uses SDSS data as an input catalogue). Gaia data taken from Perryman et al. (2001) for G = 20 − 21 mag stars. The line-of-sight velocity errors from Gaia are ≈ 5 km s −1 for cool stars. The Gaia-ESO survey (Gilmore et al. 2012) aims to record spectra of 10 5 Gaia stars which will yield line-of-sight velocity errors of ≈ 1 km s −1 for cool stars. The fractional error in the distance for Pan-STARRS, LSST and Gaia are determined from the error in the parallax under a linear approximation.  and OA2 the observation errors are the same, but the recovery of the parameter estimates with the two methods are different: the circular speed is better recovered by averaging in observable space. This is achieved without an increase in the quoted error of the parameter estimates. Second we can weather much larger observational errors. The errors in observation OA3 seem achievable with future data and we correctly recover the potential parameters using the averaging method. For all three observations the estimated errors encompass the true potential parameters.
In conclusion we can achieve the most accurate results by first averaging in observable space and then performing the algorithm on the reduced data set. This is the correct method to use as we remove unphysical measurements (those with infinite actions) and hence we only spend time calculating the angles and frequencies for reliable phase-space points. Similarly we need only calculate the angles and frequencies -a time-consuming process -for a handful of points. Scattering and binning is, in comparison, very fast. These principles apply to any process trying to calculate actions, or any other non-trivial variable, from noisy data: binning the data in the space of observables removes outliers and results in fewer, more reliable points to run through the complicated calculation.
Finally we briefly investigate how the recovery of the potential parameters depends upon the initial mass of the cluster. In Paper I we showed that the stream-orbit misalignment is independent of the cluster mass. The effect of increasing the cluster mass is to scale the angle and frequency distributions without altering the morphology. We take the Mc = 2 × 10 5 M simulation from Paper I, which was evolved on the same orbit for the same time as the above simulation. Due to the higher mass the resulting stream is longer, spanning ∼ 190 • in Galactic longitude, so we expect that the estimates of the parameters will be superior as the stream probes a larger range in both angles and frequencies. In Table 3 we show the estimates of the parameters from this higher-mass simulation using the observational errors from O4 and OA3 with the observable-space binning (these are labelled in the table as O4M and OA3M). For O4M the increased stream length has weakened the systematic shift of the circular velocity found in O4, producing a mean value which is closer to the truth. Despite the increased width of the stream the error in the parameters is small. For OA3M the recovery of parameters is similar to the OA3 observation, but the error in these estimates has been reduced without excluding the truth from the error ellipse. These two experiments show that longer streams, which have a larger spread in angle space, produce superior parameter estimates.

CONCLUSIONS
Tidal streams are very attractive structures for probing the Galactic potential on large scales, but it is essential that appropriate algorithms are developed for their study. In Paper I we showed that orbit-fitting is inappropriate for many streams in the Milky Way, and can lead to order one errors in estimation of parameters of the Galactic potential.
Motivated by the need for an improvement over orbit-fitting, we have presented an algorithm for using tidal-stream data to constrain the potential of the Galaxy without assuming that the stream delineates an orbit. Instead it identifies the true potential as the one that yields corresponding patterns in angle and frequency space. The algorithm was tested by evolving an N-body simulation of a King cluster in a two-parameter logarithmic potential until a stream is formed. The degree of correlation between the angle and frequency structure was maximised with respect to trial potentials. The correct parameters were recovered within the estimated systematic errors of the method.
As tidal streams are very distant structures we expect large errors in the observables. Therefore, it is imperative that any streamfitting method is shown to function for large observational errors. We have shown that the observational errors in the distances and proper motions for individual stars in tidal streams are currently too large to use the above technique with any confidence. However, if the data are first binned and averaged in observable space on the sky, we can recover the correct potential parameters even for large observational errors. The current observational errors may be small enough for close streams such as GD-1 and it seems promising that in the era of Gaia the data for more streams will be sufficiently accurate to use this algorithm.
We have shown that longer streams produce superior potential parameter estimates, so there is hope for using higher-mass streams to produce better constraints on the potential. We have seen that observing a stream at different times results in different constraints on the potential. Therefore there is much to be gained by using several streams simultaneously to constrain the potential. Hopefully this would also remove local minima and make a global minimum more apparent. Similarly the approach taken here uses a constant prior for the potential parameters. In reality, a more informative prior could be used, that would rule out regions of the parameter space which are populated by local minima.
We have only investigated how well a very simple twoparameter potential may be constrained. In reality, models of the Galactic potential have many more parameters. In this case we expect many more degeneracies in parameter space and a much fuller Monte Carlo search of this higher dimensional space would be required. From the test results here we have seen that we can constrain the circular speed of the potential more effectively than the shape. It would be interesting to explore with a more complex potential which parameters/features of the potential we are able to constrain more accurately than others. For instance, when applying an orbit-fitting algorithm to the GD-1 stream Koposov et al. (2010) found that the mass of the disc in their Galaxy model could be more accurately constrained than the shape of the halo.
Finally, this algorithm, unlike an orbit-fitting algorithm, requires full 6D data for the stream. The Galaxy is being increasingly mapped in 6D and we have 6D data for the GD-1 stream (Koposov et al. 2010). However it may be some time before we have accurate 6D data for many distant streams. Therefore, to make the presented algorithm more usable in the near future it would be interesting to investigate what alterations we can make to deal with reduced phase-space information. We intend to adapt the above approach to produce a Bayesian model of the stream structure in angle-action space, which will be useful in this respect.

APPENDIX A: LOCALLY FITTING STÄCKEL POTENTIALS
Sanders (2012) presented a method for estimating the angle-action variables in a general axisymmetric potential given a 6D phasespace point. It is this method which we use in this paper to determine the angle-and frequency-space structure of the stream. The method proceeded by first finding the region the point would explore as it proceeded along its orbit in the potential. The given potential is then approximated by a Stäckel potential inside this region. Once an appropriate Stäckel potential is found, the true actions, angles and frequencies may be estimated by those calculated in the Stäckel potential. Stäckel potentials are the most general class of potentials for which angle-action variables can be calculated analytically. In this appendix we present the relevant equations for determining actions, angles and frequencies in a Stäckel potential. For more information on the algorithm readers should consult Sanders (2012).
In a Stäckel potential the Hamilton-Jacobi equations separate which allows us to write down an expression for the third isolating integral, I3 (de Zeeuw 1985). Axisymmetric Stäckel potentials are associated with prolate spheroidal coordinate systems defined by two constants (a, c). These coordinates are related to cylindrical polar coordinates (R, φ, z) by where λ and ν are the roots of τ such that c 2 ν a 2 λ. Surfaces of constant λ are prolate spheroids and surfaces of constant ν are two-sheeted hyperboloids of revolution which intersect the spheroids orthogonally. An axisymmetric potential is of Stäckel form if ΦS is fully defined by a single function f (τ ). A single function may be used as λ and ν take different ranges of values except at λ = a 2 , ν = a 2 , where we require f to be continuous so the potential remains finite. The momentum pτ is solely a function of its conjugate variables, τ , and the three isolating integrals in a Stäckel potential, (the energy E, the z-component of the angular momentum Lz and I3): We define the action variables, JR and Jz, as where the integration is over all values of τ for which p 2 τ 0. The third action, J φ , is simply Lz. The corresponding angle coordinates, θ = (θR, θ φ , θz), are calculated by the introduction of the generating function, S(λ, φ, ν, JR, Lz, Jz) for the canonical transformation from (λ, φ, ν, p λ , pν , Lz) to (θR, θ φ , θz, JR, Lz, Jz). The angles are found by differentiating the generating function with respect to the respective action such that The frequencies, Ω, are related to the derivatives of the actions with respect to the integrals of the motion by ΩR = 1 Γ ∂Jz ∂I3 , where Expressions for all these derivatives are given in Sanders (2012).

A1 Estimating I3
In the algorithm presented in Sanders (2012) I3 was estimated by averaging three estimates along the orbit. I3 is an integral of the motion in a Stäckel potential so in that paper it was desirable to avoid the estimates of I3 depending on the initial position on the orbit. This produced much smaller errors in the estimated actions so was a favourable scheme for the task presented. However, problems arise around the turning points of the orbit with a poor choice of I3.
A small error in I3 can move the boundary of the orbit away from the true boundary, so points which are close to the boundary appear further away than they should be. As I3 is a separation constant it can be estimated in two different ways, usingλ orν: In a Stäckel potential these two estimates are identical but in a general potential we expect a discrepancy. Using only theλ estimate leads to errors in θz near the turning points and similarly using only theν estimate leads to errors in θR near the turning points. When analysing the stream data we are primarily interested in the angles and the behaviour of the stream near apsis. Also, we are only interested in relative differences between stars in the stream. Therefore, we use a modified scheme to that presented in Sanders (2012). We choose to only estimate I3 at the given phase-space point. We also calculate two different estimates for I3 using thė λ andν. The equation of motion for λ uses theλ estimate and similarly for ν. In this way we remove noise around the turning points and the stream structure is recovered much more cleanly.
Several other small alterations have been made to the algorithm presented in Sanders (2012), which improve the performance for the present task. We have increased the number of α-estimates per particle, and increased the size of the potential-fitting region and selected the weight function Λ(λ) = 3λ −4 (λ −3 + − λ −3 − ) −1 to reduce noise in the frequencies.

A2 Impact of errors on suggested algorithm
The Stäckel-fitting algorithm used to estimate the angles and frequencies introduces errors, which systematically depend on the orbital phase. Using the same method to estimate the errors as that presented in Sanders (2012), we find that the standard errors in the angles for the orbit used in Section 4 are (σ θ R , σ θ φ , σ θz ) = (9.4, 5.7, 5.4)×10 −3 rad. For a single orbit the frequencies should be constant at all points along the orbit. We estimate the error in the calculated frequencies as the standard deviation of their estimates around the orbit which yields (σΩ R , σΩ φ , σΩ z ) = (3.7, 4.0, 2.6)× 10 −3 Gyr −1 . These errors are much smaller than the size of the distributions shown in Fig. 4. The errors in the frequency and angle estimation depend upon the phase of the particle, with the largest error occurring at pericentre.
However, these absolute errors do not give a good indication of the accuracy of the algorithm presented in this paper. As we are measuring the gradients of the frequency distribution and the angle distribution, we are instead concerned with the errors in the differences of the frequencies/angles of the particles in the stream, which are subject to more subtle effects. For simplicity we limit the discussion to the errors in the frequencies but similar effects are found in the angles. Let us consider two particles in the stream: one in the cluster with frequency Ω0 = (ΩR0, Ω φ0 , Ωz0) and another particle, which has just been stripped from the progenitor with frequency Ω = (ΩR0+∆ΩR, Ω φ0 +∆Ω φ , Ωz0+∆Ωz). The Stäckelfitting algorithm produces deviations in the frequencies, given by σ(t, Ω), which depend on the orbital phase so fluctuate in time at a rate determined by the frequencies.
At a given time, the difference in the estimated frequencies is given by where gi(∆Ω, t) is an oscillating function of the frequency difference, and we have dropped the fast-oscillating part. Therefore, there is an error in the difference which oscillates in time at a frequency related to the beat frequency. In Fig. A1 we plot the azimuthal frequency difference, ∆Ω φ , as a function of time for a single particle from the simulation integrated for a long time.
The particle was stripped at the third pericentric passage and then integrated independent of the simulation for many more periods. We observe that the fluctuations in the frequency introduced by the algorithm are producing beats in ∆Ω φ with a frequency of ∼ 0.3 Gyr −1 . We expect that at early times t 5 Gyr the error in the difference will be small as the systematic errors in the progenitor and particle frequency-estimates are in phase and so nearly cancel. At large times when t ≈ 5 Gyr the error fluctuations in the particle and progenitor frequencies have drifted out of phase, so the error in the difference is large. The error in ∆Ω φ reaches a maximum of ∼ 10 per cent. A consequence of this systematic is that, at early times, the particles with the largest frequency difference will introduce the largest errors, as they were the first to leave the cluster. This explains the broadening of the extremes of the frequency distributions in Fig. 4. A similar effect is observed in the angles shown in Fig. 2. The largest error in the angles occurs at pericentre (Sanders 2012). Around each pericentric passage the Stäckel-fitting algorithm produces a small blip in the angle difference. This blip increases in magnitude with time as the systematic errors introduced by the algorithm shift out of phase with each other.
The discussion has been limited to the errors introduced when finding the gradient using a single particle and the progenitor. It is more difficult to assess how the linear regression of the angles and frequencies of many particles in the stream is affected, but it is clear that it is systematic and not random, as the errors of neighbouring stream particles are correlated. The errors depend upon the initial cluster conditions which govern ∆Ω, the time since the cluster started being stripped, and the phase at which the stream is observed. We also expect this source of error to decrease with the mass of the progenitor. Larger progenitor masses produce larger (Ω φ − Ω φ0 )/Gyr −1 Figure A1. The azimuthal frequency difference between the progenitor and a single particle taken from the simulation, and integrated for a long time. For all shown times the particle is moving freely in the external Galactic potential. The error in the frequency difference exhibits beats at a frequency of ∼ 0.3 Gyr −1 characteristic of two particles oscillating at close frequencies drifting in and out of phase. The units give the times of pericentric passage of the progenitor.
frequency distributions (see Paper I), so the errors introduced by the Stäckel-fitting algorithm become less significant. This paper has been typeset from a T E X/ L A T E X file prepared by the author.