Paras31

245 Reputation

9 Badges

1 years, 95 days
Hellenic Open University
Mathematician

Social Networks and Content at Maplesoft.com

Teacher of Mathematics with a proven track record of working in education management. Proficient in Ease of Adaptation, Course Design, and Instructional Technology. Holds a Bachelor's degree in Mathematics from the University of the Aegean and a Master's in Applied Mathematics at the Hellenic Open University, focusing on Ordinary and Partial Differential Equations. His enthusiasm lies in the application of mathematical models to real-world contexts, such as epidemiology and population growth. Aside from his passion for teaching, Athanasios enjoys football, basketball, and spending time with his dogs.

MaplePrimes Activity


These are replies submitted by Paras31

@Hullzie16  I tried now to replicate it with a loop but this way failed too,

restart;
with(plots):

L := 200;
K := 99;
kappa := 1;
omegaD := 1;
beta := 1;
delta := 0.05;
j := 2;
dt:=0.05:
tmax := 3000;
h := L/(K + 1);
nsp := [(-L/2 + h*i) $ (i = 0 .. L/h)]:
km := nops(nsp);
omegaD2 := h^2*omegaD^2;
deltaHat := h*delta;
a := 1.8;
var := seq(x[i](t), i = 1 .. km):
initialPositions := seq(x[i](0) = a*sin(j*h*Pi*nsp[i]/L), i = 1 .. km);
initialVelocities := seq(D(x[i])(0) = 0, i = 1 .. km):

200

 

99

 

1

 

1

 

1

 

0.5e-1

 

2

 

3000

 

2

 

101

 

4

 

.10

 

1.8

 

x[1](0) = 0., x[2](0) = 1.8*sin((1/25)*Pi), x[3](0) = 1.8*sin((2/25)*Pi), x[4](0) = 1.8*sin((3/25)*Pi), x[5](0) = 1.8*sin((4/25)*Pi), x[6](0) = 1.8*sin((1/5)*Pi), x[7](0) = 1.8*sin((6/25)*Pi), x[8](0) = 1.8*sin((7/25)*Pi), x[9](0) = 1.8*sin((8/25)*Pi), x[10](0) = 1.8*sin((9/25)*Pi), x[11](0) = 1.8*sin((2/5)*Pi), x[12](0) = 1.8*sin((11/25)*Pi), x[13](0) = 1.8*sin((12/25)*Pi), x[14](0) = 1.8*sin((12/25)*Pi), x[15](0) = 1.8*sin((11/25)*Pi), x[16](0) = 1.8*sin((2/5)*Pi), x[17](0) = 1.8*sin((9/25)*Pi), x[18](0) = 1.8*sin((8/25)*Pi), x[19](0) = 1.8*sin((7/25)*Pi), x[20](0) = 1.8*sin((6/25)*Pi), x[21](0) = 1.8*sin((1/5)*Pi), x[22](0) = 1.8*sin((4/25)*Pi), x[23](0) = 1.8*sin((3/25)*Pi), x[24](0) = 1.8*sin((2/25)*Pi), x[25](0) = 1.8*sin((1/25)*Pi), x[26](0) = 0., x[27](0) = -1.8*sin((1/25)*Pi), x[28](0) = -1.8*sin((2/25)*Pi), x[29](0) = -1.8*sin((3/25)*Pi), x[30](0) = -1.8*sin((4/25)*Pi), x[31](0) = -1.8*sin((1/5)*Pi), x[32](0) = -1.8*sin((6/25)*Pi), x[33](0) = -1.8*sin((7/25)*Pi), x[34](0) = -1.8*sin((8/25)*Pi), x[35](0) = -1.8*sin((9/25)*Pi), x[36](0) = -1.8*sin((2/5)*Pi), x[37](0) = -1.8*sin((11/25)*Pi), x[38](0) = -1.8*sin((12/25)*Pi), x[39](0) = -1.8*sin((12/25)*Pi), x[40](0) = -1.8*sin((11/25)*Pi), x[41](0) = -1.8*sin((2/5)*Pi), x[42](0) = -1.8*sin((9/25)*Pi), x[43](0) = -1.8*sin((8/25)*Pi), x[44](0) = -1.8*sin((7/25)*Pi), x[45](0) = -1.8*sin((6/25)*Pi), x[46](0) = -1.8*sin((1/5)*Pi), x[47](0) = -1.8*sin((4/25)*Pi), x[48](0) = -1.8*sin((3/25)*Pi), x[49](0) = -1.8*sin((2/25)*Pi), x[50](0) = -1.8*sin((1/25)*Pi), x[51](0) = 0., x[52](0) = 1.8*sin((1/25)*Pi), x[53](0) = 1.8*sin((2/25)*Pi), x[54](0) = 1.8*sin((3/25)*Pi), x[55](0) = 1.8*sin((4/25)*Pi), x[56](0) = 1.8*sin((1/5)*Pi), x[57](0) = 1.8*sin((6/25)*Pi), x[58](0) = 1.8*sin((7/25)*Pi), x[59](0) = 1.8*sin((8/25)*Pi), x[60](0) = 1.8*sin((9/25)*Pi), x[61](0) = 1.8*sin((2/5)*Pi), x[62](0) = 1.8*sin((11/25)*Pi), x[63](0) = 1.8*sin((12/25)*Pi), x[64](0) = 1.8*sin((12/25)*Pi), x[65](0) = 1.8*sin((11/25)*Pi), x[66](0) = 1.8*sin((2/5)*Pi), x[67](0) = 1.8*sin((9/25)*Pi), x[68](0) = 1.8*sin((8/25)*Pi), x[69](0) = 1.8*sin((7/25)*Pi), x[70](0) = 1.8*sin((6/25)*Pi), x[71](0) = 1.8*sin((1/5)*Pi), x[72](0) = 1.8*sin((4/25)*Pi), x[73](0) = 1.8*sin((3/25)*Pi), x[74](0) = 1.8*sin((2/25)*Pi), x[75](0) = 1.8*sin((1/25)*Pi), x[76](0) = 0., x[77](0) = -1.8*sin((1/25)*Pi), x[78](0) = -1.8*sin((2/25)*Pi), x[79](0) = -1.8*sin((3/25)*Pi), x[80](0) = -1.8*sin((4/25)*Pi), x[81](0) = -1.8*sin((1/5)*Pi), x[82](0) = -1.8*sin((6/25)*Pi), x[83](0) = -1.8*sin((7/25)*Pi), x[84](0) = -1.8*sin((8/25)*Pi), x[85](0) = -1.8*sin((9/25)*Pi), x[86](0) = -1.8*sin((2/5)*Pi), x[87](0) = -1.8*sin((11/25)*Pi), x[88](0) = -1.8*sin((12/25)*Pi), x[89](0) = -1.8*sin((12/25)*Pi), x[90](0) = -1.8*sin((11/25)*Pi), x[91](0) = -1.8*sin((2/5)*Pi), x[92](0) = -1.8*sin((9/25)*Pi), x[93](0) = -1.8*sin((8/25)*Pi), x[94](0) = -1.8*sin((7/25)*Pi), x[95](0) = -1.8*sin((6/25)*Pi), x[96](0) = -1.8*sin((1/5)*Pi), x[97](0) = -1.8*sin((4/25)*Pi), x[98](0) = -1.8*sin((3/25)*Pi), x[99](0) = -1.8*sin((2/25)*Pi), x[100](0) = -1.8*sin((1/25)*Pi), x[101](0) = 0.

(1)

boundaryConditions := [x[1](t) = 0, x[km](t) = 0]

[x[1](t) = 0, x[101](t) = 0]

(2)

equations := seq(diff(x[n](t), t, t) - kappa*(x[n + 1](t) - 2*x[n](t) + x[n - 1](t)) + deltaHat*diff(x[n](t), t) - omegaD2^2*(x[n](t) - beta*x[n](t)^3) = 0, n = 2 .. km - 1), diff(x[1](t), t, t) = 0, diff(x[101](t), t, t) = 0:

sol := dsolve({equations, initialPositions, initialVelocities}, maxfun=0,numeric, method = rkf45,output=listprocedure)

`[Length of output exceeds limit of 1000000]`

(3)

# Use odeplot to plot the trajectory of x[67](t)
odeplot(sol, [[t, x[67](t)]], t = 0 .. 100, numpoints = 3500, title = "Trajectory of x[67](t)", axes = boxed, gridlines=true, color = ["Blue"], size = [500, 300]);

 

# Plot x[67](t) vs u[67](t) = diff(x[67](t), t)
odeplot(sol, [[x[67](t), diff(x[67](t), t)]], t = 0 .. 100, numpoints = 3500, title = "x_n vs u_n", axes = boxed, gridlines=true, color = ["Blue"], size = [500, 300]);

 

odeplot(sol, [[t, diff(x[67](t), t)]], t = 0 .. 100, numpoints = 3500, title = "u_n", axes = boxed, gridlines = true, color = ["Red"], size = [500, 300])

 

getDisplacements := proc (t_val) local U, i; U := [seq(eval(x[i](t_val), sol), i = 1 .. km)]; return U end proc

TT := table(); for t_val from 0 by dt to 3000 do U := getDisplacements(t_val); plotU := pointplot([seq([nsp[i], U[i]], i = 1 .. K+2)], style = point, symbol = solidcircle, color = blue, title = cat("t = ", t_val, ", a = ", a), labels = ["n", "Displacement"], grid = [true, true], view = [-100 .. 100, -2 .. 2]); TT[t_val] := plotU; DocumentTools:-Tabulate([plotU]) end do

table( [ ] )

 

[x[1](0), x[2](0), x[3](0), x[4](0), x[5](0), x[6](0), x[7](0), x[8](0), x[9](0), x[10](0), x[11](0), x[12](0), x[13](0), x[14](0), x[15](0), x[16](0), x[17](0), x[18](0), x[19](0), x[20](0), x[21](0), x[22](0), x[23](0), x[24](0), x[25](0), x[26](0), x[27](0), x[28](0), x[29](0), x[30](0), x[31](0), x[32](0), x[33](0), x[34](0), x[35](0), x[36](0), x[37](0), x[38](0), x[39](0), x[40](0), x[41](0), x[42](0), x[43](0), x[44](0), x[45](0), x[46](0), x[47](0), x[48](0), x[49](0), x[50](0), x[51](0), x[52](0), x[53](0), x[54](0), x[55](0), x[56](0), x[57](0), x[58](0), x[59](0), x[60](0), x[61](0), x[62](0), x[63](0), x[64](0), x[65](0), x[66](0), x[67](0), x[68](0), x[69](0), x[70](0), x[71](0), x[72](0), x[73](0), x[74](0), x[75](0), x[76](0), x[77](0), x[78](0), x[79](0), x[80](0), x[81](0), x[82](0), x[83](0), x[84](0), x[85](0), x[86](0), x[87](0), x[88](0), x[89](0), x[90](0), x[91](0), x[92](0), x[93](0), x[94](0), x[95](0), x[96](0), x[97](0), x[98](0), x[99](0), x[100](0), x[101](0)]

 

Error, (in plots:-pointplot) points cannot be converted to floating-point values

 
 

NULL

Download v4.mw

@Hullzie16 As I can understand I have to create a pointplot spatial points over var:= seq(x[i](t), i = 1 .. km) the, but still I have not figured out how to replicate it

restart;
with(plots):

L := 200;
K := 99;
kappa := 1;
omegaD := 1;
beta := 1;
delta := 0.05;
j := 2;
tmax := 3000;
h := L/(K + 1);
nsp := [(-L/2 + h*i) $ (i = 0 .. L/h)]:
km := nops(nsp);
omegaD2 := h^2*omegaD^2;
deltaHat := h*delta;
a := 1.8;
var := seq(x[i](t), i = 1 .. km):
initialPositions := seq(x[i](0) = a*sin(j*h*Pi*nsp[i]/L), i = 1 .. km):
initialVelocities := seq(D(x[i])(0) = 0, i = 1 .. km):

200

 

99

 

1

 

1

 

1

 

0.5e-1

 

2

 

3000

 

2

 

101

 

4

 

.10

 

1.8

(1)

boundaryConditions := [x[1](t) = 0, x[km](t) = 0]

[x[1](t) = 0, x[101](t) = 0]

(2)

equations := seq(diff(x[n](t), t, t) - kappa*(x[n + 1](t) - 2*x[n](t) + x[n - 1](t)) + deltaHat*diff(x[n](t), t) - omegaD2^2*(x[n](t) - beta*x[n](t)^3) = 0, n = 2 .. km - 1), diff(x[1](t), t, t) = 0, diff(x[101](t), t, t) = 0:

sol := dsolve({equations, initialPositions, initialVelocities}, maxfun=0,numeric, method = rkf45,output=listprocedure)

`[Length of output exceeds limit of 1000000]`

(3)

# Use odeplot to plot the trajectory of x[67](t)
odeplot(sol, [[t, x[67](t)]], t = 0 .. 100, numpoints = 3500, title = "Trajectory of x[67](t)", axes = boxed, gridlines=true, color = ["Blue"], size = [500, 300]);

 

# Plot x[67](t) vs u[67](t) = diff(x[67](t), t)
odeplot(sol, [[x[67](t), diff(x[67](t), t)]], t = 0 .. 100, numpoints = 3500, title = "x_n vs u_n", axes = boxed, gridlines=true, color = ["Blue"], size = [500, 300]);

 

odeplot(sol, [[t, diff(x[67](t), t)]], t = 0 .. 100, numpoints = 3500, title = "u_n", axes = boxed, gridlines = true, color = ["Red"], size = [500, 300])

 

solVals := sol(0); solVals; dataPoints := [seq([nsp[i], evalf(solVals[i][2])], i = 1 .. km)]

[t(0) = HFloat(0.0), (x[1](t))(0) = HFloat(0.0), (diff(x[1](t), t))(0) = HFloat(0.0), (x[2](t))(0) = HFloat(0.225599820415749), (diff(x[2](t), t))(0) = HFloat(0.0), (x[3](t))(0) = HFloat(0.447641796896737), (diff(x[3](t), t))(0) = HFloat(0.0), (x[4](t))(0) = HFloat(0.66262419483242), (diff(x[4](t), t))(0) = HFloat(0.0), (x[5](t))(0) = HFloat(0.867156613383085), (diff(x[5](t), t))(0) = HFloat(0.0), (x[6](t))(0) = HFloat(1.05801345412645), (diff(x[6](t), t))(0) = HFloat(0.0), (x[7](t))(0) = HFloat(1.23218479067164), (diff(x[7](t), t))(0) = HFloat(0.0), (x[8](t))(0) = HFloat(1.38692383699642), (diff(x[8](t), t))(0) = HFloat(0.0), (x[9](t))(0) = HFloat(1.51979026590362), (diff(x[9](t), t))(0) = HFloat(0.0), (x[10](t))(0) = HFloat(1.62868869443883), (diff(x[10](t), t))(0) = HFloat(0.0), (x[11](t))(0) = HFloat(1.71190172933128), (diff(x[11](t), t))(0) = HFloat(0.0), (x[12](t))(0) = HFloat(1.76811705131164), (diff(x[12](t), t))(0) = HFloat(0.0), (x[13](t))(0) = HFloat(1.79644811117089), (diff(x[13](t), t))(0) = HFloat(0.0), (x[14](t))(0) = HFloat(1.79644811117089), (diff(x[14](t), t))(0) = HFloat(0.0), (x[15](t))(0) = HFloat(1.76811705131164), (diff(x[15](t), t))(0) = HFloat(0.0), (x[16](t))(0) = HFloat(1.71190172933128), (diff(x[16](t), t))(0) = HFloat(0.0), (x[17](t))(0) = HFloat(1.62868869443883), (diff(x[17](t), t))(0) = HFloat(0.0), (x[18](t))(0) = HFloat(1.51979026590362), (diff(x[18](t), t))(0) = HFloat(0.0), (x[19](t))(0) = HFloat(1.38692383699642), (diff(x[19](t), t))(0) = HFloat(0.0), (x[20](t))(0) = HFloat(1.23218479067164), (diff(x[20](t), t))(0) = HFloat(0.0), (x[21](t))(0) = HFloat(1.05801345412645), (diff(x[21](t), t))(0) = HFloat(0.0), (x[22](t))(0) = HFloat(0.867156613383085), (diff(x[22](t), t))(0) = HFloat(0.0), (x[23](t))(0) = HFloat(0.66262419483242), (diff(x[23](t), t))(0) = HFloat(0.0), (x[24](t))(0) = HFloat(0.447641796896737), (diff(x[24](t), t))(0) = HFloat(0.0), (x[25](t))(0) = HFloat(0.225599820415749), (diff(x[25](t), t))(0) = HFloat(0.0), (x[26](t))(0) = HFloat(0.0), (diff(x[26](t), t))(0) = HFloat(0.0), (x[27](t))(0) = HFloat(-0.225599820415749), (diff(x[27](t), t))(0) = HFloat(0.0), (x[28](t))(0) = HFloat(-0.447641796896737), (diff(x[28](t), t))(0) = HFloat(0.0), (x[29](t))(0) = HFloat(-0.66262419483242), (diff(x[29](t), t))(0) = HFloat(0.0), (x[30](t))(0) = HFloat(-0.867156613383085), (diff(x[30](t), t))(0) = HFloat(0.0), (x[31](t))(0) = HFloat(-1.05801345412645), (diff(x[31](t), t))(0) = HFloat(0.0), (x[32](t))(0) = HFloat(-1.23218479067164), (diff(x[32](t), t))(0) = HFloat(0.0), (x[33](t))(0) = HFloat(-1.38692383699642), (diff(x[33](t), t))(0) = HFloat(0.0), (x[34](t))(0) = HFloat(-1.51979026590362), (diff(x[34](t), t))(0) = HFloat(0.0), (x[35](t))(0) = HFloat(-1.62868869443883), (diff(x[35](t), t))(0) = HFloat(0.0), (x[36](t))(0) = HFloat(-1.71190172933128), (diff(x[36](t), t))(0) = HFloat(0.0), (x[37](t))(0) = HFloat(-1.76811705131164), (diff(x[37](t), t))(0) = HFloat(0.0), (x[38](t))(0) = HFloat(-1.79644811117089), (diff(x[38](t), t))(0) = HFloat(0.0), (x[39](t))(0) = HFloat(-1.79644811117089), (diff(x[39](t), t))(0) = HFloat(0.0), (x[40](t))(0) = HFloat(-1.76811705131164), (diff(x[40](t), t))(0) = HFloat(0.0), (x[41](t))(0) = HFloat(-1.71190172933128), (diff(x[41](t), t))(0) = HFloat(0.0), (x[42](t))(0) = HFloat(-1.62868869443883), (diff(x[42](t), t))(0) = HFloat(0.0), (x[43](t))(0) = HFloat(-1.51979026590362), (diff(x[43](t), t))(0) = HFloat(0.0), (x[44](t))(0) = HFloat(-1.38692383699642), (diff(x[44](t), t))(0) = HFloat(0.0), (x[45](t))(0) = HFloat(-1.23218479067164), (diff(x[45](t), t))(0) = HFloat(0.0), (x[46](t))(0) = HFloat(-1.05801345412645), (diff(x[46](t), t))(0) = HFloat(0.0), (x[47](t))(0) = HFloat(-0.867156613383085), (diff(x[47](t), t))(0) = HFloat(0.0), (x[48](t))(0) = HFloat(-0.66262419483242), (diff(x[48](t), t))(0) = HFloat(0.0), (x[49](t))(0) = HFloat(-0.447641796896737), (diff(x[49](t), t))(0) = HFloat(0.0), (x[50](t))(0) = HFloat(-0.225599820415749), (diff(x[50](t), t))(0) = HFloat(0.0), (x[51](t))(0) = HFloat(0.0), (diff(x[51](t), t))(0) = HFloat(0.0), (x[52](t))(0) = HFloat(0.225599820415749), (diff(x[52](t), t))(0) = HFloat(0.0), (x[53](t))(0) = HFloat(0.447641796896737), (diff(x[53](t), t))(0) = HFloat(0.0), (x[54](t))(0) = HFloat(0.66262419483242), (diff(x[54](t), t))(0) = HFloat(0.0), (x[55](t))(0) = HFloat(0.867156613383085), (diff(x[55](t), t))(0) = HFloat(0.0), (x[56](t))(0) = HFloat(1.05801345412645), (diff(x[56](t), t))(0) = HFloat(0.0), (x[57](t))(0) = HFloat(1.23218479067164), (diff(x[57](t), t))(0) = HFloat(0.0), (x[58](t))(0) = HFloat(1.38692383699642), (diff(x[58](t), t))(0) = HFloat(0.0), (x[59](t))(0) = HFloat(1.51979026590362), (diff(x[59](t), t))(0) = HFloat(0.0), (x[60](t))(0) = HFloat(1.62868869443883), (diff(x[60](t), t))(0) = HFloat(0.0), (x[61](t))(0) = HFloat(1.71190172933128), (diff(x[61](t), t))(0) = HFloat(0.0), (x[62](t))(0) = HFloat(1.76811705131164), (diff(x[62](t), t))(0) = HFloat(0.0), (x[63](t))(0) = HFloat(1.79644811117089), (diff(x[63](t), t))(0) = HFloat(0.0), (x[64](t))(0) = HFloat(1.79644811117089), (diff(x[64](t), t))(0) = HFloat(0.0), (x[65](t))(0) = HFloat(1.76811705131164), (diff(x[65](t), t))(0) = HFloat(0.0), (x[66](t))(0) = HFloat(1.71190172933128), (diff(x[66](t), t))(0) = HFloat(0.0), (x[67](t))(0) = HFloat(1.62868869443883), (diff(x[67](t), t))(0) = HFloat(0.0), (x[68](t))(0) = HFloat(1.51979026590362), (diff(x[68](t), t))(0) = HFloat(0.0), (x[69](t))(0) = HFloat(1.38692383699642), (diff(x[69](t), t))(0) = HFloat(0.0), (x[70](t))(0) = HFloat(1.23218479067164), (diff(x[70](t), t))(0) = HFloat(0.0), (x[71](t))(0) = HFloat(1.05801345412645), (diff(x[71](t), t))(0) = HFloat(0.0), (x[72](t))(0) = HFloat(0.867156613383085), (diff(x[72](t), t))(0) = HFloat(0.0), (x[73](t))(0) = HFloat(0.66262419483242), (diff(x[73](t), t))(0) = HFloat(0.0), (x[74](t))(0) = HFloat(0.447641796896737), (diff(x[74](t), t))(0) = HFloat(0.0), (x[75](t))(0) = HFloat(0.225599820415749), (diff(x[75](t), t))(0) = HFloat(0.0), (x[76](t))(0) = HFloat(0.0), (diff(x[76](t), t))(0) = HFloat(0.0), (x[77](t))(0) = HFloat(-0.225599820415749), (diff(x[77](t), t))(0) = HFloat(0.0), (x[78](t))(0) = HFloat(-0.447641796896737), (diff(x[78](t), t))(0) = HFloat(0.0), (x[79](t))(0) = HFloat(-0.66262419483242), (diff(x[79](t), t))(0) = HFloat(0.0), (x[80](t))(0) = HFloat(-0.867156613383085), (diff(x[80](t), t))(0) = HFloat(0.0), (x[81](t))(0) = HFloat(-1.05801345412645), (diff(x[81](t), t))(0) = HFloat(0.0), (x[82](t))(0) = HFloat(-1.23218479067164), (diff(x[82](t), t))(0) = HFloat(0.0), (x[83](t))(0) = HFloat(-1.38692383699642), (diff(x[83](t), t))(0) = HFloat(0.0), (x[84](t))(0) = HFloat(-1.51979026590362), (diff(x[84](t), t))(0) = HFloat(0.0), (x[85](t))(0) = HFloat(-1.62868869443883), (diff(x[85](t), t))(0) = HFloat(0.0), (x[86](t))(0) = HFloat(-1.71190172933128), (diff(x[86](t), t))(0) = HFloat(0.0), (x[87](t))(0) = HFloat(-1.76811705131164), (diff(x[87](t), t))(0) = HFloat(0.0), (x[88](t))(0) = HFloat(-1.79644811117089), (diff(x[88](t), t))(0) = HFloat(0.0), (x[89](t))(0) = HFloat(-1.79644811117089), (diff(x[89](t), t))(0) = HFloat(0.0), (x[90](t))(0) = HFloat(-1.76811705131164), (diff(x[90](t), t))(0) = HFloat(0.0), (x[91](t))(0) = HFloat(-1.71190172933128), (diff(x[91](t), t))(0) = HFloat(0.0), (x[92](t))(0) = HFloat(-1.62868869443883), (diff(x[92](t), t))(0) = HFloat(0.0), (x[93](t))(0) = HFloat(-1.51979026590362), (diff(x[93](t), t))(0) = HFloat(0.0), (x[94](t))(0) = HFloat(-1.38692383699642), (diff(x[94](t), t))(0) = HFloat(0.0), (x[95](t))(0) = HFloat(-1.23218479067164), (diff(x[95](t), t))(0) = HFloat(0.0), (x[96](t))(0) = HFloat(-1.05801345412645), (diff(x[96](t), t))(0) = HFloat(0.0), (x[97](t))(0) = HFloat(-0.867156613383085), (diff(x[97](t), t))(0) = HFloat(0.0), (x[98](t))(0) = HFloat(-0.66262419483242), (diff(x[98](t), t))(0) = HFloat(0.0), (x[99](t))(0) = HFloat(-0.447641796896737), (diff(x[99](t), t))(0) = HFloat(0.0), (x[100](t))(0) = HFloat(-0.225599820415749), (diff(x[100](t), t))(0) = HFloat(0.0), (x[101](t))(0) = HFloat(0.0), (diff(x[101](t), t))(0) = HFloat(0.0)]

 

[[-100, (t(0) = HFloat(0.0))[2]], [-98, ((x[1](t))(0) = HFloat(0.0))[2]], [-96, ((diff(x[1](t), t))(0) = HFloat(0.0))[2]], [-94, ((x[2](t))(0) = HFloat(0.225599820415749))[2]], [-92, ((diff(x[2](t), t))(0) = HFloat(0.0))[2]], [-90, ((x[3](t))(0) = HFloat(0.447641796896737))[2]], [-88, ((diff(x[3](t), t))(0) = HFloat(0.0))[2]], [-86, ((x[4](t))(0) = HFloat(0.66262419483242))[2]], [-84, ((diff(x[4](t), t))(0) = HFloat(0.0))[2]], [-82, ((x[5](t))(0) = HFloat(0.867156613383085))[2]], [-80, ((diff(x[5](t), t))(0) = HFloat(0.0))[2]], [-78, ((x[6](t))(0) = HFloat(1.05801345412645))[2]], [-76, ((diff(x[6](t), t))(0) = HFloat(0.0))[2]], [-74, ((x[7](t))(0) = HFloat(1.23218479067164))[2]], [-72, ((diff(x[7](t), t))(0) = HFloat(0.0))[2]], [-70, ((x[8](t))(0) = HFloat(1.38692383699642))[2]], [-68, ((diff(x[8](t), t))(0) = HFloat(0.0))[2]], [-66, ((x[9](t))(0) = HFloat(1.51979026590362))[2]], [-64, ((diff(x[9](t), t))(0) = HFloat(0.0))[2]], [-62, ((x[10](t))(0) = HFloat(1.62868869443883))[2]], [-60, ((diff(x[10](t), t))(0) = HFloat(0.0))[2]], [-58, ((x[11](t))(0) = HFloat(1.71190172933128))[2]], [-56, ((diff(x[11](t), t))(0) = HFloat(0.0))[2]], [-54, ((x[12](t))(0) = HFloat(1.76811705131164))[2]], [-52, ((diff(x[12](t), t))(0) = HFloat(0.0))[2]], [-50, ((x[13](t))(0) = HFloat(1.79644811117089))[2]], [-48, ((diff(x[13](t), t))(0) = HFloat(0.0))[2]], [-46, ((x[14](t))(0) = HFloat(1.79644811117089))[2]], [-44, ((diff(x[14](t), t))(0) = HFloat(0.0))[2]], [-42, ((x[15](t))(0) = HFloat(1.76811705131164))[2]], [-40, ((diff(x[15](t), t))(0) = HFloat(0.0))[2]], [-38, ((x[16](t))(0) = HFloat(1.71190172933128))[2]], [-36, ((diff(x[16](t), t))(0) = HFloat(0.0))[2]], [-34, ((x[17](t))(0) = HFloat(1.62868869443883))[2]], [-32, ((diff(x[17](t), t))(0) = HFloat(0.0))[2]], [-30, ((x[18](t))(0) = HFloat(1.51979026590362))[2]], [-28, ((diff(x[18](t), t))(0) = HFloat(0.0))[2]], [-26, ((x[19](t))(0) = HFloat(1.38692383699642))[2]], [-24, ((diff(x[19](t), t))(0) = HFloat(0.0))[2]], [-22, ((x[20](t))(0) = HFloat(1.23218479067164))[2]], [-20, ((diff(x[20](t), t))(0) = HFloat(0.0))[2]], [-18, ((x[21](t))(0) = HFloat(1.05801345412645))[2]], [-16, ((diff(x[21](t), t))(0) = HFloat(0.0))[2]], [-14, ((x[22](t))(0) = HFloat(0.867156613383085))[2]], [-12, ((diff(x[22](t), t))(0) = HFloat(0.0))[2]], [-10, ((x[23](t))(0) = HFloat(0.66262419483242))[2]], [-8, ((diff(x[23](t), t))(0) = HFloat(0.0))[2]], [-6, ((x[24](t))(0) = HFloat(0.447641796896737))[2]], [-4, ((diff(x[24](t), t))(0) = HFloat(0.0))[2]], [-2, ((x[25](t))(0) = HFloat(0.225599820415749))[2]], [0, ((diff(x[25](t), t))(0) = HFloat(0.0))[2]], [2, ((x[26](t))(0) = HFloat(0.0))[2]], [4, ((diff(x[26](t), t))(0) = HFloat(0.0))[2]], [6, ((x[27](t))(0) = HFloat(-0.225599820415749))[2]], [8, ((diff(x[27](t), t))(0) = HFloat(0.0))[2]], [10, ((x[28](t))(0) = HFloat(-0.447641796896737))[2]], [12, ((diff(x[28](t), t))(0) = HFloat(0.0))[2]], [14, ((x[29](t))(0) = HFloat(-0.66262419483242))[2]], [16, ((diff(x[29](t), t))(0) = HFloat(0.0))[2]], [18, ((x[30](t))(0) = HFloat(-0.867156613383085))[2]], [20, ((diff(x[30](t), t))(0) = HFloat(0.0))[2]], [22, ((x[31](t))(0) = HFloat(-1.05801345412645))[2]], [24, ((diff(x[31](t), t))(0) = HFloat(0.0))[2]], [26, ((x[32](t))(0) = HFloat(-1.23218479067164))[2]], [28, ((diff(x[32](t), t))(0) = HFloat(0.0))[2]], [30, ((x[33](t))(0) = HFloat(-1.38692383699642))[2]], [32, ((diff(x[33](t), t))(0) = HFloat(0.0))[2]], [34, ((x[34](t))(0) = HFloat(-1.51979026590362))[2]], [36, ((diff(x[34](t), t))(0) = HFloat(0.0))[2]], [38, ((x[35](t))(0) = HFloat(-1.62868869443883))[2]], [40, ((diff(x[35](t), t))(0) = HFloat(0.0))[2]], [42, ((x[36](t))(0) = HFloat(-1.71190172933128))[2]], [44, ((diff(x[36](t), t))(0) = HFloat(0.0))[2]], [46, ((x[37](t))(0) = HFloat(-1.76811705131164))[2]], [48, ((diff(x[37](t), t))(0) = HFloat(0.0))[2]], [50, ((x[38](t))(0) = HFloat(-1.79644811117089))[2]], [52, ((diff(x[38](t), t))(0) = HFloat(0.0))[2]], [54, ((x[39](t))(0) = HFloat(-1.79644811117089))[2]], [56, ((diff(x[39](t), t))(0) = HFloat(0.0))[2]], [58, ((x[40](t))(0) = HFloat(-1.76811705131164))[2]], [60, ((diff(x[40](t), t))(0) = HFloat(0.0))[2]], [62, ((x[41](t))(0) = HFloat(-1.71190172933128))[2]], [64, ((diff(x[41](t), t))(0) = HFloat(0.0))[2]], [66, ((x[42](t))(0) = HFloat(-1.62868869443883))[2]], [68, ((diff(x[42](t), t))(0) = HFloat(0.0))[2]], [70, ((x[43](t))(0) = HFloat(-1.51979026590362))[2]], [72, ((diff(x[43](t), t))(0) = HFloat(0.0))[2]], [74, ((x[44](t))(0) = HFloat(-1.38692383699642))[2]], [76, ((diff(x[44](t), t))(0) = HFloat(0.0))[2]], [78, ((x[45](t))(0) = HFloat(-1.23218479067164))[2]], [80, ((diff(x[45](t), t))(0) = HFloat(0.0))[2]], [82, ((x[46](t))(0) = HFloat(-1.05801345412645))[2]], [84, ((diff(x[46](t), t))(0) = HFloat(0.0))[2]], [86, ((x[47](t))(0) = HFloat(-0.867156613383085))[2]], [88, ((diff(x[47](t), t))(0) = HFloat(0.0))[2]], [90, ((x[48](t))(0) = HFloat(-0.66262419483242))[2]], [92, ((diff(x[48](t), t))(0) = HFloat(0.0))[2]], [94, ((x[49](t))(0) = HFloat(-0.447641796896737))[2]], [96, ((diff(x[49](t), t))(0) = HFloat(0.0))[2]], [98, ((x[50](t))(0) = HFloat(-0.225599820415749))[2]], [100, ((diff(x[50](t), t))(0) = HFloat(0.0))[2]]]

(4)

pointPlot := pointplot(dataPoints, symbol = solidcircle, symbolsize = 8, color = blue)

Error, (in plots:-pointplot) points cannot be converted to floating-point values

 
 

NULL

Download dsolve_fix_3.mw

@Hullzie16 These plots are created by Matlab for my research. You can read this post and maybe this will help you to understand what I want to create Numerical Simulation of the Discrete Klein-Gordon Equation: A Study on Damped, Driven Nonlinear Wave Systems with Spatially Extended Initial Conditions

@Hullzie16 I tried some ideas and Maple created some useful results, but still, I can not figure out how to create the above results. Thank you very much for your effort!

restart;
with(plots):

L := 200;
K := 99;
kappa := 1;
omegaD := 1;
beta := 1;
delta := 0.05;
j := 2;
tmax := 3000;
h := L/(K + 1);
nsp := [(-L/2 + h*i) $ (i = 0 .. L/h)]:
km := nops(nsp);
omegaD2 := h^2*omegaD^2;
deltaHat := h*delta;
a := 1.8;
var := seq(x[i](t), i = 1 .. km):
initialPositions := seq(x[i](0) = a*sin(j*h*Pi*nsp[i]/L), i = 1 .. km):
initialVelocities := seq(D(x[i])(0) = 0, i = 1 .. km):

200

 

99

 

1

 

1

 

1

 

0.5e-1

 

2

 

3000

 

2

 

101

 

4

 

.10

 

1.8

(1)

boundaryConditions := [x[1](t) = 0, x[km](t) = 0]

[x[1](t) = 0, x[101](t) = 0]

(2)

equations := seq(diff(x[n](t), t, t) - kappa*(x[n + 1](t) - 2*x[n](t) + x[n - 1](t)) + deltaHat*diff(x[n](t), t) - omegaD2^2*(x[n](t) - beta*x[n](t)^3) = 0, n = 2 .. km - 1), diff(x[1](t), t, t) = 0, diff(x[101](t), t, t) = 0:

sol := dsolve({equations, initialPositions, initialVelocities}, maxfun=0,numeric, method = rkf45,output=listprocedure)

`[Length of output exceeds limit of 1000000]`

(3)

# Use odeplot to plot the trajectory of x[50](t)
odeplot(sol, [[t, x[67](t)]], t = 0 .. 100, numpoints = 3500, title = "Trajectory of x[100](t)", axes = boxed, gridlines=true, color = ["Blue"], size = [500, 300]);

 

# Plot x[67](t) vs u[67](t) = diff(x[67](t), t)
odeplot(sol, [[x[67](t), diff(x[67](t), t)]], t = 0 .. 100, numpoints = 3500, title = "x_n vs u_n", axes = boxed, gridlines=true, color = ["Blue"], size = [500, 300]);

 
 

 

Download dsolve_fix_3.mw

Oh ok!! @acer I will have it on my mind. I will not do that again

 

@Hullzie16 When you try to plot it, do you receive results?

Using the following code 

odeplot(sol, [[t, x[100](t)]], t = 0 .. 3000, numpoints = 3500, title = "Trajectory of x[100](t)", axes = boxed, gridlines=true, color = ["Blue"], size = [600, 200]);

but I am looking for the plot a=2, at t=3000

@Hullzie16 Thank you, I appreciate that. The link that is attached is not working

If the symbolic approach is too cumbersome or doesn’t yield a solution that respects the boundary conditions well, a numerical solution is a more robust approach, especially when dealing with boundary conditions at infinity. Here's how you could proceed:

You can attempt to solve the ODE as a Bessel equation and apply boundary conditions to determine constants C1​ and C2.

Instead of dealing directly with x=−∞, choose a very large negative number as an approximation for infinity, say x=−100

Numerically, you can solve the ODE with approximated boundary conditions near −∞ using dsolve(..., numeric) in Maple.

1.pdf

Download solution.mw

@janhardo I tried to do it on my own without getting the results I wanted 

@janhardo The following is the code I use on Matlab. But from now on I want to do everything in Maple so I'm trying to get the same result 

% Parameters
L = 200;  % Length of the system
K = 99;  % Number of spatial points
j = 2;  % Mode number
omega_d = 1;  % Characteristic frequency
beta = 1;  % Nonlinearity parameter
delta = 0.05;  % Damping coefficient

% Spatial grid
h = L / (K + 1);
n = linspace(-L/2, L/2, K+2);  % Spatial points
N = length(n);
omegaDScaled = h * omega_d;
deltaScaled = h * delta;

% Time parameters
dt = 1; % Time step
tmax = 3000; % Maximum time
tspan = 0:dt:tmax; % Time vector

% Values of amplitude 'a' to iterate over
a_values = [2, 1.95, 1.9, 1.85, 1.82];  % Modify this array as needed

% Differential equation solver function
function dYdt = odefun(~, Y, N, h, omegaDScaled, deltaScaled, beta)
    U = Y(1:N);
    Udot = Y(N+1:end);
    Uddot = zeros(size(U));

    % Laplacian (discrete second derivative)
    for k = 2:N-1
        Uddot(k) = (U(k+1) - 2 * U(k) + U(k-1)) ;
    end

    % System of equations
    dUdt = Udot;
    dUdotdt = Uddot - deltaScaled * Udot + omegaDScaled^2 * (U - beta * U.^3);

    % Pack derivatives
    dYdt = [dUdt; dUdotdt];
end

% Create a figure for subplots
figure;

% Initial plot
a_init = 2;  % Example initial amplitude for the initial condition plot
U0_init = a_init *  sin((j * pi * h * n) / L); % Initial displacement
U0_init(1) = 0; % Boundary condition at n = 0
U0_init(end) = 0; % Boundary condition at n = K+1
subplot(3, 2, 1);
plot(n, U0_init, 'r.-', 'LineWidth', 1.5, 'MarkerSize', 10); % Line and marker plot
xlabel('$x_n$', 'Interpreter', 'latex');
ylabel('$U_n$', 'Interpreter', 'latex');
title('$t=0$', 'Interpreter', 'latex');
set(gca, 'FontSize', 12, 'FontName', 'Times');
 xlim([-L/2 L/2]);
ylim([-3 3]);
grid on;

% Loop through each value of 'a' and generate the plot
for i = 1:length(a_values)
    a = a_values(i);

    % Initial conditions
    U0 = a * sin((j * pi * h * n) / L); % Initial displacement
    U0(1) = 0; % Boundary condition at n = 0
    U0(end) = 0; % Boundary condition at n = K+1
    Udot0 = zeros(size(U0)); % Initial velocity

    % Pack initial conditions
    Y0 = [U0, Udot0];

    % Solve ODE
    opts = odeset('RelTol', 1e-5, 'AbsTol', 1e-6);
    [t, Y] = ode45(@(t, Y) odefun(t, Y, N, h, omegaDScaled, deltaScaled, beta), tspan, Y0, opts);

    % Extract solutions
    U = Y(:, 1:N);
    Udot = Y(:, N+1:end);

    % Plot final displacement profile
    subplot(3, 2, i+1);
    plot(n, U(end,:), 'b.-', 'LineWidth', 1.5, 'MarkerSize', 10); % Line and marker plot
    xlabel('$x_n$', 'Interpreter', 'latex');
    ylabel('$U_n$', 'Interpreter', 'latex');
    title(['$t=3000$, $a=', num2str(a), '$'], 'Interpreter', 'latex');
    set(gca, 'FontSize', 12, 'FontName', 'Times');
      xlim([-L/2 L/2]);
ylim([-2 2]);
    grid on;
end

% Adjust layout
set(gcf, 'Position', [100, 100, 1200, 900]); % Adjust figure size as needed

@janhardo  The below worksheet has some changes that are needed but still, the plot is not the desired. Firstly, I want to be sure that the code gives me the desired results. In the initial post, there is what I want to create

restart; Digits := 15; with(plots)

L := 200; K := 99; j := 2; omega_d := 1; beta := 1; delta := 0.5e-1

NULL

h := L/(K+1); n := Vector([`$`(-(1/2)*L+h*i, i = 0 .. K+1)])

_rtable[36893488152112297132]

(1)

dt := 0.5e-1; tmax := 300; num_steps := ceil((tmax+0)/dt); tspan := [seq(0+dt*i, i = 0 .. trunc(tmax/dt))]

6000

(2)

omegaDScaled := h*omega_d; deltaScaled := h*delta

.10

(3)

a := 1.9; U0 := a*map(proc (x) options operator, arrow; evalf(sin(j*Pi*h*x/L)) end proc, n); U0[1] := 0; U0[K+2] := 0; Udot0 := Vector(K+2, 0)

discrete_laplacian := proc (U) local i, Laplacian; Laplacian := Vector(K+2); for i from 2 to K+1 do Laplacian[i] := U[i+1]-2*U[i]+U[i-1] end do; Laplacian[1] := 0; Laplacian[K+2] := 0; return Laplacian end proc

NULL

U := U0; Udot := Udot0; TT := 'TT'; for t to num_steps do Lap := discrete_laplacian(U); Ucube := map(proc (x) options operator, arrow; x^3 end proc, U); for i from 2 to K+1 do Udot[i] := Udot[i]+dt*(2*omegaDScaled^2*U[i]-delta*Udot[i]-deltaScaled*Ucube[i]+Lap[i]) end do; for i from 2 to K+1 do U[i] := dt*Udot[i]+U[i] end do; U[1] := 0; U[K+2] := 0; if `mod`(t, 100) = 0 then plotU := plot(n, U, style = pointline, color = blue, title = cat("Displacement at t=", t*dt), labels = ["n", "Displacement"], grid = [true, true]); TT[t] := plotU; DocumentTools:-Tabulate([plotU]) end if end do

NULL

Download v2.mw

@acer The animation is very useful indeed. Could I create a procedure that runs different values of alpha without changing alpha every time? 

For example alpha={2, 1.91, 1.9}

@C_R  I tried to plot the TSUCS2 Attractor with the command odeplot. However, I could not find a way to create the nice colorful output like with the DEplot above

The Lorenz attractor can be compressed and distorted along the double scrolls. Then, with trial-and-error numerical simulations, found a new chaotic attractor from the following three-dimensional quadratic autonomous system with four smooth quadratic terms:NULLNULL

"x'=a(y-x)+dxz,"NULL

"y'=cx-xz+fy,"NULLNULL

diff(z(x), x) = -ex^2+bz+xy 

where the coefficients a, b, c,d,e, and f are adjustable constants.

 

This new strange attractor has recently been called a Lorenz-like attractor.

restart; with(plots)NULL

a := 40.00; b := 1.833; c := 55; d := .16; e := .65; f := 20

sys := {diff(x(t), t) = a*(y(t)-x(t))+d*x(t)*z(t), diff(y(t), t) = c*x(t)-x(t)*z(t)+f*y(t), diff(z(t), t) = b*z(t)+x(t)*y(t)-e*x(t)^2}

{diff(x(t), t) = 40.00*y(t)-40.00*x(t)+.16*x(t)*z(t), diff(y(t), t) = 55*x(t)-x(t)*z(t)+20*y(t), diff(z(t), t) = 1.833*z(t)+x(t)*y(t)-.65*x(t)^2}

(1)

ics := {x(0) = 1, y(0) = 1, z(0) = 1}

{x(0) = 1, y(0) = 1, z(0) = 1}

(2)

sol := dsolve(`union`(sys, ics), {x(t), y(t), z(t)}, numeric, range = 0 .. 200, maxfun = 0, output = listprocedure)

`[Length of output exceeds limit of 1000000]`

(3)

odeplot(sol, [x(t), y(t), z(t)], t = 0 .. 50, numpoints = 100000, thickness = .9, color = "Navy", linestyle = solid, title = `TSUCS2 Attractor`, titlefont = ["ROMAN", 15])

 

References

1. 

A New Three-Scroll Unified Chaotic System Coined

NULL

Download TSUCS2.mw

1 2 3 4 5 6 Page 3 of 6