# desolve initial condition involving e gives strange answer

I'm trying to do some basic differential equations in Sage. When I run the following:

var('t')
y = function('y')(t)
de1 = t^3*diff(y, t) + 4*t^2*y == e^(t^2)
desolve(de1, y, ics = [1,e])


The output is

1/2*(e^(t^2) + y(t))/t^4


My expectation is that there shouldn't by any y(t) term in the output. If I make a seemingly meaningless tweak to my initial conditions:

desolve(de1, y, ics = [1,e*1])


I get the expected output of

1/2*(e + e^(t^2))/t^4


If I change the initial conditions to [1, e/2], I again get the output I expect. I haven't been able to reproduce this issue with any other example. Maybe the issue just comes in converting Sage's version of e into Maxima? Does anyone know what is going on here?

edit retag close merge delete

Sort by ยป oldest newest most voted

Indeed, a raw e leads to a symbolic constant, while e*1 leads to a symbolic expression:

sage: type(e)
<type 'sage.symbolic.constants_c.E'>
sage: type(e*1)
<type 'sage.symbolic.expression.Expression'>


Thanks for reporting, this is now trac ticket 26490.

more

Looking at the source of desolve the difference is in how the variable tempic is set, namely the offending expression is (dvar==ics[1])._maxima_():

sage: y == e
e == y(t)


versus

sage: y == 1*e
y(t) == e


So it seems that Sage cannot be trusted to preserve the ordering LHS = RHS of an equation. This is definitely a bug which should be reported.

more

1

This is very weird, only the constant e reverses the equalities:

sage: var('x')
x
sage: x == sage.symbolic.constants.pi
x == pi
sage: x == sage.symbolic.constants.e
e == x
sage: x == sage.symbolic.constants.catalan
x == catalan
sage: x == sage.symbolic.constants.euler_gamma
x == euler_gamma
sage: x == sage.symbolic.constants.I
x == I


Looking at the source code, e is handled by the dedicated src/sage/symbolic/constants_c.pyx.

( 2018-10-15 11:33:47 +0200 )edit

Nice ink bucket...

( 2018-10-15 13:57:01 +0200 )edit
1

I created trac ticket 26492 for this larger issue.

( 2018-10-15 15:14:03 +0200 )edit