Reputation: 11
Step 1: declaration of symbolic objects using symmatrix
:
n = 2;
A = symmatrix('A', n);
lambda = symmatrix('lambda', [n,1]);
g = symmatrix('g', [n,1]);
phi = symmatrix('phi', [n,1]);
l = symmatrix('l', [n,1]);
item = symmatrix('i', [n,1]);
Step 2: declaration of equations:
arga = (l.'*(((lambda).*(A * g) + (phi.'*lambda) * (A * g))));
argb = (l.'*(((lambda).*(item) + (phi.'*lambda) * (A * g))));
Step 3: differenciating with respect to lambda: arga
and argb
should work in the same way, as both item
and A*g
are 2x1 vectors. However I cannot run the sum in the parenthesis of the output for sola
due to dimensionality issues:
sola = diff(arga, lambda)
solb = diff(argb, lambda)
Step 4: Moreover, running the example below, sola
and solb
give two different results when substituting item
with a*g
, which should not be the case:
l=[1.2;1.1]
g=[1.9876;1.88]
phi=[1.0987;1.5192]
A=[132 123;1222 124]
item=A * g
Running sola
, I get the following expression, which I now evaluate with the value of the example:
l.'*((eye(2)) .* A*g + kron(phi.', A*g))
same for solb
:
l.'*(kron(phi.', A*g) + (eye(2)) .* l)
ISSUES: I was expecting:
sola
,solb
after the evaluation
but that is not the case.What am I missing?
Upvotes: 0
Views: 52