Код:
In[1]:= L=-1/2 (x'[t]^2+y'[t]^2+1-2Sqrt[x'[t]^2+y'[t]^2])
Out[1]= 1/2 (-1-(x^\[Prime])[t]^2-(y^\[Prime])[t]^2+2 Sqrt[(x^\[Prime])[t]^2+(y^\[Prime])[t]^2])
In[2]:= f1=y[t]*HeavisideTheta[t-(t0-0.02)]*HeavisideTheta[t0+0.02-t]
Out[2]= HeavisideTheta[0.02 +t-t0] HeavisideTheta[0.02 -t+t0] y[t]
In[3]:= L1=L+f1
Out[3]= HeavisideTheta[0.02 +t-t0] HeavisideTheta[0.02 -t+t0] y[t]+1/2 (-1-(x^\[Prime])[t]^2-(y^\[Prime])[t]^2+2 Sqrt[(x^\[Prime])[t]^2+(y^\[Prime])[t]^2])
In[4]:= eqn1=Dt[D[L1,x'[t]],t]-D[L1,x[t]]
Out[4]= 1/2 (-2 (x^\[Prime]\[Prime])[t]+(2 (x^\[Prime]\[Prime])[t])/Sqrt[(x^\[Prime])[t]^2+(y^\[Prime])[t]^2]-((x^\[Prime])[t] (2 (x^\[Prime])[t] (x^\[Prime]\[Prime])[t]+2 (y^\[Prime])[t] (y^\[Prime]\[Prime])[t]))/((x^\[Prime])[t]^2+(y^\[Prime])[t]^2)^(3/2))
In[5]:= eqn2=Dt[D[L1,y'[t]],t]-D[L1,y[t]]
Out[5]= -HeavisideTheta[0.02 +t-t0] HeavisideTheta[0.02 -t+t0]+1/2 (-2 (y^\[Prime]\[Prime])[t]+(2 (y^\[Prime]\[Prime])[t])/Sqrt[(x^\[Prime])[t]^2+(y^\[Prime])[t]^2]-((y^\[Prime])[t] (2 (x^\[Prime])[t] (x^\[Prime]\[Prime])[t]+2 (y^\[Prime])[t] (y^\[Prime]\[Prime])[t]))/((x^\[Prime])[t]^2+(y^\[Prime])[t]^2)^(3/2))
In[6]:= cond={x[0]==0,x[1]==1,y[0]==0,y[1]==0}
Out[6]= {x[0]==0,x[1]==1,y[0]==0,y[1]==0}
In[7]:= t0=0.5
Out[7]= 0.5
In[8]:= SLV=NDSolve[{eqn1==0,eqn2==0,cond},{x[t],y[t]},{t,0,1}]
During evaluation of In[8]:= Power::infy: Infinite expression 1/Sqrt[0.] encountered. >>
During evaluation of In[8]:= Power::infy: Infinite expression 1/0. encountered. >>
During evaluation of In[8]:= Infinity::indet: Indeterminate expression 0. ComplexInfinity ComplexInfinity encountered. >>
During evaluation of In[8]:= Power::infy: Infinite expression 1/0.^(3/2) encountered. >>
During evaluation of In[8]:= General::stop: Further output of Power::infy will be suppressed during this calculation. >>
During evaluation of In[8]:= Infinity::indet: Indeterminate expression 0. ComplexInfinity encountered. >>
During evaluation of In[8]:= Infinity::indet: Indeterminate expression 0. ComplexInfinity encountered. >>
During evaluation of In[8]:= General::stop: Further output of Infinity::indet will be suppressed during this calculation. >>
During evaluation of In[8]:= NDSolve::ndnum: Encountered non-numerical value for a derivative at t == 0.`. >>
Out[8]= NDSolve[{1/2 (-2 (x^\[Prime]\[Prime])[t]+(2 (x^\[Prime]\[Prime])[t])/Sqrt[(x^\[Prime])[t]^2+(y^\[Prime])[t]^2]-((x^\[Prime])[t] (2 (x^\[Prime])[t] (x^\[Prime]\[Prime])[t]+2 (y^\[Prime])[t] (y^\[Prime]\[Prime])[t]))/((x^\[Prime])[t]^2+(y^\[Prime])[t]^2)^(3/2))==0,-HeavisideTheta[0.52 -t] HeavisideTheta[-0.48+t]+1/2 (-2 (y^\[Prime]\[Prime])[t]+(2 (y^\[Prime]\[Prime])[t])/Sqrt[(x^\[Prime])[t]^2+(y^\[Prime])[t]^2]-((y^\[Prime])[t] (2 (x^\[Prime])[t] (x^\[Prime]\[Prime])[t]+2 (y^\[Prime])[t] (y^\[Prime]\[Prime])[t]))/((x^\[Prime])[t]^2+(y^\[Prime])[t]^2)^(3/2))==0,{x[0]==0,x[1]==1,y[0]==0,y[1]==0}},{x[t],y[t]},{t,0,1}]