On Sep 27, 5:53 pm, luisfe <lftab...@yahoo.es> wrote: > On Sep 27, 3:34 pm, Johannes <dajo.m...@web.de> wrote: > > > Hi list, > > is there a way to get a sum of fraction to a common devisor? or even > > better into a product of a fraction like \frac{1}{something here} and a > > sum of integers? > > and my next step would be this, i dont have a single value, which i want > > to get as the above produkt, but i've got a vector for wich i want to > > write as produkt of a skalar times an integervektor. > > how can i do this? > > > greatz Johannes > > Hi, > > Is this what you want? > > sage: v = vector([2/3,1/4,0]) > sage: common_denom = denominator(v) > sage: common_denom > 12 > sage: vector_of_nums = v * common_denom > sage: vector_of_nums > (8, 3, 0) > > note that here, internally, vector of nums is a vector with rational > entries. If you want a vector of sage integers you could do > > sage: vector_of_nums = vector_of_nums.change_ring(ZZ) > > And you will have a vector with Integer entries, if you need this last > command or not depends on what do you want to do with your vector. > > Luis
Or to get it further simplified: sage: v = vector([2/3, 4/3, 4]) sage: c = reduce(QQ.content, v) sage: c 2/3 sage: v/c (1, 2, 6) -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org