# Solving a system of PDEs expressed in matrix notation

A = SparseArray[{Band[{1, 2}] -> 1, Band[{2, 1}] -> -1}, {n, n}]/(2*Δx);

B = SparseArray[{Band[{1, 1}] -> -2, Band[{1, 2}] -> 1, Band[{2, 1}] -> 1}, {n, n}]/(Δx^2);

R = SparseArray[{Band[{1, 1}] -> 1}, {n, n}];

pde = -D[V[S, t], t] == ((r - 0.5 σ^2).A + (0.5 σ^2).B - r.R)V


Having constructed my matrices A, B and R, how do I get Mathematica to solve for a single matrix? I need to replace it in the above equation. I've tried the above codes but failed. I need every element in each matrix be multiplied by the respective scalar.

-
Having constructed my matrices A,B and R, how do i solve in mathematica to get a single matrix? I need to replace it in the above equation. I've tried the above codes but failed. I need every element in each matrix be multiplied to the respective scalar. Please help. Thanking you. I should get a linear system, ie, dV/dt = X V, where X is the single matrix and V a vector matrix. Please help. –  aria01 Nov 14 '12 at 14:56
What's the shape of $r$, is it a scalar or a vector? If it's a scalar, do you want the expression to look like: (((r - 0.5 \[Sigma]^2)*A + (0.5 \[Sigma]^2)*B - r*R) // Normal // TableForm ).V –  ssch Nov 14 '12 at 15:08
Sorry i forgot values, r = 0.03 and sigma = 0.2. Only V which is a vector matrix here. @ssch –  aria01 Nov 14 '12 at 15:29
@ssch thanks,i've tried the command but unfortunately the scalar is remaining outside the matrix. I need it to be solved into a single matrix. Could anyone help me. –  aria01 Nov 14 '12 at 20:19
You might want -D[V[s, t], t] == ((r - 0.5 \[Sigma]^2) A + (0.5 \[Sigma]^2) B - r R).V[s, t] Point being, you seem to have reversed Dot and (element-wise) Times. –  Daniel Lichtblau Feb 12 '13 at 22:46

((r - 0.5 \[Sigma]^2)*A + (0.5 \[Sigma]^2)*B - r*R).Table[
V[s, t][[i]], {i, 1, n}]


So Mathematica sees the different dimensions of V.

It behaves like this:

IdentityMatrix[3].y
(* {{1,0,0},{0,1,0},{0,0,1}}.y *)

IdentityMatrix[3].{y[1], y[2], y[3]}
(* {y[1],y[2],y[3]} *)

-