Increasing Precision with Complex Variables

Learning APL or new to Dyalog? Ask "silly" questions here, without fear...

Increasing Precision with Complex Variables

Postby REMINGTON30 on Mon Nov 05, 2018 8:45 pm

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?
REMINGTON30
 
Posts: 19
Joined: Fri Aug 11, 2017 2:17 pm

Re: Increasing Precision with Complex Variables

Postby Morten|Dyalog on Tue Nov 06, 2018 7:26 am

⎕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.
User avatar
Morten|Dyalog
 
Posts: 324
Joined: Tue Sep 09, 2008 3:52 pm

Re: Increasing Precision with Complex Variables

Postby REMINGTON30 on Wed Nov 07, 2018 10:02 pm

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
PolySolve3.dyalog
Polynomial Root Finder
(5.57 KiB) Downloaded 13 times
REMINGTON30
 
Posts: 19
Joined: Fri Aug 11, 2017 2:17 pm

Re: Increasing Precision with Complex Variables

Postby AndyS|Dyalog on Thu Nov 08, 2018 9:12 am

Looks like that issue was fixed in August.

We'll contact you separately to sort out getting you a fix for this issue.
User avatar
AndyS|Dyalog
 
Posts: 183
Joined: Tue May 12, 2009 6:06 pm

Re: Increasing Precision with Complex Variables

Postby REMINGTON30 on Thu Nov 08, 2018 3:04 pm

Thanks. I will apply any updates/patches as soon as possible.
REMINGTON30
 
Posts: 19
Joined: Fri Aug 11, 2017 2:17 pm


Return to New to Dyalog?

Who is online

Users browsing this forum: No registered users and 1 guest