﻿ Problems Solving Quadratic Fit - Chromatography Forum

## Problems Solving Quadratic Fit

Discussions about HPLC, CE, TLC, SFC, and other "liquid phase" separation techniques.

### Problems Solving Quadratic Fit

I have a very nice quadratic fit for a calibration curve in excel when I have mg/mL on the x. To solve for x though, I wanted to switch the axises (to put mg/mL on y and area counts on x) but then the fit is awful and the resulting values aren't even logical. Any tips on how to hand the quadratic calibration curves? I have never done non-linears before. I tried to solve by hand with the quadratic formula but it only worked for the higher x values.

I have fit it with a "power" fit, but it's not as good at all.

Any ideas?

### Re: Problems Solving Quadratic Fit

try to use "polynomical fit", second order

but indeed, Excel seems to have a "problem" when interchanging the axis.

### Re: Problems Solving Quadratic Fit

The 2nd order polynomial fit is what I used. We also tried plugging the polynomial fit/data into the Igor graphing program and got the same results as excel. It might be some weird math thing. I was hoping that someone had a good trick to pull off what I described above.

### Re: Problems Solving Quadratic Fit

I'm sorry, I'm not totally clear what you're doing. Can I just check this is the situation:

You have a calibration curve of Peak Area (Y) versus Amount (X) which works well as a quadratic fit.
You therefore have an equation Area = a*Amt^2 + b*Amt + c where you know a, b, c
You are now trying to find Amt in unknown samples from Area.
This should be fairly straightforward in that you can rearrange the equation to
0 = a*Amt^2 + b*Amt + (c-Area)
and solve this using the well-known
Amt = (-b PlusOrMinus square-root[b^2 - 4ac])/2a
99% of the time this ought to give you the right answer. If it isn't doing so, there are two things that can be going wrong.
Firstly, obviously, your low-concentration points may actually be fractionally a long way from the calibration curve but you don't see it when you look at the curve because all the values are small. This will give big percentage errors in any measured samples at low concentrations. This is a real problem in the analysis side of things, and not a mere matter of maths.
Secondly, if you're really unlucky (but it's never happened to me) the standard equation for solving quadratics as above isn't the most numerically stable. Textbooks recommend you calculate:
q = -0.5*[b + sign(b)*squareroot(b^2-4ac)]
after which the solutions are q/a and c/q (of which of course only one is relevant in your case; the other will probably be negative).

In my hands, the most likely thing to go wrong is me mistyping the equations in Excel.

### Re: Problems Solving Quadratic Fit

What we have found to be a good solution is to take the natural log of both the area counts and the concentration. We plot this, the result is linear and we can do our calculations this way.

Thanks for the help, those of you who responded!

### Re: Problems Solving Quadratic Fit

Which textbooks do you recomend to get a detailed understanding of this (using quadratic equation to calculate unknown conc. from non-linear std curve)?

lmh wrote:
I'm sorry, I'm not totally clear what you're doing. Can I just check this is the situation:

You have a calibration curve of Peak Area (Y) versus Amount (X) which works well as a quadratic fit.
You therefore have an equation Area = a*Amt^2 + b*Amt + c where you know a, b, c
You are now trying to find Amt in unknown samples from Area.
This should be fairly straightforward in that you can rearrange the equation to
0 = a*Amt^2 + b*Amt + (c-Area)
and solve this using the well-known
Amt = (-b PlusOrMinus square-root[b^2 - 4ac])/2a
99% of the time this ought to give you the right answer. If it isn't doing so, there are two things that can be going wrong.
Firstly, obviously, your low-concentration points may actually be fractionally a long way from the calibration curve but you don't see it when you look at the curve because all the values are small. This will give big percentage errors in any measured samples at low concentrations. This is a real problem in the analysis side of things, and not a mere matter of maths.
Secondly, if you're really unlucky (but it's never happened to me) the standard equation for solving quadratics as above isn't the most numerically stable. Textbooks recommend you calculate:
q = -0.5*[b + sign(b)*squareroot(b^2-4ac)]
after which the solutions are q/a and c/q (of which of course only one is relevant in your case; the other will probably be negative).

In my hands, the most likely thing to go wrong is me mistyping the equations in Excel.

### Re: Problems Solving Quadratic Fit

this is a very ancient thread; there has been a more informative version, more recently, but I can't find it.

Short answer: I personally recommend that people stick to using chromatography software packages to do their calibrations, and avoid setting up calibration curves in Excel if at all possible. It is very rare for it to be genuinely necessary. Chromatography software is designed for the purpose and does it better: it will allow you to combine appropriate curves-shapes with weighting of points, and all at the tick of a few boxes.

I'm not sure what to recommend for those who want to understand the numerical side of quadratic fits. They're really just another least-squares method. I'd guess most textbooks on numerical analysis will mention the subject. Numerical Recipes (Press et al.) gives the improved equations for solving quadratics, but books like this are grossly excessive for a simple calibration curve - though they're a good read if you're so minded!

### Re: Problems Solving Quadratic Fit

If you really want to get into it, check out the series of 52 articles from American Laboratory: https://www.americanlaboratory.com/1403 ... Chemistry/
You have to download each article separately, but collectively this is my "go to" text on statistics, if for no other reason than all the examples are from chromatography (as opposed to, say, widget manufacturing)>
-- Tom Jupille
LC Resources / Separation Science Associates
tjupille@lcresources.com
+ 1 (925) 297-5374

### Re: Problems Solving Quadratic Fit

Hollow wrote:
Excel seems to have a "problem" when interchanging the axis.

This is not a problem of Excel or any software. If one has even a simple function y = x^2, inverting the axes results in a function x = y^0.5. Of course, the latter square-root function cannot be fitted with a quadratic equation.

Generally, a function y = a0 + a1*x + a2*x^2 cannot be converted to a function x = b0 + b1*y + b2*y^2, or to a function x = k*y^n, or to a function log(x) = c0 + c1*log(y).

### Re: Problems Solving Quadratic Fit

... see the other thread. The quadratic fit, in any case, minimises the error in the y-direction, so it should be used on data where the expected error is in that direction; swapping the axes to make life arithmetically simpler is statistically dubious.

Yes, if you've got a curve of defined shape and it's a polynomial one way round, if you swap the axes it won't be a polynomial. It may, however, give quite a decent approximation to a polynomial over a limited span. If you have a curve of unknown shape, then it can be hard to know whether you're more justified in treating y versus x as polynomial or x versus y as polynomial. That's rather the point of fitting a polynomial: you're not necessarily saying that the underlying function is polynomial, you're saying that a polynomial fit gives a decent approximation to the data and allows you to interpolate.

Basically: make sure y is where the errors are, look at the residuals, and if they deviate unacceptably from random, then consider a different fit.

### Who is online

In total there are 8 users online :: 1 registered, 0 hidden and 7 guests (based on users active over the past 5 minutes)
Most users ever online was 599 on Tue Sep 18, 2018 9:27 am

Users browsing this forum: Google [Bot] and 7 guests

### Latest Blog Posts from Separation Science

Separation Science offers free learning from the experts covering methods, applications, webinars, eSeminars, videos, tutorials for users of liquid chromatography, gas chromatography, mass spectrometry, sample preparation and related analytical techniques.

Subscribe to our eNewsletter with daily, weekly or monthly updates: Food, Environmental, (Bio)Pharmaceutical, Bioclinical, Liquid Chromatography, Gas Chromatography and Mass Spectrometry.