# Solving a system of ODE

I try to solve a system of 5 odes but I get an annoying error:

I use

ClearAll
ode1 = y'[x] == -y[x] + xSin[x] + xExp[x];
ode2 = y'[x] == (y[x] (1 - x)/x^2);
ode3 = y'[x] == xy[x]/(x^2 - 2 y^2);
ode4 = 2 xy'[x] == -x^2 y''[x] + y[x];
ode5 = -4 y'[x] == y''[x] - 4 y[x] + xExp[x];
DSolve[{ode1, ode2, ode3, ode4, ode5}, {y[x]}, x]

then I am told "DSolve::dvnoarg: The function y appears with no arguments."

ClearAll
ode1 = y'[x] == -y[x] + xSin[x] + xExp[x];
ode2 = y'[x] == (y[x] (1 - x)/x^2);
ode3 = y'[x] == xy[x]/(x^2 - 2 y^2);
ode4 = 2 xy'[x] == -x^2 y''[x] + y[x];
ode5 = -4 y'[x] == y''[x] - 4 y[x] + xExp[x];
ic = y[0] == 1, y'[0] == 0, y''[0] == 1;
DSolve[{ode1, ode2, ode3, ode4, ode5}, {y[x]}, x]

and I get

"Syntax::tsntxi: "ic=y[0]==1,y'[0]==0,y''[0]==1;" is incomplete; more input is needed."

I try Nassers correction, and it works out well, but a new strange message appears

ode1 = y'[x] == -y[x] + x*Sin[x] + x*Exp[x];
ode2 = y1'[x] == (y1[x] (1 - x)/x^2);
ode3 = y2'[x] == x*y2[x]/(x^2 - 2 y2[x]^2);
ode4 = 2 x*y3'[x] == -x^2*y3''[x] + y3[x];
ode5 = -4 y4'[x] == y4''[x] - 4 y4[x] + x*Exp[x];
DSolve[{ode1, ode2, ode3, ode4, ode5}, {y[x], y1[x], y2[x], y3[x],
y4[x]}, x]

Solve::ifun: Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information.

From here I am not sure where the error lies.

Does anyone have a hint?

• You have many problems. some math, and some syntax., First the math: why do you have different ode's all with same dependent variable and trying to solve them all for one variable? You will get DSolve::overdet: There are fewer dependent variables than equations, so the system is overdetermined. now for the syntax part. Need to use y[x] and not y everywhere. do y^2 is wrong. It should be y[x]^2. Also watch for spaces. Better to use explicit *. So xy[x] is wrong. it should be x*y[x] or x y[x]. Same for xExp[x]. I prefer to use * myself as it is more clear. Sep 20, 2022 at 8:35
• ... more syntax. You can not write ic = y[0] == 1, y'[0] == 0, y''[0] == 1; it needs to be a list. like this ic ={ y[0] == 1, y'[0] == 0, y''[0] == 1}; Sep 20, 2022 at 8:38
• Yes. Or use y1[x] and y2[x] and y3[x] and so on. Just different variables for each ode. If these are coupled ode's, that is ok. Just need to have same number of dependent variables as number of ode's. I prefer y1 and y2 etc.. so that the number helps me know how many odes' there are. But the independent variable should all be the same! i.e. x in your examples. Sep 20, 2022 at 8:42
• You can post your new odes' after the fixes you made. it looks like you still have more problems. Sep 20, 2022 at 8:45
• Posted just now Sep 20, 2022 at 8:48

First of all, back to the math issues. Why are you solving these 5 odes at once? You only do that when the odes' are coupled which is not the case here. So you can solve them each on its own! This will make life much simpler for you and for Mathematica also.

In addition, some initial conditions lead to singularity, so need to make sure to use the correct ic.

I made up some to get solutions with no errors

ClearAll["Global`*"]
ode1 = y1'[x] == -y1[x] + x*Sin[x] + x*Exp[x];
ode2 = y2'[x] == (y2[x] (1 - x)/x^2);
ode3 = y3'[x] == x*y3[x]/(x^2 - 2 y3[x]^2);
ode4 = 2 x*y4'[x] == -x^2*y4''[x] + y4[x];
ode5 = -4 y5'[x] == y5''[x] - 4 y5[x] + x*Exp[x];

ic1 = y1[0] == 1;
ic2 = y2[1] == 0;
ic3 = y3[1] == 1;
ic4 = {y4[1] == 1, y4'[1] == 1};
ic5 = {y5[0] == 1, y5'[0] == 0};

That is all what you need. Now you can solve each ode on its own, since these are not coupled. To solve an ode numerically do like this for each ode

NDSolve[{ode1, ic1}, y1, {x, 0, 1}]

To solve it analytically do

DSolve[{ode1, ic1}, y1[x], x]

Repeat the above for each ode. Notice the difference. Numerically you need to give the domain of x but not with analytical solution.

• Thanks fort this! Sep 20, 2022 at 9:11