Summation of an infinate series

1 visualización (últimos 30 días)
TS
TS el 29 de Abr. de 2015
Comentada: TS el 29 de Abr. de 2015
I need help creating a code that computes the summation of L=1/(2^n) where the summation will stop when the difference between values becomes 0.0001. Any suggestions?
  1 comentario
James Tursa
James Tursa el 29 de Abr. de 2015
Please post what you have done so far and we can comment on it and make suggestions.

Iniciar sesión para comentar.

Respuesta aceptada

pfb
pfb el 29 de Abr. de 2015
Editada: pfb el 29 de Abr. de 2015
That can be done in 3 lines of code tops. However, giving you the solution for your assignment straight away does not seem fair.
Finding the nmax satisfying your threshold should not be hard analytically.
After that, you can use the builtin function sum to calculate the sum of the elements of a vector containing the terms 1/n^2 up to the threshold you calculated.
Take a look at the elementwise operations ./ and .^2.
Total, three lines of code, if you build the vector in a separate instruction
1) calculate the threshold
2) build the vector
3) sum the vector
  1 comentario
TS
TS el 29 de Abr. de 2015
Thank you, this helps a lot!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by