1

I have this differential equation in terms of the variable $y$

deq[y_]=y^2 U''[y] + (a y^2 + b y + c) U'[y] + (d y + f) U[y]=0

and I want to make the change of variable y=t x and express deq[y_] as deq[x_]. Just defining y=t x, the above equation will be

(f + d t x) U[t x] + (c + b t x + a t^2 x^2) U'[t x] + t^2 x^2 U''[t x]

as can be seen, in this way, Mathematica only substitutes y by t x but according to these tranformation

$$ \frac{d}{\text{dy}}= \frac{\text{dx}}{\text{dy}} \frac{d}{\text{dx}}=\frac{1}{t} \frac{d}{\text{dx}} $$ and

$$ \frac{d^2}{\text{dy}^2}=\frac{1}{t^2} \frac{d^2}{\text{dx}^2}$$

I expect the differential equation deq[x_] as

deq[x_]=(f + d t x) U[x] + (c + b t x + a t^2 x^2) 1/t  U'[ x] + 
 t^2 x^2 1/t^2  U''[x]=0

How can I ask Mathematica to do this directly (I mean change the derivative functions as well)?

PhysFan
  • 63
  • 5

2 Answers2

3
ClearAll["Global`*"]
ode = y^2 *U''[y] + (a*y^2 + b*y + c)*U'[y] + (d*y + f)*U[y] == 0
DSolveChangeVariables[Inactive[DSolve][ode, U[y], y], u, x, x == y/t]

Mathematica graphics


Update

The above function is for V 13.1 and higher. For older versions you could try Kuba's DChange

First you need to install it

(If[DirectoryQ[#], DeleteDirectory[#, DeleteContents -> True]];
   CreateDirectory[#];
   URLSave[
    "https://raw.githubusercontent.com/" <> 
     "kubaPod/MoreCalculus/master/MoreCalculus/MoreCalculus.m", 
    FileNameJoin[{#, "MoreCalculus.m"}]]) &@
 FileNameJoin[{$UserBaseDirectory, "Applications", "MoreCalculus"}]

Mathematica graphics

I do not know if you can do this at University computer or not. After the the above load the package using

<< MoreCalculus`

Now you can do

ode = y^2*U''[y] + (a*y^2 + b*y + c)*U'[y] + (d*y + f)*U[y] == 0
DChange[ode, {y == x*t}, {y}, {x}, {U[y]}]

Mathematica graphics

Nasser
  • 143,286
  • 11
  • 154
  • 359
  • I am using Mathematica 12. Running your code, I get DSolveChangeVariables[DSolve[(f + d y) U[y] + (c + b y + a y^2) U'[y]+ y^2U''[y] == 0, U[y], y], u, x, x == y/t] – PhysFan Feb 03 '24 at 15:15
  • Is the beginning of your code DSolveChangeVariables[Inactive[DSolve] correct? – PhysFan Feb 03 '24 at 15:18
  • 1
    @PhysFan According to the documentation, DSolveChangeVariables is new in Verion 14. If I recall correctly, code to change ODE independent variables for earlier versions of Mathematica was posted somewhere on this site. – bbgodfrey Feb 03 '24 at 15:49
  • 1
    @bbgodfrey actually it was added in V 13.1 in 2022. I do not know why the page says NEW but scrolling down to the bottom of the above pages says V 13.1 also this page of new features of 13.1 shows it there. So it has been around for 2 years now. Time for OP to upgrade :) – Nasser Feb 03 '24 at 21:20
  • @Nasser How can I upgrade it? I have Mathematica only at our university. – PhysFan Feb 03 '24 at 21:28
  • 1
    @PhysFan you could ask your Univ. Computer lab person to update Mathematica. Meanwhile I added version for older Mathematica – Nasser Feb 03 '24 at 21:48
1

If you want to do it with just plain substitution you can do this.

deq = y^2  U''[y] + (a  y^2 + b  y + c)  U'[y] + (d  y + f)  U[y] == 0

deq /. {U -> (U[#/t] &)} /. y -> t x

((U'[x] (a t^2 x^2 + b t x + c))/t + U[x] (d t x + f) + x^2 U''[x] == 0)

I think this works for any Version of Mathematica.

Bill Watts
  • 8,217
  • 1
  • 11
  • 28