Hi Johannes!

On 16 Nov., 23:48, Johannes Huisman <johannes.huis...@gmail.com>
wrote:
> Does sage have a command for polynomial division by increasing powers? I
> could not find such a command. Of course, one may use power series
> division in order to compute the quotient, but it would be neat if one
> could avoid all that.

What exactly do you expect?

For example:

sage: P.<x> = QQ[]
sage: p = P.random_element()
sage: q = P.random_element()
sage: p
4/3*x^2 - x + 7
sage: q
2/7*x^2 - x

1.
Apparently you do not want that the quotient of p and q lives in the
fraction field, as it is currently the case:
sage: p/q
(4/3*x^2 - x + 7)/(2/7*x^2 - x)

2.
Do you need the "quotient with remainder"? Then you could do
sage: p.quo_rem(q)
(14/3, 11/3*x + 7)

3.
Or do you want that the quotient of p and q actually is a power
series? So, like this:
sage: p/q  # not implemented
-7*x^-1 - 1 - 34/21*x - 68/147*x^2 - 136/1029*x^3 - 272/7203*x^4 -
544/50421*x^5 - 1088/352947*x^6 - 2176/2470629*x^7 - 4352/17294403*x^8
- 8704/121060821*x^9 - 17408/847425747*x^10 - 34816/5931980229*x^11 -
69632/41523861603*x^12 - 139264/290667031221*x^13 -
278528/2034669218547*x^14 - 557056/14242684529829*x^15 -
1114112/99698791708803*x^16 - 2228224/697891541961621*x^17 -
4456448/4885240793731347*x^18 + O(x^19)

Possibility 3. requires that Frac(P) does not return a formal fraction
field (which is currently the case) but a power series ring. I am sure
that it would require much persuasion and a poll on sage-devel if one
wants such change.

Also note that the term order in P and Q differs (with the additional
complication that Q(p) does not have an attribute leading_coefficient,
but p does).
sage: p
4/3*x^2 - x + 7
sage: Q(p)
7 - x + 4/3*x^2


So, if what you want is 3., then currently you have to use the power
series ring manually, such as:
sage: Q = PowerSeriesRing(QQ,'x')
sage: Q(p)/q  # q is automatically coerced into Q
-7*x^-1 - 1 - 34/21*x - 68/147*x^2 - 136/1029*x^3 - 272/7203*x^4 -
544/50421*x^5 - 1088/352947*x^6 - 2176/2470629*x^7 - 4352/17294403*x^8
- 8704/121060821*x^9 - 17408/847425747*x^10 - 34816/5931980229*x^11 -
69632/41523861603*x^12 - 139264/290667031221*x^13 -
278528/2034669218547*x^14 - 557056/14242684529829*x^15 -
1114112/99698791708803*x^16 - 2228224/697891541961621*x^17 -
4456448/4885240793731347*x^18 + O(x^19)

Cheers,
Simon

-- 
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

Reply via email to