I'm new to mathematica and am interested in solving the following BVP:
$\epsilon \,y'' + 2 y' + y^3 = 0$, for $0 < x < 1$ and $y(0) = 0, y(1) = 1/2$.
I have no experience with coding, so although I have read through the Mathematica documentation, I'm still a bit confused as to how to do this. I think I understand DSolve
, but what does that actually give me, and how do i plot it?
Answer
Nice to have something to solve while waiting for coeffee.
Manipulate[
eq = \[Epsilon]\[Epsilon] y''[x] + 2 y'[x] + y[x]^3 == 0;
ic = {y[0] == ic0, y[1] == ic1};
sol = First@NDSolve[Flatten[{eq, ic}], y[x], {x, 0, to}];
Plot[y[x] /. sol, {x, 0, to},
Frame -> True,
PlotRange -> All,
ImagePadding -> 50,
FrameLabel -> {
{y[x], None},
{x,
Style[Row[{"solution to ", \[Epsilon] y''[x] + 2 y'[x] +y[x]^3 == 0}], 12]
}
},
GridLines -> Automatic,
GridLinesStyle -> Directive[LightGray, Thickness[.001]]
],
{{\[Epsilon]\[Epsilon], 1, \[Epsilon]}, 0, 1, .01, ImageSize -> Tiny,
Appearance -> "Labeled"},
{{to, 2, "to?"}, 2, 10, .01, ImageSize -> Tiny,
Appearance -> "Labeled"},
{{ic0, 0, "y(0)"}, 0, 1, .01, ImageSize -> Tiny,
Appearance -> "Labeled"},
{{ic1, 0.5, "y(1)"}, 0, 1, .01, ImageSize -> Tiny,
Appearance -> "Labeled"}
]
Comments
Post a Comment