You are right about the correct inner product definition for complex vectors. In your first example Sage seems not to be doing any conjugation.
RR is real numbers (to some precision) while QQ is rational numbers (which are exact). If you want complex numbers with real and imaginary parts in QQ that qould be anumber field QQ(i). But I would not expect Sage to automatically see how to take an inner product of vectors whose entries are in number fields (for which there is no easy answer since number fields in general have both real and complex embeddings). I doubt if that is what you mean, so that leaves you working with CC which will definitely be approximate (even with exact input). Now the fact that Sage does not (apparently) recognise complex vectors and use an appropriate definition for inner_product() is surely a bug. It should be easy to fix if the parent field is CC (or is coerciable to CC?). John On 06/01/2008, Fabio Tonti <[EMAIL PROTECTED]> wrote: > sage: u=vector([2+3*I,5+2*I,-3+I]) > sage: v=vector([1+2*I,-4+5*I,0+5*I]) > sage: p1=u*v;p1.expand() > 9*I - 39 > sage: p2=u.inner_product(v);p2.expand() > > 9*I - 39 > sage: p3=u.dot_product(v);p3.expand() > 9*I - 39 > sage: p4=u.inner_product(vector([i.conjugate() for i in v]));p4.expand() > 3 - 19*I > > Am I right in the assumption that for the inner product of two complex > vectors, the result should be the sum of the element wise multiplication of > the element of the first vector times the complex conjugate of the element > of the second vector? I had to do this by hand, as you can see for p4. I had > a look at Mathematica, and it seems like they don't do it either. So I might > be wrong. > > Another thing: > sage: parent(p1) > Symbolic Ring > sage: parent(u) > Vector space of dimension 3 over Symbolic Ring > is it meant to be over symbolic Ring? > > and one more: > sage: k=vector([complex(1,2),complex(3,4),complex(25,15)]) > Traceback (most recent call last): > ... > TypeError: unable to find a common ring for all elements > > seriously? why that? > sage: > u=vector(CC,[complex(1,2),complex(3,4),complex(25,15)]);u > (1.00000000000000 + 2.00000000000000*I, 3.00000000000000 + > 4.00000000000000*I > , 25.0000000000000 + 15.0000000000000*I) > And now I've got creepy precision stuff in there. And the inner product > still doesn't do what I'd like it to. > > Does a complex number from CC constructed by complex(<re>,<im>) have as > resulting real and imaginary part have elements from RR? What's the > difference between RR and QQ anyway? QQ is arbitrary precision, does RR use > machine precision maybe? > > Now maybe I've asked too many questions, but I've had no luck with the > reference manual so far (maybe I just don't get the explanations in > there...). > I know that today there's the big AMS meeting (good luck for that), so no > need to hurry in order to reply for anyone. And excuse my English, there > maybe some mistakes since I'm in a rush... > > Thanks a lot, Fabio > > > > -- John Cremona --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/ -~----------~----~----~----~------~----~------~--~---