sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.34k stars 452 forks source link

Conversion of power series to symbolic ring #14693

Open eviatarbach opened 11 years ago

eviatarbach commented 11 years ago

Converting a power series to the symbolic ring doesn't work as expected:

sage: R.<t> = PowerSeriesRing(QQ)
sage: p = R([1,2,3])
sage: SR(p).variables()
()
sage: diff(SR(p))
0

Perhaps it could be converted to a polynomial first and then converted to the symbolic ring?

sage: SR(p.polynomial()).variables()
(t,)
sage: diff(SR(p.polynomial()))      
6*t + 2

Or maybe just raise an error (as per #13360)?

Component: symbolics

Issue created by migration from https://trac.sagemath.org/ticket/14693

eviatarbach commented 11 years ago

Description changed:

--- 
+++ 
@@ -17,3 +17,5 @@
 sage: diff(SR(p.polynomial()))      
 6*t + 2

+ +Or maybe just raise an error (as per #13360)?

eviatarbach commented 10 years ago
comment:4

15707 is related.

nbruin commented 10 years ago

Description changed:

--- 
+++ 
@@ -1,4 +1,4 @@
-Coercing a power series to the symbolic ring doesn't work as expected:
+Converting a power series to the symbolic ring doesn't work as expected:

sage: R. = PowerSeriesRing(QQ) @@ -9,7 +9,7 @@ 0


-Perhaps it could be converted to a polynomial first and then coerced to the symbolic ring?
+Perhaps it could be converted to a polynomial first and then converted to the symbolic ring?

sage: SR(p.polynomial()).variables()

nbruin commented 10 years ago
comment:5

The examples here refer to conversion; not coercion. That fact that power series over "basic" ring types such as rationals or integers don't convert into SR is, I think, a shortcoming that can be fixed. The main thing is to find how to represent the relevant "big-Oh" in SR. Maxima does have power series, so there is at least one back-end that provides some support: http://maxima.sourceforge.net/docs/manual/en/maxima_28.html#IDX1221. Linking up maxima's internal format with sage might need some work:

sage: F=maxima_calculus('taylor(sin(x),x,0,3)')
sage: F
x-x^3/6
sage: F.ecl()
<ECL: ((MRAT SIMP (((%SIN SIMP) $X) $X) (#:|sin(x)2136| #:X2137)
  (($X ((3 . 1)) 0 NIL #:X2137 . 2)) TRUNC)
 PS (#:X2137 . 2) ((3 . 1)) ((1 . 1) 1 . 1) ((3 . 1) -1 . 6))>
sage: F-x+x^3/6
+0
sage: (F-x+x^3/6).ecl()
<ECL: ((MRAT SIMP ($X) (#:X2145) (($X ((3 . 1)) 0 NIL #:X2145 . 1)) TRUNC) 0 . 1)>

(in maxima this prints with dots, so it knows it's a power series)

ea1d0bf8-c27a-4548-8cb7-de0b1d02441a commented 8 years ago
comment:8

seems fixed?