Hướng dẫn how do you write simpsons rule in python? - làm thế nào để bạn viết quy tắc simpsons trong python?

Có mã của tôi (tôi nghĩ đó là phương pháp dễ dàng nhất). Tôi đã làm điều này trong Notebook Jupyter. Mã dễ nhất và chính xác nhất cho phương pháp Simpson là 1/3.

Show

Giải trình

Đối với phương pháp tiêu chuẩn (a = 0, h = 4, b = 12) và f = 100- (x^2)/2

Chúng tôi có: n = 3.0, y0 = 100.0, y1 = 92.0, y2 = 68.0, y3 = 28.0,

Vì vậy, Simpson Method = h/3*(y0+4*y1+2*y2+y3) = 842,7 (điều này không đúng). Sử dụng quy tắc 1/3 mà chúng tôi có:

h = h/2 = 4/2 = 2 và sau đó:

n = 3.0, y0 = 100.0, y1 = 98.0, y2 = 92.0, y3 = 82.0, y4 = 68.0, y5 = 50.0, y6 = 28.0,

Bây giờ chúng tôi tính toán tích phân cho mỗi bước (n = 3 = 3 bước):

Tích hợp của bước đầu tiên: h/3*(y0+4*y1+y2) = 389.3333333333333

Tích hợp của bước thứ hai: h/3*(y2+4*y3+y4) = 325.3333333333333

Tích hợp của bước thứ ba: h/3*(y4+4*y5+y6) = 197.3333333333331

Tổng hợp tất cả, và chúng tôi nhận được 912.0 và điều này là đúng

x=0
b=12
h=4
x=float(x)
h=float(h)
b=float(b)
a=float(x)
def fun(x): 
    return 100-(x**2)/2
h=h/2
l=0  #just numeration
print('n=',(b-x)/(h*2))
n=int((b-a)/h+1)
y = []   #tablica/lista wszystkich y / list of all "y"
yf = []
for i in range(n):
    f=fun(x)
    print('y%s' %(l),'=',f)
    y.append(f)
    l+=1
    x+=h
print(y,'\n')
n1=int(((b-a)/h)/2)  
l=1
for i in range(n1):
    nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
    y=y[2:]  # with every step, we deleting 2 first "y" and we move 2 spaces to the right, i.e. y2+4*y3+y4
    print('Całka dla kroku/Integral for a step',l,'=',nf)
    yf.append(nf)
    l+=1
print('\nWynik całki/Result of the integral =', sum(yf) )

Lúc đầu, tôi đã thêm mục nhập dữ liệu đơn giản:

d=None
while(True):
    print("Enter your own data or enter the word "test" for ready data.\n")
    x=input ('Enter the beginning of the interval (a): ') 
    if x == 'test':
        x=0
        h=4  #krok (Δx)
        b=12 #granica np. 0>12  
        #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
        break
    h=input ('Enter the size of the integration step (h): ')
    if h == 'test':
        x=0
        h=4 
        b=12 
        break
    b=input ('Enter the end of the range (b): ')
    if b == 'test':
        x=0
        h=4  
        b=12 
        break 
    d=input ('Give the function pattern: ')
    if d == 'test':
        x=0
        h=4  
        b=12
        break
    elif d != -9999.9:
        break

x=float(x)
h=float(h)
b=float(b)
a=float(x)

if d == None or d == 'test':
    def fun(x): 
        return 100-(x**2)/2 #(20*x)-(x**2)
else:
    def fun(x): 
        w = eval(d)
        return  w
h=h/2
l=0  #just numeration
print('n=',(b-x)/(h*2))
n=int((b-a)/h+1)
y = []   #tablica/lista wszystkich y / list of all "y"
yf = []
for i in range(n):
    f=fun(x)
    print('y%s' %(l),'=',f)
    y.append(f)
    l+=1
    x+=h
print(y,'\n')
n1=int(((b-a)/h)/2)  
l=1
for i in range(n1):
    nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
    y=y[2:]
    print('Całka dla kroku/Integral for a step',l,'=',nf)
    yf.append(nf)
    l+=1
print('\nWynik całki/Result of the integral =', sum(yf) )

Evaluate logx dx within limit 4 to 5.2.

First we will divide interval into six equal 
parts as number of interval should be even.

x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64

Now we can calculate approximate value of integral
using above formula:
     = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                      1.60 ) +2 *(1.48 + 1.56)]
     = 1.84
Hence the approximation of above integral is 
1.827 using Simpson's 1/3 rule.  
          
6
Enter lower limit of integration: 0
Enter upper limit of integration: 1
Enter number of sub intervals: 6
Integration result by Simpson's 1/3 method is: 0.785398
2
Evaluate logx dx within limit 4 to 5.2.

First we will divide interval into six equal 
parts as number of interval should be even.

x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64

Now we can calculate approximate value of integral
using above formula:
     = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                      1.60 ) +2 *(1.48 + 1.56)]
     = 1.84
Hence the approximation of above integral is 
1.827 using Simpson's 1/3 rule.  
          
87

PHPSimpson 1/3 method is defined using python function definition

d=None
while(True):
    print("Enter your own data or enter the word "test" for ready data.\n")
    x=input ('Enter the beginning of the interval (a): ') 
    if x == 'test':
        x=0
        h=4  #krok (Δx)
        b=12 #granica np. 0>12  
        #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
        break
    h=input ('Enter the size of the integration step (h): ')
    if h == 'test':
        x=0
        h=4 
        b=12 
        break
    b=input ('Enter the end of the range (b): ')
    if b == 'test':
        x=0
        h=4  
        b=12 
        break 
    d=input ('Give the function pattern: ')
    if d == 'test':
        x=0
        h=4  
        b=12
        break
    elif d != -9999.9:
        break

x=float(x)
h=float(h)
b=float(b)
a=float(x)

if d == None or d == 'test':
    def fun(x): 
        return 100-(x**2)/2 #(20*x)-(x**2)
else:
    def fun(x): 
        w = eval(d)
        return  w
h=h/2
l=0  #just numeration
print('n=',(b-x)/(h*2))
n=int((b-a)/h+1)
y = []   #tablica/lista wszystkich y / list of all "y"
yf = []
for i in range(n):
    f=fun(x)
    print('y%s' %(l),'=',f)
    y.append(f)
    l+=1
    x+=h
print(y,'\n')
n1=int(((b-a)/h)/2)  
l=1
for i in range(n1):
    nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
    y=y[2:]
    print('Całka dla kroku/Integral for a step',l,'=',nf)
    yf.append(nf)
    l+=1
print('\nWynik całki/Result of the integral =', sum(yf) )
0.

Evaluate logx dx within limit 4 to 5.2. First we will divide interval into six equal parts as number of interval should be even. x : 4 4.2 4.4 4.6 4.8 5.0 5.2 logx : 1.38 1.43 1.48 1.52 1.56 1.60 1.64 Now we can calculate approximate value of integral using above formula: = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 1.60 ) +2 *(1.48 + 1.56)] = 1.84 Hence the approximation of above integral is 1.827 using Simpson's 1/3 rule. 96 d=None while(True): print("Enter your own data or enter the word "test" for ready data.\n") x=input ('Enter the beginning of the interval (a): ') if x == 'test': x=0 h=4 #krok (Δx) b=12 #granica np. 0>12 #w=(20*x)-(x**2) lub (1+x**3)**(1/2) break h=input ('Enter the size of the integration step (h): ') if h == 'test': x=0 h=4 b=12 break b=input ('Enter the end of the range (b): ') if b == 'test': x=0 h=4 b=12 break d=input ('Give the function pattern: ') if d == 'test': x=0 h=4 b=12 break elif d != -9999.9: break x=float(x) h=float(h) b=float(b) a=float(x) if d == None or d == 'test': def fun(x): return 100-(x**2)/2 #(20*x)-(x**2) else: def fun(x): w = eval(d) return w h=h/2 l=0 #just numeration print('n=',(b-x)/(h*2)) n=int((b-a)/h+1) y = [] #tablica/lista wszystkich y / list of all "y" yf = [] for i in range(n): f=fun(x) print('y%s' %(l),'=',f) y.append(f) l+=1 x+=h print(y,'\n') n1=int(((b-a)/h)/2) l=1 for i in range(n1): nf=(h/3*(y[+0]+4*y[+1]+y[+2])) y=y[2:] print('Całka dla kroku/Integral for a step',l,'=',nf) yf.append(nf) l+=1 print('\nWynik całki/Result of the integral =', sum(yf) ) 7Evaluate logx dx within limit 4 to 5.2. First we will divide interval into six equal parts as number of interval should be even. x : 4 4.2 4.4 4.6 4.8 5.0 5.2 logx : 1.38 1.43 1.48 1.52 1.56 1.60 1.64 Now we can calculate approximate value of integral using above formula: = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 1.60 ) +2 *(1.48 + 1.56)] = 1.84 Hence the approximation of above integral is 1.827 using Simpson's 1/3 rule. 98d=None while(True): print("Enter your own data or enter the word "test" for ready data.\n") x=input ('Enter the beginning of the interval (a): ') if x == 'test': x=0 h=4 #krok (Δx) b=12 #granica np. 0>12 #w=(20*x)-(x**2) lub (1+x**3)**(1/2) break h=input ('Enter the size of the integration step (h): ') if h == 'test': x=0 h=4 b=12 break b=input ('Enter the end of the range (b): ') if b == 'test': x=0 h=4 b=12 break d=input ('Give the function pattern: ') if d == 'test': x=0 h=4 b=12 break elif d != -9999.9: break x=float(x) h=float(h) b=float(b) a=float(x) if d == None or d == 'test': def fun(x): return 100-(x**2)/2 #(20*x)-(x**2) else: def fun(x): w = eval(d) return w h=h/2 l=0 #just numeration print('n=',(b-x)/(h*2)) n=int((b-a)/h+1) y = [] #tablica/lista wszystkich y / list of all "y" yf = [] for i in range(n): f=fun(x) print('y%s' %(l),'=',f) y.append(f) l+=1 x+=h print(y,'\n') n1=int(((b-a)/h)/2) l=1 for i in range(n1): nf=(h/3*(y[+0]+4*y[+1]+y[+2])) y=y[2:] print('Całka dla kroku/Integral for a step',l,'=',nf) yf.append(nf) l+=1 print('\nWynik całki/Result of the integral =', sum(yf) ) 90


# Simpson's 1/3 Rule

# Define function to integrate
def f(x):
    return 1/(1 + x**2)

# Implementing Simpson's 1/3 
def simpson13(x0,xn,n):
    # calculating step size
    h = (xn - x0) / n
    
    # Finding sum 
    integration = f(x0) + f(xn)
    
    for i in range(1,n):
        k = x0 + i*h
        
        if i%2 == 0:
            integration = integration + 2 * f(k)
        else:
            integration = integration + 4 * f(k)
    
    # Finding final integration value
    integration = integration * h/3
    
    return integration
    
# Input section
lower_limit = float(input("Enter lower limit of integration: "))
upper_limit = float(input("Enter upper limit of integration: "))
sub_interval = int(input("Enter number of sub intervals: "))

# Call trapezoidal() method and get result
result = simpson13(lower_limit, upper_limit, sub_interval)
print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )

# Simpson's 1/3 Rule # Define function to integrate def f(x): return 1/(1 + x**2) # Implementing Simpson's 1/3 def simpson13(x0,xn,n): # calculating step size h = (xn - x0) / n # Finding sum integration = f(x0) + f(xn) for i in range(1,n): k = x0 + i*h if i%2 == 0: integration = integration + 2 * f(k) else: integration = integration + 4 * f(k) # Finding final integration value integration = integration * h/3 return integration # Input section lower_limit = float(input("Enter lower limit of integration: ")) upper_limit = float(input("Enter upper limit of integration: ")) sub_interval = int(input("Enter number of sub intervals: ")) # Call trapezoidal() method and get result result = simpson13(lower_limit, upper_limit, sub_interval) print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) ) 1 # Simpson's 1/3 Rule # Define function to integrate def f(x): return 1/(1 + x**2) # Implementing Simpson's 1/3 def simpson13(x0,xn,n): # calculating step size h = (xn - x0) / n # Finding sum integration = f(x0) + f(xn) for i in range(1,n): k = x0 + i*h if i%2 == 0: integration = integration + 2 * f(k) else: integration = integration + 4 * f(k) # Finding final integration value integration = integration * h/3 return integration # Input section lower_limit = float(input("Enter lower limit of integration: ")) upper_limit = float(input("Enter upper limit of integration: ")) sub_interval = int(input("Enter number of sub intervals: ")) # Call trapezoidal() method and get result result = simpson13(lower_limit, upper_limit, sub_interval) print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) ) 2 1.82784703Evaluate logx dx within limit 4 to 5.2. First we will divide interval into six equal parts as number of interval should be even. x : 4 4.2 4.4 4.6 4.8 5.0 5.2 logx : 1.38 1.43 1.48 1.52 1.56 1.60 1.64 Now we can calculate approximate value of integral using above formula: = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 1.60 ) +2 *(1.48 + 1.56)] = 1.84 Hence the approximation of above integral is 1.827 using Simpson's 1/3 rule. 98 # Simpson's 1/3 Rule # Define function to integrate def f(x): return 1/(1 + x**2) # Implementing Simpson's 1/3 def simpson13(x0,xn,n): # calculating step size h = (xn - x0) / n # Finding sum integration = f(x0) + f(xn) for i in range(1,n): k = x0 + i*h if i%2 == 0: integration = integration + 2 * f(k) else: integration = integration + 4 * f(k) # Finding final integration value integration = integration * h/3 return integration # Input section lower_limit = float(input("Enter lower limit of integration: ")) upper_limit = float(input("Enter upper limit of integration: ")) sub_interval = int(input("Enter number of sub intervals: ")) # Call trapezoidal() method and get result result = simpson13(lower_limit, upper_limit, sub_interval) print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) ) 06

Enter lower limit of integration: 0
Enter upper limit of integration: 1
Enter number of sub intervals: 6
Integration result by Simpson's 1/3 method is: 0.785398

Xem thảo luận

Cải thiện bài viết

Lưu bài viết

  • Đọc
  • Bàn luận
  • Xem thảo luận

    Cải thiện bài viết

    Lưu bài viết

    Đọc

    Bàn luận 

    Hướng dẫn how do you write simpsons rule in python? - làm thế nào để bạn viết quy tắc simpsons trong python?

    Trong phân tích số, quy tắc Simpson 1/3 là một phương pháp xấp xỉ bằng số của các tích phân xác định. Cụ thể, đó là xấp xỉ sau: & nbsp;
    the area into n equal segments of width Δx. 
    Simpson’s rule can be derived by approximating the integrand f (x) (in blue) 
    by the quadratic interpolant P(x) (in red). 
     

    Hướng dẫn how do you write simpsons rule in python? - làm thế nào để bạn viết quy tắc simpsons trong python?

    & nbsp; & nbsp;
    1.Select a value for n, which is the number of parts the interval is divided into. 
    2.Calculate the width, h = (b-a)/n 
    3.Calculate the values of x0 to xn as x0 = a, x1 = x0 + h, …..xn-1 = xn-2 + h, xn = b. 
    Consider y = f(x). Now find the values of y(y0 to yn) for the corresponding x(x0 to xn) values. 
    4.Substitute all the above found values in the Simpson’s Rule Formula to calculate the integral value.
    Approximate value of the integral can be given by Simpson’s Rule

    Bàn luận 

    Hướng dẫn how do you write simpsons rule in python? - làm thế nào để bạn viết quy tắc simpsons trong python?

    Trong phân tích số, quy tắc Simpson 1/3 là một phương pháp xấp xỉ bằng số của các tích phân xác định. Cụ thể, đó là xấp xỉ sau: & nbsp; In this rule, n must be EVEN.
    Application : 
    It is used when it is very difficult to solve the given integral mathematically. 
    This rule gives approximation easily without actually knowing the integration rules.
    Example : 
     

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              

    C++

    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    1

    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    2

    & nbsp; & nbsp;

    Trong quy tắc 1/3 của Simpson, chúng tôi sử dụng parabolas để xấp xỉ từng phần của đường cong. & nbsp; bởi nội suy bậc hai p (x) (màu đỏ). & nbsp; & nbsp;

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    0

    Để tích hợp bất kỳ hàm f (x) nào trong khoảng (a, b), hãy làm theo các bước được đưa ra dưới đây: 1. Chọn một giá trị cho n, đó là số phần mà khoảng thời gian được chia thành. & Nbsp; 2.Calculation Chiều rộng, h = (b-a) /n 3 Hãy xem xét y = f (x). Bây giờ tìm các giá trị của y (y0 đến yn) cho các giá trị x (x0 đến xn) tương ứng. được đưa ra bởi quy tắc của Simpson: & nbsp;

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    5

    Lưu ý: Trong quy tắc này, n phải chẵn. Ứng dụng: & nbsp; nó được sử dụng khi rất khó để giải quyết tính tích phân đã cho.

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    0

    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    3
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    4
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    5

    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    6
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    7
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    6
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    9

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    2
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    3
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    4

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    7

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    9

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    5

    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    6
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    7
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    6
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    9
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    6
    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    1
    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    2
    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    3

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    2
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    3
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    4

    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    6
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    7
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    6
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    9
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    6
    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    1
    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    2
    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    3

    lower_limit3lower_limit4

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    6
    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    7

    lower_limit3upper_limit0

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6lower_limit6

    lower_limit3upper_limit4

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    5

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1upper_limit8

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    6
    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    0

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    5

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    2
    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    3
    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    2
    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    5

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    0

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    6
    1.827847
    4

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6lower_limit1 lower_limit2

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6lower_limit6 lower_limit1 lower_limit8

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1f(x)6

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    2 sub_interval1

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    5

    Enter lower limit of integration: 0 Enter upper limit of integration: 1 Enter number of sub intervals: 6 Integration result by Simpson's 1/3 method is: 0.785398 2 sub_interval4

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    6 sub_interval8

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    6 f(x)1

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    0

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    2
    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    3
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    6
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    16

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    5

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    05
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    6
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    7
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    6
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    9
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    6
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    26

    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    27
    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    2
    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    3

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    0

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    6
    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    7

    Các

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    6
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    45
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    38
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    6
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    40
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    41
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    42

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    2
    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    3
    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    2
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    55
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    56
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    57

    lower_limit3

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    7

    lower_limit3

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    9

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    5

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    6
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    66
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    56
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    68

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    2
    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    3
    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    2
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    55
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    56
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    57

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    6
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    66
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    56
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    68

    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    81lower_limit4

    lower_limit3lower_limit1

    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    78
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    56
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    80

    lower_limit3lower_limit6 lower_limit1

    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    86
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    87
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    88
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    56
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    90

    lower_limit3lower_limit6

    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    81
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    92
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    93
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    94

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    5

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    04
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    05
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    06

    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    81
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    92
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    87
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    94

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    5

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    2 sub_interval1

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    18

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    01
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    05
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    15
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    16

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    6
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    21
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    93
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    68

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    6
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    26
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    6
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    90
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    29
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    68

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    37

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    38
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    39

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    5

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    5

    Python3

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    2
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    33
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    34
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    68

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    43
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    44

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    45
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    46

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    2
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    49

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    45
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    51

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    53
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    54
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    55
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    56
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    57
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    58
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    59

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    61
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    54
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    63
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    64

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    66
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    54
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    63
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    64

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    71
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    54
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    56

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    75
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    76
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    54
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    78

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    86

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    80
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    81
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    71
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    83
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    84

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    71
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    81
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    54
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    91

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    66
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    54
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    63
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    64

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    71
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    54
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    56

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    75
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    76
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    54
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    78

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    80
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    81
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    71
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    83
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    84

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    71
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    81
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    54
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    91

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    93
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    54
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    56

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6lower_limit6
    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    29

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6lower_limit1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    71
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    54
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    54
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    56
    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    11
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    71__

    lower_limit3

    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    17
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    81
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    54
    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    20

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    22
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    71
    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    24
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    87
    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    26
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    54
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    56
    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    29

    lower_limit3

    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    17
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    81
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    54
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    93
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    83
    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    20

    lower_limit3

    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    17
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    81
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    54
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    87
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    83
    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    20

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    48
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    81
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    54
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    91

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    93
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    54
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    93
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    83
    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    57__

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    2
    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    17

    C#

    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    64
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    54 ________ 193 & nbsp; & nbsp;

    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    67
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    54
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    29

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    0

    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    70
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    54
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    34

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    0

    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    73
    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    3
    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    75
    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    24
    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    77

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    5

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    05
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    6
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    7
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    6
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    9
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    6
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    26

    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    3
    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    79

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    0

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    6
    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    7

    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    01
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    02
    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    82

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    05
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    6
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    7
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    6
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    9

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    2
    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    3
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    6
    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    96

    lower_limit3

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    7

    lower_limit3

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    9

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    5

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    07
    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    2
    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    3

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    2
    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    3
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    6
    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    96

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    07
    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    2
    Enter lower limit of integration: 0
    Enter upper limit of integration: 1
    Enter number of sub intervals: 6
    Integration result by Simpson's 1/3 method is: 0.785398
    
    3

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    6
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    37
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    38
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    6
    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    20

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    6
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    45
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    38
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    6
    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    20

    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    81upper_limit0

    lower_limit3lower_limit6

    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    81upper_limit4

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    5

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6upper_limit8

    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    81
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    92
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    87
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    94

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    5

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    2 sub_interval1

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    0

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    01
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    05
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    15
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    16

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    6
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    21
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    93
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    68

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    6
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    26
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    6
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    90
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    29
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    68

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    89

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    38
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    39

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    5

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    5

    Evaluate logx dx within limit 4 to 5.2. First we will divide interval into six equal parts as number of interval should be even. x : 4 4.2 4.4 4.6 4.8 5.0 5.2 logx : 1.38 1.43 1.48 1.52 1.56 1.60 1.64 Now we can calculate approximate value of integral using above formula: = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 1.60 ) +2 *(1.48 + 1.56)] = 1.84 Hence the approximation of above integral is 1.827 using Simpson's 1/3 rule. 6Enter lower limit of integration: 0 Enter upper limit of integration: 1 Enter number of sub intervals: 6 Integration result by Simpson's 1/3 method is: 0.785398 2 # Simpson's 1/3 Rule # Define function to integrate def f(x): return 1/(1 + x**2) # Implementing Simpson's 1/3 def simpson13(x0,xn,n): # calculating step size h = (xn - x0) / n # Finding sum integration = f(x0) + f(xn) for i in range(1,n): k = x0 + i*h if i%2 == 0: integration = integration + 2 * f(k) else: integration = integration + 4 * f(k) # Finding final integration value integration = integration * h/3 return integration # Input section lower_limit = float(input("Enter lower limit of integration: ")) upper_limit = float(input("Enter upper limit of integration: ")) sub_interval = int(input("Enter number of sub intervals: ")) # Call trapezoidal() method and get result result = simpson13(lower_limit, upper_limit, sub_interval) print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) ) 33 # Simpson's 1/3 Rule # Define function to integrate def f(x): return 1/(1 + x**2) # Implementing Simpson's 1/3 def simpson13(x0,xn,n): # calculating step size h = (xn - x0) / n # Finding sum integration = f(x0) + f(xn) for i in range(1,n): k = x0 + i*h if i%2 == 0: integration = integration + 2 * f(k) else: integration = integration + 4 * f(k) # Finding final integration value integration = integration * h/3 return integration # Input section lower_limit = float(input("Enter lower limit of integration: ")) upper_limit = float(input("Enter upper limit of integration: ")) sub_interval = int(input("Enter number of sub intervals: ")) # Call trapezoidal() method and get result result = simpson13(lower_limit, upper_limit, sub_interval) print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) ) 34d=None while(True): print("Enter your own data or enter the word "test" for ready data.\n") x=input ('Enter the beginning of the interval (a): ') if x == 'test': x=0 h=4 #krok (Δx) b=12 #granica np. 0>12 #w=(20*x)-(x**2) lub (1+x**3)**(1/2) break h=input ('Enter the size of the integration step (h): ') if h == 'test': x=0 h=4 b=12 break b=input ('Enter the end of the range (b): ') if b == 'test': x=0 h=4 b=12 break d=input ('Give the function pattern: ') if d == 'test': x=0 h=4 b=12 break elif d != -9999.9: break x=float(x) h=float(h) b=float(b) a=float(x) if d == None or d == 'test': def fun(x): return 100-(x**2)/2 #(20*x)-(x**2) else: def fun(x): w = eval(d) return w h=h/2 l=0 #just numeration print('n=',(b-x)/(h*2)) n=int((b-a)/h+1) y = [] #tablica/lista wszystkich y / list of all "y" yf = [] for i in range(n): f=fun(x) print('y%s' %(l),'=',f) y.append(f) l+=1 x+=h print(y,'\n') n1=int(((b-a)/h)/2) l=1 for i in range(n1): nf=(h/3*(y[+0]+4*y[+1]+y[+2])) y=y[2:] print('Całka dla kroku/Integral for a step',l,'=',nf) yf.append(nf) l+=1 print('\nWynik całki/Result of the integral =', sum(yf) ) 68

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    95

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    43
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    44

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    0

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    45
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    46

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    5

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    2
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    49

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    0

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    45
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    51

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    53
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    54
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    55
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    56
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    57
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    58
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    59

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    0

    Các

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    1.827847
    50
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    40
    1.827847
    28
    1.827847
    53
    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    98
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    40
    1.827847
    28
    1.827847
    57

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    5

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    1.827847
    61
    1.827847
    62

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    2
    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    3
    1.827847
    28

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    0

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6lower_limit1
    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    3
    1.827847
    28

    lower_limit3

    1.827847
    61
    1.827847
    87
    1.827847
    50
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    40
    1.827847
    28
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    42

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6lower_limit6 lower_limit1
    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    3
    1.827847
    28
    1.827847
    97

    lower_limit3

    1.827847
    61 lower_limit00
    1.827847
    50
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    40
    1.827847
    28
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    42

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6lower_limit6

    lower_limit3

    1.827847
    61 lower_limit09
    1.827847
    50
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    40
    1.827847
    28
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    42

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    5

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    1.827847
    61 lower_limit18
    1.827847
    61 lower_limit20
    1.827847
    17 lower_limit22

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    2
    1.827847
    61
    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    68

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    5

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1lower_limit29 lower_limit30

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1lower_limit32 lower_limit33

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    1.827847
    13 lower_limit36

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1lower_limit38
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    7lower_limit29
    1.827847
    10____632
    1.827847
    10
    1.827847
    13
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    06

    lower_limit46

    JavaScript

    lower_limit47

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    96 lower_limit50

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    0

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    2 lower_limit55

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    5

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    96 lower_limit60

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    0

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6lower_limit64

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6lower_limit66

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6lower_limit68

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    2 lower_limit71

    lower_limit3

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    7

    lower_limit3

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    9

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    5

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6lower_limit79

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    2 lower_limit71

    lower_limit3lower_limit1 lower_limit2

    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    81lower_limit4

    lower_limit3lower_limit6 lower_limit1 lower_limit8

    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    81upper_limit0

    lower_limit3lower_limit6

    d=None
    while(True):
        print("Enter your own data or enter the word "test" for ready data.\n")
        x=input ('Enter the beginning of the interval (a): ') 
        if x == 'test':
            x=0
            h=4  #krok (Δx)
            b=12 #granica np. 0>12  
            #w=(20*x)-(x**2)  lub   (1+x**3)**(1/2)
            break
        h=input ('Enter the size of the integration step (h): ')
        if h == 'test':
            x=0
            h=4 
            b=12 
            break
        b=input ('Enter the end of the range (b): ')
        if b == 'test':
            x=0
            h=4  
            b=12 
            break 
        d=input ('Give the function pattern: ')
        if d == 'test':
            x=0
            h=4  
            b=12
            break
        elif d != -9999.9:
            break
    
    x=float(x)
    h=float(h)
    b=float(b)
    a=float(x)
    
    if d == None or d == 'test':
        def fun(x): 
            return 100-(x**2)/2 #(20*x)-(x**2)
    else:
        def fun(x): 
            w = eval(d)
            return  w
    h=h/2
    l=0  #just numeration
    print('n=',(b-x)/(h*2))
    n=int((b-a)/h+1)
    y = []   #tablica/lista wszystkich y / list of all "y"
    yf = []
    for i in range(n):
        f=fun(x)
        print('y%s' %(l),'=',f)
        y.append(f)
        l+=1
        x+=h
    print(y,'\n')
    n1=int(((b-a)/h)/2)  
    l=1
    for i in range(n1):
        nf=(h/3*(y[+0]+4*y[+1]+y[+2]))
        y=y[2:]
        print('Całka dla kroku/Integral for a step',l,'=',nf)
        yf.append(nf)
        l+=1
    print('\nWynik całki/Result of the integral =', sum(yf) )
    
    81upper_limit4

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    5

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6upper_limit8

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    2 sub_interval1

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    1
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    5

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6upper_limit08

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6upper_limit10

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6upper_limit12

    Evaluate logx dx within limit 4 to 5.2.
    
    First we will divide interval into six equal 
    parts as number of interval should be even.
    
    x    :  4     4.2   4.4   4.6   4.8  5.0  5.2
    logx :  1.38  1.43  1.48  1.52  1.56 1.60 1.64
    
    Now we can calculate approximate value of integral
    using above formula:
         = h/3[( 1.38 + 1.64) + 4 * (1.43 + 1.52 + 
                          1.60 ) +2 *(1.48 + 1.56)]
         = 1.84
    Hence the approximation of above integral is 
    1.827 using Simpson's 1/3 rule.  
              
    6upper_limit14

    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    38
    
    # Simpson's 1/3 Rule
    
    # Define function to integrate
    def f(x):
        return 1/(1 + x**2)
    
    # Implementing Simpson's 1/3 
    def simpson13(x0,xn,n):
        # calculating step size
        h = (xn - x0) / n
        
        # Finding sum 
        integration = f(x0) + f(xn)
        
        for i in range(1,n):
            k = x0 + i*h
            
            if i%2 == 0:
                integration = integration + 2 * f(k)
            else:
                integration = integration + 4 * f(k)
        
        # Finding final integration value
        integration = integration * h/3
        
        return integration
        
    # Input section
    lower_limit = float(input("Enter lower limit of integration: "))
    upper_limit = float(input("Enter upper limit of integration: "))
    sub_interval = int(input("Enter number of sub intervals: "))
    
    # Call trapezoidal() method and get result
    result = simpson13(lower_limit, upper_limit, sub_interval)
    print("Integration result by Simpson's 1/3 method is: %0.6f" % (result) )
    
    39

    upper_limit17

    Output:  
     

    1.827847

    Ví dụ quy tắc của Simpson là gì?

    Quy tắc của Simpson dựa trên thực tế là với bất kỳ ba điểm nào, bạn có thể tìm thấy phương trình của một bậc hai thông qua các điểm đó.Ví dụ: giả sử bạn có điểm (3, 12), (1, 5) và (5, 9).Sau đó, bạn có thể giải quyết hệ phương trình này cho A, B và C, và có được phương trình của bậc hai.given any three points, you can find the equation of a quadratic through those points. For example, let's say you had points (3, 12), (1, 5), and (5, 9). Then you could solve this system of equations for a, b, and c, and get the equation of the quadratic.

    Quy tắc Simpson và chi tiết của nó là gì?

    Quy tắc của Simpson là một phương pháp số để xấp xỉ tích phân của một hàm giữa hai giới hạn, a và b.Nó dựa trên việc biết khu vực dưới parabola hoặc đường cong máy bay.Trong quy tắc này, n là một số chẵn và h = (b - a) / n. Các giá trị y là hàm được đánh giá ở các giá trị x cách đều nhau giữa a và b.a numerical method for approximating the integral of a function between two limits, a and b. It's based on knowing the area under a parabola, or a plane curve. In this rule, N is an even number and h = (b - a) / N. The y values are the function evaluated at equally spaced x values between a and b.