Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>> from mm1 import*
- >>> a,b=0.251834,0.468515
- >>> a
- 0.251834
- >>> b
- 0.46851500000000001
- >>> h=(b-a)/5
- >>> x=zeros(6)
- >>> for k in range(6):
- ... x[k]=a+k*h
- ...
- >>> x
- array([ 0.251834 , 0.2951702, 0.3385064, 0.3818426, 0.4251788, 0.468515 ])
- >>> m=zeros((6,6))
- >>> for i in range (6):
- ... m[i,:]=x**i
- ...
- >>> m
- array([[ 1. , 1. , 1. , 1. , 1. , 1. ],
- [ 0.251834 , 0.2951702 , 0.3385064 , 0.3818426 , 0.4251788 , 0.468515 ],
- [ 0.06342036, 0.08712545, 0.11458658, 0.14580377, 0.18077701, 0.21950631],
- [ 0.0159714 , 0.02571684, 0.03878829, 0.05567409, 0.07686255, 0.102842 ],
- [ 0.00402214, 0.00759084, 0.01313008, 0.02125874, 0.03268033, 0.04818302],
- [ 0.00101291, 0.00224059, 0.00444462, 0.00811749, 0.01389498, 0.02257447]])
- >>> B=zeros(6)
- >>> for i in range (6):
- ... B[i]=(b**(i+1)-a**(i+1))/(i+1)
- ...
- >>> B=B/h
- >>> B
- array([ 5. , 1.8008725 , 0.66819113, 0.25475743, 0.09950828, 0.03969503])
- >>> import LinearAlgebra
- >>> A=LinearAlgebra.solve_linear_equations(m,B)
- >>> print A
- [ 0.32986111 1.30208333 0.86805556 0.86805556 1.30208333 0.32986111]
Advertisement
Add Comment
Please, Sign In to add comment