Hello.

What are the best and most popular programming languages for working with all of these things?

- natural numbers

- very large integers

- integer sequences

- modular arithmetic, congruence

- divisors, divisor function

- totient function

- number bases, radix, numeral system

- binary, hexadecimal, senary, duodecimal

- prime numbers, prime factorization

Also, how would you rank C#, Matlab and Python for doing all of the previously mentioned things?

Thanks in advance for your answers.

## 13 Replies - 2304 Views - Last Post: 26 May 2017 - 10:56 AM

### #1

# Best and most popular programming languages for doing number theory?

Posted 18 March 2016 - 10:21 AM

##
**Replies To:** Best and most popular programming languages for doing number theory?

### #2

## Re: Best and most popular programming languages for doing number theory?

Posted 18 March 2016 - 10:49 AM

Matlab and Python are the languages of choice for the math/scientific fields and can all do the things you listed there. C# can do them too but not as easily or cleanly I find. What you may find yourself doing is also using a base language like Python and adding in special libraries to give you the functionality you need to handle other scientific calculations.

So look at the types of plugins/packages that can be installed with the given language you choose. Make sure that if you can't do it in the language that there is at least a few choices of packages to help you do what it is you need to do.

So look at the types of plugins/packages that can be installed with the given language you choose. Make sure that if you can't do it in the language that there is at least a few choices of packages to help you do what it is you need to do.

### #3

## Re: Best and most popular programming languages for doing number theory?

Posted 18 March 2016 - 10:55 AM

As someone who maths, I find MATLAB to be ugly and unwieldy. A lot of engineers and folks in scientific computing tend to be drawn to it. There is a saying- MATLAB is a thin wrapper for FORTRAN while Mathematica is a thin wrapper for Steven Wolfram's ego. I'll gladly take the latter.

To contrast, Python is very popular in the data science community. I think you'll be happy with the numerical libraries like NumPy.

To contrast, Python is very popular in the data science community. I think you'll be happy with the numerical libraries like NumPy.

### #4

## Re: Best and most popular programming languages for doing number theory?

Posted 18 March 2016 - 12:12 PM

Matlab is great for calculations, but not so great for math.

I've always developed my own functions in python for working with those ideas. A quick consultation of the googles produced https://pypi.python....pi/eulerlib/0.2 which might be interesting, but if you're doing recreational mathematics I recommend at least trying to write your own. It's very rewarding.

I would say Python is likely to be your best bet of the three, but I'm sort of biased in that direction. I wouldn't really want to do this stuff in a heavyweight language like C#, and as I say Matlab/Octave is very strongly real-number oriented.

If you need Matlab-like functions or good matrix libraries, there's always numpy

I've always developed my own functions in python for working with those ideas. A quick consultation of the googles produced https://pypi.python....pi/eulerlib/0.2 which might be interesting, but if you're doing recreational mathematics I recommend at least trying to write your own. It's very rewarding.

Quote

Also, how would you rank C#, Matlab and Python for doing all of the previously mentioned things?

I would say Python is likely to be your best bet of the three, but I'm sort of biased in that direction. I wouldn't really want to do this stuff in a heavyweight language like C#, and as I say Matlab/Octave is very strongly real-number oriented.

If you need Matlab-like functions or good matrix libraries, there's always numpy

### #5

## Re: Best and most popular programming languages for doing number theory?

Posted 21 March 2016 - 08:35 AM

Thank you all for your answers so far.

What about C++, Fortran and Java? Are they good for doing all of the things that I mentioned in my first post (number theory)?

What about C++, Fortran and Java? Are they good for doing all of the things that I mentioned in my first post (number theory)?

### #6

## Re: Best and most popular programming languages for doing number theory?

Posted 21 March 2016 - 08:36 AM

I personally wouldn't want to do computational number theory problems in these languages; but in theory, you could.

### #7

## Re: Best and most popular programming languages for doing number theory?

Posted 21 March 2016 - 08:46 AM

### #8

## Re: Best and most popular programming languages for doing number theory?

Posted 21 March 2016 - 09:13 AM

R is really about stats, and it's a little, um, special. I'm not sure I'd want to deal with, say, the totient function in it.

You certainly COULD write this sort of thing in Java, and that might be an interesting exercise. But remember that in Java you have to deal with size restrictions in your primitive number classes, which means you have to deal with big number classes out of the box. I would be interested in seeing what could be done in Scala (or clojure, but I'm not so keen on clojure)

C++ gives you the advantage of maybe better speed, but I prefer a high-level language.

The question is not "can you" write these functions in some language L. You can. The question is whether you want to.

You certainly COULD write this sort of thing in Java, and that might be an interesting exercise. But remember that in Java you have to deal with size restrictions in your primitive number classes, which means you have to deal with big number classes out of the box. I would be interested in seeing what could be done in Scala (or clojure, but I'm not so keen on clojure)

C++ gives you the advantage of maybe better speed, but I prefer a high-level language.

The question is not "can you" write these functions in some language L. You can. The question is whether you want to.

### #9

## Re: Best and most popular programming languages for doing number theory?

Posted 26 May 2017 - 10:08 AM

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 at all 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?

Mathematica has not been discussed at all 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?

### #10

## Re: Best and most popular programming languages for doing number theory?

Posted 26 May 2017 - 10:11 AM

I personally love MATLAB, as long as you're not doing anything with strings. I hate Mathematica, mainly because they forced us to use it in Calc and it made my life a living hell and was confusing. I'll jump on the python train here too, but I'm a newb with it.

### #11

## Re: Best and most popular programming languages for doing number theory?

Posted 26 May 2017 - 10:23 AM

Omega Force, on 26 May 2017 - 12:08 PM, said:

Mathematica has not been discussed at all in the thread.

One reason that you don't get a lot of talk about Mathematica is that it's a proprietary language that lots of people don't want to invest in. I'm in that bunch - I don't really see shelling out $300 to use a programming language unless and until I've exhausted all of the reasonable options.

Quote

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?

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?

I can't really say anything about these questions. However, I would ask you what it is you're trying to do here. If you want to learn number theory, it might be worth your while to actually invent this wheel. If you can implement a concept effectively in some language, you can be pretty sure you understand it. If you write solid tests for your implementation, you can be very sure that you understand it.

If you just want to have access to particular functions in order to get on with whatever it is you're doing, then you should contact Wolfram and find out whether those functions are implemented in Mathematica. Then you can decide whether they're worth the investment to you (which is something I certainly can't help you with)

### #12

## Re: Best and most popular programming languages for doing number theory?

Posted 26 May 2017 - 10:25 AM

A lot of science based companies who do complex number crunching and theory use Python. I have seen a ton of jobs looking for data scientists that have Python backgrounds.

### #13

## Re: Best and most popular programming languages for doing number theory?

Posted 26 May 2017 - 10:33 AM

There's R. Ohhhh R.

### #14

## Re: Best and most popular programming languages for doing number theory?

Posted 26 May 2017 - 10:56 AM

Page 1 of 1