Thursday 19 September 2013

How to numerically compute nonlinear polynomials efficiently and accurately?

How to numerically compute nonlinear polynomials efficiently and accurately?

(I'm not sure whether I should post this problem on this site or on the
math site. Please feel free to migrate this post if necessary.)
My problem at hand is that given a value of k I'd like to numerically
compute a rational function of nonlinear polynomials in k which looks like
the following: (sorry I don't know how to typeset equations here...) where
{a_0, ..., a_N; b_0, ..., b_N; u_0, ..., u_N, v_0, ..., v_N} are real
constant numbers and i is the imaginary number. I learned from Numerical
Recipes that there are whole bunch of ways to compute polynomials quickly,
in the meanwhile keeping the rounding error small enough if all
coefficients were constant. But I do not think those ideas are useful in
my case.
Currently I calculate it in a brute force way in C with complex.h (this is
just a pseudo code):
double complex function(double k)
{
return
(a_0+a_1*cexp(I*u_1*k)*k+a_2*cexp(I*u_2*k)*k*k+...)/(b_0+b_1*cexp(I*v_1*k)*k+v_2*cexp(I*v_2*k)*k*k+...);
}
However when the number of calls of function increases (because this is
just a part of my real calculation), it is very slow and inaccurate (only
6 valid digits). I appreciate any comments and/or suggestions.

No comments:

Post a Comment