# How to fit a quadratic equation to the experimental data by manipulating quadratic coefficients?

5 views (last 30 days)
Jacob Bradley on 1 Nov 2019
Answered: James Phillips on 9 Nov 2019
I have been trying to fit a quadratic equation to my data where I can manipulate the quadratic coefficients to get the closest fit to my data.
Here is my data,
y=[4.98279822987897e-07; 4.083e-07; 2.913e-07; 2.525e-07; 2.293e-07; 2.08788064633478e-07; 1.8974e-07; 1.8209e-07; 1.75186e-07;1.76257830379737e-07; 1.85224500066765e-07; 2.04176252688011e-07; 2.32655118657041e-07;2.71795522568243e-07; 3.22436473806901e-07;3.83535479445256e-07;];
x=[5.5; 5.9; 6.9; 7.8; 8.5; 9.4; 11.2; 12.3; 13.9; 15.5; 17.2; 18.9; 20.5; 21.9; 23.1; 23.98;];
Tried using polyfit but I need to be able to manipulate the quadratic coefficients or are there any other fits to use other than polyfit? Also tried using a weighted linear regression but I could not figure it out. Thanks!

James Phillips on 9 Nov 2019
I got a good fit using the 4-parameter Nelder yield density equation:
y = (a + x) / (b + c * (a + x) + d * (a + x) * (a + x))
with parameters:
a = 1.7313390100742435E+01
b = -1.1993161122097411E+09
c = 8.2891507074461997E+07
d = -1.2404871966288472E+06
yielding RMSE = 3.772E-09 and R-squared = 0.9983

Alex Sha on 4 Nov 2019
If you don't care the type of fitting function, try the following one:
y = p1+p2*x+p3*x^3+p4/x+p5/x^2
Sum of Squared Residual: 3.237636036555E-16
Correlation Coef. (R): 0.998819161526896
R-Square: 0.997639717433292
Determination Coef. (DC): 0.997639717433292
Chi-Square: 5.89888356402621E-10
F-Statistic: 1162.36473616939
Parameter Best Estimate
---------- -------------
p1 2.73712499948838E-6
p2 -1.11638197940077E-7
p3 8.10419259268286E-11
p4 -2.22763441216914E-5
p5 7.28628219858989E-5