I have an equation given by:
f[x_,M_]:= 96.4529 E^(M x (-0.216331 - 38.7396 M x)) + 31.0508 E^(M x (0.306405 - 18.585 M x)) + 4.36041 E^(M x (3.95974 - 7.37814 M x)) + 2.00366 E^(M x (-1.54639 - 3.79704 M x)) + 119.8 E^(M x (-0.0235058 - 0.0245919 M x));
where $x$ is a variable, $M$ is the mean value from a measurement and $\delta M$ is the error in $M$. For example, let $M \pm \delta M$ be equal to $ 15.584 \pm 0.045$.
The approximate error $\delta f$ in $f$ can be given, in the simplified form assuming indipendence of $x$ and $M$, as:
$$\delta f = \sqrt{\left(\frac{\partial f}{\partial M}\right)^2(\delta M)^2 + \left(\frac{\partial f}{\partial x}\right)^2(\delta x)^2}$$
As $x$ is not a measured value, I take $\delta x = 0$ :
DfM[x_, M_] := Evaluate@ D[f[x, M], M];
Dfx[x_, M_] := Evaluate@ D[f[x, M], x];
Deltaf[x_, M_, deltaM_] := Evaluate@ Simplify[Sqrt[(DfM[x, M])^2 deltaM^2
+ (Dfx[x, M])^2 deltax^2]] /. {deltax -> 0};
This way I can find the error $\delta f$ in $f$ that is a consequence of the error $\delta M$ in $M$.
But my aim is to find the full width at half maximum (FWHM) i.e.
$$FWHM \pm \delta FWHM = (x_2-x_1) \pm \sqrt{(\delta x_1)^2 + (\delta x_2)^2}$$
along with the error $\delta FWHM$ that propagates in doing so. Here, $x_1$ and $x_2$ are the corresponding $x$-axis values for the half maximum HM
. The errors in $x_1$ and $x_2$ are $\delta x_1$ and $\delta x_2$, respectively.
To find the half of the maximum (i.e. HM
) , I find the maxima and minima of f[x,M]
as:
fMin = First[NMinimize[{f[x, 15], -0.08 < x < 0.04}, x]];
fMax = First[NMaximize[f[x, 15], x]];
HM = fMax + (fMin - fMax)/2;
There will be some error in HM
i.e. $\delta HM$ but I am unable to figure out how this error is propagating via the NMaximize
and NMinimize
functions. Additionally, to find the $x_1$ and $x_2$ I need to solve the function f[x,M]
for the value HM
but this function does not seem to have an inverse and therefore Solve
fails if I use:
Solve[f[x, 15] == HM, x]
Is there a way I could find $FWHM$ and its error $\delta FWHM$?.
EDIT:
Link to the data of which fun[x]
is a nonlinear fit: Data
fun[x_] := 96.4529 E^((-0.216331 - 38.7396 x) x) + 31.0508 E^((0.306405 - 18.585 x) x) + 4.36041 E^((3.95974 - 7.37814 x) x) + 2.00366 E^((-1.54639 - 3.79704 x) x) + 119.8 E^((-0.0235058 - 0.0245919 x) x);
the function f[x_,M_]
given above is derived using fun[x_]
as:
f[x_,M_] := fun[x*M];
Solve[f[x, 15] == HM, x]
withx1 = x /. FindRoot[f[x, 15] == HM, {x, -0.1}]
andx2 = x /. FindRoot[f[x, 15] == HM, {x, -x1}]
. (I'll work on the error part later if no one else does it sooner.) $\endgroup$-0.08 < x < 0.04
Otherwise with minimum would seem to be zero. $\endgroup$f[x,M]
is a fitted function from a data that is collected in the domain-0.08 < x < 0.04
and has the background amplitude closer tofMin
rather than a0
amplitude. $\endgroup$x /. Solve[f[x, 15] == HM, x, Reals]
. $\endgroup$