Rate of exponential decay

1.8k Views Asked by At

Good day all

I have this curve (it is a solution of a partial differential equation that am working on)

exponential decay plot

and I want to calculate numerically the rate of exponential decay but I don't know how to go about it. Is there a way to do this with Matlab? or is there any other way to calculate the rate of exponential decay for it? Any help will be greatly appreciated.

1

There are 1 best solutions below

5
On

$f(t)$ decaying (or growing) exponentially for all $t > t_0$ means that there are parameters $c,\lambda$ such that $$ f(t) = c\,e^{\lambda (t-t_0)} \text{ for $t > t_0$.} $$

Now put an logarithmic scaled on the $y$-axis, i.e. instead of $f$, we look at the function $$ \hat f(t) = \ln f(t) = \ln c + \ln e^{\lambda(t-t0_0)} = \ln c + \lambda (t-t_0) = \lambda t + \ln c - \lambda t_0 \text{,} $$ which means that $\hat t$ will then be a line with slope $\lambda$.

Thus, you can numerically find the rate of decay by fitting a line to the logarithmn of the samples of $f$ you computed.


If you really want to do non-linear regression (by the look of your curve, linear regression should work quite well!), you can use matlab's lsqcurvefit function. You'll need to provide it with the parametrized objective function you want to fit, and preferrably with it's jacobi matrix (otherwise, the algorithms must resort to numeric differentiation, which is always a bit troublesome). Our objective function is $$ F\left((c,\lambda),t\right) = c\, e^{\lambda t} $$ and has the partial derivatives $$\begin{eqnarray} \frac{\partial F}{\partial c} &=& e^{\lambda t} &\quad& \frac{\partial F}{\partial \lambda} &=& c\lambda e^{\lambda t} \text{.} \end{eqnarray}$$ The following matlab function computes both

# Evaluates F((c,lambda), t)
#   Argument p are the parameters, i.e. p(1) = c, p(2) = lambda
#   Argument ts is a vector (or matrix) of t-values at which we evaluate F
#   Return value F(i) is F(p,ts(i))
#   Return value J(i) is [dF/dc (p,ts(i)), dF/dlambda (p,ts(i))]
function [F,J] = myF(p, ts)
  c = p(1)
  lambda = p(2)
  F = c * exp(lambda * ts)
  J = reshape([
    exp(lambda * ts),
    c * lambda * exp(lambda * ts)
  ], numel(ts), 2)

You can then use this with lsqcurvefit by doing

opts = optimoptions('lsqcurvefit','Jacobian','on')
p = lsqcurvefit(@myF, [1,-1], xvalues, yvalues, [], [], opts)

Note that this is mostly off the top of my head, and I haven't actually tried it. So there might be syntax errors and other mistakes in this code.