I expected both results to be $0_3$:
P = RandomReal[1, {3, 3}];
A = MatrixFunction[Sin, t*P] /. t -> 0
B = With[{t = 0}, MatrixFunction[Sin, t*P]]
(* {{-0.362821 - 1.25562 I, 0.288053 + 1.1563 I, 0.107869 + 0.0658492 I},
{0.133223 - 1.20752 I, -0.220254 + 1.22158 I, 0.181178 - 0.148004 I},
{-0.0991967 + 0.526917 I, -0.208297 - 0.517217 I, 0.583075 + 0.0340421 }} *)
(* {{0., 0., 0.}, {0., 0., 0.}, {0., 0., 0.}} *)
Following J.M.
comments:
P = RandomReal[1, {3, 3}, MachinePrecision -> 20] (* => A == B *)
P = RandomReal[1, {3, 3}, MachinePrecision -> 10] (* => A == B *)
P = RandomReal[1, {3, 3}, MachinePrecision -> $MachinePrecision] (* => A != B *)
a = $WorkingPrecision; P = RandomReal[1, {3, 3}, MachinePrecision -> a] (* => A == B *)
Also, using SetPrecision
A
is zero:
P = RandomReal[1, {3, 3}]
A = MatrixFunction[Sin, t*SetPrecision[P, $MachinePrecision]] /. t -> 0
So it's not a misunderstanding of mine, but a peculiar behaviour of MMA.
MatrixFunction[Sin, t*P][[1, 1]] // Expand
and try to figure out what happens in the other case. $\endgroup$MatrixFunction[Sin, t*P]
a function of $t$, and $B$ it's value in $0$? $\endgroup$P = RandomReal[1, {3, 3}, WorkingPrecision -> 20];
? $\endgroup$WorkingPrecision
setting, and compare what happens when you feed it the usual machine precision matrix and the result ofSetPrecision[P, 20]
. $\endgroup$