예제 #1
0
파일: art.py 프로젝트: Garyfallidis/trn
def automaticdiffertest():
    
    #from FuncDesigner import *

    a, b, c = fd.oovars('a', 'b', 'c')

    f1, f2 = fd.sin(a) + fd.cos(b) - fd.log2(c) + fd.sqrt(b), fd.sum(c) + c * fd.cosh(b) / fd.arctan(a) + c[0] * c[1] + c[-1] / (a * c.size)

    f3 = f1*f2 + 2*a + fd.sin(b) * (1+2*c.size + 3*f2.size)

    f = 2*a*b*c + f1*f2 + f3 + fd.dot(a+c, b+c)

    point = {a:1, b:2, c:[3, 4, 5]} # however, you'd better use numpy arrays instead of Python lists

    print(f(point))

    print(f.D(point))

    print(f.D(point, a))

    print(f.D(point, [b]))

    print(f.D(point, fixedVars = [a, c]))
예제 #2
0
def sincos_function(retI = False):
	""" no = 4: function including sine and cosine

	{ sin(x1)*cos(x1) - x2 = 0
	{ x1^2 - 6*x1 + 8 - x2 = 0
	true value
	(x1, x2) = (,), (,)

	"""
	y = [0.0 for i in range(2)]
	x[0], x[1] = fd.oovars('x0', 'x1')
	y[0] = fd.sin(x[0]) * fd.cos(x[0]) - x[1]
	y[1] = x[0] * x[0] - 6 * x[0] + 8 - x[1]
	if retI == True:
		return np.matrix([[interval(-6.1, 6.)], [interval(-6., 6.)]])
	return y
예제 #3
0
def sin_function(retI = False):
	""" no = 3: function including sin

	{ (pi/2)*sin(x1) - x2 = 0
	{ x1 - x2 = 0
	true value
	(x1, x2) = (0, 0), (1.57079633.., 1.57079633..), (-1.5709633.., -1.57079633..)

	"""
	y = [0.0 for i in range(2)]
	x[0], x[1] = fd.oovars('x0', 'x1')
	#y[0] = 1.57079633 * fd.sin(x[0]) - x[1]
	y[0] = (np.pi/2) * fd.sin(x[0]) - x[1]
	y[1] = x[0] - x[1]
	if retI == True:
		return np.matrix([[interval(-3.1, 3.)], [interval(-2., 2.)]])
	return y