Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ce6e888

Browse files
committed
Serial Reimann implementation
1 parent fd88db1 commit ce6e888

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

reimann.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/python
2+
3+
def func(x):
4+
y = x * x
5+
return y
6+
7+
def main():
8+
# Domain start and end
9+
xStart = 0.0
10+
xEnd = 2.0 * 3.1415
11+
12+
# Number of total samples
13+
numRectangles = 10
14+
15+
# Rectangle width
16+
width = (xEnd-xStart) / numRectangles
17+
18+
# Empty list of Rectangle areas
19+
area_of_each_rectangle = []
20+
21+
for i in range(0,numRectangles - 1):
22+
x = i * width
23+
y = func(x)
24+
area_of_each_rectangle.append(x * y)
25+
26+
# Calculate the "Total" area
27+
total_area = 0.0
28+
29+
for i in range(0,numRectangles - 1):
30+
total_area += area_of_each_rectangle[i]
31+
32+
# Output the total area
33+
print total_area
34+
35+
main()

0 commit comments

Comments
 (0)