def test_hw07_prob01_ut06(self):
     print('\n***** CS3430: S20: HW07: Problem 01: Unit Test 06 ************')
     f = lambda x: math.sin(x)
     av = cdd.drv1_ord4(f, 0.8, 0.000001)
     tv = math.cos(0.8)
     err = 0.00000001
     assert isinstance(av, np.longdouble)
     assert abs(av - tv) <= err
     print('av={}'.format(av))
     print('tv={}'.format(tv))
     print('CS 3430: S20: HW07: Problem 01: Unit Test 06: pass')
 def test_hw07_prob01_ut09(self):
     print('\n***** CS3430: S20: HW07: Problem 01: Unit Test 09 ************')
     f = lambda x: math.e**(-2.0*x)
     ## df is the ground truth derivative function
     df = lambda x: -2.0*(math.e**(-2.0*x))
     x = 3.0
     h = 0.001
     av = cdd.drv1_ord4(f, x, h)
     tv = df(x)
     err = 0.00000001
     assert isinstance(av, np.longdouble)
     assert abs(av - tv) <= err
     print('av={}'.format(av))
     print('tv={}'.format(tv))
     print('CS 3430: S20: HW07: Problem 01: Unit Test 09: pass')
 def test_hw07_prob01_ut15(self):
     print('\n***** CS3430: S20: HW07: Problem 01: Unit Test 15 ************')
     f = lambda x: 4*(x**5.0) - 3.0*(x**-3.0) + 10.0*(x**2) - 5.0*x
     ## rename parser if necessary.
     df = tof.tof(drv.drv(parser.parse_sum('4x^5 - 3x^-3 + 10x^2 - 5x^1')))
     x = 0.5
     h = 0.0001
     av = cdd.drv1_ord4(f, x, h)
     tv = df(x)
     err = 0.0000001
     assert abs(tv - 150.25) <= err
     assert isinstance(av, np.longdouble)
     assert abs(av - tv) <= err
     print('av={}'.format(av))
     print('tv={}'.format(tv))
     print('CS 3430: S20: HW07: Problem 01: Unit Test 15: pass')
 def test_hw07_prob01_ut14(self):
     print('\n***** CS3430: S20: HW07: Problem 01: Unit Test 14 ************')
     f = lambda x: 4*(x**3.0) - 3.0*(x**2.0) + 5.0*x - 10.0
     ## rename parser if necessary.        
     df = tof.tof(drv.drv(parser.parse_sum('4x^3 - 3x^2 + 5x^1 - 10x^0')))
     x = 1.0
     h = 0.0001
     av = cdd.drv1_ord4(f, x, h)
     tv = df(x)
     err = 0.0000001
     assert abs(tv - 11.0) <= err
     assert isinstance(av, np.longdouble)
     assert abs(av - tv) <= err
     print('av={}'.format(av))
     print('tv={}'.format(tv))
     print('CS 3430: S20: HW07: Problem 01: Unit Test 14: pass')
 def test_hw07_prob01_ut12(self):
     print('\n***** CS3430: S20: HW07: Problem 01: Unit Test 12 ************')
     f = lambda x: 2*(x**3.0) + 3.0*x
     ## rename parser if necessary.        
     df = tof.tof(drv.drv(parser.parse_sum('2x^3 + 3x^1')))
     x = 1.0
     h = 0.0001
     av = cdd.drv1_ord4(f, x, h)
     tv = df(x)
     err = 0.00000001
     assert abs(tv - 9.0) <= err
     assert isinstance(av, np.longdouble)
     assert abs(av - tv) <= err
     print('av={}'.format(av))
     print('tv={}'.format(tv))
     print('CS 3430: S20: HW07: Problem 01: Unit Test 12: pass')
 def test_hw07_prob01_ut10(self):
     print('\n***** CS3430: S20: HW07: Problem 01: Unit Test 10 ************')
     ## f(x) = ln(x)
     f = lambda x: math.log(x, math.e)
     ## df is the ground truth derivative function
     df = lambda x: 1.0/x
     x = 0.25
     h = 0.0001
     av = cdd.drv1_ord4(f, x, h)
     tv = df(x)
     err = 0.00000001
     assert isinstance(av, np.longdouble)
     assert abs(av - tv) <= err
     print('av={}'.format(av))
     print('tv={}'.format(tv))
     print('CS 3430: S20: HW07: Problem 01: Unit Test 10: pass')