1
$\begingroup$

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)

$\endgroup$
2
  • 2
    $\begingroup$ If $x(t)=t^2$ then $x(1)=1$ and not $2$ and $x(0)=0$ not $1$ $\endgroup$
    – bmf
    Commented Apr 2, 2022 at 19:47
  • 1
    $\begingroup$ Also, $t^2$ does not seem to verify the equation, see for instance x''[t] + x'[t]^2 - x[t] (x[t]^2 - 3/2 x[t] + 1/2) /. x -> (#^2 &) // Factor // FullSimplify $\endgroup$
    – bmf
    Commented Apr 2, 2022 at 19:48

2 Answers 2

4
$\begingroup$
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}]

enter image description here

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}]]

enter image description here

$\endgroup$
3
$\begingroup$
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]

Mathematica graphics

$\endgroup$

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.