I have a code for error propagation :-
err[F_, w__] := {F[Map[First, List[w]] /. List -> Sequence],
Block[{parms = Table[Unique[], {x, 1, Length[List[w]]}],
values = Table[List[w][[i, 1]], {i, 1, Length[List[w]]}],
errors = Table[List[w][[i, 2]], {i, 1, Length[List[w]]}]},
Sqrt[Total[
Table[(D[F[parms /. List -> Sequence], parms[[i]]] errors[[i]])^2,
{i, 1, Length[values]}] /.
Table[parms[[i]] -> values[[i]], {i, 1, Length[values]}]]]]}
I am not able to propagate error in a complex function with this code.For example in case of real function which is defined as :-
f[a_, b_] := a + b;
err[f, {2, 0.1}, {3, 0.2}]
The output for this function is :- {5, 0.223607}. But in case of complex function say :-
f[a_, b_] := Abs[a + I b];
err[f, {2, 0.1}, {3, 0.2}]
The output is
`{Sqrt[13], Sqrt[(-0.03 + 0. I) Derivative[1][Abs][2 + 3 I]^2]}`
In output both values should be a numerical number. How can I modify my code that it will give me a numerical number in output. Thanks.
Please help me .
err
, both real and complex. $\endgroup$expr = ComplexExpand[Abs[a + I b]]
,PropagateCovariance[expr, {a, b}] // Simplify
is(2 a b cov[a, b] + a^2 var[a] + b^2 var[b])/(a^2 + b^2)
. This is the (first-order approximation of the) variance inf
as a function of the variances ina
andb
. $\endgroup$