# Sum of a function

1 view (last 30 days)
Olawale Kazeem on 24 Jun 2019
Commented: Himanshu Rai on 25 Jun 2019
Hello everyone, I am stucked on how to write particular code for a Nash-Cournout oligopolistic equilibrium problem. I have written everything correctly and it ran successfully. The only situation I am in presently is trying to vary a particular step. To be more precise
I need code for the following:
is random for every
is random for every and
is random for every . I need to execute the following Quad program $c_j(x_j) = \frac{1}{2}x{_j}^{'} P_j x_j+ {q_j}^{'} x{_j}$. I will be glad if I can get a prompt help on this.
Thanks

Himanshu Rai on 25 Jun 2019
Edited: Himanshu Rai on 25 Jun 2019
The expression below should solve your problem. Also write questions properly - would be scalar, so c is a vector. P and x are normal matrices, and q is a vector. This should solve your problem.
PS - Also update your question, and attach the image file there
c = x' * P * x / 2 + q' * x

Himanshu Rai on 25 Jun 2019
All right, so now I got what your question is, but still your dimensions doesn't satisfy rules of matrix opeations.
is , is , so will be .
is , is , so will be .
But we can't add these two results.
Olawale Kazeem on 25 Jun 2019
We need q_j to be 1by 3 as well
Himanshu Rai on 25 Jun 2019
Well if is , then can't be calculated, because again the matrices are incompatible

Olawale Kazeem on 25 Jun 2019
I just checked the mistake, hopefully I have not disturbed you too much. I am attaching a file that contains what I need.

I suppose my definition of x is wrong. I defined ; ; and ; . $c = 0.5*x'*P*x+q'*x$. This gives a matrix.