First time here? Check out the FAQ!

Ask Your Question
5

desolve initial condition involving e gives strange answer

asked 6 years ago

PW gravatar image

updated 2 years ago

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?

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
3

answered 6 years ago

tmonteil gravatar image

updated 6 years ago

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.

Preview: (hide)
link
2

answered 6 years ago

rburing gravatar image

updated 6 years ago

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.

Preview: (hide)
link

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 ( 6 years ago )

Nice ink bucket...

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 6 years ago )
1

I created trac ticket 26492 for this larger issue.

tmonteil gravatar imagetmonteil ( 6 years ago )

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: 6 years ago

Seen: 857 times

Last updated: Oct 15 '18