# decimal places

Printable View

• Jul 10th 2010, 12:23 AM
ilikec
decimal places
suppose iam to solve cos x = 2x to 5 decimal places using newton raphson method how many iterations do i need to perform?
• Jul 10th 2010, 12:31 AM
elbarto
I imagine that would depend on where your initial guess is - I am sure CB will give a better answer then that. Out of curiosity why do you need to know how many iterations to perform? Are you attempting to implement the function with a for loop rather then a while/do loop?

Regards Elbarto
• Jul 10th 2010, 12:50 AM
ilikec
yeah iam gonna implement using a for loop and ask the user to input the no of correct decimal places needed. so how am i gonna determine the no of correct decimal places at the current iteration?
• Jul 10th 2010, 02:07 AM
mr fantastic
Quote:

Originally Posted by ilikec
yeah iam gonna implement using a for loop and ask the user to input the no of correct decimal places needed. so how am i gonna determine the no of correct decimal places at the current iteration?

What you do is include a condition that is tested after each iteration. Once the condition is true the program ends. You should think about what condition will end the program once you have achieved 5 decimal places of accuracy (Hint: Once you are correct to 5 decimal place, the fifth decimal place will no longer change).
• Jul 10th 2010, 03:29 AM
ilikec
i got it mr fantasitic. But isn't there a equation that i can use or does theory say that after say n iterations you get x no of decimal places correct?
• Jul 10th 2010, 03:54 AM
mr fantastic
Quote:

Originally Posted by ilikec
i got it mr fantasitic. But isn't there a equation that i can use or does theory say that after say n iterations you get x no of decimal places correct?

Google
• Jul 10th 2010, 04:10 AM
Also sprach Zarathustra