Velocity Reviews > To find the area under the curve using C

# To find the area under the curve using C

anand
Guest
Posts: n/a

 02-26-2006
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

Guest
Posts: n/a

 02-27-2006
anand wrote:

> 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.

--

Nuke the unborn gay female whales for Jesus.

Keith Thompson
Guest
Posts: n/a

 02-27-2006
"anand" <(E-Mail Removed)> writes:
> 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.

solutions directly. For an extra fee, we'll mention your name. (Or
perhaps we should charge extra for *not* mentioning your name.)

--
Keith Thompson (The_Other_Keith) http://www.velocityreviews.com/forums/(E-Mail Removed) <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.

Robert Gamble
Guest
Posts: n/a

 02-27-2006
anand wrote:
> 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
as such discussion is off-topic here.

Robert Gamble

osmium
Guest
Posts: n/a

 02-27-2006
"anand" writes:

> 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
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.

CBFalconer
Guest
Posts: n/a

 02-27-2006
anand wrote:
>
> 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

Robert Gamble
Guest
Posts: n/a

 02-27-2006
osmium wrote:
> "anand" writes:
>
> > 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.

Robert Gamble

osmium
Guest
Posts: n/a

 02-27-2006
"Robert Gamble" writes:

> osmium wrote:
>> "anand" writes:
>>
>> > 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.

>
> Who said anything about inches?

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

Keith Thompson
Guest
Posts: n/a

 02-27-2006
"osmium" <(E-Mail Removed)> writes:
> "anand" writes:
>
>> 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".

--
Keith Thompson (The_Other_Keith) (E-Mail Removed) <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.

Robert Gamble
Guest
Posts: n/a

 02-27-2006
osmium wrote:
> "Robert Gamble" writes:
>
> > osmium wrote:
> >> "anand" writes:
> >>
> >> > 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.

> >
> > Who said anything about inches?

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