For Programmers: Free Programming Magazines  


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
osmium

2006-02-26, 9:55 pm

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


Keith Thompson

2006-02-26, 9:55 pm

"osmium" <r124c4u102@comcast.net> writes:
> "anand" writes:
>
[snip][color=darkred]
> 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) 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.
osmium

2006-02-26, 9:55 pm

"Keith Thompson" writes:

> "osmium" <r124c4u102@comcast.net> writes:
> [snip]
>
> The '"' character was a closing quotation mark, matching the opening
> quotation mark in front of the word "find".


Good grief!


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com