# Big integer and Precision

조회 수: 78(최근 30일)
saima 12 Jul 2014
Hi,
I am trying to work on some problems which deal with really large integers (much larger than intmax('uint64')). How do I deal with such integers in MATLAB? I got some stuffs online based on 'vpa'. Is there any alternative to symbolic toolbox and vpa? Using an easy example, say I am trying to calculate the value of 2^2317. How is it possible to do it?
And how do I increase the precision of calculation? Say, I am trying to calculate sqrt(3) upto 15 digits precision. How can I do it?
Thanks :-)
##### 댓글 수: 3표시숨기기 이전 댓글 수: 2
Star Strider 12 Jul 2014
eps:
• eps(X) = 2^(E-23) if isa(X,'single')
• eps(X) = 2^(E-52) if isa(X,'double')
Also: flintmax.

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

### 답변(3개)

Star Strider 12 Jul 2014
편집: Star Strider 12 Jul 2014
The vpa function in the Symbolic Math Toolbox is probably your only option. You can adjust the precision with the digits function.
From the documentation:
• digits lets you specify any number of significant decimal digits from 1 to 2^29 + 1. ’
##### 댓글 수: 1표시숨기기 없음
Image Analyst 12 Jul 2014
Wow, 536,870,913 digits of precision. I never would have guessed that you could get that much precision. And I thought 20 or 30 would have been a lot.

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

James Tursa 12 Jul 2014
편집: James Tursa 12 Jul 2014
In addition to the Symbolic Toolbox, for extended precision integer and floating point arithmetic, you can use these FEX submissions by John D'Errico:
##### 댓글 수: 0표시숨기기 이전 댓글 수: -1

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

편집: Christopher Creutzig 1 Sep 2014
You can compute with exact integers and rationals using the symbolic toolbox, just make sure they are not cut off by computing in doubles first:
>> sym(2)^2317
ans =
30654903508108357077958654144825937585978808922337901521692741170911447076693116235513237095579066485773937279334784139954181575840986269850991750398202331213943274278112396793424683275528507127617356737974156212114985333650793917021532655353073330339869206521452698460733186617040160262848093715277704279290680230304150547684590960276420040187406068172642162633162861058913834479146788713758308941909711983231722076836272997428595743463045969399361824711110350992834115834375631290260030543671026084690659491964528746134305444576187523233231429766154483330868291973263704666586462246580637588991629908758131771642269031718471782924220000298094429698919484347691856871276393621193756312248959107072
>> (sqrt(sym(2))+1/sym(7))^23
ans =
(2^(1/2) + 1/7)^23
>> expand((sqrt(sym(2))+1/sym(7))^23)
ans =
(36964502873561444765593*2^(1/2))/3909821048582988049 + 359084438788642488468527/27368747340080916343

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

### Community Treasure Hunt

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

Start Hunting!

Translated by