# Approximation of a function with polynomials

I have a function of the form

$$f(k)=\frac{1}{a_1-a_{2}k^2e^{-(a_{3}-a_{4}k^2)}};\quad k=0...n$$

I approximated it with Taylor series expansion around $k=\frac{n}{2}$, but the results is not very precise (transformation of the function in order to obtain different intervals on the argument, e.g. $[0,1]$ did not work well either).

Are there other general-purpose polynomial expansions in place that yield sharper bounds?

-
What is the purpose of the expansion? This formula is not expensive to calculate, so why not use it? As Robert Israel said, the Chebyshev polynomials are based over the whole interval, so should give a better fit. As the $(k-n/2)$ multiplier in the Taylor series goes up to $n/2$, if your coefficients aren't decreasing by this much per order, you haven't even started to converge. – Ross Millikan Aug 3 '11 at 13:05

Your problem is probably caused by the fact that the denominator can go to zero and polynomials do not fit poles well. Even if your $a$'s are such that the denominator cannot go to zero, nearby poles in the complex plane can ruin your day. You might be interested in a rational function (a ratio of polynomials) instead. There should be any information in any numerical analysis book. Section 3.2 of Numerical Recipes discusses this and the obsolete versions are free.

-
the denominator goes to $a_1$ as $n \to \infty$ , but I got your point. – sigma.z.1980 Aug 2 '11 at 23:30
But the $a$'s could be such that there is a pole at $k=7.5$, for example. Even if it is at $k=7.5+i$ you will have trouble. The book discusses trying to fit $\frac{1}{1+x^2}$, where the pole at $i$ makes the fit terrible. The exponential tail is another thing polynomials don't do well-they want to go to $\pm \infty.$ – Ross Millikan Aug 2 '11 at 23:34
"I plotted $f$ for various $a_m$, it is always convex and strictly increasing, no poles" - in the real line, yes. You didn't check the behavior in the complex plane, did you? A function that has poles, even complex ones, will never be well-approximated by a polynomial. – J. M. Aug 3 '11 at 4:01
Note, @sigma, that in your current formulation, that $a_2$ and $a_3$ are redundant. You can define a new parameter $w=a_2 e^{a_3}$ so that your new function is $(a_1-wk^2 e^{-a_4 k^2})^{-1}$, and now you only have three parameters to tangle with. – J. M. Aug 3 '11 at 4:04
@sigma.z.1980: reciprcocating another function refers to the fact that you are dividing by $a_1-a_{2}k^2e^{-(a_{3}-a_{4}k^2)}$ I think we can guarantee this has zeros, which means your function has poles. It matters a lot whether they are close or far away, and without the $a$'s we can't tell. If they are within the circle centered on n/2 with radius n/2 the Taylor series won't converge at all. If they are close it will converge slowly. Robert Israel gives an example where the rational approximation is much better. I would expect that to be normal. – Ross Millikan Aug 5 '11 at 15:47

Taylor series provide a very good approximation for a function near a particular point, but are often poor approximations farther away. If you want to approximate a continuous function on an interval, you might try Chebyshev series. If you want the best possible approximation (in infinity norm) by polynomials of a given degree, you can try the Remez algorithm.

-
Emphasis on "try"; Remes can be very finicky, especially if you don't have good starting values. – J. M. Aug 3 '11 at 4:05
For example, I used Maple's minimax command on the function $f(x) = 1/(1 - 2 x^2 e^{-0.8 x^2})$ for $x \in [0,1]$. The best degree-8 polynomial approximation is $.995210326+.688929220 x-14.2591542 x^2+146.2326158 x^3-643.8283393 x^4$ $+1551.894001 x^5-2063.567641 x^6+1431.564022 x^7-399.8472835 x^8$, with a maximum error of about .00479 on this interval. – Robert Israel Aug 3 '11 at 17:14
On the other hand, asking for a rational approximation with numerator and denominator of degree 4 I get ${\frac { 1.836509916- 0.9917795120\,x+ 1.471185234\,{x}^{2}- 0.5637244264\,{x}^{3}+ 0.3097614226\,{x}^{4}}{ 1.836507496- 0.9914826398\,x- 2.207962497\,{x}^{2}+ 1.469524317\,{x}^{3}+ 0.1023759036\,{x}^{4}}}$ with maximum error of about 0.00000132. – Robert Israel Aug 3 '11 at 17:15