-2

I am evaluating $\sin(A)$ where $A$ is a $3\times 3$ matrix. I have calculated it but now I want to check this with a Taylor series expansion of Sin[x].
What I am using is

myfn= With[{B = N[A]}, 
            Sum[ MatrixPower[B, 2 k + 1]/Factorial[2 k + 1], {k, 0, 4}]]

But I have to put $(-1)^k$ as well in the summation list. I dun know how to do it either it takes $1$ or $-1$ but it's not changing a sign whenever I am trying to evaluate

With[{B = N[A]}, 
      Sum[ MatrixPower[B, 2 k + 1]*(-1^k)/ Factorial[2 k + 1], {k, 0, 4}]]

I am seriously stuck, could anyone help?

Artes
  • 57,212
  • 12
  • 157
  • 245
user11948
  • 171
  • 6
  • 1
    Did you mean to text this to someone called 'coz'? If not, please use the help facilities (upper right corner of page) to see how to properly format code in a post. You will have a better chance of getting assistance when readers aren't required to decipher the question. – ciao Jan 25 '14 at 05:15
  • Still, you might have wanted MatrixFunction[]. – J. M.'s missing motivation Aug 13 '17 at 17:41

1 Answers1

5
With[{B = N[A]}, 
      Sum[ MatrixPower[B, 2 k + 1]*((-1)^k)/ Factorial[2 k + 1], {k, 0, 4}]]

See when is f@g not the same as f[g]? under the Operator Precedence answer for why this is. Also, it's generally a bad idea to use uppercase for the initial, you can end up clashing with MM symbols (e.g. E is MM's symbol for Euler's constant.

ciao
  • 25,774
  • 2
  • 58
  • 139
  • Hi Rasher,Thanks alot for the answer. It really helped me becuase I was using different series for positive terms and different for negatvie terms in same expression to get the anser. – user11948 Jan 26 '14 at 06:52