3.39 How to reverse the role of the dependent and independent variables in ode?

Sometimes an ode can be solved much easier if we change the roles, and make the independent variable as the dependent variable.

For example, the ode \(y'(x)=\frac {1}{e^{4 y(x)} + 2 x}\) which is not easy to solve, becomes \(x'(y)=2 x(y) + e^{4 y}\) which is linear. After solving the simpler ode, we solve for \(y\) from the result which gives the solution to the original ode.

To do the conversion, use the command  convert(ode, y_x). Below are examples

original_ode:= diff(y(x),x)=1/(exp(4*y(x))+2*x); 
sol_of_original := dsolve(ode); 
 
        y(x) = ln(-c__1 - sqrt(c__1^2 + 2*x))/2, y(x) = ln(-c__1 + sqrt(c__1^2 + 2*x))/2 
 
new_ode:= convert(original_ode, y_x); 
 
          diff(x(y), y) = exp(4*y) + 2*x(y) 
 
sol_of_new := dsolve(new_ode); 
sol_of_new := eval(sol_of_new,x(y)=x); 
sol_of_new := y(x) = solve(sol_of_new,y); 
 
        y(x) = (ln(-c__1 + sqrt(c__1^2 + 2*x))/2, ln(-c__1 - sqrt(c__1^2 + 2*x))/2)
 

We see that we get the same solution ofcourse, but solving ode after changing the roles is much easier now.