Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The PowerSeries offers an implementation usable for this usage :

sage: R1.<t>=PowerSeriesRing(QQ)
sage: cos(t).integral(t)
t - 1/6*t^3 + 1/120*t^5 - 1/5040*t^7 + 1/362880*t^9 - 1/39916800*t^11 + 1/6227020800*t^13 - 1/1307674368000*t^15 + 1/355687428096000*t^17 - 1/121645100408832000*t^19 + O(t^21)

But note that:

sage: sin(t)
t - 1/6*t^3 + 1/120*t^5 - 1/5040*t^7 + 1/362880*t^9 - 1/39916800*t^11 + 1/6227020800*t^13 - 1/1307674368000*t^15 + 1/355687428096000*t^17 - 1/121645100408832000*t^19 + O(t^20)

The discussion of :

sage: cos(t).integral(t)-sin(t)
O(t^20)

Is left to the reader as an exercise... ;-)

An alternative avoiding this subtle point is the use of the taylor method/function :

sage: cos(x).taylor(x,0,20).integral(x)
1/51090942171709440000*x^21 - 1/121645100408832000*x^19 + 1/355687428096000*x^17 - 1/1307674368000*x^15 + 1/6227020800*x^13 - 1/39916800*x^11 + 1/362880*x^9 - 1/5040*x^7 + 1/120*x^5 - 1/6*x^3 + x
sage: sin(x).taylor(x,0,21)
1/51090942171709440000*x^21 - 1/121645100408832000*x^19 + 1/355687428096000*x^17 - 1/1307674368000*x^15 + 1/6227020800*x^13 - 1/39916800*x^11 + 1/362880*x^9 - 1/5040*x^7 + 1/120*x^5 - 1/6*x^3 + x

HTH,

The PowerSeries offers an implementation usable for this usage :

sage: R1.<t>=PowerSeriesRing(QQ)
sage: cos(t).integral(t)
t - 1/6*t^3 + 1/120*t^5 - 1/5040*t^7 + 1/362880*t^9 - 1/39916800*t^11 + 1/6227020800*t^13 - 1/1307674368000*t^15 + 1/355687428096000*t^17 - 1/121645100408832000*t^19 + O(t^21)

But note that:

sage: sin(t)
t - 1/6*t^3 + 1/120*t^5 - 1/5040*t^7 + 1/362880*t^9 - 1/39916800*t^11 + 1/6227020800*t^13 - 1/1307674368000*t^15 + 1/355687428096000*t^17 - 1/121645100408832000*t^19 + O(t^20)

The discussion of :

sage: cos(t).integral(t)-sin(t)
O(t^20)

Is left to the reader as an exercise... ;-)

An alternative avoiding this subtle point is the use of the taylor method/function :

sage: cos(x).taylor(x,0,20).integral(x)
1/51090942171709440000*x^21 - 1/121645100408832000*x^19 + 1/355687428096000*x^17 - 1/1307674368000*x^15 + 1/6227020800*x^13 - 1/39916800*x^11 + 1/362880*x^9 - 1/5040*x^7 + 1/120*x^5 - 1/6*x^3 + x
sage: sin(x).taylor(x,0,21)
1/51090942171709440000*x^21 - 1/121645100408832000*x^19 + 1/355687428096000*x^17 - 1/1307674368000*x^15 + 1/6227020800*x^13 - 1/39916800*x^11 + 1/362880*x^9 - 1/5040*x^7 + 1/120*x^5 - 1/6*x^3 + x

And :

sage: cos(x).taylor(x,0,20).integral(x)-sin(x).taylor(x,0,21)
0

HTH,