Exemplo n.º 1
0
def test_functional_differential_geometry_ch3():
    # From "Functional Differential Geometry" as of 2011
    # by Sussman and Wisdom.
    x0, y0, r0, theta0 = symbols('x0, y0, r0, theta0', real=True)
    x, y, r, theta, t = symbols('x, y, r, theta, t', real=True)
    f = Function('f')
    b1 = Function('b1')
    b2 = Function('b2')
    p_r = R2_r.point([x0, y0])

    s_field = ScalarField(R2_r, [x, y], f(x,y))
    v_field = VectorField(R2_r, [x, y], [b1(x), b2(y)])
    assert v_field(s_field)(p_r) ==  b1(x0)*Derivative(f(x0, y0), x0) + b2(y0)*Derivative(f(x0, y0), y0)

    assert R2.d_dx(R2.r**2)(p_r) == 2*x0
    v = R2.d_dx + 2*R2.d_dy
    s = R2.r**2 + 3*R2.x
    assert v(s)(p_r) == 2*x0 + 4*y0 + 3

    circ = -R2.y*R2.d_dx + R2.x*R2.d_dy
    series = intcurve_series(circ, t, R2_r.point([1, 0]))
    series_x, series_y = zip(*series)
    assert all([term == cos(t).taylor_term(i,t) for i, term in enumerate(series_x)])
    assert all([term == sin(t).taylor_term(i,t) for i, term in enumerate(series_y)])