# Algebraic solution of an equation containing an error function

Convolution of a Gaussian with an exponential function (EMG) produces an asymmetric Gaussian, which I want to use for fitting experimental peak data. I am interested in finding an algebraic solution to the "apex" of the EMG in terms of the chosen parameters a0,a1,a2 and a3. a0 is the area, a1 is the Gaussian mean, a2 is the standard deviation of the Gaussian and a2 is the time constant. This can be done, perhaps in principle, by taking the first derivative of the EMG and set it to zero. Mathematica can arrive at the EMG expression by convolution but it is unable to solve for x when the derivative set to zero.

$$\text{EMG}(\text{a0\_},\text{a1\_},\text{a2\_},\text{a3\_},\text{x\_})\text{:=}\frac{\text{a0} e^{\frac{\text{a2}^2-2 \text{a3} (x-\text{a1})}{2 \text{a3}^2}} \text{erfc}\left(\frac{\text{a2}^2-\text{a3} (x-\text{a1})}{\sqrt{2} \text{a2} \text{a3}}\right)}{2 \text{a3}}$$

Its derivative is: $$\frac{\text{a0} \exp \left(\frac{\text{a2}^2-2 \text{a3} (x-\text{a1})}{2 \text{a3}^2}-\frac{\left(\text{a2}^2-\text{a3} (x-\text{a1})\right)^2}{2 \text{a2}^2 \text{a3}^2}\right)}{\sqrt{2 \pi } \text{a2} \text{a3}}-\frac{\text{a0} e^{\frac{\text{a2}^2-2 \text{a3} (x-\text{a1})}{2 \text{a3}^2}} \text{erfc}\left(\frac{\text{a2}^2-\text{a3} (x-\text{a1})}{\sqrt{2} \text{a2} \text{a3}}\right)}{2 \text{a3}^2}$$

If we use solve and set the derivative equal to zero, Mathematica is unable to find a solution even if we set all the constant parameters positive and real. Is there any approach that can help Mathematica to arrive at a solution in terms of the four parameters or is there any other way to find the apex of the EMG. Thanks.

• Please include Mathematica code that you have tried so far.
– Syed
Feb 17 at 4:55

\$Version

(* "14.0.0 for Mac OS X ARM (64-bit) (December 13, 2023)" *)

Clear["Global`*"]

You will need to use numeric techniques.

EMG[a0_?Positive, a1_?NumericQ, a2_?Positive, a3_?Positive, x_?NumericQ] :=
a0  E^((a2^2 - 2 a3 (x - a1))/(2 a3^2)) *
Erfc[(a2^2 - a3 (x - a1))/(Sqrt[2] a2  a3)]/(2 a3)

Manipulate[
Module[{pt},
arg = NArgMax[
{EMG[a0, a1, a2, a3, x], a1 - 3 a2 < x < a1 + 3 a2}, x];
pt = {arg, EMG[a0, a1, a2, a3, arg]};
Show[
Plot[EMG[a0, a1, a2, a3, x], {x, a1 - 3 a2, a1 + 3 a2}],
ListPlot[{Callout[pt, NumberForm[pt, {5, 3}]]},
PlotStyle -> Red],
PlotRange -> All,