# Ticket #6479: trac_6479_marik.patch

File trac_6479_marik.patch, 2.5 KB (added by robert.marik, 12 years ago)
• ## sage/calculus/desolvers.py

```# HG changeset patch
# User Robert Marik <marik@mendelu.cz>
# Date 1254847077 -7200
# Node ID d932f19a662c01d78d51ab308eeef89368600fac
# Parent  4b6ae67a0a0060ea0ece83505413803a260f7857
Fixes trac #6479, desolve_laplace is kept intact

diff -r 4b6ae67a0a00 -r d932f19a662c sage/calculus/desolvers.py```
 a sage: desolve(de, y) k1*e^x + k2*e^(-x) - x sage: f = desolve(de, y, [10,2,1]); f 1/2*(y(10) + 12)*e^(x - 10) + 1/2*(e^10*y(10) + 8*e^10)*e^(-x) - x -x + 5*e^(-x + 10) + 7*e^(x - 10) sage: f(x=10).expand().simplify() y(10) 2 sage: diff(f,x)(x=10).expand().simplify() 1 sage: de = diff(y,x,2) + y == 0 sage: desolve(de, y) k1*sin(x) + k2*cos(x) sage: desolve(de, y, [0,1,pi/2,4]) 4*sin(x) + cos(x) AUTHOR: David Joyner (1-2006) Robert Bradshaw (10-2008) """ ics = to_eqns([ivar, dvar], ics) soln = soln.ic1(ics[0], ics[1]) if len(ics) == 3: ics = to_eqns([ivar, dvar, dvar.derivative(ivar)], ics) soln = soln.ic2(*ics) if soln.lhs() != dvar: raise NotImplementedError, "Sage is unable to use initial conditions for this equation." dvar_str=dvar.operator()._maxima_().str() ivar_str=ivar._maxima_().str() tempic=(ivar==ics[0])._maxima_().str() tempic=tempic+","+(dvar==ics[1])._maxima_().str() tempic=tempic+",diff("+dvar_str+","+ivar_str+")="+(ics[2])._maxima_().str() cmd="ic2(ode2("+de0._maxima_().str()+","+dvar_str+","+ivar_str+"),"+tempic+")" cmd=cmd.replace("'"+dvar_str+"("+ivar_str+")",dvar_str) soln=maxima(cmd).rhs() if len(ics) == 4: ics = to_eqns([ivar, dvar, ivar, dvar], ics) soln = soln.bc(*ics) dvar_str=dvar.operator()._maxima_().str() ivar_str=ivar._maxima_().str() cmd="bc2(ode2("+de0._maxima_().str()+","+dvar_str+","+ivar_str+"),"+(ivar==ics[0])._maxima_().str()+","+dvar_str+"="+(ics[1])._maxima_().str()+","+(ivar==ics[2])._maxima_().str()+","+dvar_str+"="+(ics[3])._maxima_().str()+")" cmd=cmd.replace("'"+dvar_str+"("+ivar_str+")",dvar_str) soln=maxima(cmd).rhs() if soln.lhs() == dvar: soln = soln.rhs() return soln.sage()