Skip to content

rockround/UNIXFINAL

Repository files navigation

General:

directories p1,p2,p3,p4 correspond to their respective problems.
bonus is where the bonus files are.
use make to make all necessary files in each folder.

1.
bash
10	0	2.00000000000000000000	1.14159265358980000000	.3633802
100	0	2.84000000000000000000	.30159265358980000000	.0959999
1000	4	3.16000000000000000000	.01840734641020000000	.0058592
10000	46	3.12640000000000000000	.01519265358980000000	.0048359
C
10	0.0000000	3.6000000	0.4584073	0.1459156
100	0.0000000	3.0800000	0.0615927	0.0196056
1000	0.0000000	3.0640000	0.0775927	0.0246985
10000	0.0000000	3.1352000	0.0063927	0.0020348

1.1 
c
1610169687 trials, prediction 3.1415788

bash
31735 trials, prediction 3.13582665821471791621	

1.2

The C code was faster because it is a compiled language, and thus after compilation it is direclty read on a machine, not translated line by line by the kernel as with scripting languages.

1.3

The C code was also more accurate than bash with the same sample sizes, which can be attributed to the fact that the random number source was a much better one (using the mersenne twister), whereas the awk one is based on a worse PRNG.

2.
For problem 2, because using structs seemed difficult, I stored the result of each test as either S for success or F for fail.


Bonus.


Bonus 1 was done.

The program is called lnfactn.c. 
at n=752, stirling's approximation is within .1% of the real value. This value was attained by running the program on 1000 samples and grepping for .099.

Bonus 2 was done.

The program is called uglyNum.c
% was used to determine if it was ugly.


Bonus 3 was done.

The program is called sigmaDiv.c
% was used to determine divisibility, and summed up.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published