def test_hw06_prob01_ut10(self): print( '\n***** CS3430: S20: HW06: Problem 01: Unit Test 10 ************') s = '10x^0.5' fex = parser.parse_sum(s) print(fex) print(drv.drv_prod(fex)) gtf = lambda x: 5.0 * x**-0.5 f = tof.tof(drv.drv_prod(fex)) err = 0.0001 for i in range(1, 101): assert abs(gtf(i) - f(i)) <= err print('CS 3430: S20: HW06: Problem 01: Unit Test 10: pass')
def test_hw06_prob01_ut06(self): print( '\n***** CS3430: S20: HW06: Problem 01: Unit Test 06 ************') s = '10x^4' fex = parser.parse_sum(s) print(fex) print(drv.drv_prod(fex)) gtf = lambda x: 40.0 * x**3.0 f = tof.tof(drv.drv_prod(fex)) err = 0.0001 for i in range(-100, 101): assert abs(gtf(i) - f(i)) <= err print('CS 3430: S20: HW06: Problem 01: Unit Test 06: pass')
def test_hw06_prob01_ut07(self): print( '\n***** CS3430: S20: HW06: Problem 01: Unit Test 07 ************') s = '1x^-1' fex = parser.parse_sum(s) print(fex) print(drv.drv_prod(fex)) gtf = lambda x: -1.0 * x**(-2.0) f = tof.tof(drv.drv_prod(fex)) err = 0.0001 for i in range(-100, 0): assert abs(gtf(i) - f(i)) <= err for i in range(1, 101): assert abs(gtf(i) - f(i)) <= err print('CS 3430: S20: HW06: Problem 01: Unit Test 07: pass')