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

In summary: And then repeat for 100 and 1000 parts.In summary, the conversation discusses calculating the error function for f(x)=tan(x) over a specific range using linear, quadratic, and cubic shape functions and carrying out the calculations using Mathematica or Fortran or C for 10, 100, and 1000 elements. The shape functions refer to interpolation methods and the degree of interpolation corresponds to the number of nodes used in the approximation. The process involves replacing the original function with a polynomial of the specified degree and then calculating the approximation. The conversation also discusses different interpretations and approaches to the problem.
  • #1
GoYu
3
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
 
Mathematics news on Phys.org
  • #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
 
  • #3
Is´nt degree of interpolation is amount of nodes (10, 100 and 1000)?
 
  • #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?
 
  • #5
i'm confused now, need to figure things out-) thanks for helping
 
  • #6
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:

[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:

[tex]e^{-x^2}=a+bx[/tex]

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

x1=-1.25
x2=-1

Then compute a and b for:

[tex]e^{-x1^2}=a+b(x1)[/tex]
[tex]e^{-x2^2}=a+b(x2)[/tex]

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.
 

1. What is the purpose of calculating the error function for a given function?

The error function is a mathematical function used to measure the accuracy of a numerical approximation or calculation. In the context of a function like f(x)=tan(x), calculating the error function can help us evaluate how closely the numerical values obtained from the function match the actual values. This can be useful in verifying the correctness of a calculation or in optimizing the precision of a numerical algorithm.

2. How is the error function calculated for f(x)=tan(x) using Mathematica?

In Mathematica, the error function for f(x)=tan(x) can be calculated using the built-in function "Erf". This function takes in the numerical values obtained from the function and returns the corresponding error values. For example, Erf[tan(x)] will calculate the error values for the numerical values obtained from tan(x).

3. What is the difference between calculating the error function for f(x)=tan(x) using Mathematica and Fortran?

The main difference lies in the programming languages used. While Mathematica is a high-level programming language specifically designed for mathematical and scientific computations, Fortran is a low-level programming language used for scientific and engineering applications. This means that the syntax and methods for calculating the error function may differ between the two languages, but the underlying concept and purpose remains the same.

4. Can the error function for f(x)=tan(x) be calculated using both Mathematica and Fortran in the same program?

Yes, it is possible to use both Mathematica and Fortran in the same program to calculate the error function for f(x)=tan(x). This can be achieved by using Mathematica's "MathLink" feature, which allows for communication between Mathematica and external programs like Fortran. This can be useful in cases where complex calculations need to be done in Fortran, but the results need to be analyzed and visualized in Mathematica.

5. Are there any limitations to calculating the error function for f(x)=tan(x) with Mathematica or Fortran?

There are some limitations to consider when calculating the error function for f(x)=tan(x) using Mathematica or Fortran. One limitation is the precision of the numerical values obtained from the function, which can affect the accuracy of the error function calculation. Additionally, both Mathematica and Fortran have their own limitations and potential sources of errors, such as rounding errors and numerical stability issues, which may affect the accuracy of the results. It is important to carefully consider these limitations and choose the appropriate tools and methods for calculating the error function to ensure accurate and reliable results.

Similar threads

Replies
4
Views
2K
Replies
1
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
10
Views
2K
  • General Math
Replies
3
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
2K
  • Calculus and Beyond Homework Help
Replies
1
Views
1K
  • Advanced Physics Homework Help
Replies
4
Views
1K
  • Calculus and Beyond Homework Help
Replies
2
Views
3K
  • Calculus and Beyond Homework Help
Replies
3
Views
1K
  • Materials and Chemical Engineering
Replies
10
Views
2K
Back
Top