Comp Sci Calculating something correct upto ##m## significant figures

  • Thread starter Thread starter Wrichik Basu
  • Start date Start date
  • Tags Tags
    Significant figures
Click For Summary
SUMMARY

This discussion focuses on calculating values to a specified number of significant figures using series approximations, particularly in the context of computing the value of pi. The termination condition for the series is defined as stopping when the difference between successive terms is less than ##10^{-m}##, where ##m## is the desired number of significant figures. Participants emphasize the importance of understanding how trailing zeros affect significant figures and the necessity for a program to determine when to stop calculating based on the precision of successive approximations.

PREREQUISITES
  • Understanding of significant figures and their implications in numerical calculations.
  • Familiarity with series approximations and convergence criteria.
  • Basic programming skills to implement iterative calculations and termination conditions.
  • Knowledge of numerical methods for approximating mathematical constants like pi.
NEXT STEPS
  • Research the concept of convergence in numerical series and how it applies to significant figures.
  • Learn about implementing termination conditions in iterative algorithms for numerical calculations.
  • Explore the effects of floating-point precision in programming languages such as Python or C++.
  • Study the mathematical properties of significant figures in relation to addition and subtraction of decimal numbers.
USEFUL FOR

Mathematicians, computer scientists, and software developers interested in numerical methods, precision in calculations, and optimization of algorithms for mathematical approximations.

Wrichik Basu
Science Advisor
Insights Author
Gold Member
Messages
2,180
Reaction score
2,690
Homework Statement
The Zeta function is defined as $$\zeta(n) \ = \ \sum _{k=1} ^{\infty} \frac{1}{k^n}.$$ Given that ##\zeta(4) = \pi^4/90##, estimate a value of ##\pi## correct to three significant figures. How many terms are needed in the series for this?
Relevant Equations
Given in the question.
I have solved questions where I have been asked to find something correct to ##m## places of decimal using some series. See this thread. The logic was, the program would terminate at the ##k##th term if the ##k+1##th term is ##<10^{-m}##.

But how do I terminate the series here? Say I calculate ##S_{k+1}## and ##S_k##, and find a difference ##t_{k+1}## (actually the ##k+1##th term). Notwithstanding anything else, this term can be approximated to any number of significant terms. For example, if ##t_{k+1} \ = \ 0.0000000001,## I can still approximate that as ##0.0000000001000## and conclude that it has four significant figures. In fact, the trailing zeros can be anything depending on how precisely my computer can calculate. What should my condition of termination be in this case? More specifically, how do I check whether the current sum is correct up to certain significant figures?
 
Physics news on Phys.org
Wrichik Basu said:
More specifically, how do I check whether the current sum is correct up to certain significant figures?
Given that this is in the comp sci homework forum, is brute force an option ?
If I make a table of $$\sqrt[
\leftroot{-1}\uproot{16}\scriptstyle 4] { 90*\sum _{k=1} ^{N} \frac{1}{k^4} } \ \ $$ versus N I get:
Code:
 1    3.080070288 
 2    3.127107866
 3    3.136152380 
 4    3.138997889
 5    3.140161179
 6    3.140721718
 7    3.141024158
 8    3.141201402
 9    3.141312040
10    3.141384622
11    3.141434195
12    3.141469195
13    3.141494605
14    3.141513496
15    3.141527831
So with three terms you have three significant figures: 3.14

I don't understand your criterion
Wrichik Basu said:
find something correct to ##m## places of decimal using some series. The logic was, the program would terminate at the ##k##th term if the ##k+1##th term is ##<10^{−m}##
What if the next thousand terms are just below ##<10^{−m}## ? You'd be at m-3 signifcant digits !

Also 0.0000000001 has one significant digit. Things change when you sum: 0.1000000001 has ten !
 
BvU said:
What if the next thousand terms are just below ##<10^{−m}##?You'd be at m-3 signifcant digits !
That logic was for correct to decimal places, not significant figures. See the thread linked in the OP; I have written the logic there.
BvU said:
Given that this is in the comp sci homework forum, is brute force an option ?
If I make a table of $$\sqrt[
\leftroot{-1}\uproot{16}\scriptstyle 4] { 90*\sum _{k=1} ^{N} \frac{1}{k^4} } \ \ $$ versus N I get:
Code:
1    3.080070288
2    3.127107866
3    3.136152380
4    3.138997889
5    3.140161179
6    3.140721718
7    3.141024158
8    3.141201402
9    3.141312040
10    3.141384622
11    3.141434195
12    3.141469195
13    3.141494605
14    3.141513496
15    3.141527831
So with three terms you have three significant figures: 3.14
I couldn't understand one thing. My program doesn't know the value of pi beforehand. You calculated till ##N=15## and stopped because you were getting the value correct to three significant figures. How will the program know where to stop? If it stopped at ##N=500## rather than ##N=15##, you and I know that the value will remain 3.14, but the program doesn't know that, right?
 
Wrichik Basu said:
I couldn't understand one thing. My program doesn't know the value of pi beforehand. You calculated till ##N=15## and stopped because you were getting the value correct to three significant figures. How will the program know where to stop? If it stopped at ##N=500## rather than ##N=15##, you and I know that the value will remain 3.14, but the program doesn't know that, right?
The program can "know" by calculating the difference between successive approximations. In the values produced by @BvU, to get 3 sig. figures, or accuracy in 2 decimal places, we need to continue until the difference between successive values is less than 1/2 of a hundredth; i.e., less than .005. If we add or subtract numbers less than .005, it can't change the digit in the hundredths place. The first place in the table where the difference is less than .005 is at rows 3 and 4, with values of 3.136152380 and 3.138997889, respectively, with the difference being about .003. To the nearest hundredth, both number round to 3.14.
 
  • Like
Likes Wrichik Basu
BvU said:
Also 0.0000000001 has one significant digit. Things change when you sum: 0.1000000001 has ten !
The correct statement here would be
0.1000000000
0.0000000001
-------------------
0.1000000001

Your statement could be interpreted as meaning that
0.1
0.0000000001
-------------------
0.1000000001

which is not correct. To the proper number of significant digits, the latter would be 0.1
 
  • Like
Likes BvU

Similar threads

  • · Replies 6 ·
Replies
6
Views
1K
  • · Replies 17 ·
Replies
17
Views
3K
  • · Replies 3 ·
Replies
3
Views
3K
Replies
4
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 14 ·
Replies
14
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K