This is a calculator that has some special functions. These function include
Length of calculation is limited only by the hardware it is using. I have 3.5
terabytes of free space that I plan to use with this calculator. Addition,
subtraction, multiplication and division can be limited by the length of a number depending on the system so the number can be stored on the hard drive. I know it can be slow but I have little other options in this particular situation.
The final answer is written to a text file. This is so it doesn't have to be
instantly displayed on the screen which can slow things down quite a bit. When the calculation is complete the program should displayed a calculation complete message. If the answer is over 100 mb's big it should be saved into multiple files. So for every 100 mb's there would be a part. An example would be 300 mb's 3 text documents part 1,2, and 3. If there are multiple answers such as prime numbers that have been generated they should be separated by a ";"
I have some algorithms that I want used for the different operations.
Addition: I wasn't able to find any algorithms that increase the speed of addition
subtraction: Same as addition
multiplication: There are 4 algorithms dependent on range. Their range is
explained in better detail on wikipedia but to give you an idea they go from good for smaller calculations, good for bigger calculations then the
previous,ect. The 4 algorithms are Karatsuba algorithm ? Toom-Cook
multiplication ? Sch?nhage-Strassen algorithm ? F?rer's algorithm.
The last functions are described below.
## Deliverables
division:Here is an excerpt from wikipedia that I think explains things
perfectly for division.
"Methods designed for hardware implementation generally do not scale to integers with thousands or millions of decimal digits; these frequently occur, for example, in modular reductions in cryptography. For these large integers, more efficient division algorithms transform the problem to use a small number of multiplications, which can then be done using an asymptotically efficient multiplication algorithm such as Toom-Cook multiplication or the Sch?nhage-Strassen algorithm. Examples include reduction to multiplication by Newton's method as described above[5] as well as the slightly faster Barrett reduction algorithm.[6] Newton's method's is particularly efficient in scenarios where one must divide by the same divisor many times, since after the initial Newton inversion only one (truncated) multiplication is needed for each division."
Using multiplication in the way that they described above with the algorithms we have for multiplication will be good for speed sake.
powers:This is one of the best algorithms I have seen for powers and the best part is that it can help with factorial functions which I explain in more detail below. Here is the algorithm and make sure to read the users comments as well
[login to view URL]
square root:The work listed at this website is the best I have seen so far
[login to view URL]
factorials: This function can be difficult at times and there is many ways to
tackle this algorithm but I want to use the method described at this page
[login to view URL]
By finding the factors of the factorial in combination with the powers algorithm
we will be using we should be able to make a very powerful factorial function
that is very fast.
prime numbers This will be the most complex. It describes a variant of sunadrams
sieve that I have made that should help find prime numbers given in a certain
range. Here is how this should work.
Enter a number. The program then tries to find the two odd square numbers that
the number is in. My best suggestion for this is to use odd palindrome. For
instance 11*11=121
101*101=10201
1001*1001= 1002001
Easy to predict and to scale from.
Once the two squares have been found we get more complicated. If for instance we
wanted to have a range between 121 which we will give for this example the
variable of "T" and 169 which we will give in this example the variable "U" we
know that the square root of the lower numbers is 11. We then take the number
that the odd number would correlate with. To explain better imagine we are
counting all the odd numbers except for 1 so
3,5,7,9,11,13
1,2,3,4,5, 6
A better way to say this is to run the square root through this algorithm
lower square root (11 in our example) = x
x-1=y
y/2=z
Now we have variable z=5
We now need to do two calculations using z and I will explain why after I show
these calculations
6*z+3=A
4*z+2=B
Ok these calculations are important for a few reasons. variable "A" in our
example is equal to 33. Variable "B" in our example is equal to 22.
Now we need to subtract "b" until T is equal to "A". The reason that we subtract
until it is equal to "A" is because every difference is actually important.
prevent us from getting too confused I will just list the differences without
giving them variables. Just know that the numbers are important to the
calculations and will become important later.
so
121-22=99
99-22=77
77-22=55
55-22=33
Good now for each of these values we are going to add variable b until they are
past variable "U". We need to keep all these values. However something important
happens after we do this with variable T. We subtract 4 from b. So here listed
out is what we do. We start with variable T.
121+22=143
143+22=165
165+22=187
Ok now we subtract 4 from b getting 18. Now we move on to 99
99+18=117
117+18=135
135+18=153
153+18=171
subtract 4 from 18 getting 14. move on to 77
77+14=91
91+14=105
105+14=119
119+14=133
133+14=147
147+14=161
161+14=175
subtract 4 from 14 getting 10. move on to 55
55+10=65
65+10=75
75+10=85
85+10=95
95+10=105
105+10=115
115+10=125
125+10=135
135+10=145
145+10=155
155+10=165
165+10=175
subtract 4 from 10 getting 6. 6 will always be the last value you ever have for
this variable. move on to 33
33+6=39
39+6=45
45+6=51
51+6=57
57+6=63
63+6=69
69+6=75
75+6=81
81+6=87
87+6=93
93+6=99
99+6=105
105+6=111
111+6=117
117+6=123
123+6=129
129+6=135
135+6=141
141+6=147
147+6=153
153+6=159
159+6=165
165+6=171
Great now we take all the numbers that we have gathered which fall in the range
of the T and U variables
These numbers include
33's list
123
129
135
141
147
153
159
165
55's list
125
135
145
155
165
77's list
133
147
161
99's list
135
153
121's list
143
165
We can get rid of all duplicate numbers and combine all the lists.
121
123
125
129
133
135
141
143
145
147
153
155
159
161
165
169
Now the program will generate a list of all missing odd numbers that lie between
the two squares
127
131
137
139
149
151
157
163
167
These numbers just listed are 100% guaranteed to be prime.
The prime numbers should be saved in a text document and when they are done the
screen should display how many prime numbers there were.
This method isn't fast for small numbers but certain ranges for very large
numbers it can do fairly well.
While working on very large numbers this can obviously be computationally problematic however if you know the range of numbers we can shorten the values a bit. For instance if I wanted to work with numbers that had 100 digits in them but only 6 digits are being changed everytime we find a new number the program could store the numbers that will not be worked on for awhile on the harddrive until they need to be altered. I hope that makes sense.
If you have any questions please feel free to let me know.