Ask Your Question
5

desolve initial condition involving e gives strange answer

asked 2018-10-14 16:20:07 -0600

PW gravatar image

updated 2018-10-15 08:28:39 -0600

tmonteil gravatar image

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 flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
3

answered 2018-10-15 04:27:23 -0600

tmonteil gravatar image

updated 2018-10-15 04:28:10 -0600

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.

edit flag offensive delete link more
2

answered 2018-10-15 04:16:56 -0600

updated 2018-10-15 04:37:33 -0600

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.

edit flag offensive delete link more

Comments

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.

tmonteil gravatar imagetmonteil ( 2018-10-15 04:33:47 -0600 )edit

Nice ink bucket...

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2018-10-15 06:57:01 -0600 )edit
1

I created trac ticket 26492 for this larger issue.

tmonteil gravatar imagetmonteil ( 2018-10-15 08:14:03 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2018-10-14 16:20:07 -0600

Seen: 86 times

Last updated: Oct 15