I played around with sage and found some problems with desolve command. To solve ode diff(y(x),x)+a*y(x)+b*x+c we should first define variables and functions
x = var('x') a,b,c=var('a b c') y=function('y',x) eq=diff(y,x)+a*y+b*x+c but than unless it is obvious that the dependent variable is x and independent is y we should write such command desolve(eq,y,ivar=x) which is really annoying. And what is worse - we get a wrong answer -((a*x - 1)*b*e^(a*x)/a^2 + c*e^(a*x)/a - c)*e^(-a*x) but the right answer is -((a*x - 1)*b*e^(a*x)/a^2 + c*e^(a*x)/a - _C1)*e^(-a*x) where _C1 - arbitrary constant. Of course, if we don't use c as a variable in equation we will get a right answer, but another problem will rise. If we have a bunch of ODE and want their solutions to interact somehow, than we expect different arbitrary constant for each one. But sage uses one letter c in every solution, which causes problems. Actually the first problem is easy to solve. We can correct devel/sage-main/build/sage/calculus/desolvers.py First - make dvar variable which represent dependent variable optional by giving it default value None. < #64 def desolve(de, dvar, ics=None, ivar=None, show_method=False, contrib_ode=False): > def desolve(de, dvar=None, ics=None, ivar=None, show_method=False, contrib_ode=False): Second - add definition of dvar. dvar - is one of the functions differentiated. > after #319 if dvar is None dvars = extract_func_from_diff(de) if len(dvars) != 1: raise ValueError, "Unable to determine dependent variable, please specify." dvar = dvars.pop() Finally - change definition of ivar. ivar - is argument of dvar and it is also in parameter_set of FDerivativeOperator < #324-329 elif ivar is None: ivars = de.variables() ivars = [t for t in ivars if t is not dvar] if len(ivars) != 1: raise ValueError, "Unable to determine independent variable, please specify." ivar = ivars[0] > elif ivar is None: ivars = set(dvar.arguments()).intersection(extract_var_from_diff(de)) if len(ivars) != 1: raise ValueError, "Unable to determine independent variable, please specify." ivar = ivars.pop() where extract_*_from_diff(de) - are blackboxes which return set of functions or variables in FDerivativeOperators from de. They can be implemented by using type checking (instanceof) and operator function (I'm not sure is it possible to solve the problem using wild card and if it is any analog of Maple type function) After the changes it will be possible to call desolve(de) in most cases. At least it is clever to make simple correction <#325-326 ivars = de.variables() ivars = [t for t in ivars if t is not dvar] > ivars=dvar.arguments() After that it will be possible to call desolve(de, dvar) if dvar has only one argument. The second problem is harder and there are several solution. Anyway we need to implement new variable generator (like SR.symbol()) Then we can either change a little Maxima algorithm to be able to use variables generated by sage as integration constants or just rename all variables in equation, pass it to Maxima and then translate the result back using generated variables. -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org To unsubscribe from this group, send email to sage-devel+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.