0
$\begingroup$
p[t]=S[t]*X[t]-g[t]
X[t+1]=(Inverse((I-B*S(t+1)))(A*X[t]-B*g[t+1]+D)
S[t]=C+A*S[t+1]*(Inverse((I-B*S(t+1)))*A
g[t]=A*S[t+1]*(Inverse((I-B*S(t+1)))(B*g[t+1]-D)+A*G[T+1]+E

For t=1 to t=10

I want to the different values of S[t] and g[t] at all points in time by backward loop; then get the corresponding values of x[t] and p[t] by forward loop.

That S, A, C, and B are $2\times2$ matrices and P, X, D, E and g are $2\times1$ matrices.

The boundary condition are:

S[11]={{0,0},{0,0}}, g[11]={{0},{0}}, X[1]={{1},{0}}, p[11]={{0},{0}}
A={{0.1,0},{0,0.1}} B={{2,3},{-3,1}}, C={{0.2,0.6},{0.2,0}}, I={{1,0},{0,1}} 
D={{2},{3}}, E={{1},{0}}

How can i do the Sensitivity Analysis for above parameters?

$\endgroup$
2
  • $\begingroup$ Preferably don't use variables starting with an uppercase letter. All of Mathematica's functions start with one and it is easy to inadvertently use one. In this case you have used the reserved words I (Sqrt[-1]) and C (used for constants in differential equation solutions) $\endgroup$ Mar 2 '15 at 7:41
  • $\begingroup$ See this one: mathematica.stackexchange.com/q/76184/1783 for a really good hint $\endgroup$
    – bill s
    Mar 2 '15 at 9:17
1
$\begingroup$
A = {{0.1, 0}, {0, 0.1}};
B = {{2, 3}, {-3, 1}};
c = {{0.2, 0.6}, {0.2, 0}};
d = {2, 3};
e = {1, 0};
i = {{1, 0}, {0, 1}};
g[11] = {0, 0};
g[t_] := A.S[t+1].Inverse[i-B.S[t+1]].(B.g[t+1]-d)+A.g[t+1]+e;
p[11] = {0, 0};
p[t_] := S[t].X[t] - g[t];
S[11] = {{0, 0}, {0, 0}};
S[t_] := c + A.S[t + 1].Inverse[i - B*S[t + 1]].A ;
X[1] = {1, 0};
X[t_] := Inverse[i - B.S[t]].(A.X[t - 1] - B.g[t] + d);
For[j = 10, j >= 1, j--,
  g[j] = g[j];
  S[j] = S[j]
];
For[j = 1, j <= 10, j++,
  X[j] = X[j];
  p[j] = p[j]
]

After running that code you can inspect single values by evaluating things like

g[7]

or you can look at all values of g by evaluating

?g

Likewise for your other three functions.

$\endgroup$
1
  • $\begingroup$ how can i do the Sensitivity Analysis for above parameters? $\endgroup$
    – mehrnoosh
    Mar 5 '15 at 7:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.