Too tricky, but maybe this helps: sage: c,x = var("c,x") sage: y = function('y',x) sage: soln = desolve(diff(y,x)+sin(x)*y^6==0,y); soln 1/(5*y(x)^5) == c - cos(x) sage: soln.subs(x = pi) 1/(5*y(pi)^5) == c + 1 sage: ssoln = soln.__repr__(); ssoln '1/(5*y(x)^5) == c - cos(x)' sage: ssoln = ssoln.replace("y(x)","9"); ssoln '1/(5*9^5) == c - cos(x)' sage: ssoln = ssoln.replace("x","pi"); ssoln '1/(5*9^5) == c - cos(pi)' sage: nsoln = eval(ssoln) sage: nsoln c + 1 == 0
Hopefully there are better ways. Using SymPy: sage: x = Symbol('x') sage: C1 = Symbol('C1') sage: y = Function('y') sage: soln = dsolve(Derivative(y(x),x)+sin(x)*y(x)^6,y(x)); soln (C1 - 5*cos(x))**(-1/5) sage: ypi = soln.subs(x,pi); ypi (5 + C1)**(-1/5) But now sage: solve(ypi - 9, C1) yields an error which I don't understand. On Tue, Apr 28, 2009 at 1:59 PM, ma...@mendelu.cz <ma...@mendelu.cz> wrote: > > Hello, I just want to test, if I can do with my students in computer > lab what they usualy do on the paper > > 1. find general solution > 2. substitute from initail conditions > 3. find c > 4. use this c in general solution > > I agree that this may be strange to do this in the case, we have a > command for solving IVP. > I just wanted to know, if it is possible to substitute some value for y > (x), if y(x) is declared as a function. > > Thanks. Robert > > On 28 Dub, 16:45, David Joyner <wdjoy...@gmail.com> wrote: >> I don't know if you are asking about how to use ICs in >> desolve or if you are asking about how to do substitutions. >> Anyway, I get this: >> >> sage: y=function('y',x) >> sage: desolve(diff(y,x)+sin(x)*y^6==0,y) >> 1/(5*y(x)^5) == c - cos(x) >> sage: desolve(diff(y,x)+sin(x)*y^6==0,y,[pi,9]) >> 1/(5*y(x)^5) == (-295245*cos(x) - 295244)/295245 >> >> Does that help? >> >> On Tue, Apr 28, 2009 at 10:36 AM, ma...@mendelu.cz <ma...@mendelu.cz> wrote: >> >> > Dear memebers of SAGE-support >> >> > I wonder if it is possible to substitute initial conditions into an >> > equation produced by desolve. I tried something like >> >> > y=function('y',x) >> > desolve(diff(y,x)+sin(x)*y^6==0,y) >> > sol({x:pi,y:9}) >> >> > and got >> >> > 1/(5*y(pi)^5) == c + 1 >> >> > but I would like to see >> >> > 1/(5*9^5) == c + 1 >> >> > many thanks >> >> > Robert > > > --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---