Results 1 to 7 of 7

Math Help - Numerical Analysis - finding least squares approximations

  1. #1
    Newbie
    Joined
    Feb 2007
    Posts
    3

    Numerical Analysis - finding least squares approximations

    Hi,

    I have to find a least squares approximations to the functions cos(x) and exp(x), each on the interval [0,1].

    How do I do this??!
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Global Moderator

    Joined
    Nov 2005
    From
    New York City
    Posts
    10,616
    Thanks
    9
    Quote Originally Posted by lifeonmars View Post
    Hi,

    I have to find a least squares approximations to the functions cos(x) and exp(x), each on the interval [0,1].

    How do I do this??!
    Let us concetrate on y=cos x
    Are you asking me to do it out for you?
    It takes a long time.

    You want to find y=mx+b which minimizes the area between the curve cos x and mx+b.
    Attached Thumbnails Attached Thumbnails Numerical Analysis - finding least squares approximations-picture3.gif  
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by lifeonmars View Post
    Hi,

    I have to find a least squares approximations to the functions cos(x) and exp(x), each on the interval [0,1].

    How do I do this??!
    We will need more information. Primarily what type of functions do you want
    to fit cos(x) and exp(x) with, and what is the maximum order of basis
    function do you want to use?

    For instance do you want a least squares linear approximation, quadratic,
    cubic, fourier sin series, cosin series, gaussian sum,...

    RonL
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Newbie
    Joined
    Feb 2007
    Posts
    3
    Argh, sorry. I deleted the bit of my post with the pertinent extra information in it. Quadratic least squares!

    Thanks!
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Global Moderator

    Joined
    Nov 2005
    From
    New York City
    Posts
    10,616
    Thanks
    9
    For y=cos x on [0,1]
    The quadradic is,
    y=-.431x^2-.035x+1.00 and R^2=.999

    For y=e^x on [0,1]
    The quadradic is,
    y=.836^2+.855x+1.011 and R^2=.999

    This is mine 47th Post!!!
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Newbie
    Joined
    Feb 2007
    Posts
    3
    OK, so those are the answers - but am I going about this the right way?

    Take the cosx example - I've written down three equations:

    (int stands for integral, from 0 to 1)

    a0*int[(1.dx)]+a1*int[x.dx]+a2*int[x^2.dx]=int[cos(x).dx]
    a0*int[(x.dx)]+a1*int[x^2.dx]+a2*int[x^3.dx]=int[x.cos(x).dx]
    a0*int[(x^2.dx)]+a1*int[x^3.dx]+a2*int[x^4.dx]=int[x^2.cos(x).dx]

    and then performed the integrations, done some simultaneous equations and come out with values for a0, a1, and a2; these are the co-efficients for the x^0, x^1 and x^2 terms respectively.

    Is this the right method?

    Thanks.
    Follow Math Help Forum on Facebook and Google+

  7. #7
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by lifeonmars View Post
    OK, so those are the answers - but am I going about this the right way?

    Take the cosx example - I've written down three equations:

    (int stands for integral, from 0 to 1)

    a0*int[(1.dx)]+a1*int[x.dx]+a2*int[x^2.dx]=int[cos(x).dx]
    a0*int[(x.dx)]+a1*int[x^2.dx]+a2*int[x^3.dx]=int[x.cos(x).dx]
    a0*int[(x^2.dx)]+a1*int[x^3.dx]+a2*int[x^4.dx]=int[x^2.cos(x).dx]

    and then performed the integrations, done some simultaneous equations and come out with values for a0, a1, and a2; these are the co-efficients for the x^0, x^1 and x^2 terms respectively.

    Is this the right method?

    Thanks.
    No. There are many ways of doing this which you use will depend on
    what you have been covering in the course that this is a question from.

    The most elegant is to use orthonormal polynomials on (0,1), which we may
    call P_0(x), P_1(x), and P_3(x), then the coefficients of these polynomials in
    the expansion of cos(x) are:

    a_0 = integral P_0(x) cos(x) dx x=0,1

    a_1 = integral P_1(x) cos(x) dx x=0,1

    a_2 = integral P_2(x) cos(x) dx x=0,1

    Then the required quadratic polynomial is:

    a_0 * P_0(x) + a_1 * P_1(x) + a_2 * P_2(x).

    (Note P_0(x) is a constant polynomial the x is just for consistency with
    the others).

    If you don't know the first three orthonormal polynomials on (0,1) you
    can find them by applying the Gramm-Schmit process to: 1, x, x^2.



    RonL
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. numerical analysis
    Posted in the Advanced Applied Math Forum
    Replies: 0
    Last Post: April 25th 2010, 07:25 AM
  2. Replies: 7
    Last Post: July 4th 2009, 02:22 PM
  3. Numerical Analysis
    Posted in the Differential Geometry Forum
    Replies: 2
    Last Post: March 1st 2009, 03:50 PM
  4. Numerical analysis
    Posted in the Calculus Forum
    Replies: 2
    Last Post: February 3rd 2009, 04:47 AM
  5. numerical analysis
    Posted in the Calculus Forum
    Replies: 0
    Last Post: December 2nd 2008, 08:56 AM

Search Tags


/mathhelpforum @mathhelpforum