2
$\begingroup$

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[1] & c[2]). 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[1] -> C[3], C[2] -> C[4]};

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[1], C[2], C[3], 
     C[4]}]];

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[]).

$\endgroup$

1 Answer 1

3
$\begingroup$

Can help further this?

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

Plot[Evaluate[{xsol[x], ysol[x]}], {x, 0, 1}]

enter image description here

$\endgroup$
1
  • $\begingroup$ Thanks a lot. It was easier than my exception. $\endgroup$
    – Emad
    Commented Feb 9, 2016 at 1:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.