To find the area under the curve using C

A

anand

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
 
V

Vladimir S. Oka

anand said:
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..

We can program in C. We can probably guide you as well.

What we can't and won't do is do your homework for you. Show you've made
an effort (in C) and we can help you with any problems you encounter.

To get you going, go through your numerical analysis textbooks to
identify the methods you mention. Next, revise your C course to date.

Finally, try to actually implement what you learned.

Any C language problems along the way, and good people here will likely
try to help.
 
K

Keith Thompson

anand said:
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..

I'm sure it would.

Give us your instructor's e-mail address so we can submit our
solutions directly. For an extra fee, we'll mention your name. (Or
perhaps we should charge extra for *not* mentioning your name.)
 
R

Robert Gamble

anand said:
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..

As you will likely soon discover, the majority of regulars aren't big
on doing other peoples' homework for them, especially when you haven't
even given it a try yourself.

Give the problem your best shot, if you have a C language question
along the way feel free to come back with what you have so far. If you
have an algorithm question, consult your calculus book or ask elsewhere
as such discussion is off-topic here.

Robert Gamble
 
O

osmium

anand said:
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..

First of all, x is measured in radians, not inches. It looks like you need
at least three functions plus main. One to compute f(x), one to compute an
integral using the trapezoidal rule, and one to do the same thing via the
Romberg method. That will at least get you started. You might end up
adding some more functions later. Compile often. Start with f(x), it is the
easiest to do. For early debugging, you can change main to select one of
the two methods, one at a time.

I think the problem would be clearer if he had said "slice" size instead of
"grid" size. Where I come from, grids tend to be square.

I don't think your program can "prove" anything, it can demonstrate by
example that something or other might be true.
 
C

CBFalconer

anand said:
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..

We are happy to do homework, with advance payment of at least 1/2
day at USD 200 per hour. We also require your instructors e-mail
address for delivery of the result. Certified check or paypal will
suffice. The advance amount will be 800 USD.

You will need to also supply the he program with full
documentation. We only have the she program available.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
Also see <http://www.safalra.com/special/googlegroupsreply/>
 
K

Keith Thompson

osmium said:
anand said:
I am trying to "find the area under the curve f(x)=sin(x)/x for x=1 to
3"
[snip]
First of all, x is measured in radians, not inches. It looks like you need
at least three functions plus main.

The '"' character was a closing quotation mark, matching the opening
quotation mark in front of the word "find".
 
R

Robert Gamble

osmium said:
I saw the " and took it to be inches, rather than seconds.

He quoted the problem text, that double quote you confused for inches,
then seconds, is simply the closing quote of that text, I guess you
missed the opening quote. Twice ;)

Robert Gamble
 
O

osmium

Keith Thompson said:
osmium said:
anand said:
I am trying to "find the area under the curve f(x)=sin(x)/x for x=1 to
3"
[snip]
First of all, x is measured in radians, not inches. It looks like you
need
at least three functions plus main.

The '"' character was a closing quotation mark, matching the opening
quotation mark in front of the word "find".

Good grief!
 
F

Fred Kleinschmidt

anand said:
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.
 
O

osmium

Fred Kleinschmidt said:
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?
 
F

Fred Kleinschmidt

osmium said:
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.
 
?

=?ISO-8859-1?Q?Martin_J=F8rgensen?=

anand said:
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..

Here's some guidance: Show your program.

I would actually like to see it very much, because I'm (I could be) also
a bit interested in that...


Best regards / Med venlig hilsen
Martin Jørgensen
 
K

Keith Thompson

Fred Kleinschmidt said:
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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top