Create a free forum in seconds.
zIFBoards - Free Forum Hosting
Welcome to Dozensonline. We hope you enjoy your visit.
You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, and sending personal messages. Registration is simple, fast, and completely free. (You will be asked to confirm your email address before we sign you on.)
Join our community!
If you're already a member please log in to your account to access all of our features:

Name:   Password:


 

 Best Programming Language For Number Theory & Base
Pinbacker
  Posted: Mar 17 2016, 10:11 PM


Casual Member


Group: Members
Posts: 117
Member No.: 795
Joined: 7-February 14



Hello.

I realized that many of us are investigating what is the ultimate base, and in order to research on this eternally elusive question we do a lot of computer programming to make many number theoretic experiments. Thus an important question arises: what programming language should we use?

What are the best and most popular programming languages for working with all of these things?
  • number bases
  • prime numbers, prime factorization
  • natural numbers
  • very large integers
  • integer sequences
  • modular arithmetic, congruence
  • totient function
  • divisors, divisor function

Also, how would you rank Mapple, Mathematica, Python, IDL and Matlab for doing all of the previously mentioned things?

Thanks in advance for your answers.
Top
Dan
Posted: Mar 18 2016, 04:24 AM


Dozens Disciple


Group: Members
Posts: 1,463
Member No.: 19
Joined: 8-August 05



I like Python. Easy to use, and has built-in support for arbitrarily-large integers.

CODE
>>> 42**42
150130937545296572356771972164254457814047970568738777235893533016064


Only problem is that the implementation is slow.
Top
jrus
Posted: Mar 18 2016, 09:35 AM


Regular


Group: Members
Posts: 195
Member No.: 1,156
Joined: 23-October 15



The stuff on your list is easy enough to implement in any programming language. Having one with native support for big integers might help you though. And higher-level abstractions could save you some effort. Like Dan, I’m partial to Python.

You could also try Maple or Mathematica, if you want some symbolic computing support.
Top
wendy.krieger
Posted: Mar 18 2016, 09:50 AM


Dozens Demigod


Group: Members
Posts: 2,432
Member No.: 655
Joined: 11-July 12



Most of the stuff I did with sevenites etc, was done in UBASIC, with a REXX wrappers.

Both of these handle large numbers. Prime factorisation is typically handled at 100+ digits.

UBASIC is very fast, and I wrote programs for the inner loops in it. The upfeed was made in REXX, which you can convert formulae into numbers without much hassle.

For example, one of the processes I do is to factorise the new factors that divide x^a-y^a for random values of a. The prototypes of the algebraic forms are stored by 'a', up to 162 places.

The rexx program inputs Aj 5/3 22 and this calculates the unique factor or algebraic root, in the base 5/3A22 (ie 5^22 - 3^22), and passes the output to 'factor' by Shamus Software to factorise.

Aj.rexx allows you to do things like reverse the inputs (ie Aj -r 22 5/2), so you can scroll through values of A22. It also handles the isobase versions, where x^2+y^2 = n, xy = d, for Aj 5/3 -22. This is indicated by setting the value of a to negative. In fact, it works in this as default, and converts a regular base into this form, by going n=x^2-y^2, d = xy.
Top
Pinbacker
Posted: Mar 20 2016, 05:07 AM


Casual Member


Group: Members
Posts: 117
Member No.: 795
Joined: 7-February 14



Thank you all for your answers so far.

I'm not going to use UBASIC since it seems to be an extremely uncommon and unpopular language.

Maple and Mathematica seem to me to be very weird. They look completely different than other programming languages. They seem messy and unclean. Just pure mayhem, anarchy, pandemonium.

What about C++, Fortran and Java? Are they good for working with bases and number theory?
Top
wendy.krieger
Posted: Mar 20 2016, 09:37 AM


Dozens Demigod


Group: Members
Posts: 2,432
Member No.: 655
Joined: 11-July 12



On the other hand, UBASIC does byte-coding, which means it does not have to interpret the files. This means it does a partial compile of the code before it runs.
Top
Treisaran
Posted: Mar 20 2016, 10:11 AM


Dozens Disciple


Group: Members
Posts: 1,221
Member No.: 630
Joined: 14-February 12



The command-line calculator bc is an arbitrary-precision calculator with support for many bases (input up to unquadral inclusive; output up to base 2^27z), and can be programmed with C-like syntax. See the thread for its limitations and workarounds. I use it for all my base-n research on a computer.
Top
jrus
Posted: Mar 20 2016, 11:37 PM


Regular


Group: Members
Posts: 195
Member No.: 1,156
Joined: 23-October 15



C++ and Java are languages with lots of syntactic and conceptual overhead. It will take much more programmer effort to do what you want than if you were using Python, Ruby, Clojure, OCaml, Lua, Javascript, or the like.

Fortran might be a good choice if you have extremely large calculations that need to run very fast on scientific computing clusters, and you have large amounts of expert programmer time to spend on optimization. I don’t think it makes any sense to use it for prototyping or small scale computation.

If you are considering something like Fortran or Matlab, I would recommend Julia as an alternative. http://juliacomputing.com

But hey, use whatever tools you want. If you are already familiar with some set of tools, you’ll probably get to your goal faster by just rushing ahead with your implementation than by chatting about programming languages on the internet.
Top
Sennekuyl
Posted: Mar 21 2016, 05:37 AM


Casual Member


Group: Members
Posts: 115
Member No.: 1,075
Joined: 29-June 14



Common Lisp has a rudimentary native support for alternative bases up to 30z from memory.

See this thread

But I don't know if it does the last few items of what you require. (I've really got to set aside some time to practice programming soon. :sigh: ). As a non-programmer its seems logical that most languages can do any of that, though.
Top
Pinbacker
Posted: May 26 2017, 05:14 PM


Casual Member


Group: Members
Posts: 117
Member No.: 795
Joined: 7-February 14



After thinking for a while, I've come to the conclusion that the best language for doing number theory is either Python or Mathematica, but I don't know which one is better.

Mathematica has not been discussed much in the thread.
What are its advantages and disadvantages compared to Python?
Does Mathematica have more number theory functions than Python?
Is it faster to write programs (in number theory) in Mathematica than in Python?
Would the calculations be done faster in Mathematica than in Python?
Top
icarus
Posted: May 28 2017, 03:30 PM


Dozens Demigod


Group: Admin
Posts: 1,913
Member No.: 50
Joined: 11-April 06



I've done a great deal of work in Mathematica. (in past 3 years have written over 6000 integer sequence programs at OEIS and have coded about 1.75% of OEIS' over 287000 sequences in Mathematica). It has a large number of number theory functions, but plenty of other not necessarily mathematical tools, string and list manipulation tools, etc. that make it a great package. Problem is that it is proprietary and relatively expensive.

Python has sympi, a number theory package that you can load. I think Python is slow for many applications, unless you can compile your programs. You can read about both online. Mathematica has a stackexchange forum.

If you're into number theory, also look into PARI-GP out of France. It is open source and is fast. It does not have all the capabilities outside of number theory that Mathematica has. Search on "pari number theory" and you'll find it.
Top
Dan
Posted: May 29 2017, 03:05 AM


Dozens Disciple


Group: Members
Posts: 1,463
Member No.: 19
Joined: 8-August 05



I haven't used Mathematica, but as I understand it, it's a computer algebra system and graphing software (and a competitor to Maple), whereas Python (which I use frequently) is a general-purpose programming language that happens to have a few optional packages for scientific computing.
Top
wendy.krieger
Posted: May 30 2017, 12:36 PM


Dozens Demigod


Group: Members
Posts: 2,432
Member No.: 655
Joined: 11-July 12



If the aim is to learn how to write tight code from number theory, then i found using a rexx wrapper around a hamster is the way to go. The hamster is a little program like 'factor' or the UBASIC factor routines on this. You don't have to modify this code much, largely to get it to print some extra string on the output line.

The REXX code isn't run much: its function in life is to create a command line for the hamster to chew on. This is usually something like a command line of a search-string and a very large number.

CODE
[D:\]aj 12 96
factorising 12A96 = 34182189187166851926484583071088641
first trying brute force division by small primes
PRIME FACTOR     7489
now trying 1000 iterations of brent's method
PRIME FACTOR     3122881
PRIME FACTOR     1461573322938242802306049


The hamster here is a win32 and os2 factor program.

CODE

[D:\]factor
Incorrect Usage
factor <number>
OR
factor -f <formula>
e.g. factor 999999999999999999999999999999999999999999999999999997
or   factor -f 10#100-19

To suppress the commentary, use flag -s
To input from a file, use flag -i <filename>
To output to a file, use flag -o <filename>
e.g. factor -f 10#100-7 -s -o factors.dat

Freeware from Shamus Software, Dublin, Ireland
Full C source code and MIRACL multiprecision library available
Email to mscott@indigo.ie for details
Web page http://indigo.ie/~mscott
Source code from ftp://ftp.compapp.dcu.ie/pub/crypto/miracl.zip


I use it fromhttp://home.netcom.com/%7Ejrhowell49/math/index.html which is updated.

The optimisation comes from feeding the hamster correctly. A spot of optimisation, over a period of three or so days, reduced the running time of a number of projects by months.

Another good trick in the rexx program is to put the program into shutdown mode, where a signal is raised by creating a file, and the batch run ends at the end of the signal. The last good record is kept updated, so it starts with the first undone one on power failure etc.
Top
« Next Oldest | General | Next Newest »
DealsFor.me - The best sales, coupons, and discounts for you

Topic Options



Hosted for free by zIFBoards* (Terms of Use: Updated 2/10/2010) | Powered by Invision Power Board v1.3 Final © 2003 IPS, Inc.
Page creation time: 0.0245 seconds · Archive