Nonlinear ODEs

Example of a simple nonlinear ODE, solution found

Clear[t,x,χ0]
∫Csc[x]\[DifferentialD]x
TrigToExp[%]
Solve[t==Log[Abs[((Csc[χ0]+Cot[χ0])/(Csc[x]+Cot[x]))]],x] (*inverting the expression*)

Simple 1st order nonlinear ODE (1-D flow problem)

Solving analytically

DSolve[x'[t]== Sin[x[t]],x[t],t]

Plotting the phase portrait and the numerical solution

Clear[x,x0,sols,sol2,IC]
t0=0.0;
tmax=10;

Plot[Sin[x],{x,0,2 Pi},PlotRange->All,AxesLabel->{x,"(∂_t)x"},PlotLabel-> Style["Phase portrait directly from the equation",17],LabelStyle->17]

sols=ParametricNDSolveValue[{x'[t]== Sin[x[t]],x[0]==IC},x,{t,t0,tmax},{IC}];
prologue=Plot[Evaluate[Table[sols[ic][t],{ic,0,2 Pi,2 Pi/20}]],{t,t0,tmax},AxesLabel->{t,x[t]},ImageSize->400,PlotRange->{0,2 Pi},LabelStyle->17,PlotStyle->{{LightGray}}];
Manipulate[
sol2=NDSolve[{x'[t]== Sin[x[t]],x[0]==x0},x,{t,t0,tmax}];
plot1a=Plot[Evaluate[x[t]/.sol2],{t,t0,tmax},AxesLabel->{t,x[t]},ImageSize->400,PlotRange->{0,2 Pi},LabelStyle->17,PlotLabel-> Style["Integrated solution",17],PlotStyle->{Red,Thick}];
plot2a=ParametricPlot[Evaluate[{x[t],x'[t]}/.sol2],{t,t0,tmax},PlotRange->{{0,2 Pi},{-1,1}},AxesLabel->{x,"(∂_t)x"},ImageSize->400,LabelStyle->17,PlotLabel-> Style["Phase portrait",17],PlotStyle->{Red,Thick}];
Column[{Show[prologue,plot1a],plot2a}],
Control[{{x0,1,"Initial condition, x0"},0,2 Pi,Appearance->"Labeled"}],SaveDefinitions->True,TrackedSymbols:>{x0}]

Creation of this notebook was supported by IT Academy program of Information Technology Foundation for Education (HITSA).