Processing math: 100%

First time here? Check out the FAQ!

Ask Your Question
1

quick latex question

asked 7 years ago

userX gravatar image

I am writing a worksheet for an ODE course and would like to display the following equation as y+y=1 OR as d2ydx2+y=1 However sage always reverts to partials. Is there an easy way to display these as ordinary differential equations?

thx

see sage cell link text

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
2

answered 7 years ago

slelievre gravatar image

updated 7 years ago

Possibly a duplicate of

A quick and dirty workaround would be to replace your original code:

x   = var('x')
y   = function('y')(x)
DEQ = diff(y,x) + y - 1 == 0
sol = desolve(DEQ, y)

show(DEQ)
print(latex(DEQ))

by something along the lines of:

sage: x = SR.var('x')
sage: y = function('y')(x)
sage: de = diff(y, x) + y - 1 == 0
sage: de
y(x) + diff(y(x), x) - 1 == 0

sage: y1 = function("y'")(x)
sage: de_pretty = de.substitute({diff(y, x): y1})
sage: de_pretty
y(x) + y'(x) - 1 == 0

and running show or view or latex on de_pretty rather than de.

One could write a function to prettify differential equations, by parsing the expression tree of the differential equation, and substituting derivatives by aptly named replacement functions.

One would then run desolve on the original differential equation, and use the prettified equation for showing, viewing, latexing.

Or maybe it would be easier to work the other way! Start by defining the pretty differential equation, and substitute an actual differential equation for solving.

Preview: (hide)
link

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

Seen: 899 times

Last updated: Mar 21 '18