Difference between revisions of "Mathematica/Example"

From ScientificComputing
Jump to: navigation, search
Line 1: Line 1:
As an example for running a Mathematica job on the cluster, we look at numbers of the form <math>2^x-1</math> and check if they are prime numbers.
+
As an example for running a Mathematica job on the cluster, we look at numbers of the form and check if they are prime numbers.
  
 
  [leonhard@euler04 mathematica]$ '''cat test.m'''
 
  [leonhard@euler04 mathematica]$ '''cat test.m'''
Line 21: Line 21:
 
  {2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127}
 
  {2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127}
  
The output lists the exponents of all Mersenne prime number smaller than <math>2^{500}</math>.
+
The output lists the exponents of all Mersenne prime number smaller than.

Revision as of 06:47, 26 August 2016

As an example for running a Mathematica job on the cluster, we look at numbers of the form and check if they are prime numbers.

[leonhard@euler04 mathematica]$ cat test.m
LaunchKernels[2];
a=Parallelize[Select[Range[500],PrimeQ[2^# - 1]&]]
Print[a]
CloseKernels[];
[leonhard@euler04 mathematica]$ module load mathematica/10.2.0
[leonhard@euler04 mathematica]$ bsub -n 2 -W 4:00 -R "rusage[mem=512]" "math -script test.m > output.out"
Mathematica job.
Job <25719610> is submitted to queue <normal.4h>.
[leonhard@euler04 mathematica]$ bjobs
JOBID      USER    STAT  QUEUE      FROM_HOST   EXEC_HOST   JOB_NAME   SUBMIT_TIME
25719610   leonhard    PEND  normal.4h  euler04
[leonhard@euler04 mathematica]$ bjobs
JOBID      USER    STAT  QUEUE      FROM_HOST   EXEC_HOST   JOB_NAME   SUBMIT_TIME
25719610   leonhard    RUN   normal.4h  euler04     2*e2248     *utput.out Aug 25 08:31
[leonhard@euler04 mathematica]$ bjobs
No unfinished job found
[leonhard@euler04 mathematica]$ cat output.out 
{2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127}

The output lists the exponents of all Mersenne prime number smaller than.