Mathfun.py 2.1 |
Date Added: January 18, 2010 | Visits: 226 |
|
||||||||
|
Mathfun.py project s a rather small Python library that contains some of the more obscure (others would say less useful 8^) mathematical formula/functions that I have always found interesting/amusing. These include primality tests, fibonacci sequences and turning characters into numbers, among other things. The next paragraph includes a little story about my strange habits as a teenager. The paragraph after that contains some ramblings about primes and formulas. The paragraph after that hasnt been decided on yet, but you can be assured that it will be more stream-of- consciousness rambling about something mathematic by yours truly. One of the reasons that this library exists is that, as a junior programmer in high school, I spent an insane amount of time writing BASIC programs on our IIgs that would calculate the first 100 primes or some other such nonsense. I would write it one way, get out a stop watch, run it, record the time it took, rewrite it, rerun it, retime it and calculate the difference as percentage decrease in time. Repeat the previous until you get BASIC that looked like an explosion in a type factory. All in some sort of quest to... well, I dont really know what I was shooting for. I just enjoyed it. Calculating if a number was prime, calculating the prime factorization, calculating the first N prime numbers... Yeah, I was a strange one. But, in retrospect, all that solitary math kinda helped. While I reinvented many a prime wheel, I did it on my own, which was something of a personal fulfillment once I had learned more of a history of mathematics. And I never forgot most of those formulas that I worked out on that Apple. For instance, mathfun.isprime(number) utilizes most of what I learned back in high school. It iterates through the odd numbers, up to the integer value of the square root of the number in question. I still remember the epiphany that I had that I only needed to calculate through the square root of the number. 8^) Theres a minor paradox with the calculation of a prime. The quickest way to generate primes would be to only attempt modular arithmetic with prime numbers. However, to do it that way means that you have to generate a list of prime numbers first, which involves a primality test on every odd number up to the square root of the number in question. This would be sloooooow for the primality test for any single number. (For instance, isprime(10000) would involved roughly 50 full primality tests to generate the list needed to be a maximally efficient test on it.) So, we accept that even if were not going to get any results doing (N mod 9), its much quicker to eat those wasted cycles than to determine if 9 is prime first. However, if youre doing nothing more than simply cranking out prime after prime, it becomes much more efficient to only do the primality test with a list of primes, since (if you start from 2) youve already determined the ealier ones before. (Theres probably a break-even time first (machine dependent) before "determine all primes with primes" becomes more efficient than "crank through the odd numbers".) Its easy to see however, that for very large numbers its much better to only work with primes. Theres also a minor question of the speed of the data structures used to store the prime list versus the very fast next odd number test. However, Ill leave that one up to the True Computer Scientists..
|
| License: Freeware | Size: 11.26 KB |
|
Libraries
-
Class Library for Numbers 1.1.13
Class Library for Numbers in short CLN is a library for computations with all kinds of numbers.. |
1.62 MB | |
|
Calculators
-
Random List Generator 1.0
Random List Generator is a Windows application developed to generate very quickly a list of thousands random numbers. Random List creator enables you to create a number as longer as 18 digits and making the list of these 5000 numbers. The list... |
960.41 KB | |
|
Libraries
-
HAVEGE 1.0
HAVEGE (HArdware Volatile Entropy Gathering and Expansion) is a user-level software unpredictable random number generator for general-purpose computers that exploits these modifications of the internal volatile hardware states as a source of... |
317.44 KB | |
|
Communication Tools
-
Reverse cell phone number directory 1.0
Reverse cell phone number directory The Mobile Phone Directory may be the one of the most extensive directory all-around where you are able to search by cell phone number as opposed to by name. Now whenever you get a call in your cellular phone... |
1.31 MB | |
|
Libraries
-
GODI 20060118
GODI library provides an advanced programming environment for the Objective Caml (OCaml) language. From INRIA (who created OCaml) you can get the OCaml compiler and runtime system, but this is usually not enough to develop applications. You also... |
1.5 MB | |
|
Programming
-
PyRoe 1.0
PyRoe project is a "static partial linker" for small helper Python libraries. PyRoe links a Python script with its helper libraries into self-contained Python executable (PyRoe capsule). Pyroe HOWTO Assume that your main module is called... |
4.1 KB | |
|
Libraries
-
Libeval 1.0.7
Libeval provides simple means of evaluating simple arithmetic expressions involving literal numeric values, variables and functions using the addition (+), subtraction (-), multiplication (*), division (/), modulo division (), exponentiation (^),... |
27.65 KB | |
|
Libraries
-
wwtxt 1.11
Parsing XML and CSS data is rather simple, but most libraries that aim for this simple goal are bloated with a whole lot of other irrelevant additions. The wwtxt library is a very minimalistic library containing just the required parsers (and... |
46.08 KB | |
|
Libraries
-
Math::BigInt::Calc 1.87
Math::BigInt::Calc is a pure Perl module to support Math::BigInt. SYNOPSIS Provides support for big integer calculations. Not intended to be used by other modules. Other modules which sport the same functions can also be used to support... |
194.56 KB | |
|
Web Searching Tools
-
Golden Niche Finder 1.0
Golden Niche finder Lite Edition is completely free to download and use. The program is quickest way that we know of to help you find the niches and niche related keywords that will help you to run profitable SEO and PPC campaigns. There are... |
10.73 MB |
|
Programming
-
RailsTidy 0.1
RailsTidy project is a plugin for Ruby On Rails.. |
11.26 KB | |
|
Programming
-
Strings edit 1.9
Strings edit is a library that provides I/O facilities for integer, floating-point, Roman numbers, and strings. Both input and output subroutines support string pointers for consequent stream processing. The output can be aligned in a fixed size... |
54.27 KB | |
|
Programming
-
BScript 0.3
BScript is a (yet another) BASIC interpreter. It is free software and open-sourced, licensed under the terms of the GNU General Public License version 2 or later. You can use BScript to teach BASIC to your students, write understandable shell... |
112.64 KB | |
|
Programming
-
Kits JavaScript Brainf*ck Interpreter 0.01
Kits JavaScript Brainf*ck Interpreter is a rather fast interpreter for the Brainf*ck esoteric programming language.. Kit's JavaScript Brainfuck Interpreter v0.01 |
5.12 KB | |
|
Programming
-
dis6502 0.12
dis6502 is a flow-tracing disassembler for the 6502, originally written by Robert Bond and supporting Atari binary files. Robert posted dis6502 to the Usenet newsgroup net.sources on 9-Oct-1986, and to comp.sources.unix 7-Jun-1988. Udi... |
19.46 KB | |
|
Libraries
-
Module::MakefilePL::Parse 0.12
Module::MakefilePL::Parse is a Perl module to parse required modules from Makefile.PL. SYNOPSIS use Module::MakefilePL::Parse; open $fh, Makefile.PL; $parser = Module::MakefilePL::Parse->new( join("", ) ); $info = $parser->required;... |
8.19 KB | |
|
Libraries
-
sqlpp 0.06
sqlpp Perl package is a SQL preprocessor. sqlpp is a conventional cpp-alike preprocessor taught to understand SQL ( PgSQL, in particular) syntax specificities. In addition to the standard #define/#ifdef/#else/#endif cohort, provides also... |
10.24 KB | |
|
Libraries
-
App::SimpleScan::Substitution::Line 2.02
App::SimpleScan::Substitution::Line is a line with optional fixed variable values. SYNOPSIS my $line = App::SimpleScan::Substitution::Line->new(" this "); # Use only this value when substituting " ". $line->fix(substituite =>... |
54.27 KB | |
|
Libraries
-
PDL::Graphics::TriD 2.4.3
PDL::Graphics::TriD is a PDL 3D interface. SYNOPSIS use PDL::Graphics::TriD; # After each graph, let the user rotate is and # wait for him to press q, then make new graph line3d($coords); # $coords = (3,n,...) line3d($coords,$colors); #... |
2.1 MB | |
|
Libraries
-
SmartColorWell 1.2
SmartColorWell is a cross-platform open-source ColorWell class for REALbasic 4 or greater. The SmartColorWell control stores a color value and displays that color in a simulated BevelButton that when pressed allows the user to change the color... |
21.5 KB |
