Exemple #1
0
def error_lg(Nq_liste,a,b):
    #error = np.zeros(Nq)
    error = np.zeros(len(Nq))
    F = fredholm_rhs(xc,F_eval)
    for i in Nq_liste:
        xq,w = np.polynomial.legendre.leggauss(i)
        t = 0.5*(xq + 1)*(b - a) + a
        A_rho = np.matmul(fredholm_lhs(xc,xs,t,w/2),rho(omega,gamma,xs,N_eval))
        ny_liste = np.zeros(N_eval)
        for j in range(N_eval):
            ny_liste[j] = F[j] - A_rho[j]
        error[i-1] = np.linalg.norm(ny_liste,np.inf)
    return error
Exemple #2
0
def error(Nq_liste, a, b):
    # error = np.zeros(Nq)
    error = np.zeros(len(Nq_liste))
    F = fredholm_rhs(xc, F_eval)
    for i in range(len(Nq_liste)):
        xq, w = Newton_Cotes(a, b, Nq_liste[i])
        A_rho = np.matmul(fredholm_lhs(xc, xs, xq, w),
                          rho(omega, gamma, xs, N_eval))
        ny_liste = np.zeros(N_eval)
        for j in range(N_eval):
            ny_liste[j] = F[j] - A_rho[j]
        error[i] = np.linalg.norm(ny_liste, np.inf)
    return error
Exemple #3
0
def rho_error(Ns, Nc, F, d):
    error = np.zeros(len(Ns))
    for i in range(len(Ns)):
        xs = chebyshev(a, b, Ns[i])
        xc = chebyshev(a, b, Nc[i])
        xq_old, w = np.polynomial.legendre.leggauss(Ns[i]**2)
        xq = 0.5 * (xq_old + 1) * (b - a) + a
        A = fredholm_lhs(xc, xs, xq, w / 2)

        F_eval = F(xc, d)
        B = fredholm_rhs(xc, F_eval)

        losning = np.linalg.solve(A, B)
        ny_liste = np.zeros(Ns[i])
        for j in range(Ns[i]):
            ny_liste[j] = rho(omega, gamma, xs, Ns[i])[j] - losning[j]
        error[i] = np.linalg.norm(ny_liste, np.inf)
    return error
Exemple #4
0
    for i in range(len(xc)):
        F_error[i] = F_eval[i] * (1 +
                                  np.random.uniform(-delta, delta, N_eval)[i])
    return F_eval, F_error


F_eval1, F_error1 = finn_b(0.025)
F_eval2, F_error2 = finn_b(0.25)
F_eval3, F_error3 = finn_b(2.5)

analytisk_rho = rho(omega, gamma, xs, N_eval)
xq_old, w = np.polynomial.legendre.leggauss(N_eval**2)
xq = 0.5 * (xq_old + 1) * (b - a) + a
A = fredholm_lhs(xc, xs, xq, w / 2)
B = fredholm_rhs(xc, F_eval1)
losning = np.linalg.solve(A, B)

# analytisk rho uten perturbering
rho1 = np.linalg.solve(A, F_eval1)
rho2 = np.linalg.solve(A, F_eval2)
rho3 = np.linalg.solve(A, F_eval3)

# analytisk rho med perturbering
rho1_error = np.linalg.solve(A, F_error1)
rho2_error = np.linalg.solve(A, F_error2)
rho3_error = np.linalg.solve(A, F_error3)

plt.figure('F og F med feil')
plt.plot(xc, F_eval1, label='F ved d = 0.025')
plt.plot(xc, F_error1, label='F med feil ved d = 0.025')