Java code to calculate cos(x) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Java code to calculate cos(x)

in cosine series we have take summation from k=0 to k=infinity. for. x^k/k! how to limit k from 0 to infinity ?

12th Mar 2017, 7:16 AM
onkar
1 Answer
+ 2
A sum till infinity is just a mathematical concept –you cannot effectively iterate till infinity. Instead, set a tolerance like t=.00001 (for example), and keep on adding till the difference between the previous sum and the actual sum is less than (in absolute value) that tolerance value.
13th Mar 2017, 6:24 AM
Álvaro