Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91217559
compute_pi.hh
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Nov 9, 02:01
Size
570 B
Mime Type
text/x-c++
Expires
Mon, Nov 11, 02:01 (2 d)
Engine
blob
Format
Raw Data
Handle
22222416
Attached To
R9484 sp4e-homework-lars-bertil
compute_pi.hh
View Options
#ifndef COMPUTEPI_HPP
#define COMPUTEPI_HPP
#include "series.hh"
class
ComputePi
:
public
Series
{
public
:
//PREVIOUS IMPLEMENTATION:
//double compute(unsigned int N) {
// double result = 0.0;
// for (int a = 1; a<=N; ++a) {
// result=result+1.0/(a*a);
// }
// result = sqrt(6.0*result);
// return result;
//}
double
compute
(
unsigned
int
N
)
{
double
current_value
=
Series
::
compute
(
N
);
return
sqrt
(
6.0
*
current_value
);
}
double
computeValue
(
int
k
)
{
return
1.
/
(
1.
*
k
*
k
);
}
double
getAnalyticPrediction
(){
return
M_PI
;
}
};
#endif
Event Timeline
Log In to Comment