Calculating Error Function for f(x)=tan(x) with Mathematica/Fortran/C

  • Context: Mathematica 
  • Thread starter Thread starter GoYu
  • Start date Start date
  • Tags Tags
    Error Function
Click For Summary

Discussion Overview

The discussion revolves around calculating the error function for the function f(x) = tan(x) over the interval [-1.25, 1.25]. Participants explore the implications of using linear, quadratic, and cubic shape functions for interpolation and how to implement these calculations using programming languages like Mathematica, Fortran, or C for varying numbers of elements (10, 100, and 1000).

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • Some participants express confusion about the meaning of "linear, quadratic, and cubic shape functions," questioning whether it refers to interpolation or polynomial degrees.
  • One participant suggests dividing the interval into n segments and fitting linear, quadratic, and cubic functions to the evaluated tan(x) values, followed by calculating the errors for each fit.
  • Another participant questions the interpretation of "nodes," suggesting that more samples lead to better curve fitting, but also notes the limitations of using a straight line for approximation.
  • A later reply proposes a specific interpretation of the error function as the integral of e^{-z^2} from 0 to tan(x) and outlines a method for calculating the coefficients of linear approximations.

Areas of Agreement / Disagreement

Participants generally express uncertainty about the problem's requirements and interpretations, indicating that multiple competing views remain regarding the approach to take for the calculations.

Contextual Notes

There are unresolved assumptions regarding the definitions of shape functions and the degree of polynomials in relation to the number of nodes. The discussion also highlights potential limitations in accuracy based on the choice of polynomial degree.

GoYu
Messages
3
Reaction score
0
Hello!
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
 
Physics news on Phys.org
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
 
Is´nt degree of interpolation is amount of nodes (10, 100 and 1000)?
 
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?
 
i'm confused now, need to figure things out-) thanks for helping
 
GoYu said:
Hello!
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

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)?

That:

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

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

e^{-x^2}=a+bx

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

x1=-1.25
x2=-1

Then compute a and b for:

e^{-x1^2}=a+b(x1)
e^{-x2^2}=a+b(x2)

Now, compute the integral:

\int_{\tan(x1)}^{\tan(x2)} (a+bx)dx

do that over the entire interval and sum them then compare to the actual value. Then do the quadratic and cubic over the interval.
 

Similar threads

  • · Replies 7 ·
Replies
7
Views
15K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
2
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 3 ·
Replies
3
Views
5K
  • · Replies 2 ·
Replies
2
Views
6K