1

You will write a program that evaluates the integral of sin(x) using the left-hand rectangle rule with 2000 subintervals, over 10 intervals. The intervals to test are [0, 1), [1, 2), …, [8, 9), [9, 10). You will declare an array of type double that can hold 10 elements, and you will use this array to hold all 10 results you get from evaluating each interval.

I am in testing my code, what should be the output? For example, [0, 1)? Any idea?

Thanks.

10
  • This is probably homework? You should identify homework as such. Commented Apr 16, 2010 at 0:52
  • Yes. It is a homework. But I just need some real output to test it out. Thanks. Commented Apr 16, 2010 at 0:55
  • 2
    It helps to first think what the output looks like before writing the program. Call me crazy. Commented Apr 16, 2010 at 0:55
  • 1
    This is a programming Q&A site, not a calculus one. Besides, calculus is so easy... Commented Apr 16, 2010 at 1:09
  • 3
    @Hamish: Uh no. They aren't elitists, they're actually quite nice. MathOverflow.net is for post-graduate level questions only. If you don't fit that bill, don't post there. It's that simple. Commented Apr 16, 2010 at 1:12

1 Answer 1

2

In case of a sin function you should be able to figure it out. For more complicated cases use this tool:

http://calc.matthen.com/

http://integrals.wolfram.com/index.jsp

Sign up to request clarification or add additional context in comments.

4 Comments

Thank you Hamish for your help. I think I got verification from some other people too. So my classmates were all wrong with the area. Thanks. I just need to confirm on the output. even if i have perfect codes, only knowing the real solutions can verify the code. Thanks
Haha! The brutal reality ... do not mess with machines, says Kasparov.
@JohnWong: Actually, a numerical integration algorithm won't return the very exact answer but for some trivial cases that don't require numerical integration algorithms anyway. Given bad input (for example, bad intervals), numerical algorithms can return bogus answers.
@ edurado, yes. i noticed that my answers were off by 0.0001 - 0.0002 but it was totally acceptable as you mention. thanks bro

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.