Maple Questions and Posts

These are Posts and Questions associated with the product, Maple


 

Analysis of the semiclassical (SC) momentum rate equations

Plotting the ICs and BCs and examining sensitivity to the Re and Im forces

MRB: 24/2/2020, 27/2/2020, 2/3/2020.

We examine solution of the SC version of the momentum rate equations, in which O`ℏ`^2 terms for u(x, t) are removed. A high level of sensitivity to ICs and BCs makes solution finding difficult.

restart;

with(PDETools): with(CodeTools):with(plots):

We set up the initial conditions:

ICu := {u(x, 0) = .1*sin(2*Pi*x)}; ICv := {v(x, 0) = .2*sin(Pi*x)};

{u(x, 0) = .1*sin(2*Pi*x)}

 

{v(x, 0) = .2*sin(Pi*x)}

(1)

plot([0.1*sin(2*Pi*x),0.2*sin(Pi*x)],x = 0..2, title="ICs:\n u(x,0) (red), v(x,0) (blue)",color=[red,blue],gridlines=true);  

 

The above initial conditions represent a positive velocity field v(x, 0) (blue) and a colliding momentum field u(x, t)(red).

 

Here are the BCs

BCu := {u(0,t) = 0.5*(1-cos(2*Pi*t))};

{u(0, t) = .5-.5*cos(2*Pi*t)}

(2)

BCv := {v(0,t) = 0.5*sin(2*Pi*t),v(2,t)=-0.5*sin(2*Pi*t)};  

{v(0, t) = .5*sin(2*Pi*t), v(2, t) = -.5*sin(2*Pi*t)}

(3)

plot([0.5*(1-cos(2*Pi*t)),0.5*sin(2*Pi*t),-0.5*sin(2*Pi*t)],t=0..1,color=[red,blue,blue],linestyle=[dash,dash,dot],title="BCs:\n u(0,t) (red-dash),\n v(0,t) (blue-dash), v(1,t) (blue-dot)",gridlines=true);

 

 

We can now set up the PDEs for the semiclassical case.

hBar:= 1:m:= 1:Fu:= 0.2:Fv:= 0.1:#1.0,0.2

pdeu := diff(u(x,t),t)+u(x,t)/m*(diff(u(x,t),x)) = Fu;

diff(u(x, t), t)+u(x, t)*(diff(u(x, t), x)) = .2

(4)

pdev := diff(v(x,t),t)+u(x,t)/m*(diff(v(x,t),x))-hBar*(diff(u(x,t),x$2))/(2*m)+v(x,t)*(diff(u(x,t),x))/m = Fv;  

diff(v(x, t), t)+u(x, t)*(diff(v(x, t), x))-(1/2)*(diff(diff(u(x, t), x), x))+v(x, t)*(diff(u(x, t), x)) = .1

(5)

ICu:={u(x,0) = 0.1*sin(2*Pi*x)};  

{u(x, 0) = .1*sin(2*Pi*x)}

(6)

ICv:={v(x,0) = 0.2*sin(Pi*x/2)};  

{v(x, 0) = .2*sin((1/2)*Pi*x)}

(7)

IC := ICu union ICv;  

{u(x, 0) = .1*sin(2*Pi*x), v(x, 0) = .2*sin((1/2)*Pi*x)}

(8)

BCu := {u(0,t) = 0.5*(1-cos(2*Pi*t)), D[1](u)(2,t) = 0.1*cos(2*Pi*t)};

{u(0, t) = .5-.5*cos(2*Pi*t), (D[1](u))(2, t) = .1*cos(2*Pi*t)}

(9)

BCv := {v(0,t) = 0.2*(1-cos(2*Pi*t))};  

{v(0, t) = .2-.2*cos(2*Pi*t)}

(10)

BC := BCu union BCv;  

{u(0, t) = .5-.5*cos(2*Pi*t), v(0, t) = .2-.2*cos(2*Pi*t), (D[1](u))(2, t) = .1*cos(2*Pi*t)}

(11)

We now set up the PDE solver:

pds := pdsolve({pdeu,pdev},{BC[],IC[]},time = t,range = 0..2,numeric);#'numeric' solution

_m2592591229440

(12)

Cp:=pds:-animate({[u, color = red, linestyle = dash],[v,color = blue,linestyle = dash]},t = 30,frames = 400,numpoints = 400,title="Semiclassical momentum equations solution for Re and Im momenta u(x,t) (red) and v(x,t) (blue) \n under respective constant positive forces [0.2, 0.1] \n with sinusoidal boundary conditions at x = 0, 1 and sinusoidal initial conditions: \n time = %f ", gridlines = true,linestyle=solid):Cp;

Error, (in pdsolve/numeric/animate) unable to compute solution for t>HFloat(0.0):
Newton iteration is not converging

 

Cp

(13)

Observations on the quantum case:

The classical equation for u(x, t) is independent of the equation for v(x, t).  u(x, t) (red) is a solution of the classical Burgers equation subject to a force 0.2, but u(x, t) is NOT influenced by v(x, t).  On the otherhand, v(x, t) (blue) is a solution of the quantum dynamics equation subject to force 0.1 and is influenced by u(x, t).   This one way causality (u " implies v")  is a feature of the semiclassical case, and it emphasises the controlling influence of the classical u(x, t), which modulates the quantum solution for v(x, t).  Causally, we have u" implies v".

 

The initial conditions are of low momentum amplitude:"+/-"0.1 for the classical u(x, 0) (red) field and`&+-`(0).2 for v(x, 0) (blue)  but their influence is soon washed out by the boundary conditions "u(0,t) ~1, v(0,t)~0.5" and "v(1,t)~0.5" that drive the momentum dynamics.

 

The temporal frequency of the boundary condition on the v-field is twice that of the classical u-field. This is evident in the above blue transient plot. Moreover, the">=0" boundary condition on the classical u-momentum (red), drives that field in the positive direction, initially overtaking the quantum v(x, t) field, as consistent with the applied forces [0.2, 0.1]. NULLAlthough initially of greater amplitude than the classical u(x, t)field, the v(x, t) momentum field is asymptotically of the same amplitude as the u(x, t) field, but has greater spatial and temporal frequency, owing to the boundary conditions.

 

Referring to the semiclassical momentum rate equations, we note that the classical field u(x, t) (red) modulates the quantum momentum rate equation for v(x, t).

``

 

 

 


 

Download SC-plots.mw

I am having difficulty getting solutions to a pair of PDEs.  Would anyone like to cast an eye over the attached file, incase I am missing something.

Thanks

Melvin

Hi everybody, I’m Helena

I have a function with the following general characteristics:

y= const*M*[Int_def (from a to b) [f(x)*g(x, M)*p(x, t, M,K)]dx]

::::::::::::::::::::::::::::::::::::::::::::::::::

y= dependent variable

a= 1.76E-7

b= 1.76E-9

x= integration variable

M= unknown parameter

K= unknown parameter

t= independent variable

::::::::::::::::::::::::::::::::::::::::::::::::::

... and I'm trying to fit it to my experimental data (421 values), to determine the best values for M and K. In order to do that I’m using the package Statistic and the NonlinearFit command from maple, however, it seems that NonlinearFit cannot fit the model (y(t)) to the experimental data. It gives an error: “Error, (in Statistics:-NonlinearFit) integration range or variable must be specified in the second argument, got HFloat(1.0) = 0 .. 1” for which I could not find any explanation or solution on the internet. Could you please give me some advice or ideas about how can I solve this problem?

Thank you so much in advance for your attention and help.

Hi, I would like to represent the piecewise function as a Bar Graph. I can only get a line Graph. Thanks in advance.
 

EXAMPLE 8 Interior Design Services Employees

 

"N(t):={[[-4.64 t +76.2 ,7<=t<=10],[0.90 t+20.0,11<=t<=12]]"

proc (t) options operator, arrow, function_assign; piecewise(7 <= t and t <= 10, -4.64*t+76.2, 11 <= t and t <= 12, .90*t+20.0) end proc

(1)

"->"

 

 

For 2007:

N(7) = 43.72 thousand employees

For 2011:

N(11) = 29.90 thousand employees``


 

Download Ch1_3_Functions_Exam8.mw

 Recently I often drew some graphs in Graph Theory  by Maple. I tried to use DrawGraph, but  I found that evey edge only meets straight line  style in this package.

For example: 

restart:
with(GraphTheory):
with(SpecialGraphs):
a:=CycleGraph(8):
DrawGraph(a)

 

How do I draw some edges with curve syle in graph? like following:

 

 

 

Thanks!

 

 

 

In answer to a previous question (https://www.mapleprimes.com/questions/228965-How-Can-I-Save-A-Record) acer introduced me to the .mla archives as a possible store location for variables.

I have been working with this and now end up having 4 .mla files (called results1.mla...results4.mla) that each hold output from some lengthy batch running of maple. Each of these has two tables with values called Beams and Beams2 (same name in each of these archives). While named the same the content is different.

My question is: How do I get at each of these? As acer explained, the content (i.e. the tables Beams and Beams2) is mapped into the namespace of the Maple session once libname includes the directory where the .mla files sit. They are actually in the same directory as the associated Maple programs so they mask each other.

I tried to juggle libname prepending the .mla file I want to the rest; but that does not seem to work (I always get the same data). I do need the data all in one worksheet for collating and postprocessing and display.

TIA,

M.D.

Hi everybody:

How can I solve this system of nonlinear equations without use the fsolve command?

eq[1] := -3*c[0]+3*c[1] = c[0]*(1-259*d[0]*(1/192)+43*d[1]*(1/64)-11*d[2]*(1/64)+(1/64)*d[3])-23/6;
eq[2] := -3*d[0]+3*d[1] = d[0]*(-2+23*c[0]*(1/80)+139*c[1]*(1/320)-17*c[2]*(1/160)+3*c[3]*(1/320))-1;
eq[3] := -4*c[0]*(1/3)+c[2]+(1/3)*c[3] = (8*c[0]*(1/27)+4*c[1]*(1/9)+2*c[2]*(1/9)+(1/27)*c[3])*(1-2657*d[0]*(1/5184)-343*d[1]*(1/1728)-185*d[2]*(1/1728)-79*d[3]*(1/5184))-3;
eq[4] := -4*d[0]*(1/3)+d[2]+(1/3)*d[3] = (8*d[0]*(1/27)+4*d[1]*(1/9)+2*d[2]*(1/9)+(1/27)*d[3])*(-2+109*c[0]*(1/8640)+553*c[1]*(1/1440)+559*c[2]*(1/2880)+37*c[3]*(1/1080))-5/6;
eq[5] := -(1/3)*c[0]-c[1]+4*c[3]*(1/3) = ((1/27)*c[0]+2*c[1]*(1/9)+4*c[2]*(1/9)+8*c[3]*(1/27))*(1-673*d[0]*(1/5184)-455*d[1]*(1/1728)-505*d[2]*(1/1728)-767*d[3]*(1/5184))-49/27;
eq[6] := -(1/3)*d[0]-d[1]+4*d[3]*(1/3) = ((1/27)*d[0]+2*d[1]*(1/9)+4*d[2]*(1/9)+8*d[3]*(1/27))*(-2-173*c[0]*(1/4320)+241*c[1]*(1/2880)+59*c[2]*(1/180)+2191*c[3]*(1/8640))-11/36;
eq[7] := c[0] = 1;
eq[8] := d[0] = 0;

tnx...

I'm trying to Graph a Piecewise Defined Function.

j(x) = piecewise(x < 0, x^2 + 1, 0 <= x, x - 1);

It doesn't provide a plot option.

Download piecewisegraph.mw


 

Function Misrepresented

y^2-x = 1"(->)"[[y = (x+1)^(1/2)], [y = -(x+1)^(1/2)]]NULL

NULL

 

Expected output for y

 

y = `&+-`(sqrt(1+x))

 

Yes it's the same meaning but i would like less to look at.


 

Download funct_misrep.mw


data := [[0., 9.1300, 0.931e-1, 0.899e-1, .1000, 0.], [30.0000, 8.9300, .1270, .1230, .2270, 0.49e-2], [60.0000, 8.6000, .1510, .1390, .4920, 0.153e-1], [90.0000, 8.2800, .1540, .1490, .7780, 0.249e-1], [120.0000, 7.9700, .1540, .1570, 1.0700, 0.329e-1], [150.0000, 7.8600, .1540, .1600, 1.1700, 0.348e-1], [180.0000, 7.8100, .1530, .1530, 1.2100, 0.404e-1], [210.0000, 7.7700, .1400, .1420, 1.2800, 0.432e-1]];
des := [diff(y1(t), t) = -k1*y1(t)-k2*y1(t), diff(y2(t), t) = k2*y1(t)-k3*y2(t), diff(y3(t), t) = k1*y1(t)+k3*y2(t)-k4*y3(t), diff(y4(t), t) = k4*y3(t)-k5*y2(t)*y4(t)+k6*y5(t), diff(y5(t), t) = k5*y2(t)*y4(t)-k6*y5(t)];
ics := seq((y || i)(0) = data[1, i+1], i = 1 .. 5):
Error, unable to match delimiters
Typesetting:-mambiguous(Typesetting:-mambiguous(ics Assign seq

  lparlpary verbarverbar irpar(0) equals data(1comma i + 1)comma 

  i equals 1 periodperiod 5rparcolon, 

  Typesetting:-merror("unable to match delimiters")))
res := dsolve({ics, des[]}, numeric, parameters = [k1, k2, k3, k4, k5, k6]);
Error, (in dsolve/numeric/process_input) system must be entered as a set/list of expressions/equations
timeList := [0, 30, 60, 90, 120, 150, 180, 210];
              [0, 30, 60, 90, 120, 150, 180, 210]
sse := proc (k1, k2, k3, k4, k5, k6) res(parameters = [k1, k2, k3, k4, k5, k6]); add((rhs(select(has, res(timeList[i]), y1)[])-data[i, 2])^2+(rhs(select(has, res(timeList[i]), y2)[])-data[i, 3])^2+(rhs(select(has, res(timeList[i]), y3)[])-data[i, 4])^2+(rhs(select(has, res(timeList[i]), y4)[])-data[i, 5])^2+(rhs(select(has, res(timeList[i]), y5)[])-data[i, 6])^2, i = 2 .. 8) end proc;
proc(k1, k2, k3, k4, k5, k6)  ...  end;
c := GlobalOptimization:-GlobalSolve(('sse')(k1, k2, k3, k4, k5, k6), k1 = 0 .. 1, k2 = 0 .. 1, k3 = 0 .. 1, k4 = 0 .. 1, k5 = 0 .. 1, k6 = 0 .. 1, timelimit = 10); [.219132447080011505, [k1 = 0.852482740113834e-3, k2 = 0.52683998680924474e-4, k3 = 0., k4 = 0.5113239298267808e-1, k5 = 0.4363021255887466e-2, k6 = 0.]];
Error, `GlobalOptimization` does not evaluate to a module
[0.219132447080011505, [k1 = 0.000852482740113834, 

  k2 = 0.000052683998680924474, k3 = 0., 

  k4 = 0.05113239298267808, k5 = 0.004363021255887466, k6 = 0.]]

res(parameters = c[2]):  p:=Array(1..5):  for n from 1 to 5 do     p[n]:=plots:-display(plots:-odeplot(res, [t, (y || n)(t)], t = 0 .. 210),plots:-pointplot([seq([data[i, 1], data[i, n+1]], i = 1 .. 8)]));  end do; plots:-display(p) ;
Error, unable to match delimiters
Typesetting:-mambiguous(Typesetting:-mambiguous(res(parameters 

  equals c(2))colon  pAssignArray(1periodperiod5)colon  for n 

  from 1 to 5 do     p(n)Assignplotscolon - displaylparplotscolon

   - odeplotlparrescomma lsqbtcomma lpary verbarverbar nrpar(t)

  rsqbcomma t equals 0 periodperiod 210rparcommaplotscolon - 

  pointplot((seq((data(icomma 1)comma data(icomma n + 1))comma i 

  equals 1 periodperiod 8)))rparsemi  end dosemi plotscolon - 

  display(p) , Typesetting:-merror("unable to match delimiters")))

 I cannot solve this equation. Please help me

How can I use maple to get the numerical solution of this non-autonomous system

sys_ode := diff(x(t), t) = ax(t)-bx(t)y(t)+2sin(t), diff(y(t), t) = -cy(t)+dx(t)y(t)

where a,b,c,d is parameters, they can take any value.

Hi! 

 

I'm having a weird issue. :( 

DEplot command worked when I initially ran the executed it, but then when I executed the entire worksheet, it didn't plot. Instead I just get this output. 

 

This is the entire worksheet so far without the output. 

 

If someone could please help me, I would greatly appreciate it!!!!!

 


restart;
with(DEtools);

eq1 := diff(y(x), x) = 3*x*y(x);

dsolve(eq1, y(x));

ini1 := y(0) = 3;

dsolve({eq1, ini1}, y(x));

ini2 := y(1) = -3;

dsolve({eq1, ini2}, y(x));

eq2 := y(x)*diff(y(x), x) = -x;

dsolve(eq2, y(x));

dsolve({eq2, ini1}, y(x));

restart;
with(plots);

eq := diff(y(x), x) = 3*x*y(x);

ini := y(0) = 5;


dsolve({eq, ini}, y(x));




sol := rhs(%);

plot(sol, x = -2 .. 2, y = 0 .. 10);
DEplot(eq, y(x), x = -2 .. 2, y = 0 .. 10, [[ini]]);





 

Does anyone use MTM toobox and why?

 

I discovered this through the eig help search and found the MATLAB format of [V, D] = eig(Matrix) for eigenvectors and eigenvalues as a single function call with output a nice shortcut vs two calls to LinearAlgebra[Eigenvalues], LinearAlegebra[Eigenvectors]

 

But, is the overhead and overmapping of standard maple functions worth it?   I find very little descriptions about the Maple Toolbox, specifically the MTM package.

Hi everyone:

how can I obtain the B from A?

A:=u[1, 0](t)*v[1, 3](t)+u[1, 1](t)*v[1, 2](t)+u[1, 2](t)*v[1, 1](t)+u[1, 3](t)*v[1, 0](t)
B:=u[1, 0](t)*v[1, 3](tau)+u[1, 1](t)*v[1, 2](tau)+u[1, 2](t)*v[1, 1](tau)+u[1, 3](t)*v[1, 0](tau)

tnx... 

The binary search algorithm is used to obtain the index of a given number by dividing the search bound in half over iteration. If the value entered in the array a message pop up telling that ''value is not present in the array". Please see the code. 
 

restart; with(ArrayTools); AA := Array(1 .. 10, [20, 2, 30, 4, 50, 7, 60, 8, 90, 100]); AA := sort(AA); KEYVALUE := 200; DUP_KEYVALUE := infinity; low := 1; high := NumElems(AA); while DUP_KEYVALUE <> KEYVALUE do mid := floor((low+high)*(1/2)); if AA[mid] = KEYVALUE then DUP_KEYVALUE := KEYVALUE; printf("%s\n %a\n", "the index is ", mid) elif AA[mid] < KEYVALUE then low := mid+1 elif AA[mid] > KEYVALUE then high := mid-1 end if; if low > high then printf("%s\n", "value not present in the array"); break end if end do


 

Download BINARY_SEARCH1.mw

 

First 457 458 459 460 461 462 463 Last Page 459 of 2097