Hi David,

It's not completely intuitive but you can do the substitution in several 
stages. In your example (this is run isympy where f and g are both 
functions):

In [24]: eq = Eq(n**2*f(x) - x*Derivative(f(x), x) + (1 - 
2*x)*Derivative(f(x), (x, 2)), 0)                                       

In [25]: eq                                                                 
                                                      
Out[25]: 
                                   2          
 2          d                     d           
n ⋅f(x) - x⋅──(f(x)) + (1 - 2⋅x)⋅───(f(x)) = 0
            dx                     2          
                                 dx           

In [26]: eq.subs(f(x), g(cos(t)))                                           
                                                      
Out[26]: 
                                             2               
 2               d                          d                
n ⋅g(cos(t)) - x⋅──(g(cos(t))) + (1 - 2⋅x)⋅───(g(cos(t))) = 0
                 dx                          2               
                                           dx                

In [27]: eq.subs(f(x), g(cos(t))).doit()                                   
                                                       
Out[27]: 
 2              
n ⋅g(cos(t)) = 0

More substitutions are probably needed to continue from here.

Ideally sympy would have a function like maple's dchange:
https://www.maplesoft.com/support/help/Maple/view.aspx?path=PDEtools/dchange
https://github.com/sympy/sympy/issues/17590

Oscar
On Thursday, 19 November 2020 at 00:08:01 UTC [email protected] wrote:

> 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
>
>
>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/07b2ec37-30b8-4a6f-8690-c05bfe958ce0n%40googlegroups.com.

Reply via email to