# Solving differential equations of dependant variables

I want to figure out $$x(u)$$ and $$y(v)$$ by solving differential equations. $$v(u)$$ is a function of $$u$$ and I want $$y(v)$$ expressed by $$v$$. I'm trying this using DSolve.

Hereis a simple example that unfortunately produces an error:

v = 1/u;
DSolve[{y[v] == -x'[u], x[u] == y'[v]}, {y[v], x[u]}, u]


DSolve::litarg: To avoid possible ambiguity, the arguments of the dependent variable in y[1/u] should literally match the independent variables.

I can solve this simple example by hand, but the equation I want to solve is too complicated.

How can I solve this?

DSolve requires the arguments of the unknown functions being sought to be the same variables. Set z[u] == y[1/u] and differentiate to figure out you have to substitute z[u] for y[v] and u^2 z'[u] for y'[v]. There is a function DChange for making such substitutions, which might be useful in your more complicated use-case. In simple cases, I just use calculus by hand:

D[z[u] == y[1/u], u]
(*  z[u] == -(y'[1/u]/u^2)  *)

DSolve[{z[u] == -x'[u], x[u] == u^2 z'[u]}, {z, x}, u];
sol = {y -> Function @@ {u, Simplify[z[1/u] /. First@%]}, x -> (x /. First@%)}
(*
{y -> Function[u,
1/(2 Sqrt[1/
u]) (-(C + Sqrt C) Cos[
1/2 Sqrt Log[1/u]] + (Sqrt C - C) Sin[
1/2 Sqrt Log[1/u]])],
x -> Function[{u},
Sqrt[u] C Cos[1/2 Sqrt Log[u]] +
Sqrt[u] C Sin[1/2 Sqrt Log[u]]]}
*)


Slightly more general processing of the solution, in case DSolve returns more than one solution (for a nonlinear system).

DSolve[{z[u] == -x'[u], x[u] == u^2 z'[u]}, {z, x}, u];
sol = {y -> Inactive[Function][u, z[1/u]], Inactive[Symbol]["x"] -> x} /. % //
Simplify[#, u > 0] & // Activate
(*
{{y -> Function[u,
1/2 Sqrt[u] (-(C + Sqrt C) Cos[
1/2 Sqrt Log[u]] + (-Sqrt C + C) Sin[
1/2 Sqrt Log[u]])],
x -> Function[{u},
Sqrt[u] C Cos[1/2 Sqrt Log[u]] +
Sqrt[u] C Sin[1/2 Sqrt Log[u]]]}}
*)


Another way

Clear[x, y, yy, u, v]

v = 1/u

de1 = y[v] == -x'[u]


And convert the differential equation.

de11 = de1 /. {y -> (yy[1/#] &)}
(*yy[u] == -x'[u]*)

de2 = x[u] == y'[v]


and convert

de22 = de2 /. {y -> (yy[1/#] &)}
(*x[u] == -u^2 yy'[u]*)

sol = DSolve[{de11, de22}, {yy[u], x[u]}, u] // Flatten // FullSimplify
(*{x[u] -> u^(1/2 - Sqrt/2) (C u^Sqrt + C),
yy[u] -> 1/2 u^( 1/2 (-1 - Sqrt)) ((Sqrt - 1) C - (1 + Sqrt) C u^Sqrt)}*)

x[u_] = (x[u] /. sol)

yy[u_] = yy[u] /. sol

y[u_] = yy[1/u]


Check the results. For the converted diff eq with x and yy

de11 // Simplify
(*True*)

de22 // Simplify
(*True*)


And the original unconverted differential equations with x andy

de1 // Simplify
(*True*)

de2 // Simplify
(*True*)


FWIW the solution by Michael E2 also satisfies de1 and de2 showing the form of solution can vary widely depending on the method used.