Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: vpa help with matrices
Date: Sun, 18 Apr 2010 18:32:07 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 28
Message-ID: <hqfj77$p87$1@fred.mathworks.com>
References: <hqfald$g20$1@fred.mathworks.com> <hqfej0$fj4$1@fred.mathworks.com> <hqfg9c$bii$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1271615527 25863 172.30.248.38 (18 Apr 2010 18:32:07 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 18 Apr 2010 18:32:07 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:627640

"ben payne" <ben.is.located@gmail.com> wrote in message <hqfg9c$bii$1@fred.mathworks.com>...
> Hello. I am somewhat confused as to how useful vpa is if it only displays output from symbolic computation. For example, if I want to perform a numeric calculation to better than double or quad precision, it sounds like matlab is unable to do that?
> 
> I am asking basically the same question as on
> http://www.mathworks.com/support/solutions/en/data/1-1AGHW/index.html?product=SM&solution=1-1AGHW
> but they don't answer my question there. Namely, if I have two variables known to 100 decimal places, can I perform operations with those variables and retain precision?
> 
> Unlike thread 151496, I don't need the fastest library. The original program is written in Fortran 90, and I have used quadruple precision for that. However, quadruple precision is insufficient.
> 
> Do I need to be using something like the following?
> http://www.mathworks.com/matlabcentral/fileexchange/6446
> I assumed matlab would be able to perform vpa arithmetic.

  On my system if I type

 x = vpa('sqrt(2)',100)

I get the square root of two out to a hundred decimal places of accuracy, but if I merely type

 y = vpa(sqrt(2),100)

I get a hundred decimal places but it is accurate only out to the sixteenth place.

  The difference is that I have convinced 'vpa' to regard the first expression as being of type 'sym', but the second is only regarded as of type 'double'.  There is a world of difference between the two entities.

  To obtain 100-place accuracy in general computations you will need a system that is capable of handling type 'sym'.  When you say, "I have two variables known to 100 decimal places" you cannot be talking about a variable represented as a 64-bit double precision floating point number.  It can't be done with such a limited object.  It has to be in another form with far greater capacity, a form which the symbolic toolbox can use, which is to say a type 'sym'.  As you are probably aware, matlab's symbolic toolbox accomplishes this with strings of characters or strings of decimal digits of variable lengths depending on the required accuracy.

Roger Stafford