1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

How can I find a polynomial that approximates |x|

  1. May 8, 2009 #1
    1. The problem statement, all variables and given/known data

    According to Stone Weierstrass Theorem, there exists a polynomial such that lim P = |x|.
    Can anyone give me an example of P? Maybe within the range of 0.01?
    ie. |f-P|< 0.01


    2. Relevant equations



    3. The attempt at a solution
     
  2. jcsd
  3. May 8, 2009 #2

    dx

    User Avatar
    Homework Helper
    Gold Member

    I'm not sure but I think the Legendre polynomial expansion for |x| would converge uniformly to |x| as stated by Stone-Weierstrass.
     
  4. May 8, 2009 #3
    I think it converges in the mean. Since the Legendre polynomials are orthogonal, then we can write:

    [tex]f(x)=a_0 P_0(x)+a_1 P_1(x)+a_2 P_2(x)+\cdots[/tex]

    with:

    [tex]a_k=\frac{2k+1}{2}\int_{-1}^{1} f(x)P_k(x)dx[/tex]

    I'd try say 25 of them programatically (in Mathematica) then compare it to [tex]f(x)=|x|[/tex] happybear.
     
  5. May 8, 2009 #4

    dx

    User Avatar
    Homework Helper
    Gold Member

    The important facts are that the Legendre polynomials are both orthogonal and complete. This means that the mean square of the difference between f and the first n terms in the series goes to zero as n → ∞, i.e. the series converges uniformly to f.

    EDIT: Turns out this is not true. Read jbunniii's post #8.
     
    Last edited: May 8, 2009
  6. May 8, 2009 #5

    Hurkyl

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    In the interest of making correct statements, what you mean is that there is a sequence of polynomials {Pn} such that limn -> inf Pn(x) = |x| uniformly in x. (Or... maybe you just mean that it converges at each value of x)
     
  7. May 8, 2009 #6

    jbunniii

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    Mean square convergence does not imply uniform convergence in general!

    Consider f_n(x) (for n = 1,2,...) defined on [0,1] as an isosceles triangle whose base is the interval [0,1/n] and whose height is 1. If f(x) = 0 on [0,1] then f_n converges to f in the mean square sense (and also pointwise) but the convergence is not uniform.

    Maybe it's true that you can find a sequence of Legendre polynomials that converge uniformly to |x| (I'm not sure one way or the other) but if so, this fact isn't implied by mean square convergence.

    P.S. I don't think anyone mentioned it yet, but Stone-Weierstrass applies only on a compact set, so it only applies for f(x) = |x| if you restrict the domain.

    P.P.S. The Bernstein polynomials were "used by Bernstein in a constructive proof for the Stone-Weierstrass approximation theorem." -- see http://en.wikipedia.org/wiki/Bernstein_polynomial
     
    Last edited: May 8, 2009
  8. May 8, 2009 #7

    dx

    User Avatar
    Homework Helper
    Gold Member

    The functions in your example are not orthogonal. I could be wrong, but I remember reading somewhere that orthogonality and completeness imply uniform convergence.
     
  9. May 8, 2009 #8

    jbunniii

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    Orthogonality and completeness imply L^2 convergence (mean-squared) but not in general L^infinity convergence (uniform). L^2 is special because it is a Hilbert space, whereas L^p is not a Hilbert space if p is not 2.

    As I said, I'm not sure whether a sequence of Legendre polynomials that converges to f in L^2 will also converge uniformly. (I haven't found any statements or proofs to that effect after a fair amount of Googling.) But the orthogonality/L^2 convergence alone are not enough to guarantee this.

    By the way, there's a very similar situation with Fourier series: the complex exponentials are an orthonormal basis for L^2 and their linear combinations are dense in L^2. For any function f in L^2, its Fourier series converges to f in the L^2 norm (mean-squared sense).

    However, there exist even continuous functions whose Fourier series (the partial sums of which are trigonometric polynomials) don't converge at every point (the best you can hope for is pointwise convergence except on a set of measure 0), let alone converge uniformly.

    You CAN find a sequence of trigonometric polynomials that do converge uniformly to f if it's continuous [this is in fact also guaranteed by the Stone-Weierstrass theorem if you use a sufficiently general version], but you have to construct them using Fejer sums instead of the "raw" Fourier series.

    This is analogous to the situation with Stone-Weierstrass and polynomials - there certainly exist uniformly approximating polynomials to any continuous function on a compact set, but just because you find a sequence of polynomials (orthonormal ones, even) that converges in some other sense (pointwise or L^2) doesn't mean that particular sequence converges uniformly.
     
    Last edited: May 9, 2009
  10. May 10, 2009 #9
    Sorry if I caused some awkwardness with the convergence question above, something I barely understand myself. I just want to post some empirical results cus' I'm curious. The plot below is the actual function and a plot of the first 25 terms of the Legendre expansion created with this Mathematica code:

    Code (Text):
    f[x_] := Abs[x];
    clist = Table[((2*n + 1)/2)*
         Integrate[f[x]*LegendreP[n, x],
          {x, -1, 1}], {n, 0, 25}];
    g[x_] := Sum[clist[[n]]*LegendreP[n - 1,
          x], {n, 1, 26}];
    Plot[{f[x], g[x]}, {x, -1, 1}]

     
     

    Attached Files:

Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook