Welcome to Dream.In.Code
Become an Expert!

Join 149,614 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,864 people online right now. Registration is fast and FREE... Join Now!




Python program to evaluate a Riemann sum?

 
Reply to this topicStart new topic

Python program to evaluate a Riemann sum?, using python to evaluate a Riemann sum for the function f(x) = x^3

FarmGirl
3 Sep, 2007 - 10:06 PM
Post #1

New D.I.C Head
*

Joined: 3 Sep, 2007
Posts: 5


My Contributions
"Create a python program that evaluates a Riemann sum for the function f(x) = x^3 and use this to approximate the integral from a to b of x^3 dx for a=1, b=2."

I don't know even how to begin to do this! Do I start with a range? Can I have a hint as to how to start? HELP!
User is offlineProfile CardPM
+Quote Post

NickDMax
RE: Python Program To Evaluate A Riemann Sum?
4 Sep, 2007 - 08:13 PM
Post #2

2B||!2B
Group Icon

Joined: 18 Feb, 2007
Posts: 2,869



Thanked: 53 times
Dream Kudos: 550
My Contributions
Your teacher has actually asked you to do something a little abstract so you should start by making some decisions.
How many intervals will you use?
Where will you choose your x* from (first point in interval, mid-point, last point (usually the "Riemann sum" refers to a point inside the interval so the mid-point is often easiest)?
Break up the intervals evenly?

Once you have made such choices... choose the points in the interval (a, cool.gif and then calculate y(xi) for each of these points. If you have made the intervals evenly broken up (so dx = (b - a)/n where n = number of intervals) then you can sum up the areas dx*y(xi).

I am no Python expert, so I would just use simple loops and linear interpolation myself.

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 12:29AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month