Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

taylor uses Maxima's algorithm, which may be buggy. You may explore Sage's github issues to see if this has been already reported, and possibly report it, possibly after querying sage-support.

A workaround is to use the series method of symbolic expressions, which invisibly use Sage's power series rings. Your coefficient can be computed as :

# Note that you need to ask for an 8th order series to get a significant x4^7 term !
c7=g.series(x4==0, 8).truncate().coefficient(x4, 7)
CPU times: user 780 ms, sys: 0 ns, total: 780 ms
Wall time: 779 ms

which I won't print, because it's a sum of 228 (large) terms :

sage: c7.operator()
<function add_vararg at 0x7efd2aa99620>
sage: len(c7.operands())
228

Another workaround is to use other interpreter's relevant series. For example :

# Giac
sage: %time Gc7=g._giac_().series(x4, 0, 8)._sage_().coefficient(x4, 7)
CPU times: user 274 ms, sys: 0 ns, total: 274 ms
Wall time: 492 ms
# Mathematica (here, the gratis-but-not-free Wolfram Engine)
sage: %time Mc7=g._mathematica_().Series((x4, 0, 8)).Normal().sage().coefficient(x4, 7)
CPU times: user 72 ms, sys: 632 µs, total: 72.6 ms
Wall time: 98.4 ms

Sympy's series method seems to have a hard time with this expression : it does not return in reasonable time.

Formally checking the equality of these expressions seems hard : Sage doesn't return in reasonable time. Numerically checking them may be easier but do not give a proof...

HTH,

taylor uses Maxima's algorithm, which may be buggy. You may explore Sage's github issues to see if this has been already reported, and possibly report it, possibly after querying sage-support.

A workaround is to use the series method of symbolic expressions, which invisibly use Sage's power series rings. Your coefficient can be computed as :

# Note that you need to ask for an 8th order series to get a significant x4^7 term !
c7=g.series(x4==0, 8).truncate().coefficient(x4, 7)
CPU times: user 780 ms, sys: 0 ns, total: 780 ms
Wall time: 779 ms

which I won't print, because it's a sum of 228 (large) terms :

sage: c7.operator()
<function add_vararg at 0x7efd2aa99620>
sage: len(c7.operands())
228

Another workaround is to use other interpreter's relevant series. For example :

# Giac
sage: %time Gc7=g._giac_().series(x4, 0, 8)._sage_().coefficient(x4, 7)
CPU times: user 274 ms, sys: 0 ns, total: 274 ms
Wall time: 492 ms
# Mathematica (here, the gratis-but-not-free Wolfram Engine)
sage: %time Mc7=g._mathematica_().Series((x4, 0, 8)).Normal().sage().coefficient(x4, 7)
CPU times: user 72 ms, sys: 632 µs, total: 72.6 ms
Wall time: 98.4 ms

Sympy's series method seems to have a hard time with this expression : it does not return in reasonable time.

Formally checking the equality of these expressions seems hard : Sage doesn't return in reasonable time. Numerically checking them may be easier but do not give a proof...

EDIT : The expressions returned by Giac and Mathematica can be proved equal :

sage: %time (Gc7-Mc7).is_zero()
CPU times: user 25.6 s, sys: 129 ms, total: 25.7 s
Wall time: 23.9 s
True

Similarly, the quantities returned by Mathematica and Sage can be proved equal by using Mathematica :

sage: %time (c7-Mc7)._mathematica_().FullSimplify().sage().is_zero()
CPU times: user 16.1 s, sys: 12 ms, total: 16.1 s
Wall time: 49.1 s
True

However, %time (c7-Mc7).is_zero() does not return in a "reasonable" time (a few minutes).

HTH,

taylor uses Maxima's algorithm, which may be buggy. You may explore Sage's github issues to see if this has been already reported, and possibly report it, possibly after querying sage-support.

A workaround is to use the series method of symbolic expressions, which invisibly use Sage's power series rings. Your coefficient can be computed as :

# Note that you need to ask for an 8th order series to get a significant x4^7 term !
c7=g.series(x4==0, 8).truncate().coefficient(x4, 7)
CPU times: user 780 ms, sys: 0 ns, total: 780 ms
Wall time: 779 ms

which I won't print, because it's a sum of 228 (large) terms :

sage: c7.operator()
<function add_vararg at 0x7efd2aa99620>
sage: len(c7.operands())
228

Another workaround is to use other interpreter's relevant series. For example :

# Giac
sage: %time Gc7=g._giac_().series(x4, 0, 8)._sage_().coefficient(x4, 7)
CPU times: user 274 ms, sys: 0 ns, total: 274 ms
Wall time: 492 ms
# Mathematica (here, the gratis-but-not-free Wolfram Engine)
sage: %time Mc7=g._mathematica_().Series((x4, 0, 8)).Normal().sage().coefficient(x4, 7)
CPU times: user 72 ms, sys: 632 µs, total: 72.6 ms
Wall time: 98.4 ms

Sympy's series method seems to have a hard time with this expression : it does not return in reasonable time.

Formally checking the equality of these expressions seems hard : Sage doesn't return in reasonable time. Numerically checking them may be easier but do not give a proof...

EDIT : The expressions returned by Giac and Mathematica can be proved equal :

sage: %time (Gc7-Mc7).is_zero()
CPU times: user 25.6 s, sys: 129 ms, total: 25.7 s
Wall time: 23.9 s
True

Similarly, the quantities returned by Mathematica and Sage can be proved equal by using Mathematica :

sage: %time (c7-Mc7)._mathematica_().FullSimplify().sage().is_zero()
CPU times: user 16.1 s, sys: 12 ms, total: 16.1 s
Wall time: 49.1 s
True

However, %time (c7-Mc7).is_zero() does not return in a "reasonable" time (a few minutes).

EDIT 2 : The solution proposed by @Max Alekseyev gives an expression much easier to handle by Sage's default algorithms :

sage: R1.<p4>=PowerSeriesRing(SR, default_prec=8)
sage: %time Rg=eval(preparse("R1(%s)"%str(g).replace("x4", "p4"))) # See comments below
sage: %time Pc7=Rg[7]
CPU times: user 100 µs, sys: 0 ns, total: 100 µs
Wall time: 113 µs
sage: %time (Pc7-Mc7).full_simplify()
CPU times: user 8.21 s, sys: 16.1 ms, total: 8.23 s
Wall time: 7.23 s
0
sage: %time (Pc7-Gc7).full_simplify()
CPU times: user 18.5 s, sys: 63 ms, total: 18.5 s
Wall time: 16.9 s
0

HTH,

taylor uses Maxima's algorithm, which may be buggy. You may explore Sage's github issues to see if this has been already reported, and possibly report it, possibly after querying sage-support.

A workaround is to use the series method of symbolic expressions, which invisibly use Sage's power series rings. Your coefficient can be computed as :

# Note that you need to ask for an 8th order series to get a significant x4^7 term !
c7=g.series(x4==0, 8).truncate().coefficient(x4, 7)
CPU times: user 780 ms, sys: 0 ns, total: 780 ms
Wall time: 779 ms

which I won't print, because it's a sum of 228 (large) terms :

sage: c7.operator()
<function add_vararg at 0x7efd2aa99620>
sage: len(c7.operands())
228

Another workaround is to use other interpreter's relevant series. For example :

# Giac
sage: %time Gc7=g._giac_().series(x4, 0, 8)._sage_().coefficient(x4, 7)
CPU times: user 274 ms, sys: 0 ns, total: 274 ms
Wall time: 492 ms
# Mathematica (here, the gratis-but-not-free Wolfram Engine)
sage: %time Mc7=g._mathematica_().Series((x4, 0, 8)).Normal().sage().coefficient(x4, 7)
CPU times: user 72 ms, sys: 632 µs, total: 72.6 ms
Wall time: 98.4 ms

Sympy's series method seems to have a hard time with this expression : it does not return in reasonable time.

Formally checking the equality of these expressions seems hard : Sage doesn't return in reasonable time. Numerically checking them may be easier but do not give a proof...

EDIT : The expressions returned by Giac and Mathematica can be proved equal :

sage: %time (Gc7-Mc7).is_zero()
CPU times: user 25.6 s, sys: 129 ms, total: 25.7 s
Wall time: 23.9 s
True

Similarly, the quantities returned by Mathematica and Sage can be proved equal by using Mathematica :

sage: %time (c7-Mc7)._mathematica_().FullSimplify().sage().is_zero()
CPU times: user 16.1 s, sys: 12 ms, total: 16.1 s
Wall time: 49.1 s
True

However, %time (c7-Mc7).is_zero() does not return in a "reasonable" time (a few minutes).

EDIT 2 : The solution proposed by @Max Alekseyev gives an expression much easier to handle by Sage's default algorithms :

sage: R1.<p4>=PowerSeriesRing(SR, default_prec=8)
sage: %time Rg=eval(preparse("R1(%s)"%str(g).replace("x4", "p4"))) # See comments below
below Max's anwer
sage: %time Pc7=Rg[7]
CPU times: user 100 µs, sys: 0 ns, total: 100 µs
Wall time: 113 µs
sage: %time (Pc7-Mc7).full_simplify()
CPU times: user 8.21 s, sys: 16.1 ms, total: 8.23 s
Wall time: 7.23 s
0
sage: %time (Pc7-Gc7).full_simplify()
CPU times: user 18.5 s, sys: 63 ms, total: 18.5 s
Wall time: 16.9 s
0

HTH,

taylor uses Maxima's algorithm, which may be buggy. You may explore Sage's github issues to see if this has been already reported, and possibly report it, possibly after querying sage-support.

A workaround is to use the series method of symbolic expressions, which invisibly use Sage's power series rings. Your coefficient can be computed as :

# Note that you need to ask for an 8th order series to get a significant x4^7 term !
c7=g.series(x4==0, 8).truncate().coefficient(x4, 7)
CPU times: user 780 ms, sys: 0 ns, total: 780 ms
Wall time: 779 ms

which I won't print, because it's a sum of 228 (large) terms :

sage: c7.operator()
<function add_vararg at 0x7efd2aa99620>
sage: len(c7.operands())
228

Another workaround is to use other interpreter's relevant series. For example :

# Giac
sage: %time Gc7=g._giac_().series(x4, 0, 8)._sage_().coefficient(x4, 7)
CPU times: user 274 ms, sys: 0 ns, total: 274 ms
Wall time: 492 ms
# Mathematica (here, the gratis-but-not-free Wolfram Engine)
sage: %time Mc7=g._mathematica_().Series((x4, 0, 8)).Normal().sage().coefficient(x4, 7)
CPU times: user 72 ms, sys: 632 µs, total: 72.6 ms
Wall time: 98.4 ms

Sympy's series method seems to have a hard time with this expression : it does not return in reasonable time.

Formally checking the equality of these expressions seems hard : Sage doesn't return in reasonable time. Numerically checking them may be easier but do not give a proof...

EDIT : The expressions returned by Giac and Mathematica can be proved equal :

sage: %time (Gc7-Mc7).is_zero()
CPU times: user 25.6 s, sys: 129 ms, total: 25.7 s
Wall time: 23.9 s
True

Similarly, the quantities returned by Mathematica and Sage can be proved equal by using Mathematica :

sage: %time (c7-Mc7)._mathematica_().FullSimplify().sage().is_zero()
CPU times: user 16.1 s, sys: 12 ms, total: 16.1 s
Wall time: 49.1 s
True

However, %time (c7-Mc7).is_zero() does not return in a "reasonable" time (a few minutes).

EDIT 2 : The solution proposed by @Max Alekseyev gives an expression much easier to handle by Sage's default algorithms :

sage: R1.<p4>=PowerSeriesRing(SR, default_prec=8)
sage: %time Rg=eval(preparse("R1(%s)"%str(g).replace("x4", "p4"))) # See comments below Max's anwer
sage: %time Pc7=Rg[7]
CPU times: user 100 µs, sys: 0 ns, total: 100 µs
Wall time: 113 µs
sage: %time (Pc7-Mc7).full_simplify()
CPU times: user 8.21 s, sys: 16.1 ms, total: 8.23 s
Wall time: 7.23 s
0
sage: %time (Pc7-Gc7).full_simplify()
CPU times: user 18.5 s, sys: 63 ms, total: 18.5 s
Wall time: 16.9 s
0

EDIT 2 : The Maxima problem seems attributable to Sage's interface to Maxima, since the code runs without triggering an error in a standalone Maxima session. See this sage-support thread

HTH,