Consider a BVP $x^{\prime\prime}(t)+x^{\prime2}(t)-x(t)\left(x^{2}(t)-\frac{3}{2}x(t)+\frac{1}{2}\right)=0,$. The Boundary conditions are $x(0)=1$ and $x(1)=2$. It follows that the exact solution is $x(t)=t^{2}$, $0\leq t\leq 1$. How I plot this solution for t and f(t) (t=0.1,0.2,0.3,...0.9)
2 Answers
$\begingroup$
$\endgroup$
Clear["Global`*"]
eqns = {x''[t] + x'[t]^2 - x[t] (x[t]^2 - 3/2 x[t] + 1/2) == 0,
x[0] == 1, x[1] == 2};
sol = NDSolveValue[eqns, x, {t, 0, 1}]
data = sol /@ Range[0.1, 0.9, 0.1]
{1.11777, 1.22389, 1.32168, 1.41398, 1.50345, 1.59261, 1.68403, \
1.78037, 1.88458}
Show[
Plot[sol[t], {t, 0, 1}],
ListPlot[data, DataRange -> {0.1, 0.9}]]
$\begingroup$
$\endgroup$
ClearAll[x, t]
ode = x''[t] + x'[t]^2 - x[t]*(x[t]^2 - 3/2*x[t] + 1/2) == 0
bc = {x[0] == 1, x[1] == 2};
sol = NDSolveValue[{ode, bc}, x, {t, 0, 1}];
data = Table[{t,sol[t]}, {t, Range[0.1, 0.9, 0.1]}]
ListLinePlot[data, Mesh -> All, MeshStyle -> Red,
GridLines -> Automatic, GridLinesStyle -> LightGray]
x''[t] + x'[t]^2 - x[t] (x[t]^2 - 3/2 x[t] + 1/2) /. x -> (#^2 &) // Factor // FullSimplify
$\endgroup$