x = var('x')
y = function('y',x) # define y a function of x
DE = x*diff(y,x) - y - 3*x^4*cos((y/x))^2
print 'DE:';show(DE)

u = function('u',x)
DE = DE.subs({y:x*u,diff(y,x):diff(x*u,x)}) # substituting y/x as u
print 'DE substituted:';show(DE)

soln = desolve(DE,u,ics=[1,0])
soln = soln.subs({u:y/x}) # getting soln back in terms of y and x only
sol = solve(soln,y)
print 'Solution:';show(sol)

SageDays/Kreyszig-1.3-21 (last edited 2010-08-09 14:01:15 by PrashantAgrawal)