use the for or while looping to the series S=4*[sin(theata)/1 +sin(3theata)/3+sin(5theata)/5+.....] ,,in the range 0<theata<pi with error bound of 10^-6..?....please help me to solve this question in the earliest opportunity
Show older comments
S=4*[sin(theata)/1 +sin(3theata)/3+sin(5theata)/5+.....]
Accepted Answer
More Answers (2)
Image Analyst
on 15 Apr 2013
0 votes
Hint, have a loop over k and calculate sin(k*theata)/k in the loop. I hope that's not doing too much of your homework for you. You still have to make the loop and sum up the term in the loop into the overall sum and then multiply that by 4.
2 Comments
majid
on 15 Apr 2013
Edited: Image Analyst
on 15 Apr 2013
Image Analyst
on 15 Apr 2013
Use a for loop instead of a while loop. Have an outer for loop over theata.
for theata = 0: 0.01 : pi
Don't use "sum" since that is a built in function name and you'll be destroying it. Use S like you started to. Finally you need to calculate the "true" value (whatever that is) and compare it to S and bail out of your inner for loop once the error is less than 1E-6.
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!