Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Problem in solving Differential Equation
Replies: 3   Last Post: Mar 28, 2013 5:12 PM

 Messages: [ Previous | Next ]
 Bob Hanlon Posts: 906 Registered: 10/29/11
Re: Problem in solving Differential Equation
Posted: Mar 6, 2013 5:54 AM

Arguments to functions (e.g., Sin, Cos) must be enclosed in squares
brackets: Sin[x[t]] and Cos[x[t]]

Clear[x];
\[Omega] = -2;
eqn =
x''[t] + Sin[x[t]] - \[Omega]^2 Sin [x[t]] Cos[x[t]] == 0 //
Simplify;
sol = NDSolve[
{eqn, x[0] == 1/2, x'[0] == 0},
x[t], {t, 0, 25}][[1]];
ParametricPlot[
Evaluate[{x[t] /. sol, D[x[t] /. sol, t]}],
{t, 0, 25},
Frame -> True,
Axes -> False,
FrameLabel -> (Style[#, "Courier", Bold, 16] & /@
{x, Overscript[x, "."]}),
AspectRatio -> 1,
PlotStyle -> {{Red, AbsoluteThickness[2]}}]
ParametricPlot[
Evaluate[{t, x[t] /. sol}],
{t, 0, 10},
Frame -> True,
Axes -> False,
FrameLabel -> (Style[#, "Courier", Bold, 16] & /@
{t, x}),
AspectRatio -> .5,
PlotStyle -> {{Green, AbsoluteThickness[3]}}]

Bob Hanlon

On Tue, Mar 5, 2013 at 10:14 PM, Rahul Chakraborty
<rahul.6sept@gmail.com> wrote:
> Dear all,
>
> Following differential equation seems to have some error in coding by me. kindly let me know where i have gone wrong.
>
> Clear[x];
> \[Omega]:=-2;
> eqn=x''[t]+ Sin x[t]-\[Omega]^2 Sin x[t]Cos x[t]==0//Simplify;
> sol=NDSolve[{eqn,x[0]==1/2,x'[0]==0},x[t],{t,0,1000}][[1]]
> ParametricPlot[Evaluate[{x[t]/.sol,D[x[t]/.sol,t]}],{t,0,25},Frame->True,AxesLabel->{"x",Overscript[x,"."]},AspectRatio->1,PlotStyle->{{Red,AbsoluteThickness[2]}},TextStyle->{FontFamily->"Courier",FontWeight->"Bold",FontSize->16}]
> ParametricPlot[Evaluate[{t,x[t]/.sol}],{t,0,10},Frame->True,AxesLabel->{"t","x"},AspectRatio->.5,PlotStyle->{{Green,AbsoluteThickness[3]}},TextStyle->{FontFamily->"Courier",FontWeight->"Bold",FontSize->16}]
>
> Regards,
>
> rahul
>

Date Subject Author
3/6/13 Bob Hanlon
3/28/13 Tomas Garza Hernandez
3/28/13 Bob Hanlon