Cococubed.com Fitting to Conic Sections

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

Cold neutron stars
Stellar opacities
Neutrino energy loss rates
Ephemeris routines
Fermi-Dirac 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

Supernova light curves
Exact Riemann solutions
1D PPM hydrodynamics
Hydrodynamic test cases
Galactic chemical evolution

Universal two-body problem
Circular and elliptical 3 body
The pendulum
Phyllotaxis

MESA
MESA-Web
FLASH

Zingale's software
Brown's dStar
GR1D code
Herwig's NuGRID
Meyer's NetNuc
Presentations
Illustrations
Public Outreach
Education materials
2022 ASU Solar Systems Astronomy
2022 ASU Energy in Everyday Life

AAS Journals
2022 Earendel, A Highly Magnified Star
2022 TV Columbae, Micronova
2022 White Dwarfs and 12C(α,γ)16O
2022 Black Hole mass spectrum
2022 MESA VI
2022 MESA in Don't Look Up
2022 MESA Marketplace
2012-2023 MESA Schools
2022 MESA Classroom
2021 Bill Paxton, Tinsley Prize

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) least-squares 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 semi-major and semi-minor 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, least-squares 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, least-squares 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, least-squares 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 least-squares fitting of data to a non-specific 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 co-authorship as appropriate.