473,387 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

To find the area under the curve using C

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

Feb 26 '06 #1
15 5750
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.
--
BR, Vladimir

Nuke the unborn gay female whales for Jesus.

Feb 27 '06 #2
"anand" <an**************@gmail.com> 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.

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

--
Keith Thompson (The_Other_Keith) ks***@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.
Feb 27 '06 #3
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
have an algorithm question, consult your calculus book or ask elsewhere
as such discussion is off-topic here.

Robert Gamble

Feb 27 '06 #4
"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
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.
Feb 27 '06 #5
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?

Robert Gamble

Feb 27 '06 #6
"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.
Feb 27 '06 #7
"osmium" <r1********@comcast.net> 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) ks***@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.
Feb 27 '06 #8
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
"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/>

Feb 27 '06 #9
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

Feb 27 '06 #10
"Keith Thompson" writes:
"osmium" <r1********@comcast.net> 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".


Good grief!
Feb 27 '06 #11

"anand" <an**************@gmail.com> wrote in message
news:11**********************@j33g2000cwa.googlegr oups.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
Feb 27 '06 #12
"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?
Feb 27 '06 #13

"osmium" <r1********@comcast.net> wrote in message
news:46************@individual.net...
"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?

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
Feb 27 '06 #14
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..


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

--
---------------------------------------------------------------------------
Home of Martin Jørgensen - http://www.martinjoergensen.dk
Feb 27 '06 #15
"Fred Kleinschmidt" <fr******************@boeing.com> writes:
"osmium" <r1********@comcast.net> wrote in message
news:46************@individual.net...
"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?

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) ks***@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.
Feb 27 '06 #16

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Betty Harvey | last post by:
The next meeting of the XML Users Group will be held on Wednesday, November 19, 2003 at the American Geophysical Union (AGU) at 2000 Florida Avenue, N.W., Washington, DC 20009-1277. The meeting...
0
by: Betty Harvey | last post by:
Happy 2004! I hope everyone had a great holiday and will have a good new year. The next meeting of the XML Users Group will be held on Wednesday, January 21, 2004 at the American Geophysical...
5
by: reagan | last post by:
I am trying to get a program(in visual C++) to draw a sine curve (from 0 to 2pi). It takes 8 lines to draw the complete curve. However, the user can choose to use up to 100 lines to make the curve...
2
by: MLH | last post by:
This question, I apologize, is more of a math question than it is an Access question - I'm almost certain. The bell curve is another name for the normal distribution, which is a common type of...
2
by: Jeremy S. | last post by:
I know these questions can have no objective and definitive/correct answer - but I'm looking for some general insight, non specific as it may be. So, from those of you who have actually worked...
13
by: usenet | last post by:
How and where can one find out about the basics of VB/Access2003 syntax? I am a died in the wool C/C++/Java Linux/Unix programmer and I am finding it difficult to understand the program format...
4
by: babyinc | last post by:
Please help me. I am totally beginner of C++ and my tutor give us these huge program to solve within 20 days. As a MSc student I am really gonna cry. Please anyone can help me. sumon1in1@yahoo.com ...
0
by: sa6113 | last post by:
Hello there, I have a problem on curve fitting , would you please help me ?! I want to to develop a application that reads a text file with 2 columns of floating point data (as x and y) and...
0
by: RAZA1 | last post by:
hello, i am using Visual studio environment to run GUI in c#, which is connecting to a Micro controller via Rs232, the problem is i am getting a wave on GUI (sometimes multiple waves)(using A/D...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.