

Home Astronomy research Software instruments Stellar equation of states EOS with ionization EOS for supernovae Chemical potentials Stellar atmospheres Voigt Function Jeans escape Polytropic stars Cold white dwarfs Adiabatic white dwarfs Cold neutron stars Stellar opacities Neutrino energy loss rates Ephemeris routines FermiDirac functions Polyhedra volume Plane  cube intersection Coating an ellipsoid Nuclear reaction networks Nuclear statistical equilibrium Laminar deflagrations CJ detonations ZND detonations Fitting to conic sections Unusual linear algebra Derivatives on uneven grids Pentadiagonal solver Quadratics, Cubics, Quartics Supernova light curves Exact Riemann solutions 1D PPM hydrodynamics Hydrodynamic test cases Galactic chemical evolution Universal twobody problem Circular and elliptical 3 body The pendulum Phyllotaxis MESA MESAWeb FLASH Zingale's software Brown's dStar GR1D code Iliadis' STARLIB database Herwig's NuGRID Meyer's NetNuc Presentations Illustrations cococubed YouTube Bicycle adventures Public Outreach Education materials AAS Journals AAS Youtube 2022 MESA Marketplace 2022 MESA Summer School 2022 MESA Classroom 2022 MESA in Don't Look Up 2022 ASU Solar Systems Astronomy 2022 ASU Energy in Everyday Life Contact: F.X.Timmes my one page vitae, full vitae, research statement, and teaching statement. 
Lots of tools exist for fitting a set a data to a straight line. How about fits to a general conic $$ a x^2 + b x y + c y^2 + d x + e y + f = 0 \ , \label{eq1} \tag{1} $$ perhaps with a constraint that enforces a specific conic section? References I found useful include Thomas & Chan 1989, Halir & Flusser 1998, Fitzgibbon et al 1999, and Harker et al 2008. For direct (i.e., not iterative) leastsquares fitting of data to an ellipse, fit_ellipse.f90.tbz will generate noisy data for an ellipse (an interesting problem itself!), fit the noisy data to equation (1) with the constraint $b^2  4 a c \lt 0$ that assures an ellipse, and report key geometric attributes such as the center coordinates, foci coordinates, lengths of the semimajor and semiminor axes, and rotatation angle of the conic. This tool currently depends on the lapack routines dgetrf and dgetri to invert a 3x3 matrix and the lapack routine dgeev to obtain the eigensystem of a 3x3 matrix. For direct, leastsquares fitting of data to a hyperbola, fit_hyperbola.tbz will do the same as above, except with the constraint $b^2  4 a c \gt 0$ that assures a hyperbola. Parabolas, defined by the constraint $b^2  4 a c = 0$ with zero to near machine precision, lie on the boundary surface between ellipses and hyperbolas. Two of the figures below show that $b^2  4 a c = 0$ is an elliptical cone with its vertex at the origin. All ellipses lie within the cone, hyperbolas lie outside the cone. Direct, leastsquares fitting of data to a parabola is thus more involved than for ellipses or hyperbola. The tool fit_parabola.tbz will do the same exercises as its ellipse and hyperbola cousins above. For direct, leastsquares fitting of data to a circle where the measure of fit goodness is an area and not a length, the tool fit_circle.tbz will do the same as its cousins above. For iterative leastsquares fitting of data to a nonspecific conic, the tool fit_nonspecific_conic.tbz will do a traditional singular value decomposition on equation (1) ala e.g., Gander, Golub & Strebel 1994. Here is an example of noisy parabolic data with the returned best fit coefficients suggesting the geometery is an ellipse. 


Please cite the relevant references if you publish a piece of work that use these codes, pieces of these codes, or modified versions of them. Offer coauthorship as appropriate. 
