def test_hw07_prob03_ut09(self): print('\n***** CS3430: S20: HW07: Problem 03: Unit Test 09 ************') def f(t): return 2000*math.log(140000.0/(140000.0 - 2100*t), math.e) - 9.8*t err = 0.34 tv = 11061.0 ## Approximating integral of f(x) on [a=8, b=30] with R[20,20]. av = rmb.rjl(f, 8, 30, 20, 20) assert abs(tv - av) <= err print('av = {}'.format(av)) print('tv = {}'.format(tv)) print('CS 3430: S20: HW07: Problem 03: Unit Test 09: pass')
def test_hw07_prob03_ut08(self): print('\n***** CS3430: S20: HW07: Problem 03: Unit Test 08 ************') def f(x): return math.e**(-(x**2.0)) err = 0.000001 tv = 0.7468241328124273 ## Approximating integral of f(x) on [a=0, b=1] with R[20,20]. av = rmb.rjl(f, 0, 1, 25, 25) assert abs(tv - av) <= err print('av = {}'.format(av)) print('tv = {}'.format(tv)) print('CS 3430: S20: HW07: Problem 03: Unit Test 08: pass')
def test_hw07_prob03_ut04(self): print('\n***** CS3430: S20: HW07: Problem 03: Unit Test 04 ************') def f(x): return math.e**(-(x**2.0)) err = 0.00001 tv = 0.7471804289095104 ## Approximating integral of f(x) on [a=0, b=1] with R[2,2]. av = rmb.rjl(f, 0, 1, 2, 2) assert abs(tv - av) <= err print('av = {}'.format(av)) print('tv = {}'.format(tv)) print('CS 3430: S20: HW07: Problem 03: Unit Test 04: pass')
def test_hw07_prob03_ut03(self): print('\n***** CS3430: S20: HW07: Problem 03: Unit Test 03 ************') def f(x): return math.e**(-(x**2.0)) err = 0.00001 tv = 0.74298409780038121575 ## Approximating integral of f(x) on [a=0, b=1] with R[3,1]. av = rmb.rjl(f, 0, 1, 3, 1) assert abs(tv - av) <= err print('av = {}'.format(av)) print('tv = {}'.format(tv)) print('CS 3430: S20: HW07: Problem 03: Unit Test 03: pass')
def test_hw07_prob03_ut02(self): print('\n***** CS3430: S20: HW07: Problem 03: Unit Test 02 ************') def f(x): return math.e**(-(x**2.0)) err = 0.00001 tv = 0.73137025182856307826 ## Approximating integral of f(x) on [a=0, b=1] with R[2,1]. av = rmb.rjl(f, 0, 1, 2, 1) assert abs(tv - av) <= err print('av = {}'.format(av)) print('tv = {}'.format(tv)) print('CS 3430: S20: HW07: Problem 03: Unit Test 02: pass')
def test_hw07_prob03_ut01(self): print('\n***** CS3430: S20: HW07: Problem 03: Unit Test 01 ************') def f(x): return math.e**(-(x**2.0)) err = 0.00001 tv = 0.683939720585721167 ## Approximating integral of f(x) on [a=0, b=1] with R[1,1]. av = rmb.rjl(f, 0, 1, 1, 1) assert abs(tv - av) <= err print('av = {}'.format(av)) print('tv = {}'.format(tv)) print('CS 3430: S20: HW07: Problem 03: Unit Test 01: pass')
def test_hw07_prob03_ut11(self): print('\n***** CS3430: S20: HW07: Problem 03: Unit Test 11 ************') ## f(x) def f(x): return 3.0*x**2.0 + 5.0*x - 10.0 ## anti-derivative of f(x) def antidf(x): return x**3.0 + 2.5*x**2.0 - 10.0*x err = 0.000001 tv = antidf(100.0) - antidf(51.0) ## Approximating integral of f(x) on [a=51, b=100] with R[15,14]. av = rmb.rjl(f, 51, 100, 15, 14) assert abs(tv - av) <= err print('av = {}'.format(av)) print('tv = {}'.format(tv)) print('CS 3430: S20: HW07: Problem 03: Unit Test 11: pass')
def test_hw07_prob03_ut10(self): print('\n***** CS3430: S20: HW07: Problem 03: Unit Test 10 ************') ## f(x) def f(x): return 3.0*x**2.0 + 5.0*x ## anti-derivative of f(x) def antidf(x): return x**3.0 + 2.5*x**2.0 err = 0.001 tv = antidf(10.0) - antidf(1.0) ## Approximating integral of f(x) on [a=1, b=10] with R[5,4]. av = rmb.rjl(f, 1, 10, 5, 4) #assert abs(tv - av) <= err print('av = {}'.format(av)) print('tv = {}'.format(tv)) print('CS 3430: S20: HW07: Problem 03: Unit Test 10: pass')