Summation, Please help i will buy you a cookie :D

조회 수: 4 (최근 30일)
S Weinberg
S Weinberg 2014년 2월 11일
편집: S Weinberg 2014년 2월 12일
I thought i had figured out summation, but apparent not :( I have a text book question that asks " evaluate series Σ Un (to infinity, with n=1) and Un is not known." The book gives you Un+1 = (Un)^2 with U1 = 0.5. Stop summation at Un < 10^-8 My code i wrote myself is
n = 2;
v = 10^-10
for ii = 0.5:length(v);
sum= (ii)^n;
end;
disp(sum)
Why does it not work....please help! :D

채택된 답변

Kevin Claytor
Kevin Claytor 2014년 2월 11일
Let's break it down into some steps. First consider the problem for a moment;
We have the series U(n+1) = U(n)^2, U(1) = 0.5
By hand we can tell that the next few terms in the series are; U(2) = .5*.5 = 0.25, U(3) = .25*.25 = 0.0625, U(4) ~= 0.0039, ...
Here's a question for you: How can we get these numerically? Can you give me a for-loop that computes each of these?
Now, the next condition is deciding when to stop. Since we are computing the sum, we are going to stop when we end up adding very small terms. Hence we'll get an approximate answer. We've decided that this will be when U(n) < 10^(-8). Perhaps we can check this condition with an if or a while statement? Can you give an example of one of these?
If you can implement these two parts, I think you will see the answer.
  댓글 수: 2
Walter Roberson
Walter Roberson 2014년 2월 11일
For this, the poster will give you a cookie recipe ;-)
S Weinberg
S Weinberg 2014년 2월 12일
편집: S Weinberg 2014년 2월 12일
Thanks i did work figure out the first few terms as you have said and tried to work out the ratio of the sum. Thus i was going to use the ratio in sum to infinity, but the Un+1/Un keeps changing in ration when substituting new terms in (i.e. terms 2 and 1, then 3 and 2 etc.)..let me have another look and struggle till late in the morning again :(
None-the-less you deserve a cookie Kevin, what flavour do you like? :D

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

추가 답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2014년 2월 11일
Have you checked the length of v?
Don't use sum as variable (sum is a Matlab built-in function)
When you write
a=10
a=20
a=1
What is the final result?
  댓글 수: 3
Azzi Abdelmalek
Azzi Abdelmalek 2014년 2월 11일
편집: Azzi Abdelmalek 2014년 2월 11일
Have you checked the length of v?
Don't use sum as variable (sum is a Matlab built-in function)
What your for loop is doing?
S Weinberg
S Weinberg 2014년 2월 12일
Ok, i am going to go back and check this sum again, i think your help has been awesome thanks :D

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

Community Treasure Hunt

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

Start Hunting!

Translated by