Professional Documents
Culture Documents
Method-----")
print("#NOTE: In the problem, the given are:")
print("-----A(1-5)= 1 in^2; A(6-11)= 2 in^2")
print("-----P(odd)= 0lb; P(even)= -1000lb")
print("-----E= 30psi; l= 30in")
print("----------------------------Input Value--------------------------------")
import numpy as np
import math
from numpy.linalg import inv
N = 24
print("Input Value")
a = float(input("Enter Value of A(1-5) in square inch: "))
b =float(input("Enter Value of A(6-11)in square inch: "))
guess = np.array([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
U = np.triu(A,1)
L = np.tril(A,-1)
D = np.diagflat(np.diag(A))
inv_of_D = inv(D)
minus_L_minus_U = -L-U
for i in range(N):
minus_L_minus_U_dot_x_plus_b = np.dot(minus_L_minus_U, guess) + b
guess = np.dot(inv_of_D, minus_L_minus_U_dot_x_plus_b)
print("line-",i +1, np.round(guess, 10))