Dear Group,
Suppose I have a differential equation such as:
Eq(n^2*f(x) - x*Derivative(f(x), x) + (1 - 2*x)*Derivative(f(x), (x, 2)))
(Though typically more complicated)
and I want to replace the x variable - say x=cos(t)
Is there a way to make that substitution within SymPy and get back a differential equation in t, as opposed to simply throwing the equation to dsolve and hoping that it will solve it?
Likewise, is it possible to make a change of variable within an integral without simply letting integrate loose on it?
David
I obviously wasn't paying enough attention when I wrote that :)
I know the feeling, because I also managed to garble the differential equation, which should read:
n**2*f(x) - x*Derivative(f(x), x) + (1 - x**2)*Derivative(f(x), (x, 2))
I am pretty sure that should resolve to a simple differential equation after the substitution x=cos(t)
I tried to follow your prescription but I think the confusion may have set in here,
In [233]: xf = Function('x') # make x a function of t
I also had difficulty following what you were doing once I reached the nested lambda expressions!
It would be great if you could find the time to demonstrate your method on my example - a working example is always worth its weight in gold.
When I originally put in this query, I had assumed that there would be a one-line answer buried in SymPy.
I have also explored my own Python solution to the problem, recursively processing down the whole ODE expression and picking off the derivatives as I come across them. It looks feasible, but it isn't finished yet.
I know it is a very busy time for you right now, so if you want
to put this in your pending tray for a week, that is fine :)
David
On Wed, 25 Nov 2020 at 16:37, David Bailey <da...@dbailey.co.uk> wrote:
I really appreciate that!Okay now it works:
We definitely do need to supply a function for doing this. It's really not trivial to get this right. If we had something like dsubs or dchange then we could make use of it internally as well (e.g. in the ode module).
That is what I had expected would be there - just as you already have for integration in Integral.transform - which is presumably more difficult because you also have the limits to take care of.
Best wishes,
David