BookmarkSubscribeRSS Feed
RaniaMamdouh
Calcite | Level 5

How can I convert the fact10alpha to a numeric to use it in the computations???

Kurt_Bremser
Super User

That is the core of the problem: you cannot. SAS simply can not deal with numbers that fall outside of what can be handled with 8 bytes real.

Get the right tool for this kind of math and do it there. SAS is not the right tool.

RichardinOz
Quartz | Level 8

To deal with numbers of the order of 1e395 as an integer without loss of precision you would need a machine representation of around 165 bytes (against SAS use of floating point 8 bytes - which does not allow even 2**64 precision).  Using scientific notation does not change this requirement. 

The example using Proc Groovy demonstrates there are other tools (Java, in this instance - I showed my age in mentioning Fortran) which can accommodate very large numbers. You should use those tools. 

Any attempt to carry out numerical analysis on this scale in SAS is an exercise in futility.

Richard

Rick_SAS
SAS Super FREQ

Again, the question is "what are you trying to accomplish."  It looks like you are trying to fnd the roots of a tenth-degree polynomial with coefficients given by some alternating expression that involves ... binomial coefficients?  Looks like there is an "n choose k" term, or in your notation, "alpha choose i," but there are other terms as well.

What is the polynomial, and why are you trying to find its roots?

By the way, I wouldn't trust the result of the POLYROOT function on a polynomial with such huge coefficients. How do I know that the coefficients are huge?  Well, you can compute the coefficients without computing factorials of the large numbers. Note that

(alpha + p)! = alpha! * (alpha+1) * (alpha+2) * ... * (alpha + p)

so that the term (alpha + 10)! in the numerator cancels most of the terms of (alpha + i)! in the denominator.

You are left with a numerator that is the simple product: (alpha + i + 1) * ... * (alpha + 10).

The denominator simplifies to (10 + 1)! * i!

From these computations, the coefficients of the i_th term of the polynomial are roughly of the order +/-alpha##(10-i).  You can use the PROD function to compute the coefficients exactly, but again I emphasize that this is NOT something I recommend. Instead, I recommend understanding the purpose of finding the roots.

RaniaMamdouh
Calcite | Level 5

I try to find the roots to calculate the nodes and weights of the Gauss-Laguerre integration.

Do you mean that


xi= (Fact10alpha*((-1)**i))/(fact(10-i)*Factalphaij*fact(i));


will be

xi=numerator/ denominator

numerator= (alpha+i+1)* (alpha+1)* (alpha+2)* (alpha+3)* (alpha+4)* (alpha+5)* (alpha+6)* (alpha+7)* (alpha+8)* (alpha+9)* (alpha+10)* ((-1)**i)

denominator=(fact(10-i)*fact(10+1)*fact(i))

Rick_SAS
SAS Super FREQ

Close. I think it's

numerator= (alpha+i+1)* (alpha+i+2)* ... *(alpha+10)* (-1)**i

denominator=(fact(10-i)*fact(i))

What is the integral you are trying to solve?

RaniaMamdouh
Calcite | Level 5

I'm very grateful to you for drawing my attention to cancel the factorials in the numerator and denominator.

I work in the quality control area. I try to compute the ARL of the EWMA chart using marcov chain approach. I need to solve integral of variable follows chi squared.

What do you mean by using the PROD function to compute the coefficients exactly?????? And if you don't trust the result of the POLYROOT function on a polynomial with such huge coefficients, Is there another way to find the roots of a polynomial with such huge coefficients??????

Rick_SAS
SAS Super FREQ

Ahh, this is good information! You are trying to accurately compute the average run length (ARL) for an EWMA control chart.  This can be a difficult computation.

Have you looked at the EWMAARL function in the DATA step? There is an example of computing average run lengths in the documentation for the EWMACHART statement of the MACONTROL procedure in SAS/QC software.

RaniaMamdouh
Calcite | Level 5

But i try to compute the ARL of the EWMA with unknown parameters. Also, I will develop the EWMA to the AEWMA chart. I'm already designed the program but I want to know Is there another way to find the roots of a polynomial with such huge coefficients to complete the program?????

Rick_SAS
SAS Super FREQ

I need to move on to other responsibilities, so I'll let others advise you further. If you want to compute the roots of a tenth-order polynomial in SAS 9.2, you can try to use the POLYROOT function.  Other choices are described in this article:

Finding the root (zero) of a function in SAS

Good luck.

RaniaMamdouh
Calcite | Level 5

Thanks so much Mr/Rick . I'm waiting for your reply because I want to compute the roots of a twenty fifth- order polynomial.

Do you know if there is a module in SAS for the Halley's method?????

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 25 replies
  • 5511 views
  • 5 likes
  • 6 in conversation