how many number of values when added becomes equal to B(Known value)
Mostrar comentarios más antiguos
I have to find the X value for which \sum_(i=1)^X (i * a_i ) >= B
or ( 1*a_1 + 2*a_2 + --- + X*a_x >= B ) where a_i & B are known.
For finding the X value; is there any explicit formula? If anyone knows, please answer.
Thank you very much, kalpana
Respuesta aceptada
Más respuestas (1)
ES
el 28 de Jul. de 2014
0 votos
Immediate Response would be, you can run a loop and sum it up and check if the sum is greater than or equal to B at every iteration and break out of loop when it is satisfied.
A more measured approach will be, to use summation by parts. For example if length of a_i is 100, you could first check if summation(a_i*X) for X=1:50. If B is smaller, then you can run the summation for X=1:75. If B is greater, then you can run for X=1:25 and proceed so on.. But for this to work, a_i should be monotonically increasing.
Analysis of a_i (if it is a series or so) could also be useful.
1 comentario
kalpana
el 28 de Jul. de 2014
Categorías
Más información sobre Mathematics en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!