American Citizen on Sun, 08 Jun 2025 23:59:55 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

question on method of least squares for sideways parabolas


Hello:

There are many websites showing how to use the method of least squares for solving for a parabola and this is standard fare in many college textbooks, but my problem is a bit different and a casual search on the internet turned up nothing (for me)

The standard method has

M = [ n, sum(xi), sum(xi^2) ; sum(xi), sum(xi^2), sum(xi^3); sum(xi^2), sum(xi^3), sum(xi^4)]

B = [ sum(yi), sum(yi xi), sum(yi xi^2) ]~

X = matsolve(M,B)

which solves y = ax^2 + bx + c for the vertical parabola

My parabola is the sideways positive x-axis parabola: x = ay^2 + by + c (limited to 1st and 4th quadrants)

Currently I am solving for a,b,c as i M above, but transposing the xi and yi values in both M and B and then solving for Y (not X)

Then having found a,b,c I take real(polroots(ay^2+by+c - x)[2]) where x is my value to find the corresponding y value for (not using y to find x, but going backwards x-> y)

Maxima shows that solving x = ay^2 + by + c and solving for y as

y = +/- (sqrt(4ax-4ac+b^2)-b)/(2a) but I don't know how to do least squares on a rational surd expression such as this to obtain a,b,c

Is my method basically the best way to do this?

Randall