Hi,
I was just looking at a way to solve ODEs algebraically and came up with
the code below which almost works (just needs integration constants). I
have a few questions though.
1. What is the right way to define an arbitrary invertible function and its
inverse?
2. Is the code below abusing doit() or is that a reasonable way to use it?
3. Should I check for the inverses in __new__ or is there a better way to
do that?
4. Does this represent a reasonable approach for something that could be
implemented in dsolve?
5. How can I make a different integration constant each time I call
intx.doit()?
class diffx(Function):
def __new__(cls, expr):
if isinstance(expr, intx):
return expr.args[0]
else:
return super().__new__(cls, expr)
def inverse(self):
return intx
class intx(Function):
def __new__(cls, expr):
if isinstance(expr, diffx):
return expr.args[0]
else:
return super().__new__(cls, expr)
def inverse(self):
return intx
def doit(self):
return Integral(self.args[0].doit(), x).doit() # + Symbol('C')
eqn = diffx(x*diffx(f(x)))/x - exp(x)
soln,= solve(eqn, f(x))
print(soln.doit())
--
Oscar
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/CAHVvXxS%2Brg9Jd4U%2BiHQH%3Df64MvJKxPB4RpO9t%3DLYfyGzESuyDA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.