Increasing Precision with Complex Variables

Learning APL or new to Dyalog? Ask "silly" questions here, without fear...
Post Reply
REMINGTON30
Posts: 22
Joined: Fri Aug 11, 2017 2:17 pm

Increasing Precision with Complex Variables

Post by REMINGTON30 »

I have a user-written function that solves for the roots of polynomials. The calculations include complex variables (both real and imaginary parts). The function would benefit from greater than default precision in the floating-point calculations. Setting ⎕FR←1287 often produces a "fatal error" and ends function execution.

Execution time is not an issue in the application considered.

Back in Fortran days, there were double-precision floating point variables and calculations. How does one get increased precision with complex variables in APL?
User avatar
Morten|Dyalog
Posts: 460
Joined: Tue Sep 09, 2008 3:52 pm

Re: Increasing Precision with Complex Variables

Post by Morten|Dyalog »

⎕FR←645 gives you "double precision", which is the most widely used format for floating-point numbers. A complex number consists of a pair of doubles. ⎕FR←1287 enables the use of a QUADRUPLE precision DECIMAL floating-point representation, which is useful for large financial calculations. However, there is no corresponding quadruple precision complex number format; if you perform a calculation which returns a complex number with ⎕FR set to 1287, you will lose precision and end up with two doubles.

This was simply a "business decision"; we decided that it was not worth the effort to implement QUAD precision complex numbers, as we believed there was essentially no market for them. Your application is the first one I have heard of which requires complex numbers AND more than the 15 digits of precision that DOUBLEs give you.

However, you should NOT be getting "fatal errors"; if you have examples which reproduce this we would be very interested in having the details and fixing what sounds like a bug.
REMINGTON30
Posts: 22
Joined: Fri Aug 11, 2017 2:17 pm

Re: Increasing Precision with Complex Variables

Post by REMINGTON30 »

The text file of the code is attached. For test input, the coefficients of the polynomial are

Coeff←3480 ¯11906 16167 ¯11380 4639 ¯1174 193 ¯20 1

The APL code is given in the attached text file. I currently use
Dyalog APL/W-64 Version 17.0.33755
Serial No : 504716
Unicode Edition

Fix the code to the workspace. The function syntax is

PolySolve3 Coeff

⎕FR←645 gives correct results
⎕FR←1287 gives fatal error and exit from APL

Please excuse the somewhat crude code -- I am a beginner.

For the input mentioned, the exact roots are 1 1 2 3 4 5 2J5 2J¯5

Thanks.
Attachments

[The extension dyalog has been deactivated and can no longer be displayed.]

User avatar
AndyS|Dyalog
Posts: 263
Joined: Tue May 12, 2009 6:06 pm

Re: Increasing Precision with Complex Variables

Post by AndyS|Dyalog »

Looks like that issue was fixed in August.

We'll contact you separately to sort out getting you a fix for this issue.
REMINGTON30
Posts: 22
Joined: Fri Aug 11, 2017 2:17 pm

Re: Increasing Precision with Complex Variables

Post by REMINGTON30 »

Thanks. I will apply any updates/patches as soon as possible.
Post Reply