Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 9th, 2012  |  syntax: None  |  size: 1.19 KB  |  hits: 22  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. >>> from mm1 import*
  2. >>> a,b=0.251834,0.468515
  3. >>> a
  4. 0.251834
  5. >>> b
  6. 0.46851500000000001
  7. >>> h=(b-a)/5
  8. >>> x=zeros(6)
  9. >>> for k in range(6):
  10. ...     x[k]=a+k*h
  11. ...    
  12. >>> x
  13. array([ 0.251834 ,  0.2951702,  0.3385064,  0.3818426,  0.4251788,  0.468515 ])
  14. >>> m=zeros((6,6))
  15. >>> for i in range (6):
  16. ...     m[i,:]=x**i
  17. ...    
  18. >>> m
  19. array([[ 1.        ,  1.        ,  1.        ,  1.        ,  1.        ,  1.        ],
  20.        [ 0.251834  ,  0.2951702 ,  0.3385064 ,  0.3818426 ,  0.4251788 ,  0.468515  ],
  21.        [ 0.06342036,  0.08712545,  0.11458658,  0.14580377,  0.18077701,  0.21950631],
  22.        [ 0.0159714 ,  0.02571684,  0.03878829,  0.05567409,  0.07686255,  0.102842  ],
  23.        [ 0.00402214,  0.00759084,  0.01313008,  0.02125874,  0.03268033,  0.04818302],
  24.        [ 0.00101291,  0.00224059,  0.00444462,  0.00811749,  0.01389498,  0.02257447]])
  25. >>> B=zeros(6)
  26. >>> for i in range (6):
  27. ...     B[i]=(b**(i+1)-a**(i+1))/(i+1)
  28. ...    
  29. >>> B=B/h
  30. >>> B
  31. array([ 5.        ,  1.8008725 ,  0.66819113,  0.25475743,  0.09950828,  0.03969503])
  32. >>> import LinearAlgebra
  33. >>> A=LinearAlgebra.solve_linear_equations(m,B)
  34. >>> print A
  35. [ 0.32986111  1.30208333  0.86805556  0.86805556  1.30208333  0.32986111]