Summation of an infinate series

조회 수: 3 (최근 30일)
TS
TS 2015년 4월 29일
댓글: TS 2015년 4월 29일
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
James Tursa
James Tursa 2015년 4월 29일
Please post what you have done so far and we can comment on it and make suggestions.

댓글을 달려면 로그인하십시오.

채택된 답변

pfb
pfb 2015년 4월 29일
편집: pfb 2015년 4월 29일
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
TS
TS 2015년 4월 29일
Thank you, this helps a lot!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by