Thread Subject: need quadruple precision

Subject: need quadruple precision

From: Juliette Salexa

Date: 29 Jun, 2009 00:17:00

Message: 1 of 6

I need quadruple precision in matlab,
and the calculations with which I am dealing are not suitable for symbolic arithmetic (the expressions are so complex that merely evaluating them results in truncation errors leading to my answers being less accurate than my numerical algorithm .. this was tested in maple with 1000 digits of precision).

If there's not a package that allows me to deal with quadruple precision .. Matlab should really incorporate one in its next version.

Subject: need quadruple precision

From: James Tursa

Date: 29 Jun, 2009 00:40:02

Message: 2 of 6

"Juliette Salexa" <juliette.physicist@gmail.com> wrote in message <h2915s$ctj$1@fred.mathworks.com>...
> I need quadruple precision in matlab,
> and the calculations with which I am dealing are not suitable for symbolic arithmetic (the expressions are so complex that merely evaluating them results in truncation errors leading to my answers being less accurate than my numerical algorithm .. this was tested in maple with 1000 digits of precision).

You could try this:

http://www.mathworks.com/matlabcentral/fileexchange/6446

James Tursa

Subject: need quadruple precision

From: John D'Errico

Date: 29 Jun, 2009 01:25:02

Message: 3 of 6

"Juliette Salexa" <juliette.physicist@gmail.com> wrote in message <h2915s$ctj$1@fred.mathworks.com>...
> I need quadruple precision in matlab,
> and the calculations with which I am dealing are not suitable for symbolic arithmetic (the expressions are so complex that merely evaluating them results in truncation errors leading to my answers being less accurate than my numerical algorithm .. this was tested in maple with 1000 digits of precision).
>
> If there's not a package that allows me to deal with quadruple precision .. Matlab should really incorporate one in its next version.

Yes, but you will never be happy. Given quad
precision, you will then plead for double that,
and then twice more.

john

Subject: need quadruple precision

From: Steven Lord

Date: 29 Jun, 2009 02:20:38

Message: 4 of 6


"Juliette Salexa" <juliette.physicist@gmail.com> wrote in message
news:h2915s$ctj$1@fred.mathworks.com...
>I need quadruple precision in matlab,
> and the calculations with which I am dealing are not suitable for symbolic
> arithmetic (the expressions are so complex that merely evaluating them
> results in truncation errors leading to my answers being less accurate
> than my numerical algorithm .. this was tested in maple with 1000 digits
> of precision).

So if 1000 digits of precision was not sufficient for your purposes, why
would you expect that quadruple precision (which has much less than 1000
digits of precision) would be?

From what you said about evaluating them resulting in lower precision, are
you trying to do something like:

x = sym(3^400)

and being disappointed about the precision? If so, realize that this
evaluates 3^400 in double precision and converts that double precision value
into a symbolic object. That's not what you want -- try this instead:

y = sym(3)^400

3 can be exactly represented in double precision, and so sym(3) exactly
captures the value 3 and sym(3)^400 causes the exponentiation to be
performed symbolically, not numerically.

> If there's not a package that allows me to deal with quadruple precision
> .. Matlab should really incorporate one in its next version.

There is one -- the arbitrary-precision capability of Symbolic Math Toolbox.

--
Steve Lord
slord@mathworks.com

Subject: need quadruple precision

From: Juliette Salexa

Date: 29 Jun, 2009 19:09:01

Message: 5 of 6

Thank you Steven for your response,
but you are not understanding. (Probably I wasn't clear, so I'll blame myself)

Maple performs my computation symbolically, and gives me back the correct analytic result to 100% accuracy .. but the expression is so complicated that just to EVALUATE that analytic expression, will require more than 1000 digits of precision. (1000 digits of precision gave me a curve that was not physically realistic, and I dont' think more will help).

Instead, I'm using a NUMERICAL SCHEME .. which doesn't deal with the analytic expressions at all.

This is analogous to finding the eigenvalues of a 3x3 matrix. Solving the cubic characteristic polynomial using caradno's formula gives 100% accurate analytic eigenvalues, but evaluating them results in truncation errors yielding overall errors up to 10^6 units in size [if you don't believe me see "Efficient Numerical Diagonalization of Hermitian 3x3 Matrices http://arxiv.org/abs/physics/0610206]. The Jacobi rotation NUMERICAL algorithm, doesn't even CONSIDER the characteristic polynomial, it just keeps modifying the matrix with operations that preserve the eigenvalues, until the non-diagonal elements are 0 (to machine precision), and therefore gives you much more accurate results than evaluating it symbolically and then evaluating it.

In fact with double precision, the numerical scheme is more accurate than with 1000 digits of precision using the analytic scheme (yes it's unintuitive). I am quite sure that MATLAB uses the numerical scheme for eigenvalue finding (because the analytic scheme won't work for matrices bigger than 4x4) .. I want it to use the numerical scheme, but with quadruple precision.

I'm afraid that if I use matlab's symbolic tool box, it will start using the analytic scheme to derive symbolic expressions for the eigenvalues, and then it will let me evaluate them with x-digits of precision (which is what maple does)
 
Does that make sense ??

"Steven Lord" <slord@mathworks.com> wrote in message <h298cb$j6e$1@fred.mathworks.com>...
>
> "Juliette Salexa" <juliette.physicist@gmail.com> wrote in message
> news:h2915s$ctj$1@fred.mathworks.com...
> >I need quadruple precision in matlab,
> > and the calculations with which I am dealing are not suitable for symbolic
> > arithmetic (the expressions are so complex that merely evaluating them
> > results in truncation errors leading to my answers being less accurate
> > than my numerical algorithm .. this was tested in maple with 1000 digits
> > of precision).
>
> So if 1000 digits of precision was not sufficient for your purposes, why
> would you expect that quadruple precision (which has much less than 1000
> digits of precision) would be?
>
> From what you said about evaluating them resulting in lower precision, are
> you trying to do something like:
>
> x = sym(3^400)
>
> and being disappointed about the precision? If so, realize that this
> evaluates 3^400 in double precision and converts that double precision value
> into a symbolic object. That's not what you want -- try this instead:
>
> y = sym(3)^400
>
> 3 can be exactly represented in double precision, and so sym(3) exactly
> captures the value 3 and sym(3)^400 causes the exponentiation to be
> performed symbolically, not numerically.
>
> > If there's not a package that allows me to deal with quadruple precision
> > .. Matlab should really incorporate one in its next version.
>
> There is one -- the arbitrary-precision capability of Symbolic Math Toolbox.
>
> --
> Steve Lord
> slord@mathworks.com
>

Subject: need quadruple precision

From: James Tursa

Date: 29 Jun, 2009 20:25:03

Message: 6 of 6

What problem are you trying to solve? The eigenvalue problem? Or was that just a convenient example? e.g., for the eigenvalue problem or other problems that can be solved using BLAS or LAPACK routines, one avenue you could pursue would be to:

- Create a quad precision class in MATLAB.
- Download the source code for the algorithm you want from netlib.org BLAS and LAPACK section
- Convert the Fortran source code to quad precision (i.e., change double precision to real(16))
- Create a mex interface for these routines
- Compile and link them using a compiler that supports real(16), e.g. ifort.

That would give you a good numerical algorithm with quad precision. The drawbacks of course are the time and effort it takes to do all of the above, and the execution time will suffer quite a bit since you are not using optimized libraries. But if you are desperate, it could be done.

MATLAB relies heavily on optimized BLAS and LAPACK libraries to do the behind-the-scenes calculations. I don't know if the current libraries that MATLAB uses support quad precision routines. One could, I suppose, use dependency walker to examine the library to see if anything there resembles quad precision routine names.

James Tursa

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
quadruple preci... Juliette Salexa 28 Jun, 2009 20:19:02
rssFeed for this Thread

Contact us at files@mathworks.com