The initial terms in such series are often relatively too large in comperison with the following ones. So after a few terms, we have been adding very small number to too large numbers.The error here is caused by the chopping of the computer while calculating the series.
By the definiton above we examine the problems below:
Problem 3:
F(N)= Σ 1/(n*n) where n=1 to n=N
Compute the series by adding with the variable n=1 to 10,000 and by adding the varieble n=10,000 to n=1.Compare the results.
This is the code solution program of the problem in Java:
import javax.swing.JOptionPane;
public class series{
public static void main(String args[]){
double x =0.0;
double y=0.0;
for(double i=1.0; i<10001.0; i++){
x += 1.0/(i*i);
}
for(double i=10000.0; i>0.0; i--){
y +=1/(i*i);
}
JOptionPane.showMessageDialog(null,"The sum begined from n=1 :"+x+'\n'+"The sum begined from n=10,000 :"+y);
}
}
And these are the outputs:
Thursday, March 27, 2008
Adding a Large and Small Number Error
Etiketler:
adding,
asp .Net,
C#,
code,
html,
java,
large number,
php c#,
pseudocode,
SAP,
small number,
SQL
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment