#Name:Mandy
#Date: January 15, 2018
#Program Title: Area Calculator
#Program Function: This program calcuates the area under curves (mathematical functions)

'''
(1) Find the area under y = sin(x) from x=0 to x = PI.
(2) Find the area under y = 2^x from x = 1 to x = 10
(3) Find the area under a curve of your choice on a range of your choice.
'''
from math import *
#part1
a1 = 0.0 #This is the starting x value
b1 = pi #This is the ending x value
n = 1000000
Area1 = 0.0 #This is the total area
def g(x):
    return sin(x)

for i in range(1,n+1):
    #Find xi, the current x value
    xi1 = (b1-a1)/n + a1   
    #Find the area of the rectangle, Ai, using the function
    Ai1 =g((b1-a1)/n*i+a1) * (b1-a1)/n
    #Add it to the total area, "Area"
    Area1 += Ai1
#Print the area here
print (Area1)

#part2
a = 1.0 #This is the starting x value
b = 10.0 #This is the ending x value
n = 1000000 #This is the number of rectangles
Area = 0.0 #This is the total area
#This is the function to use in the area calculation
def f(x):
    return 2**x

for i in range(1,n+1):
    #Find xi, the current x value
    xi = (b-a)/n + a  
    #Find the area of the rectangle, Ai, using the function
    Ai =f((b-a)/n*i+a) * ((b-a)/n)
    #Add it to the total area, "Area"
    Area += Ai
#Print the area here
print (Area)

#part3
a3 = 1.0 #This is the starting x value
b3 = 100.0 #This is the ending x value
n = 1000000 #This is the number of rectangles
Area3 = 0.0 #This is the total area
#This is the function to use in the area calculation
def h(x):
    return x**4

for i in range(1,n+1):
    #Find xi, the current x value
    xi3 = (b3-a3)/n + a3   
    #Find the area of the rectangle, Ai, using the function
    Ai3 =h((b3-a3)/n*i+a3) * (b3-a3)/n
    #Add it to the total area, "Area"
    Area3 += Ai3
#Print the area here
print (Area3)


220355d956584bc7d88ed8ca3dd3eeffd123954c
<mask token>


def g(x):
    return sin(x)


<mask token>


def f(x):
    return 2 ** x


<mask token>


def h(x):
    return x ** 4


<mask token>

<mask token>


def g(x):
    return sin(x)


for i in range(1, n + 1):
    xi1 = (b1 - a1) / n + a1
    Ai1 = g((b1 - a1) / n * i + a1) * (b1 - a1) / n
    Area1 += Ai1
print(Area1)
<mask token>


def f(x):
    return 2 ** x


for i in range(1, n + 1):
    xi = (b - a) / n + a
    Ai = f((b - a) / n * i + a) * ((b - a) / n)
    Area += Ai
print(Area)
<mask token>


def h(x):
    return x ** 4


for i in range(1, n + 1):
    xi3 = (b3 - a3) / n + a3
    Ai3 = h((b3 - a3) / n * i + a3) * (b3 - a3) / n
    Area3 += Ai3
print(Area3)

<mask token>
a1 = 0.0
b1 = pi
n = 1000000
Area1 = 0.0


def g(x):
    return sin(x)


for i in range(1, n + 1):
    xi1 = (b1 - a1) / n + a1
    Ai1 = g((b1 - a1) / n * i + a1) * (b1 - a1) / n
    Area1 += Ai1
print(Area1)
a = 1.0
b = 10.0
n = 1000000
Area = 0.0


def f(x):
    return 2 ** x


for i in range(1, n + 1):
    xi = (b - a) / n + a
    Ai = f((b - a) / n * i + a) * ((b - a) / n)
    Area += Ai
print(Area)
a3 = 1.0
b3 = 100.0
n = 1000000
Area3 = 0.0


def h(x):
    return x ** 4


for i in range(1, n + 1):
    xi3 = (b3 - a3) / n + a3
    Ai3 = h((b3 - a3) / n * i + a3) * (b3 - a3) / n
    Area3 += Ai3
print(Area3)

<mask token>
from math import *
a1 = 0.0
b1 = pi
n = 1000000
Area1 = 0.0


def g(x):
    return sin(x)


for i in range(1, n + 1):
    xi1 = (b1 - a1) / n + a1
    Ai1 = g((b1 - a1) / n * i + a1) * (b1 - a1) / n
    Area1 += Ai1
print(Area1)
a = 1.0
b = 10.0
n = 1000000
Area = 0.0


def f(x):
    return 2 ** x


for i in range(1, n + 1):
    xi = (b - a) / n + a
    Ai = f((b - a) / n * i + a) * ((b - a) / n)
    Area += Ai
print(Area)
a3 = 1.0
b3 = 100.0
n = 1000000
Area3 = 0.0


def h(x):
    return x ** 4


for i in range(1, n + 1):
    xi3 = (b3 - a3) / n + a3
    Ai3 = h((b3 - a3) / n * i + a3) * (b3 - a3) / n
    Area3 += Ai3
print(Area3)

#Name:Mandy
#Date: January 15, 2018
#Program Title: Area Calculator
#Program Function: This program calcuates the area under curves (mathematical functions)

'''
(1) Find the area under y = sin(x) from x=0 to x = PI.
(2) Find the area under y = 2^x from x = 1 to x = 10
(3) Find the area under a curve of your choice on a range of your choice.
'''
from math import *
#part1
a1 = 0.0 #This is the starting x value
b1 = pi #This is the ending x value
n = 1000000
Area1 = 0.0 #This is the total area
def g(x):
    return sin(x)

for i in range(1,n+1):
    #Find xi, the current x value
    xi1 = (b1-a1)/n + a1   
    #Find the area of the rectangle, Ai, using the function
    Ai1 =g((b1-a1)/n*i+a1) * (b1-a1)/n
    #Add it to the total area, "Area"
    Area1 += Ai1
#Print the area here
print (Area1)

#part2
a = 1.0 #This is the starting x value
b = 10.0 #This is the ending x value
n = 1000000 #This is the number of rectangles
Area = 0.0 #This is the total area
#This is the function to use in the area calculation
def f(x):
    return 2**x

for i in range(1,n+1):
    #Find xi, the current x value
    xi = (b-a)/n + a  
    #Find the area of the rectangle, Ai, using the function
    Ai =f((b-a)/n*i+a) * ((b-a)/n)
    #Add it to the total area, "Area"
    Area += Ai
#Print the area here
print (Area)

#part3
a3 = 1.0 #This is the starting x value
b3 = 100.0 #This is the ending x value
n = 1000000 #This is the number of rectangles
Area3 = 0.0 #This is the total area
#This is the function to use in the area calculation
def h(x):
    return x**4

for i in range(1,n+1):
    #Find xi, the current x value
    xi3 = (b3-a3)/n + a3   
    #Find the area of the rectangle, Ai, using the function
    Ai3 =h((b3-a3)/n*i+a3) * (b3-a3)/n
    #Add it to the total area, "Area"
    Area3 += Ai3
#Print the area here
print (Area3)

