# Minimizing Mean Squared Error for Exponential Function

I have a function that I'm trying to model using an exponential function and I'm trying to determine the constants for the exponential. I know I could optimize it using trial-and-error in R or another language, but I'd like to learn an analytic solution.

I figured that minimizing mean squared error would be the way to go about this, so I have:

$$\underset{r,k}{\operatorname{argmin}}\sum_{t=0}^T (s(t)-\hat{s}(t\mid r,k))^2$$

Where $s(t)$ is the function that I'm trying to model and $\hat{s}(t)$ is $(1+r)^{t+k}$ .

The only constraint I could come up with was $r>0$. I suppose I could also assume $k>0$ for now.

I learned about Kuhn-Tucker constraints as an extension to Lagrange constraints (which I already know) but I wasn't able to solve it.

Am I even going about this the right way? If I am, how can I solve this problem?

@AndyBromberg: no, the problem is that equations involving sums of non-integral powers usually can't be solved except numerically. Think of $1.45^{2.3+x}+1.45^{4.7+x}=10000$ You would like to take logs of both sides, but the log of a sum is not the sum of the logs, so it doesn't help. – Ross Millikan May 16 '13 at 23:22
Thanks again for the response. So if I removed the $k$ term from the equation so all I had was $(1+r)^{t}$, that would be solvable? Or is the issue that there's a variable exponent in the first place? – Andy Bromberg May 16 '13 at 23:48
@AndyBromberg: it might be if all your $t$'s are integers and not too big (no more than four or larger and you get lucky). But problems like this usually have more data points than that. One-dimensional root finding is much easier, so if you don't need $k$ for a decent fit it would be nice to remove it. But with one fewer parameter, you may have more trouble fitting. – Ross Millikan May 16 '13 at 23:50