Factorization

조회 수: 1 (최근 30일)
Mohsin Shah
Mohsin Shah 2011년 5월 20일
Howto find factors of 2^1024 and 2^2048 in Matlab??
  댓글 수: 1
John D'Errico
John D'Errico 2011년 5월 20일
Do you wish to know all of the factors, or all the divisors?

댓글을 달려면 로그인하십시오.

답변 (5개)

Daniel Shub
Daniel Shub 2011년 5월 20일
repmat(factor(2), 1, 1024)
  댓글 수: 5
Sean de Wolski
Sean de Wolski 2011년 5월 20일
And with the world ending in just a few hours ;-)
Andrew Newell
Andrew Newell 2011년 5월 20일
Oh, no! So little time left to answer questions!

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2011년 5월 20일
With some difficulty, seeing that both numbers are larger than any number that can be directly represented in MATLAB except by using the Fixed Point Toolbox or the Symbolic Toolbox.

John D'Errico
John D'Errico 2011년 5월 20일
No problem. Just use a tool designed to solve the problem.
>> factor(vpi(2)^1024)
ans =
Columns 1 through 16
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
Columns 17 through 32
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
Columns 33 through 48
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
...
And so on for all 1024 factors of the number.

Andy
Andy 2011년 5월 20일
For any prime p and positive integer n, the factors of p^n are all of the form p^k for 0 <= k <= n. So the factors of 2^1024 are just 2^k for 0 <= k <= 1024, and similarly for 2^2048. No need to use MATLAB.
  댓글 수: 2
Walter Roberson
Walter Roberson 2011년 5월 20일
But those numbers are not necessarily directly representable in MATLAB, especially if p is not a power of 2.
Andy
Andy 2011년 5월 20일
That's true. But the OP was unclear as to whether he wanted to represent the factors of these numbers in MATLAB, or whether he simply wanted to solve this problem (and thought of MATLAB as a tool for solving it). Since all of the other answers were of the first sort, I thought I'd throw in an answer of the second sort.

댓글을 달려면 로그인하십시오.


Andrew Newell
Andrew Newell 2011년 5월 20일
The Symbolic Toolbox has a really nice way of handling this:
two = sym(2);
factor(two^1024)
ans =
2^1024
  댓글 수: 2
Walter Roberson
Walter Roberson 2011년 5월 20일
factor() for the symbolic toolbox does algebraic factoring and does not touch numbers.
I do not know at the moment how to produce factors in MuPad; in Maple it would be by using ifactor() or numtheory[divisors]() or one of the related numtheory package members.
Walter Roberson
Walter Roberson 2011년 5월 21일
In Maple,
numtheory[divisors](2^512-5) %a smaller problem
yields an error,
Error, (in ifactor/QuadraticSieve) object too large
It thus seems unlikely that Maple would be able to factor 2^2048-5 using the built-in routines.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Number Theory에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by