Add Packages to MATLAB for Higher Order Arithmetic

In summary, the author suggests using either the MATLAB Symbolic Math Toolbox or the Mathcad package MathSMath, and suggests that factorizing an integer 100 digits long will be a very difficult challenge.
  • #1
Firepanda
430
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
  • #2


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.
 
  • #3


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).
 
  • #4


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: 789
  • #5


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.
 

1. How do I add packages to MATLAB for higher order arithmetic?

To add packages for higher order arithmetic in MATLAB, you can use the "addpath" function. This function allows you to specify the location of the package you want to add to the MATLAB search path. Once the package is added, you can use its functions and features in your code.

2. What are some popular packages for higher order arithmetic in MATLAB?

Some popular packages for higher order arithmetic in MATLAB include High Precision Floating Point Arithmetic, MathWorks Precision Toolbox, and MP Toolbox. These packages offer a variety of functions for performing calculations with higher precision and accuracy.

3. Can I create my own package for higher order arithmetic in MATLAB?

Yes, you can create your own package for higher order arithmetic in MATLAB. MATLAB allows you to create custom packages using the "package" keyword and the "classdef" keyword. You can then add your package to the MATLAB search path using the "addpath" function.

4. How do I use higher order arithmetic in my code?

To use higher order arithmetic in your code, you can either use the built-in functions in MATLAB or import a package that offers higher order arithmetic functions. The syntax for using these functions is similar to the standard arithmetic functions in MATLAB, but with a higher precision and accuracy.

5. Can I use higher order arithmetic for all types of calculations in MATLAB?

Yes, you can use higher order arithmetic for most types of calculations in MATLAB. However, it is important to note that using higher precision and accuracy may also result in longer computation times. It is recommended to use higher order arithmetic only when necessary, such as in calculations that require a high degree of accuracy.

Similar threads

  • Introductory Physics Homework Help
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
Replies
81
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
13
Views
7K
  • Linear and Abstract Algebra
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
5K
Back
Top