def test_cos_log10_rpow(): f = AD.cos(AD.log(2**x1, base=10)) assert tol > abs(f.x - 0.82417070595) assert tol > abs(f.dx - -0.17048576675265)
import numpy as np import matplotlib.pyplot as plt import matplotlib.animation as animation import modules.rollingball as RB import AutoDiff_CKMZ.modules.AutoDiff as AD from time import time function_list = [lambda x: AD.sin(x), lambda x: AD.exp(x), lambda x: x * AD.sin(x), lambda x: - AD.log(x), lambda x: AD.sinh(x), lambda x: AD.exp(AD.cos(x)), lambda x: 2 ** x, lambda x: 1 / AD.tan(x), lambda x: AD.sin(x) / x, lambda x: x ** 2] derivative_list = [lambda x: np.cos(x), lambda x: np.exp(x), lambda x: np.sin(x) + x * np.cos(x), lambda x: -1 / x, lambda x: np.cosh(x), lambda x: - np.exp(np.cos(x)) * np.sin(x), lambda x: 2 ** x * np.log(2), lambda x: - 1 / np.sin(x) ** 2, lambda x: (x * np.cos(x) - np.sin(x)) / x ** 2, lambda x: 2 * x] class function():
def test_cos(): f = AD.cos(x1) assert f.x == np.cos(2) assert f.dx == -np.sin(2) f = AD.cos(0.2) assert f == np.cos(0.2)