Is there a way to increase "realmax" in MATLAB?

realmax on my machine:

1.7977e + 308

I know I need to write my code to avoid long whole calculations, but is there a way to increase the limit?
I mean something like gmp library in C

+3


source to share


1 answer


You can find vpa

( variable precision arithmetic ):

R = vpa(A)

uses variable precision arithmetic (VPA) to calculate each element of A

at least d

decimal digits of precision, where d

is the current setting digits

.

R = vpa(A,d)

uses equally d

significant (nonzero) digits instead of the current setting digits

.

Here's an example on how to use it:



>> x = vpa('10^500/20')
ans =
5.0e498

      

Note that:

  • the output x

    has a symbolic ( sym

    ). Of course, you shouldn't convert it to double

    , because it will exceed realmax

    :

    >> double(x)
    ans =
       Inf
    
          

  • Use string input to avoid evaluating large input values ​​like double

    . For example, it doesn't work.

    >> vpa(10^500/20)
    ans =
    Inf
    
          

    because it 10^500

    is evaluated as double

    , giving inf

    , and then used as input for vpa

    .

+5


source







All Articles