示例#1
0
def test_sin_pow_log():
    f = AD.sin(x1)**2 * AD.log(x1)
    assert tol > abs(f.x - 0.573109206726)
    assert tol > abs(f.dx - -0.111164610647518727)
示例#2
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():
示例#3
0
def test_sin():
    f = AD.sin(x1)
    assert f.x == np.sin(2)
    assert f.dx == np.cos(2)
    f = AD.sin(1)
    assert f == np.sin(1)