예제 #1
0
def next_q_r(k, a, b, moments, q_i, q_r):
    """Helper method for modify_divide_r"""
    term1 = alpha(k) * a * q_r[k]
    term2 = -alpha(k) * b * q_i[k]
    term3 = -beta(k) * q_r[k - 1]
    term4 = alpha(k) * moments[k]
    return term1 + term2 + term3 + term4
예제 #2
0
def modify_divide_r2(k_max, moments, a, b, first_term, second_term):
    """
    Create the modified moments for k(x,y) * Pn / ((x - a)^2 + b^2) from
    the modified moments for k(x, y) * Pn
    The first two terms must be computed explicitly from the
    expression for the kernel, k(x, y).
    See (iii) on page 35 of Diligenti, Monegato 1997
    I assume use of the Legendre Polynomials
    """
    new_list = []

    # The first two terms are computed explicitly
    new_list.append(first_term)
    new_list.append(second_term)

    # Compute m_2 explicitly
    term1 = alpha(1) * (moments[0] + 2 * a * new_list[1])
    term2 = -(alpha(1) * (a ** 2 + b ** 2) + beta(1)) * new_list[0]
    m_2 = term1 + term2
    new_list.append(m_2)

    # Compute q_r and q_i (the real and imaginary parts of the helper
    # integral)
    q_r = initial_q_r(a, new_list)
    q_i = initial_q_i(b, new_list)
    for k in range(1, k_max):
        q_r.append(next_q_r(k, a, b, moments, q_i, q_r))
        q_i.append(next_q_i(k, a, b, q_i, q_r))

    # Compute m_j through the relation to q_j^I
    for k in range(3, k_max + 1):
        new_list.append(q_i[k] / b)

    return new_list
예제 #3
0
def next_q_r(k, a, b, moments, q_i, q_r):
    """Helper method for modify_divide_r"""
    term1 = alpha(k) * a * q_r[k]
    term2 = -alpha(k) * b * q_i[k]
    term3 = -beta(k) * q_r[k - 1]
    term4 = alpha(k) * moments[k]
    return term1 + term2 + term3 + term4
예제 #4
0
def modify_divide_r2(k_max, moments, a, b, first_term, second_term):
    """
    Create the modified moments for k(x,y) * Pn / ((x - a)^2 + b^2) from
    the modified moments for k(x, y) * Pn
    The first two terms must be computed explicitly from the
    expression for the kernel, k(x, y).
    See (iii) on page 35 of Diligenti, Monegato 1997
    I assume use of the Legendre Polynomials
    """
    new_list = []

    # The first two terms are computed explicitly
    new_list.append(first_term)
    new_list.append(second_term)

    # Compute m_2 explicitly
    term1 = alpha(1) * (moments[0] + 2 * a * new_list[1])
    term2 = -(alpha(1) * (a**2 + b**2) + beta(1)) * new_list[0]
    m_2 = term1 + term2
    new_list.append(m_2)

    # Compute q_r and q_i (the real and imaginary parts of the helper
    # integral)
    q_r = initial_q_r(a, new_list)
    q_i = initial_q_i(b, new_list)
    for k in range(1, k_max):
        q_r.append(next_q_r(k, a, b, moments, q_i, q_r))
        q_i.append(next_q_i(k, a, b, q_i, q_r))

    # Compute m_j through the relation to q_j^I
    for k in range(3, k_max + 1):
        new_list.append(q_i[k] / b)

    return new_list
예제 #5
0
def initial_q_r(a, new_list):
    """Helper method for modify_divide_r"""
    # Compute q_0^R and q_1^R explicitly
    q_r = []
    q_r.append(1 / alpha(0) * new_list[1] - a * new_list[0])
    q_r.append(1 / alpha(1) * new_list[2] - a * new_list[1] +
               beta(1) / alpha(1) * new_list[0])
    return q_r
예제 #6
0
def initial_q_r(a, new_list):
    """Helper method for modify_divide_r"""
    # Compute q_0^R and q_1^R explicitly
    q_r = []
    q_r.append(1 / alpha(0) * new_list[1] - a * new_list[0])
    q_r.append(1 / alpha(1) * new_list[2] -
               a * new_list[1] +
               beta(1) / alpha(1) * new_list[0])
    return q_r
예제 #7
0
def B(k, ay, by):
    term1 = (beta(k) * alpha(k - 2) - alpha(k)) / (alpha(k) * alpha(k - 2))
    term2 = -(2 * k - 1) / (-1.0) * \
            (((beta(k) * alpha(k - 2) + beta(k - 1) * alpha(k)) /\
                    (alpha(k - 2) * alpha(k - 1) * alpha(k))) + \
                (ay ** 2 + by ** 2))
    return term1 + term2
예제 #8
0
def B(k, ay, by):
    term1 = (beta(k) * alpha(k - 2) - alpha(k)) / (alpha(k) * alpha(k - 2))
    term2 = -(2 * k - 1) / (-1.0) * \
            (((beta(k) * alpha(k - 2) + beta(k - 1) * alpha(k)) /\
                    (alpha(k - 2) * alpha(k - 1) * alpha(k))) + \
                (ay ** 2 + by ** 2))
    return term1 + term2
예제 #9
0
def modify_times_x_minus_a(k_max, moments, a):
    """
    Create the modified moments for k(x,y) * (x - a) * Pn from the
    modified moments for k(x, y) * Pn
    See (i) on page 34 of Diligenti, Monegato 1997
    I assume use of the Legendre Polynomials
    """
    new_list = []
    new_list.append(moments[1] - a * moments[0])
    for k in range(1, k_max + 1):
        term1 = (1.0 / alpha(k)) * moments[k + 1]
        term2 = -a * moments[k]
        term3 = beta(k) / alpha(k) * moments[k - 1]
        new_moment = term1 + term2 + term3
        new_list.append(new_moment)
    return new_list
예제 #10
0
def modify_times_x_minus_a(k_max, moments, a):
    """
    Create the modified moments for k(x,y) * (x - a) * Pn from the
    modified moments for k(x, y) * Pn
    See (i) on page 34 of Diligenti, Monegato 1997
    I assume use of the Legendre Polynomials
    """
    new_list = []
    new_list.append(moments[1] - a * moments[0])
    for k in range(1, k_max + 1):
        term1 = (1.0 / alpha(k)) * moments[k + 1]
        term2 = -a * moments[k]
        term3 = beta(k) / alpha(k) * moments[k - 1]
        new_moment = term1 + term2 + term3
        new_list.append(new_moment)
    return new_list
예제 #11
0
def modify_divide_x_minus_a(k_max, moments, a, first_term):
    """
    Create the modified moments for k(x,y) * Pn / (x - a) from the
    modified moments for k(x,y) * Pn
    The first term depends on k(x,y) and thus, the correct value
    must be provided
    See (ii) on pages 34 and 35 of Diligenti, Monegato 1997
    I assume use of the Legendre polynomials
    """
    new_list = []

    new_list.append(first_term)
    new_list.append(a * new_list[0] + moments[0])
    for k in range(1, k_max):
        term1 = alpha(k) * a * new_list[k]
        term2 = -beta(k) * new_list[k - 1]
        term3 = alpha(k) * moments[k]
        new_moment = term1 + term2 + term3
        new_list.append(new_moment)
    return new_list
예제 #12
0
def modify_divide_x_minus_a(k_max, moments, a, first_term):
    """
    Create the modified moments for k(x,y) * Pn / (x - a) from the
    modified moments for k(x,y) * Pn
    The first term depends on k(x,y) and thus, the correct value
    must be provided
    See (ii) on pages 34 and 35 of Diligenti, Monegato 1997
    I assume use of the Legendre polynomials
    """
    new_list = []

    new_list.append(first_term)
    new_list.append(a * new_list[0] + moments[0])
    for k in range(1, k_max):
        term1 = alpha(k) * a * new_list[k]
        term2 = -beta(k) * new_list[k - 1]
        term3 = alpha(k) * moments[k]
        new_moment = term1 + term2 + term3
        new_list.append(new_moment)
    return new_list
예제 #13
0
def A(k, ay, by):
    return ((2 * k - 1) / (-1.0)) * (2 * ay / alpha(k - 1)) - ay
예제 #14
0
def D(k, ay, by):
    return - ((2 * k - 1) / (-1.0) *\
            ((beta(k - 1) * beta(k - 2)) / (alpha(k - 2) * alpha(k - 1)))) - \
            (beta(k - 2) / alpha(k - 2))
예제 #15
0
def E(k, ay, by):
    numer = (-1.0) * alpha(k - 1) * alpha(k)
    denom = (2 * k - 1) - (-1.0) * alpha(k - 1)
    return numer / denom
예제 #16
0
def next_q_i(k, a, b, q_i, q_r):
    """Helper method for modify_divide_r"""
    term1 = alpha(k) * a * q_i[k]
    term2 = alpha(k) * b * q_r[k]
    term3 = -beta(k) * q_i[k - 1]
    return term1 + term2 + term3
예제 #17
0
def C(k, ay, by):
    return ay + (2 * k - 1) / (-1.0) * (2 * ay / alpha(k - 1) * beta(k - 1))
예제 #18
0
def E(k, ay, by):
    numer = (-1.0) * alpha(k - 1) * alpha(k)
    denom = (2 * k - 1) - (-1.0) * alpha(k - 1)
    return numer / denom
예제 #19
0
def D(k, ay, by):
    return - ((2 * k - 1) / (-1.0) *\
            ((beta(k - 1) * beta(k - 2)) / (alpha(k - 2) * alpha(k - 1)))) - \
            (beta(k - 2) / alpha(k - 2))
예제 #20
0
def C(k, ay, by):
    return ay + (2 * k - 1) / (-1.0) * (2 * ay / alpha(k - 1) * beta(k - 1))
예제 #21
0
def next_q_i(k, a, b, q_i, q_r):
    """Helper method for modify_divide_r"""
    term1 = alpha(k) * a * q_i[k]
    term2 = alpha(k) * b * q_r[k]
    term3 = -beta(k) * q_i[k - 1]
    return term1 + term2 + term3
예제 #22
0
def A(k, ay, by):
    return ((2 * k - 1) / (-1.0)) * (2 * ay / alpha(k - 1)) - ay