Add Packages to MATLAB for Higher Order Arithmetic

Click For Summary

Discussion Overview

The discussion revolves around the challenges of performing higher order arithmetic and prime factorization in MATLAB for an MSc dissertation. Participants explore potential solutions, including add-on packages and alternative software options, while addressing the limitations of MATLAB in this context.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant expresses frustration with MATLAB's limitations for higher order arithmetic, specifically regarding prime numbers and integer factorization.
  • Another participant suggests using the MATLAB Symbolic Math Toolbox, indicating it may offer arbitrary precision capabilities, but notes that significant changes to the existing code may be necessary.
  • A different viewpoint proposes using C/C++ libraries for number theory work, emphasizing the computational intensity of factoring large integers and the advantages of optimized libraries.
  • Further suggestions include exploring additional MATLAB add-ons for variable precision integer arithmetic and considering alternatives like Mathcad and SMath, which also support arbitrary precision arithmetic.
  • One participant recommends Python libraries such as mpmath and sympy for multi-precision and number system functions, questioning the specific functions needed for the dissertation work.

Areas of Agreement / Disagreement

Participants present multiple competing views on how to address the limitations of MATLAB, with no consensus on a single solution or approach. The discussion remains unresolved regarding the best path forward for the original poster.

Contextual Notes

Participants acknowledge the computational challenges associated with factoring large integers, particularly those with 100 digits, and the potential need for significant computational resources or time. There is also mention of the need for clarity on the specific types of functions required for the dissertation work.

Firepanda
Messages
425
Reaction score
0
Basically I'm writing my MSc dissertation right now, and I've been doing a lot on primes

I've written all my code in MATLAB, but my supervisor told me today that MATLAB is crap for higher order arithmetic and the primes only go up to something like 10 digits long.

SO I'm kinda screwed right now, he suggests using Maple but I'm already so far through. Is there any way I can add something to MATLAB to make it store more primes? Or be able to factor an integer 100 digits long?

Thanks
 
Physics news on Phys.org


See if the Matlab Sybmolic Math Toolbox will let you finish.

http://www.mathworks.com/products/symbolic/

It looks like the Matlab folks made a deal with the Mupad folks to incorporate some arbitrary precision stuff into Matlab. That probably means you will have to make some changes to your code and learn some new things, but you might be able to keep and make use of some of what you have done.

Unless you have a lot of compute power or time or "easy" numbers to factor I am guessing that 100 digit numbers are going to be a very very difficult challenge. 50 digit factors are still considered fairly impressive records.

http://www.alpertron.com.ar/ECMREC.HTM

Unfortunately that doesn't mention how many processor megaseconds it took to find each of those.
 


If you need to do some serious number theory work, it's probably better to use a C/C++ library (or some other optimized library that can be called from something like the way ScyPy is from Python).

I say this because you want to factor a 100-digit library and this is going to be computationally intensive to say the least (remember that a lot of high performance libraries have routines that can factor big integers with a variety of algorithms).
 


Firepanda said:
Basically I'm writing my MSc dissertation right now, and I've been doing a lot on primes

I've written all my code in MATLAB, but my supervisor told me today that MATLAB is crap for higher order arithmetic and the primes only go up to something like 10 digits long.

SO I'm kinda screwed right now, he suggests using Maple but I'm already so far through. Is there any way I can add something to MATLAB to make it store more primes? Or be able to factor an integer 100 digits long?

Thanks

Apart from the Symbolic Toolbox already mentioned, an add-on package is mentioned in this thread: https://www.physicsforums.com/showpost.php?p=3989820&postcount=3 ( http://www.mathworks.com/matlabcentral/fileexchange/22725-variable-precision-integer-arithmetic ).

An alternative produce to consider is Mathcad (it handles arbitrary precision arithmetic and has a Matlab interface and its programming is similar enough to Matlab to allow porting of many programs without too much effort). I've attached an image of part of a simple worksheet that factorizes the decades of ten (plus a small constant) and shows the times for each factorization ... some of them are quite lengthy.

attachment.php?attachmentid=49359&stc=1&d=1343400208.jpg


Another package to consider is the non-commercial SMath, a Mathcad-like application that also does arbitrary precision arithmetic. I'm not sure whether it has a factor function.
 

Attachments

  • phys - 12 07 26 factor 01.jpg
    phys - 12 07 26 factor 01.jpg
    38.9 KB · Views: 863


Traditionally Matlab has always more for number crunching than number theory.

You should take a look at python, in particular the mpmath and sympy libraries. They can handle a lot of multi-precision and number system functions.

BTW. Firepanda, can you tell us the main types of function that your work requires. For example, stuff like integer factorization, prime generation, arbitrary precision maths etc? Can you list the main types of functions you need.
 

Similar threads

  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 6 ·
Replies
6
Views
6K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 13 ·
Replies
13
Views
8K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
5
Views
12K
  • · Replies 2 ·
Replies
2
Views
3K
Replies
4
Views
4K