I'm not sure this is the right way to proceed, but I have a question related to another open question.

In this article, I am looking to analyze some quantum dot UV-Vis absorbance spectra (example data). I am a synthetic chemist and a bit of a mathematician, so I am still trying to understand this problem. In seeking different solutions to this problem, I came across a plot from this document that I am almost certain I can not publish for copyright reasons. I have therefore made an approximation in Mathematica:

Clearly, I'm using the @Silvia code in this article to generate this graph, which is not a coincidence.

As I understand this code

```
Clear(model)
model(data_, n_) :=
Module({dataconfig, modelfunc, objfunc, fitvar, fitres},
dataconfig = {A(#), μ(#), σ(#)} & /@ Range(n);
modelfunc = peakfunc(##, fitvar) & @@@ dataconfig // Total;
objfunc =
Total((data((All, 2)) - (modelfunc /. fitvar -> # &) /@
data((All, 1)))^2);
FindMinimum(objfunc, Flatten@dataconfig)
)
```

The model assumes all the same peak functions, then carries out least squares minimization.

I would like to modify this code to include a background function. I've tried something similar using `FindFit`

```
bgfunc = a + bx + c x Log(x) + d Log(e + x)
modelfunction =
a + b x + c x Log(x) + d Log(e + x) + f^2 Exp((x - g)^2/h^2) +
i^2 Exp((x - j)^2/k^2) + l^2 Exp((x - m)^2/n^2)
FindFit(data,modelfunction,{a,b,c,d,e,f,g,h,i,j,k,l,m,n},x)
```

It does not work, of course, but I do not know why.

Following this, I tried to change the code of @ Silvia, but without success. My naive assumption was that I could just increase the number of terms in peakfunc like this:

```
peakfunc(A_, mu, sigma, g_, h_, x_) =
A^2 E^(-((x - mu)^2/(2 sigma^2))) + g*(x - h)^2
```

I've used this modified peakfunc to generate the data shown above, with the following dataconfig:

```
dataconfig = {{.7, -12, 1, 0, 0}, {2.2, 0, 5, 0, 0}, {1, 9, 2, 0,
0}, {0, 1, 1, 0.01, 20}};
```

However, the modified adjustment function does not return any sensible coefficients with this modified fit function.

My next approach was to modify the adjustment function to include my background function:

```
Clear(model)
model(data_, n_) :=
Module({dataconfig, modelfunc, objfunc, fitvar, fitres,bgfunc},
bgfunc = g*(x-h)^2;
dataconfig = {A(#), (Mu)(#), (Sigma)(#)} & /@ Range(n);
modelfunc = peakfunc(##, fitvar) & @@@ dataconfig // Total;
AppendTo(modelfunc, bgfunc);
AppendTo(dataconfig, {g(1),h(1)});
objfunc =
Total((data((All, 2)) - (modelfunc /. fitvar -> # &) /@
data((All, 1)))^2);
FindMinimum(objfunc, Flatten@dataconfig))
```

I know it's a particularly awkward can, and of course, it does not work.

How could one approach the addition of a predefined background function to this code? I understand that the initial goal of the code was to find the minimum number of Gaussians to adapt to a dataset. I think my approach should work unless this problem is unsolvable.

tl; dr

- Is it possible to simultaneously adjust the peaks and the background? Suppose that the number of peaks is small and that, for the moment, it can be entered manually, and that the shape of the background is either:

$ a (x + b) ^ 2 + cx + d $

or

$ a + bx + cLog (x) + dLog (x + e) $

- If possible, what is the best way to implement it? Am I on the right track trying to edit this code by @ Silvia?
- As a supplementary question, how to analyze this expression?

```
modelfunc = peakfunc(##, fitvar) & @@@ dataconfig // Total
```

In particular, what does

```
&@@@
```

mean?

Should this be interpreted as:

```
&@ + @@
```

or

```
& + @@@
```

?

Thank you