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!

Error function

  1. Nov 1, 2011 #1
    don t understant the question.
    Calculate the error function for f(x)=tan(x), [-1.25,1.25] for linear, quadratic and cubic shape functions and carry out the calulation using Mathematica or Fortran, C for 10,100 and 1000 elements.
    WHat does mean for linear, quadratic and cubic shape functions
    It refers to interpolation or means f(x)=tan(x) in 1, 2, u 3 degree
    As i understand first i have to replace the function with polinomial in n degree (10, 100 or 1000 by problem specification) and then some how calculate the aproximation
    please, help
  2. jcsd
  3. Nov 1, 2011 #2
    I don't quite get it either, but how about this:

    For n=10:
    Divide the range [-1.25, 1.25] by n and evaluate tan(x) for those 10 values.
    Fit a straight line through the 10 tan(x) values.
    Calculate the error between the line and the actual tan(x).
    Fit quadratic line through the 10 tan(x) values.
    Calculate the error between the quadratic line and the actual tan(x).
    Fit cubic line through the 10 tan(x) values.
    Calculate the error between the cubic line and the actual tan(x).

    Repeat for n=100 and n=1000

    my 2 cents
  4. Nov 2, 2011 #3
    Is´nt degree of interpolation is amount of nodes (10, 100 and 1000)?
  5. Nov 2, 2011 #4
    I am not sure what you mean by nodes. If you mean degrees of the polynomial...I seriously doubt it...I mean, who in the world would like a 1000 degree polynomial?

    I think what they mean is that you get more and more (10, 100, 1000) samples, out of the actual function, which you can then curve-fit a line through...the more points you have, presumably, the more accurate your curve-fit...

    ...then again, for example, there is only so much accuracy a straight line is going to provide no matter how many more point you have...whereas a cubic could certainly benefit from more points...

    what do you think? does it make sense to you?
  6. Nov 2, 2011 #5
    i'm confused now, need to figure things out-) thanks for helping
  7. Nov 2, 2011 #6
    Tell you what, I'd interpret it as is and then just run with it and hope for the best:

    So error function for tan(x)?


    [tex]f(x)=\text{erf}(\tan(x))=\int_{0}^{\tan(x)} e^{-z^2}dz[/tex]

    Shape function? How about just linear, quadratic, and cubic approximations to that function so for the linear approximation, let:


    Split the domain[-1.25, 1.25] into 10 parts so:


    Then compute a and b for:


    Now, compute the integral:

    [tex]\int_{\tan(x1)}^{\tan(x2)} (a+bx)dx[/tex]

    do that over the entire interval and sum them then compare to the actual value. Then do the quadratic and cubic over the interval.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook