Mathematica

In this forum members can discuss topics about specific programming languages.
Post Reply
mjHession
Posts: 2
Joined: Wed Jun 22, 2011 11:50 pm

Mathematica

Post by mjHession »

I have some knowledge of the mathematica language from my undergraduate studies in mathematics. I am more interested in mathematics than programming and don't really want to learn another language just for these problems.

Does anyone know if that will hinder me from solving them? Does the one minute rule apply to all languages? or just c++ or java or something?
User avatar
rayfil
Administrator
Posts: 1406
Joined: Sun Mar 26, 2006 5:30 am
Location: Quebec, Canada
Contact:

Re: Mathematica

Post by rayfil »

You should be able to solve most (if not all) problems with Mathematica. As for the one-minute rule, you may not be able to meet it for all the problems. That "rule" is primarily intended for compiled languages.
When you assume something, you risk being wrong half the time.
mjHession
Posts: 2
Joined: Wed Jun 22, 2011 11:50 pm

Re: Mathematica

Post by mjHession »

When you say not meet the one minute rule. Does that mean I should expect some problems to take a few minutes. Or several hours or something...
User avatar
hk
Administrator
Posts: 10993
Joined: Sun Mar 26, 2006 10:34 am
Location: Haren, Netherlands

Re: Mathematica

Post by hk »

That will depend very much on the particular problem.
If you mainly use some built in mathematical functions it will be reasonably fast.
However, if you use it as a programming environment, it might be about 600-800 times slower than a compiled language.
And 600 minutes equals 10 hours....
I must confess that some problems were designed for programs like Mathematica to be very slow.
For others it might be a very useful tool.
Image
SteveB
Posts: 4
Joined: Sun Jun 15, 2014 11:04 pm

Re: Mathematica

Post by SteveB »

I've used Mathematica to solve the first 100 or so problems. Each was solved in less than 5 minutes run time.

* Mathematica supports parallel processing quite easily (ParallelDo, ParallelMap etc) which can reduce run time;
* Mathematica also supports "compilation". That is, it creates more efficient pseudocode for evaluating functions.
* The wealth of special functions (eg Prime, next prime etc) can often help

Many of the problems involve designing a test function then applying it over a large (but much reduced) search space so these hints hints do bring the runtime down significantly.
Agrentum
Posts: 10
Joined: Tue May 06, 2014 12:44 am

Re: Mathematica

Post by Agrentum »

I can confirm earlier claims: Mathematica is armed in pretty powerful parallelization tools and vast library of special functions. Just like all other turing-complete languages it allows solution of all classes of problems that are possible to solve in C (just using it as example, it is pretty much lingua franca for computers). But it can run sluggishly and not always operations can be done in parallel. This is when advantage of Mathematica diminishes.

What you gain in exchange is far less verbose code then most other languages. Most of my solutions above problem 100 take about five to ten times more code in C then in Mathematica.

If you would change your mind about learning another language, you could try Sage. Basically a Python framework with most of the Mathematica utilities. Runs faster in quite a lot of cases when compared to Mathematica. If you are not sure, you can make an account on their cloud computing platform and mess around for a while, preferably going through basic tutorial (easily done in about two hours on average per part, total would be around of 10-12 hours).
Image - self-demoted from 357, I want to return to this score by solving everything in C/C++.
Post Reply