# How to solve two ODE differential equations, numerically, with four dependent boundary condition

I have two ODE differential equations(DE) and four dependent B.C. $$y_1''(x)=-\frac{1}{2} \left(x-y_1(x)\right)$$ $$y_2''(y)=-\frac{1}{4} \left(y-y_2(y)-5\right)$$ $$y_1(0)=y_2(1)$$ $$y_1(1)=y_2(0)$$ $$\frac{\text{dy}_1(0)}{\text{dx}}=\frac{\text{dy}_2(1)}{\text{dx}}$$ $$\frac{\text{dy}_1(1)}{\text{dx}}=\frac{\text{dy}_2(0)}{\text{dx}}$$ In order to solve them, I did the following:

By using DSolveValue[], I solved each of DEs. Obviously, each of the gives me two equation with two unknown(c & c). At the end, by using Solve[] and applying four dependent B.C, I found unknowns for each equation and there wasn't any problem. Following is what I explained.

odey1 = DSolveValue[y1''[x] == -((x - y1[x])/2), y1[x], x];
odey2 = DSolveValue[y2''[y] == -((y - y2[y] - 5)/4), y2[y],
y] /. {C -> C, C -> C};

coef = Simplify[
Solve[(ode1 /. x -> 0) == (odey2 /. y -> 1) && (odey1 /.
y -> 1) == (odey2 /. y -> 0) && ((D[odey1, x]) /.
x -> l) == ((D[odey2, y]) /. y -> 0) && ((D[odey1, x]) /.
x -> 0) == ((D[odey2, y]) /. y -> 1), { C, C, C,
C}]];

odey1 /. coef;
odey2 /. coef;


In my real case, DEs doesn't have any close form solution and I have to use NDSolveValue[] to solve DEs. Therefore, I cannot used aforementioned procedure for finding unknowns, because of having dependent B.C. I will appreciate, If somebody can help and make an example with aforementioned example(NDSolveValue[] instead of DSolveValue[]).

Can help further this?

{xsol, ysol} =
NDSolveValue[{y1''[x] == -1/2 (x - y1[x]),
y2''[x] == -1/4 (x - y2[x] - 5), y1 == y2, y1 == y2,
y1' == y2', y1' == y2'}, {y1, y2}, {x, 0, 1}]

Plot[Evaluate[{xsol[x], ysol[x]}], {x, 0, 1}] • Thanks a lot. It was easier than my exception.