# Calculating the contributing terms of a summation equation

21 views (last 30 days)
Bharath Anantharamaiah on 21 Jun 2020
Commented: David Goodmanson on 15 Jul 2020 at 2:52
I am trying to calculate the value of a variable in a summation term. Could any of you share some leads about the coding technique in Matlab? My equation looks like: ,
in which I know the values of Y, and z. I am looking for an idea and methodology to calculate the values of the variable .

Bharath Anantharamaiah on 4 Jul 2020 at 20:51
Hi David,
Apologies for late reply. I see your point. Let me share the exact equation that I need to calculate. So it will alleviate the issue. Here it is: .
In this equation, I know the values of the vector Q, y and . I need to calculate the value of the vector . I believe I need to use some optimisation algorithms.
Bharath Anantharamaiah on 14 Jul 2020 at 12:20
Hi David,
Vectors Q(y) and y are having same dimensions. However, the dimension of q_i and x_i is solely dependant on the value of N. There is no neccessity that the dimension of Q(y) and q_i be the same. And most certainly N>2.
The idea is simple. I have a curve that is defined by Q(y) vs y. Now I need to calculate the values of pairs of q_i and x_i for fitting this curve! Hope I am clear now?
.
David Goodmanson on 15 Jul 2020 at 2:52
HI Bharath,
I am aware that Q (used to be called Y) and y have the same length, and that q and x have the same length, which may well be diffferent than the length of Q&y. Given the equatiion you posted on July 4, I believe the answer I posted is apt.

KALYAN ACHARJYA on 21 Jun 2020
Edited: KALYAN ACHARJYA on 21 Jun 2020

#### 1 Comment

Bharath Anantharamaiah on 21 Jun 2020
Dear Kalyan,
Thank you for the reply. In the link you shared, the value of dependent term is calculated based on the values of independent terms. My case is the opposite. In the equation ,
I already have the value for the dependent term (Y) and I need to calculate the possible values of the independent term ( ) using iterations.

David Goodmanson on 5 Jul 2020 at 5:44
Edited: David Goodmanson on 5 Jul 2020 at 5:45
Hi Bharath,
suppose the sum involving q is done over a dummy index j instead of i. It appears that Y and y are vectors of the same length so the expression is
Yi = sum{j=1,N} qj*xj*yi/(1+xj^2*yi^2)
or in matrix notation
Y = M*q where M(i,j) = xj*yi/(1+xj^2*yi^2)
You don't say how the length of Y and y compare to N, but if that length is >= N, then a least squares solution for q is just
q = M\Y.

Bharath Anantharamaiah on 5 Jul 2020 at 20:17
Hi David,
The approach you propose is absolutely perfect if the value of N is 1. However, if I have to choose N>1, I believe the calculation does not hold good. Please give me sometime, I am exploring the case that you described, i.e. if vector lengths of Q and q is not same as N. I will clear that doubt as soon as possible.
David Goodmanson on 6 Jul 2020 at 16:39
I will assume here that vectors Y and y have the same length as each other (if not then I don't understand the equation at all). But assuming Y and y are the same length, the key is that the entire expression is linear in q, so that a minimal q can be determined with standard linear algebra.
Assume that Y and y have length A. Then as I mentioned before, this can be put into matrix multiplication form,
Y = M*q
where Y is Ax1, q is Nx1 and M is AxN. This expression has A equations and N unknowns which are the elements of q.
If A=N there is an exact solution for q (assuming that matix M is nonsingular, which seems likely). If A>N there are more equations than unknowns and q = M\Y solves for q in the least squares sense. If A< N there are more unknowns than equations and q is not determined completely but can vary somewhat.