Home > Archive > C > February 2006 > Re: To find the area under the curve using C
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: To find the area under the curve using C
|
|
| Fred Kleinschmidt 2006-02-27, 6:57 pm |
|
"anand" <anand.kolipakkam@gmail.com> wrote in message
news:1140997410.449173.253220@j33g2000cwa.googlegroups.com...
> Dear all,
>
> I am trying to "find the area under the curve f(x)=sin(x)/x for x=1 to
> 3"
>
> a) Use the trapezoidal rule method. Prove that your trapezoidal rule
> method is second order
> accurate (using he program)
> b) Use the Romberg method. Compare the grid size neccessary to get
> convergence to within 1e-8 using TR (part a) versus the Romberg method.
>
> It would be of great help if you guys can programm in C and guide me..
>
> thanks
> Anand
>
As many others have said, show what you have tried, then we might offer
suggestions.
However, your prof should be admonished for even assigning this integration
problem. Solving the sine integral ( integrating sin(x)/x ) is NOTa trivial
task, even using Cautious Adaptive Quadrature with Romberg Extrapolation, or
Legendre-Gauss, or Lagrangian interpolation.
It is one of the most difficult to solve with any accuracy over its general
range. I note that the assignmnet was to integrate from 1 to 3. This area is
reasonabley smooth, so some accuracy can be achieved by the suggested
methods. But that might give the student the impression that he has created
an accurate algorithm. The above methods begin to fail miserably for x > 8.
--
Fred L. Kleinschmidt
Boeing Associate Technical Fellow
Technical Architect, Software Reuse Project
| |
| osmium 2006-02-27, 6:57 pm |
| "Fred Kleinschmidt" wrote:
> As many others have said, show what you have tried, then we might offer
> suggestions.
>
> However, your prof should be admonished for even assigning this
> integration problem. Solving the sine integral ( integrating sin(x)/x ) is
> NOTa trivial task, even using Cautious Adaptive Quadrature with Romberg
> Extrapolation, or Legendre-Gauss, or Lagrangian interpolation.
> It is one of the most difficult to solve with any accuracy over its
> general range. I note that the assignmnet was to integrate from 1 to 3.
> This area is reasonabley smooth, so some accuracy can be achieved by the
> suggested methods. But that might give the student the impression that he
> has created an accurate algorithm. The above methods begin to fail
> miserably for x > 8.
I assume that the OP is in a numerical analysis class and not a programming
language class. Kind of like engineering classes that sometimes had an
offhand assignment that you, of course, knew Fortran. Doesn't everybody?
| |
| Fred Kleinschmidt 2006-02-27, 6:57 pm |
|
"osmium" <r124c4u102@comcast.net> wrote in message
news:46gqf9Fb42cuU1@individual.net...
> "Fred Kleinschmidt" wrote:
>
>
> I assume that the OP is in a numerical analysis class and not a
> programming language class. Kind of like engineering classes that
> sometimes had an offhand assignment that you, of course, knew Fortran.
> Doesn't everybody?
>
Even worse if this is in a numerical analysis class - these are poor
algorithms to use for solving this problem.
--
Fred L. Kleinschmidt
Boeing Associate Technical Fellow
Technical Architect, Software Reuse Project
| |
| Keith Thompson 2006-02-27, 6:57 pm |
| "Fred Kleinschmidt" <fred.l.kleinmschmidt@boeing.com> writes:
> "osmium" <r124c4u102@comcast.net> wrote in message
> news:46gqf9Fb42cuU1@individual.net...
> Even worse if this is in a numerical analysis class - these are poor
> algorithms to use for solving this problem.
<OT>
Conceivably the point is to demonstrate that. Perhaps the next
iteration of the assignment will expand the range to where things fall
apart, and ask the students to analyze the results.
</OT>
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
|
|
|
|
|