Calculus of Variations II Examples
Author
Aleksandr Bryzgalov
Title
Calculus of Variations II Examples
Description
Calculation files for an article Calculus of Variations II
Category
Academic Articles & Supplements
Keywords
PU oscillator, pendulum with variable length, oscillations damped by two media
URL
http://www.notebookarchive.org/2022-02-6xaxfug/
DOI
https://notebookarchive.org/2022-02-6xaxfug
Date Added
2022-02-15
Date Last Modified
2022-02-15
File Size
0.5 megabytes
Supplements
Rights
Redistribution rights reserved
Download
Open in Wolfram Cloud
This file contains supplementary data for Gastão S.F. Frederico, Paolo Giordano, Alexandr A. Bryzgalov and Matheus J. Lazo, “Calculus of variations and optimal control for generalized functions,” Nonlinear Analysis, 216, 2022 112718. https://www.sciencedirect.com/science/article/pii/S0362546X21002881.
Calculus of Variations II Examples
Calculus of Variations II Examples
Aleksandr Bryzgalov
ScaleFactor=100.
100.
HeaviApprox[z_]:=(0.3989438184180913`+0.`)(1.2533141373155`+0.`)-++(0.7978845608028654`+0.`)SinIntegral[3.`z*ScaleFactor]-(3.1915382432114616`+0.`)SinIntegral[(3.`+0.`)z*ScaleFactor]+(3.191538243211461`+0.`)SinIntegral[(4.`+0.`)z*ScaleFactor]
(0.7978845608028653`+0.`)Cos[(3.`+0.`)z*ScaleFactor]
z*ScaleFactor
(0.7978845608028653`+0.`)Cos[(4.`+0.`)z*ScaleFactor]
z*ScaleFactor
Heavi1=HeaviApprox[x]
(0.398944+0.)(1.25331+0.)-++(0.797885+0.)SinIntegral[300.x]-(3.19154+0.)SinIntegral[(300.+0.)x]+(3.19154+0.)SinIntegral[(400.+0.)x]
(0.00797885+0.)Cos[(300.+0.)x]
x
(0.00797885+0.)Cos[(400.+0.)x]
x
Plot[Heavi1,{x,-0.2,0.2},AxesStyleDirective[Black,16]]
DeltaFunc=D[HeaviApprox[x],x]
(0.398944+0.)-+-+(239.365+0.)Sinc[300.x]-(957.461+0.)Sinc[(300.+0.)x]+(1276.62+0.)Sinc[(400.+0.)x]
(0.00797885+0.)Cos[(300.+0.)x]
2
x
(0.00797885+0.)Cos[(400.+0.)x]
2
x
(2.39365+0.)Sin[(300.+0.)x]
x
(3.19154+0.)Sin[(400.+0.)x]
x
DeltaFunction[z_]=(0.3989438184180913`+0.`)-+-+(239.36536824085962`+0.`)Sinc[300.`x]-(957.4614729634385`+0.`)Sinc[(300.`+0.`)x]+(1276.6152972845844`+0.`)Sinc[(400.`+0.`)x]/.x->z
(0.007978845608028654`+0.`)Cos[(300.`+0.`)x]
2
x
(0.007978845608028654`+0.`)Cos[(400.`+0.`)x]
2
x
(2.393653682408596`+0.`)Sin[(300.`+0.`)x]
x
(3.191538243211461`+0.`)Sin[(400.`+0.`)x]
x
(0.398944+0.)-+-+(239.365+0.)Sinc[300.z]-(957.461+0.)Sinc[(300.+0.)z]+(1276.62+0.)Sinc[(400.+0.)z]
(0.00797885+0.)Cos[(300.+0.)z]
2
z
(0.00797885+0.)Cos[(400.+0.)z]
2
z
(2.39365+0.)Sin[(300.+0.)z]
z
(3.19154+0.)Sin[(400.+0.)z]
z
x0=0σ=0.00001
0
0.00001
DeltaApprox[z_]:=1/(Sqrt[2*π]*σ)*Exp-
(z-x0)^2
2*σ^2
Plot[DeltaApprox[x],{x,-0.4,0.4},PlotRangeAll,AxesStyleDirective[Black,16],GridLines{Automatic,Automatic},Ticks{Automatic,Automatic},PlotStyle{Thick,Thick}]
General::unfl:Underflow occurred in computation.
DeltaFunc=DeltaFunction[x]
(0.398944+0.)-+-+(239.365+0.)Sinc[300.x]-(957.461+0.)Sinc[(300.+0.)x]+(1276.62+0.)Sinc[(400.+0.)x]
(0.00797885+0.)Cos[(300.+0.)x]
2
x
(0.00797885+0.)Cos[(400.+0.)x]
2
x
(2.39365+0.)Sin[(300.+0.)x]
x
(3.19154+0.)Sin[(400.+0.)x]
x
Plot[DeltaFunc,{x,-0.2,0.2},PlotRangeAll,AxesStyleDirective[Black,16]]
Heavi2=HeaviApprox[1-x]
(0.398944+0.)(1.25331+0.)-++(0.797885+0.)SinIntegral[300.(1-x)]-(3.19154+0.)SinIntegral[(300.+0.)(1-x)]+(3.19154+0.)SinIntegral[(400.+0.)(1-x)]
(0.00797885+0.)Cos[(300.+0.)(1-x)]
1-x
(0.00797885+0.)Cos[(400.+0.)(1-x)]
1-x
Plot[{Heavi2,HeaviApprox[-1+x]},{x,-2,2},PlotRangeAll,AxesStyleDirective[Black,16]]
L1=0.4L2=0.2g=9.8y0=π/40y1=π/20
0.4
0.2
9.8
π
40
π
20
FullSol=NDSolve[{y''[x]+g/(L2+HeavisideTheta[-y[x]+y0]*L1)*Sin[y[x]]-y'[x]^2*DeltaApprox[-y[x]+y0]*L1/(L2+HeavisideTheta[-y[x]+y0]*L1)+g*DeltaApprox[-y[x]+y0]*L1/(L2+HeavisideTheta[-y[x]+y0]*L1)^2*Cos[y[x]]0,y[0]==0,y'[0]1.},y[x],{x,0,10}]
NDSolve::ndnum:Encountered non-numerical value for a derivative at x == 0..
NDSolve+-+[x]0,y[0]0,[0]1.,y[x],{x,0,10}
3.92Cos[y[x]]DeltaApprox-y[x]
π
40
2
0.2+0.4HeavisideTheta-y[x]
π
40
9.8Sin[y[x]]
0.2+0.4HeavisideTheta-y[x]
π
40
0.4DeltaApprox-y[x][x]
π
40
2
′
y
0.2+0.4HeavisideTheta-y[x]
π
40
′′
y
′
y
sL40=NDSolve[{y''[x]+g/(L2+HeaviApprox[-y[x]+y0]*L1)*Sin[y[x]]0,y[0]==0,y'[0]1.},y[x],{x,0,10}]
{{y[x]InterpolatingFunction[{{0.,10.}},<>][x]}}
FullSol2=NDSolve[{y''[x]-y'[x]^2*DiracDelta[-y[x]+y0]*L1/(L2+HeavisideTheta[-y[x]+y0]*L1)+g*DiracDelta[-y[x]+y0]*L1/(L2+HeavisideTheta[-y[x]+y0]*L1)^2+g/(L2+HeavisideTheta[-y[x]+y0]*L1)*Sin[y[x]]0,y[0]==0,y'[0]1.},y[x],{x,0,10}]
{{y[x]InterpolatingFunction[{{0.,10.}},<>][x]}}
DiffSol=D[Evaluate[y[x]/.FullSol2],x]
{InterpolatingFunction[{{0.,10.}},<>][x]}
DiffSol2=D[DiffSol,x]
{InterpolatingFunction[{{0.,10.}},<>][x]}
Plot[{DiffSol,8*Evaluate[y[x]/.FullSol2]},{x,0,2},PlotRangeAll,GridLines{{1.319,1.622},Automatic},GridLinesStyleDirective[Gray,Dashed],Ticks{Automatic,Automatic},AxesStyleDirective[Black,16],PlotStyle{Thick,Thick},AxesLabel{"time,s","Angular speed, 8 x Angle"}]
Exclude
Plot[{DiffSol2,8*Evaluate[y[x]/.FullSol2]},{x,0,2},PlotRangeAll,ExclusionsRange[π/40-0.001,π/40+0.001],GridLines{{1.319,1.62},Automatic},GridLinesStyleDirective[Gray,Dashed],Ticks{Automatic,Automatic},AxesStyleDirective[Black,16],PlotStyle{Thick,Thick},AxesLabel{"time,s","Angular acceleration, 8 x Angle"}]
Plot[{Evaluate[y[x]/.sL40],Evaluate[y[x]/.FullSol]},{x,0,2},PlotRangeAll,GridLines{Automatic,Automatic},Ticks{Automatic,Automatic},AxesStyleDirective[Black,16],PlotStyle{Thick,Thick,Dashed,Dashed}]
sL20=NDSolve[{y''[x]+g/(L2+HeaviApprox[-y[x]+y1]*L1)*Sin[y[x]]0,y[0]==0,y'[0]1.},y[x],{x,0,10}]
{{y[x]InterpolatingFunction[{{0.,10.}},<>][x]}}
sL2=NDSolve[{y''[x]+g/(L2)*Sin[y[x]]0,y[0]==0,y'[0]1.},y[x],{x,0,10}]
{{y[x]InterpolatingFunction[{{0.,10.}},<>][x]}}
sL2L1=NDSolve[{y''[x]+g/(L2+L1)*Sin[y[x]]0,y[0]==0,y'[0]1.},y[x],{x,0,10}]
{{y[x]InterpolatingFunction[{{0.,10.}},<>][x]}}
x0=0.17016138104753686`
0.170161
CombinedSol=sL2L1*HeaviApprox[x0-x]+sL2*HeaviApprox[-x0+x]
(0.398944+0.)(y[x]InterpolatingFunction[{{0.,10.}},<>][x])(1.25331+0.)-++(0.797885+0.)SinIntegral[1200.(0.170161-x)]-(3.19154+0.)SinIntegral[(1200.+0.)(0.170161-x)]+(3.19154+0.)SinIntegral[(1600.+0.)(0.170161-x)]+(0.398944+0.)(y[x]InterpolatingFunction[{{0.,10.}},<>][x])(1.25331+0.)-++(0.797885+0.)SinIntegral[1200.(-0.170161+x)]-(3.19154+0.)SinIntegral[(1200.+0.)(-0.170161+x)]+(3.19154+0.)SinIntegral[(1600.+0.)(-0.170161+x)]
(0.00199471+0.)Cos[(1200.+0.)(0.170161-x)]
0.170161-x
(0.00199471+0.)Cos[(1600.+0.)(0.170161-x)]
0.170161-x
(0.00199471+0.)Cos[(1200.+0.)(-0.170161+x)]
-0.170161+x
(0.00199471+0.)Cos[(1600.+0.)(-0.170161+x)]
-0.170161+x
Plot[{Evaluate[y[x]/.sL40],Evaluate[y[x]/.sL20],Evaluate[y[x]/.sL2],Evaluate[y[x]/.sL2L1]},{x,0,π},PlotRangeAll,GridLines{Automatic,Automatic},Ticks{Automatic,Automatic},AxesStyleDirective[Black,16],PlotStyle{Thick,Thick,Dashed,Dashed}]
Plot[{CombinedSol,Evaluate[y[x]/.sL20]},{x,0,π},PlotRangeAll,GridLines{Automatic,Automatic},Ticks{Automatic,Automatic},AxesStyleDirective[Black,16],PlotStyle{Thick,Thick,Dashed,Dashed}]
Plot[{CombinedSol,Evaluate[y[x]/.sL20]},{x,0.1701,0.1702},PlotRangeAll,GridLines{Automatic,Automatic},Ticks{Automatic,Automatic},AxesStyleDirective[Black,16],PlotStyle{Thick,Thick,Dashed,Dashed}]
sL20A=NDSolve[{y''[x]+g/(L2+HeaviApprox[-y[x]+y1]*L1)*Sin[y[x]]0,y[0]==0,y'[0]1.},y[x],{x,0.15,0.2}]
{{y[x]InterpolatingFunction[{{0.15,0.2}},<>][x]}}
Plot[{Evaluate[y[x]/.sL20A],Evaluate[y[x]/.sL2L1]},{x,0.17,0.175},PlotRangeAll,AxesStyleDirective[Black,16]]
FindRoot[Evaluate[y[x]/.sL20A]==π/20,{x,0.17}]
{x0.170161+0.}
FindRoot[D[y[x]/.s]0,{x,0.3}],FindRoot[D[y[x]/.s0],{x,1}],FindRoot[D[y[x]/.s0],{x,1.7}]
DirSol=y[x]/.sL20A
{InterpolatingFunction[{{0.15,0.2}},<>][x]}
DirSol1=D[DirSol,x]
{InterpolatingFunction[{{0.15,0.2}},<>][x]}
DirSolL2L1=y[x]/.sL2L1
{InterpolatingFunction[{{0.,10.}},<>][x]}
DirSol2=D[DirSolL2L1,x]
{InterpolatingFunction[{{0.,10.}},<>][x]}
Plot[{Evaluate[DirSol1],Evaluate[DirSol2]},{x,0.1665,0.1699},PlotRangeAll,GridLinesAutomatic,AxesStyleDirective[Black,16],PlotStyleThick]
Plot[{Evaluate[DirSol1],Evaluate[DirSol2]},{x,0.16,0.18},PlotRangeAll,GridLinesAutomatic,AxesStyleDirective[Black,16],PlotStyleThick]
FindRoot[Evaluate[DirSol1]0,{x,0.3}]FindRoot[Evaluate[DirSol]0,{x,0.5}]
{x0.315097+0.}
{x0.630194+0.}
0.6301944739300914`-0.31509722671411705`
0.315097
FindRoot[Evaluate[DirSol1]0,{x,1}]
{x1.00161+0.}
1.0016072878173914`-0.6301944739300914`
0.371413
FindRoot[Evaluate[DirSol1]0,{x,1.7}]
{x1.68812+0.}
FindRoot[Evaluate[DirSol1]0,{x,2.4}]
{x2.37463+0.}
FindRoot[Evaluate[DirSol1]0,{x,3}]
{x3.06114+0.}
1.0016072878173914`-0.31509722671411705`
0.68651
1.6881173448712699`-1.0016072878173914`
0.68651
s2=NDSolve[{y''[x]+g/(L2+HeaviApprox[-y[x]+y0]*L1)*Sin[y[x]]0.,y[0.]==0.,y'[0.]1.},y[x],{x,0.1,0.3},AccuracyGoal->24,PrecisionGoal->24,WorkingPrecision->35,MaxSteps->Infinity]
NDSolve::precw:The precision of the differential equation +[x]0.,y[0.]0.,[0.]1.,{},{},{},{} is less than WorkingPrecision (35.).
9.8Sin[y[x]]
0.2+Times[2]
′′
y
′
y
{{y[x]InterpolatingFunction[{{0.10000000000000000555111512312578270,0.29999999999999998889776975374843460}},<>][x]}}
Plot[{Evaluate[y[x]/.s2]},{x,0.1,0.3},PlotRangeAll]
Cite this as: Aleksandr Bryzgalov, "Calculus of Variations II Examples" from the Notebook Archive (2022), https://notebookarchive.org/2022-02-6xaxfug
Download