You can use sage: v = vector([1,2,3]) sage: w = vector([1,1,-4]) sage: w.dot_product(v) -9 sage: w.norm() 3*sqrt(2)
etc. Just see http://www.sagemath.org/doc/tutorial/tour_linalg.html for more examples. On Wed, Mar 24, 2010 at 7:41 PM, <calcp...@aol.com> wrote: > OK, I use SAGE in my teaching a lot now. Its great for algebra, trig, > precalc, plots in 2D and 3D, limits, derivatives and integrals both analytic > and numerical. > > There's only one thing holding me back from using SAGE exclusively. I come > from the MATLAB/Octave world and miss the matrix paradigm. In Octave, every > variable represents some data as a matrix. This could be an actual matrix > (retangular nxm or square nxn), a 1xm row vector, an nx1 column vector or > even a 1x1 single scalar value. > > So, if you wouldn't mind excusing this poor noob, could some kind soul on > this form please help me translate the following into SAGE? I don't know if > I could use python lists or some other construct in SAGE. Is this where > importing scipy comes into play? > > SAMPLE INPUT Octave script file (vector1.m) playing with vector sums and > scalar dot products as a simple example: > #!/usr/bin/octave -q > diary vector1.txt > %vector1.m MrG 2010.0324 > %purpose: practice with script m-files and vector arith > > %initialize 2 vectors in R^3 > a=[1 2 3] > b=[-1 0 5] > > %vector sums > c=a+b > d=b-a > > %vector magnitudes > lenA = norm(a) > lenB = norm(b) > lenC = norm(c) > lenD = norm(d) > > %scalar dot product > e=a*b' > f=sum(a.*b) > g=dot(a,b) > theta1 = acos(e/lenA/lenB) > theta2 = theta1*180/pi > > SAMPLE OUTPUT Octave file (vector1.txt): > a = > > 1 2 3 > > b = > > -1 0 5 > > c = > > 0 2 8 > > d = > > -2 -2 2 > > lenA = 3.7417 > lenB = 5.0990 > lenC = 8.2462 > lenD = 3.4641 > e = 14 > f = 14 > g = 14 > theta1 = 0.74690 > theta2 = 42.794 > > TIA, > A. Jorge Garcia > http://calcpage.tripod.com > > Teacher & Professor > Applied Mathematics, Physics & Computer Science > Baldwin Senior High School & Nassau Community College > > -- > You received this message because you are subscribed to the Google Groups > "sage-edu" group. > To post to this group, send email to sage-...@googlegroups.com. > To unsubscribe from this group, send email to > sage-edu+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/sage-edu?hl=en. > > -- You received this message because you are subscribed to the Google Groups "sage-edu" group. To post to this group, send email to sage-...@googlegroups.com. To unsubscribe from this group, send email to sage-edu+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sage-edu?hl=en.