コード例 #1
0
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():
コード例 #2
0
def test_sinh():
    f = AD.sinh(x1)
    assert f.x == np.sinh(2)
    assert f.dx == np.cosh(2)
    f = AD.sinh(0.5)
    assert f == np.sinh(0.5)