ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 09 Mar 2015 18:07:50 -0500Scale to simple integershttp://ask.sagemath.org/question/26098/scale-to-simple-integers/There are many situations where multiplying an object by a scalar doesn't change its relevant properties. For example a polynomial, when all you care about are its roots. Or a matrix, when you onyl care about the kernel. Or a vector or matrix when you are dealing with homogeneous coordinates. Often it would be nice if we could choose a factor which leads to a particularly simple representation of all the objects involved. If all numbers involved are rational, we'd scale to make them integers. Then we could compute their gcd and divide by that, to obtain small integers. We might even fix the sign in some way, e.g. require the leading term of a polynomial to be positive.
Things become interesting if we nest things. If we have a matrix over the fraction field over some stack of nested polynomials, with rationals as the field underlying all of this, then we would have to traverse several layers of data structures to find all the numbers and turn them into integers. And along the way we'd multiply with the denominators from the polynomial fraction field as well.
**Is there any functionaliy in Sage to provide any of this? Perhaps not all the way to what I described, but at least part of it?**
I know there is a method `monic` both for vectors and for polynomials, to obtain a representation which is normalized in a certain sense. But that's not the sense I'm after since it usually leads to fractions. I also know that there are classes to represent [projective spaces](http://sagemath.org/doc/reference/schemes/sage/schemes/projective/projective_space.html) over arbitrary rings, and a [method to clear denominators](http://sagemath.org/doc/reference/schemes/sage/schemes/projective/projective_point.html#sage.schemes.projective.projective_point.SchemeMorphism_point_projective_field.clear_denominators) for points of such a space. But since I can't operate on such projective points using standard linear algebra matrices, and since converting between both worlds is tedious, I don't use these classes at all even though I use homogeneous coordinates all the time.
I'm tempted to write a trac ticket to request functionality along these lines (and perhaps write some of it myself later on), but I first wanted to know whether I had overlooked something like this.Mon, 09 Mar 2015 11:50:35 -0500http://ask.sagemath.org/question/26098/scale-to-simple-integers/Comment by kcrisman for <p>There are many situations where multiplying an object by a scalar doesn't change its relevant properties. For example a polynomial, when all you care about are its roots. Or a matrix, when you onyl care about the kernel. Or a vector or matrix when you are dealing with homogeneous coordinates. Often it would be nice if we could choose a factor which leads to a particularly simple representation of all the objects involved. If all numbers involved are rational, we'd scale to make them integers. Then we could compute their gcd and divide by that, to obtain small integers. We might even fix the sign in some way, e.g. require the leading term of a polynomial to be positive.</p>
<p>Things become interesting if we nest things. If we have a matrix over the fraction field over some stack of nested polynomials, with rationals as the field underlying all of this, then we would have to traverse several layers of data structures to find all the numbers and turn them into integers. And along the way we'd multiply with the denominators from the polynomial fraction field as well.</p>
<p><strong>Is there any functionaliy in Sage to provide any of this? Perhaps not all the way to what I described, but at least part of it?</strong></p>
<p>I know there is a method <code>monic</code> both for vectors and for polynomials, to obtain a representation which is normalized in a certain sense. But that's not the sense I'm after since it usually leads to fractions. I also know that there are classes to represent <a href="http://sagemath.org/doc/reference/schemes/sage/schemes/projective/projective_space.html">projective spaces</a> over arbitrary rings, and a <a href="http://sagemath.org/doc/reference/schemes/sage/schemes/projective/projective_point.html#sage.schemes.projective.projective_point.SchemeMorphism_point_projective_field.clear_denominators">method to clear denominators</a> for points of such a space. But since I can't operate on such projective points using standard linear algebra matrices, and since converting between both worlds is tedious, I don't use these classes at all even though I use homogeneous coordinates all the time.</p>
<p>I'm tempted to write a trac ticket to request functionality along these lines (and perhaps write some of it myself later on), but I first wanted to know whether I had overlooked something like this.</p>
http://ask.sagemath.org/question/26098/scale-to-simple-integers/?comment=26117#post-id-26117"If all numbers involved are rational" - I've often done something like this 'by hand' but this is a constraint that will limit the direct usefulness, so perhaps there isn't something like this now. Maybe `make_all_coefficients_integers` could be a new method.Mon, 09 Mar 2015 18:07:50 -0500http://ask.sagemath.org/question/26098/scale-to-simple-integers/?comment=26117#post-id-26117