# Fitting non linear regression with coefficients in the form of polynomial with Levenberg Marquardt

I am trying to do non-linear regression by using Levenberg Marquardt least square fitting (in R). I know that it can do the fitting for a function in the form of

$f(x) = sin(Ax)+cos(Bx)$

to calculate the values of A and B (A, B are constant coefficients). But can it find A, B for the following case?

$f(x)=(p_1A^3+q_1A^2+r_1)x+(p_2B^3+q_2B+r_2)e^{Bx};$

($p_1,p_2,q_1,q_2,r_1,r_2$ are known constants)

Especially when the polynomials in A and B can have multiple roots, and how to obtain such roots?

• Please try to avoid asking questions which could just have "yes" or "no" as answers; can you possibly edit to phrase your question in a way that invites a more expansive response? [Yes - I don't see why not. (Why would roots of the polynomials be a particular issue?)] – Glen_b -Reinstate Monica Jan 9 '15 at 5:28
• @Glen_b Edited the question – easternray Jan 9 '15 at 15:19
• I intended something like explaining why you'd be concerned about the first part (why do you think it might not work), so there's something to say beyond "yes, you can do that", or asking for alternatives if the answer is "no, it doesn't work". Unfortunately "how do I find roots of polynomials with known coefficients" isn't really on topic here (it's not a stats problem); however, many packages will do this in software. – Glen_b -Reinstate Monica Jan 9 '15 at 23:40

But can it find A, B for the following case?

Sure. I don't see why there'd be a problem for that case, at least not typically.

Especially when the polynomials in A and B can have multiple roots,

I don't think that the polynomials having multiple roots should present a particular problem, though perhaps I am missing something.

Either component being zero isn't of itself a problem.

Can you say more about the values where you get multiple roots, and why you expect a problem?

and how to obtain such roots?

Root-finding for polynomials is a pretty standard problem, and many optimization/numerical-calculation/statistical packages will locate them for you. In R, there's polyroot for example, while Matlab has roots; in Excel you might use Solver.

If the coefficients are rational*, and you want an "exact" answer (i.e. an algebraic formula), there are exact methods; with the depressed cubic (one with no $.^2$ term), Scipione del Ferro found a method around the start of the 16th century. The solution is mentioned here, and an approach to solving it is described here.

* While polynomials with rational coefficients can be converted to ones with integer coefficients and so might be representable exactly, if the coefficients are not rational you likely can't even represent it on the computer exactly, so it's likely pointless worrying about algebraic solutions when dealing with something like Levenberg-Marquardt.