Maple 2019 Questions and Posts

These are Posts and Questions associated with the product, Maple 2019

from help, it says about option of 'spacestep'=numeric to pdsolve numerical solver the following

Specifies the spacing of the spatial points on the discrete mesh on which the solution 
is computed, and defaults to 1/20th of the spatial range of the problem, 
r-L, where L is the left boundary, and r is the right. Note: The spacing must 
be small enough that a sufficient number of points are in the spatial domain 
for the given method, boundary conditions, and spatial interpolation (see below). 
If the given value of spacestep does not fit into the input domain an integral 
number of times, the closest smaller step size that does is used. For problems 
using error estimates, or an adaptive approach, the total number of spatial 
points must be odd, so again, if this is not the case for the specified 
spacestep, then it is reduced to satisfy this requirement.

In this problem, the domain is [-1,1]. So the default is 1/20 of this which is 1/10.  Why is it when using spacestep smaller than 1/11, the animator generated from the solution does not work right?  i.e. playing the animate does not produce correct result as the case when using spacestep=1/11 or spacestep=1/10?   

When using spacestep=1/16 or 1/15 or 1/14 or 1/13 or 1/12, it all produce bad animation.  I do not see why that is. 

Any ideas?  Am I doing something wrong?
 

pde := diff(u(x,t),t$2)=diff(u(x,t),x$2):
bc  := u(-1,t)=u(1,t),D[1](u)(-1,t)=D[1](u)(1,t):
f:=x->piecewise(-1/2<x and x<0,x+1/2,0<x and x<1/2,1/2-x,true,0):
plot(f(x),x=-1..1):
ic  := u(x,0)=f(x),D[2](u)(x,0)=0:
sol:=pdsolve(pde,{bc,ic},u(x,t),numeric,time=t,range=-1..1,  timestep=1/16,spacestep=1/16)

_m1793827573184

sol:-animate(t=1,frames=50,title="time = %f");

sol:=pdsolve(pde,{bc,ic},u(x,t),numeric,time=t,range=-1..1,  timestep=1/16,spacestep=1/12):
sol:-animate(t=1,frames=50,title="time = %f");

sol:=pdsolve(pde,{bc,ic},u(x,t),numeric,time=t,range=-1..1,  timestep=1/16,spacestep=1/11):
sol:-animate(t=1,frames=50,title="time = %f");

 

 

Download solving_wave_pde_2.mw

 

 

When solving this 1D wave PDE numerically, if the range used is -Pi..Pi then I get this error

sol:-plot(t=0,numpoints=100);
Error, (in Vector) unable to store '-Pi' when datatype=float[8]

When trying to plot the solution. Changing the range to -1..1 the error goes away.

I would expect the numerical solver to handle these things automatically? 

Please see attached worksheet.   How to work around this if one wants to use range from -Pi..Pi?

 

#wave PDE with periodic BC.
restart;

pde := diff(u(x,t),t$2)=diff(u(x,t),x$2);
bc  := u(-Pi,t)=u(Pi,t),D[1](u)(-Pi,t)=D[1](u)(Pi,t);
f:=x->piecewise(-Pi/2<x and x<Pi/2,1,true,0);
plot(f(x),x=-Pi..Pi);
ic  := u(x,0)=f(x),D[2](u)(x,0)=0;
sol:=pdsolve(pde,{bc,ic},u(x,t),numeric,time=t,range=-Pi..Pi)

pde := diff(u(x, t), t, t) = diff(u(x, t), x, x)

bc := u(-Pi, t) = u(Pi, t), (D[1](u))(-Pi, t) = (D[1](u))(Pi, t)

f := proc (x) options operator, arrow; piecewise(-(1/2)*Pi < x and x < (1/2)*Pi, 1, true, 0) end proc

u(x, 0) = piecewise(-(1/2)*Pi < x and x < (1/2)*Pi, 1, 0), (D[2](u))(x, 0) = 0

_m1174810042944

sol:-plot(t=0,numpoints=100);

Error, (in Vector) unable to store '-Pi' when datatype=float[8]

pde := diff(u(x,t),t$2)=diff(u(x,t),x$2);
bc  := u(-1,t)=u(1,t),D[1](u)(-1,t)=D[1](u)(1,t);
f:=x->piecewise(-1/2<x and x<1/2,1,true,0);
plot(f(x),x=-1..1);
ic  := u(x,0)=f(x),D[2](u)(x,0)=0;
sol:=pdsolve(pde,{bc,ic},u(x,t),numeric,time=t,range=-1..1)

pde := diff(u(x, t), t, t) = diff(u(x, t), x, x)

bc := u(-1, t) = u(1, t), (D[1](u))(-1, t) = (D[1](u))(1, t)

f := proc (x) options operator, arrow; piecewise(-1/2 < x and x < 1/2, 1, true, 0) end proc

u(x, 0) = piecewise(-1/2 < x and x < 1/2, 1, 0), (D[2](u))(x, 0) = 0

_m1174805392512

sol:-plot(t=0,numpoints=100);

 


 

Download solving_wave_pde.mw

The problem is to find a100 for a sequence defined as follows.


https://snipboard.io/AdZKX5.jpg I tried the following command for a recursive sequence.
(I used 10 instead of 100 to test run it).

a||1:=1;
for n from 2 to 10 do a||n:=2*sum( a||i ,i=1..n)^2/(2*sum( a||i ,i=1..n)-1); od;

This approach did not work. It says "error recursive assignment"

Any ideas how to get a(100), also if its possible how to solve the recursive sequence explicitly.

I tried rsolve :

rsolve({ f(n)=(2*sum(f(i),i=1..n)^2/(2*sum(f(i),i=1..n)-1)),f(1)=1},f(n))
rsolve({ f(n)=(2*sum(f(i),i=1..n)^2/(2*sum(f(i),i=1..n)-1)),f(1)=1},f(n))

It just returned back the expression inertly.

 

I expect the output for the following code to be a Matrix containing 720 and a Matrix containing 21. What I get is a Matrix containing x^6 and one containing 21, which shows an unexpected difference between the parameter evaluation rule for Matrix products and that for Matrix sums. Is there a good reason for this, or is it a bug? Do any other binary operators between rtables also show this weirdness? 

proc(n::nonnegint) 
local x, q, v:= <<x>>, s:= <<0>>, p:= <<1>>; 
   for x to n do p:= p.v; s:= s+v od; 
   p, s 
end proc(6);

 

Why does the following code return a vector containing x rather than containing 1 and how can I correct it?

proc() local x, v:= <x>; x:= 1; rtable_eval(v) end proc();

My actual goal is to have a Matrix with a parameter inside a procedure and to create different instantiations of the Matrix in a loop by changing the parameter. 

I can't figure out the source of the problem.  Any ideas?

restart;

with(Physics[Vectors]):

Physics:-Version();

"/usr/local/opt/maple2019/lib/update.mla", `2019, May 21, 20:18 hours, version in the MapleCloud: 445, version installed in this computer: the "Physics Updates" is not installed.`

3.0*_i + 4.0*_j;

3.0*_i+4.0*_j

3.0*_i + 0.0*_j;

Error, (in Physics:-Vectors:-+) wrong sum of a vector with the scalar 0.

 

How do we handle this when it happens within a computation burried inside a proc?

Download mw.mw

 

Hello

I have maple code saved as a text file f.txt.

It resides here

mydd:=“C:/Users/User/Downloads/f.txt”

what is the most expedient way to convert to f.mpl ?

I have an arc length parametrization problem. I got the right answer for the speed. The lines of code before the long dividing line I successfully got to work. The main problem I am having is with the code underneath that. It is producing weird answers and just returning the same words without computing any mathematical calculation.

 

with(VectorCalculus):

with(plots):

T:= 4:

r := t -> <t^2 + t, sin(t^2)*(t + 1), cos(t^2)*(t + 1)>;

speed := Norm(diff(r(t), t));

evalf(Int(speed, t = 0 .. T)); (I got 62.98633182 for this part)

----------------------------This is where I started running into problems with the arc length parametrization.

L := b -> int(speed, t = 0 .. b);

speed := t -> subs(c = t, Norm(diff(r(c), c)));

speed2 := t -> sqrt(factor(simplify(speed(t)^2)));

solve(s = L(t), s);

assume(b > 0 'real');

g := s -> solve(s = L(b), b, useassumptions = true);

newr := s -> r(g(s));

newr(s);

 

I have written the function V(R) in Maple like this:

"V(R) := D_e * (1 - exp(-a * (R - R_e)))^2"

Where D_e, a and R_e are constants but Maple evaluates them as variables. Then before the function I have now written:

"Parameters(D_e, a, R_e)" and even "constants := D_e, a, R_e" (if that helps)

I would like to find the limit as R approaches infinity, but Maple just substitutes R with ∞ in the function. The answer should just be D_e, and not "D_e * (1 - exp(-a * (∞ - R_e)))^2"

Thanks for any help out there :)

 I'd like to get all at most 15 vertices Non-isomorphic  connected  bipartite graphs. One way is to use the function NonIsomorphicGraphs(k, output = graphs, outputform = graph, restrictto = connected).

with(GraphTheory):

k:=8;
s1:=[NonIsomorphicGraphs(k,restrictto = connected,output=graphs,outputform=graph)]:
bipartitegraph:=select[flatten](x->IsBipartite(x)=true, s1):
nops(bipartitegraph);

But when k=9, it is slow, I doubted that the code 

By Checking out the encyclopedia,http://oeis.org/A033995 , we knew the following number of bipartite graphs datas of , at most 14, they are not many(the datas contain  no-connected conditions)

 

so I read the help document about  

awesome.

Ps: I know  in SageMath  we can get all bipartite graphs quikly even though n>=10  by  using the 

for g in graphs.nauty_geng('-c -b 10 -g'):
 
But I hope it can be realized in Maple. 

Thanks!

 

When I use block of 'if' in procedure Work I see empty graph. If there are no 'if' everything works properly

 

with(Maplets);
with(Elements);
with(Tools);
with(plots):
work := proc() local f, k, x0, y0, result, l;
l := Get(L::algebraic);
x0 := Get(X::algebraic);
y0 := Get(Y::algebraic);
result := subs(x = x0, l);
f := plot(l);
k := plots:-pointplot([x0, y0]);
plots[plots:-display]({f, k});

 

THESE BLOCK OF 'if'
if result = y0 then Set(res = "Belongs");
elif y0 < result then return Set(res = "Above");
elif result < y0 then return Set(res = "Below");
end if;


end proc;

 

mpt := Maplet(Window("Test", [[Plotter[f]()],
["Line eq", TextField[L]()],
["X ", TextField[X]()],
["Y ", TextField[Y]()],
["Result ", TextField[res](editable = false)],
[Button("Результат", Evaluate(f = 'work()')), Button("OK", Shutdown([res]))]]));


Display(mpt);

 

With block of 'if'

Without block of 'if'

Hi, I'm importing an Excel file then trying to feed it to FrequencyTable. While it works, it shows me some range intervals that seem to be calculated by the function. I would like to use a specific interval, but I can't find what parameter to use. Bins won't do the trick, since it doesn't let me specify the range. 

Thanks in advancce. 

I got a list containing all non isomorphic connected graphs with 6 vertices. Total number of the list members is 112 , and they are not too many . So I want to draw them all . It is good for Maple worksheet .
 
In order to save it and print it out on paper, I import it as pdf form . But the problem is that every page in pdf only contains 8 graphs . It wastes wasted too many spaces. It is unreasonable . I want to draw 20-30 graphs in one page of pdf. What is the solution to my problems? Thanks in advance. This problem has puzzled me for a long time.

with(GraphTheory):
s1:=[NonIsomorphicGraphs(6,restrictto = connected,output=graphs,outputform=graph)]:
DrawGraph~(s1);

 

fourthNONLINEARBOUD234.mwfourthNONLINEARBOUD234.mw
 

``

NULL

NULL

NULL

[0., 0, 0.]

(1)

restart

with(LinearAlgebra)

``

for i to 1 do for j from 0 by .1 to 1 do Exact[j] := exp(j); Y[0] := proc (x) options operator, arrow; 1+x-(58/9)*x^2-3*x^2*exp(1)+(64/9)*x^2*exp(3/4)+(40/9)*x^3+4*x^3*exp(1)-(64/9)*x^3*exp(3/4) end proc; Ics := Z(0) = 1, (D(Z))(0) = 1, Z(1) = exp(1), Z(3/4) = exp(3/4); exp(-x) := convert(taylor(exp(-x), x = 0, 5), polynom); f := proc (x) options operator, arrow; 0 end proc; p := proc (x) options operator, arrow; 0 end proc; q := proc (x) options operator, arrow; 0 end proc; r := proc (x) options operator, arrow; 0 end proc; u := proc (x) options operator, arrow; 0 end proc; eq[i] := diff(Z(x), `$`(x, 4)) = 0.1e-2*(diff(Y[i-1](x), `$`(x, 4)))+.999*(f(x)+exp(-x)*Y[i-1](x)*Y[i-1](x)); s[i] := dsolve({Ics, eq[i]}, Z(x)); Y[i] := unapply(op(2, s[i]), x); App[j] := evalf(Y[i](j)); Er[j] := abs(App[j]-Exact[j]); A[i] := print([App[j], Exact[j], Er[j]]) end do end do

[1., 1, 0.]

 

[1.105170012, 1.105170918, 0.906e-6]

 

[1.221399998, 1.221402758, 0.2760e-5]

 

[1.349854378, 1.349858808, 0.4430e-5]

 

[1.491819577, 1.491824698, 0.5121e-5]

 

[1.648716753, 1.648721271, 0.4518e-5]

 

[1.822115950, 1.822118800, 0.2850e-5]

 

[2.013751870, 2.013752707, 0.837e-6]

 

[2.225541500, 2.225540928, 0.572e-6]

 

[2.459603808, 2.459603111, 0.697e-6]

 

[2.718281833, 2.718281828, 0.5e-8]

 

[2., 1, 1.]

 

[2., 1.105170918, .894829082]

 

[2., 1.221402758, .778597242]

 

[2., 1.349858808, .650141192]

 

[2., 1.491824698, .508175302]

 

[2., 1.648721271, .351278729]

 

[2., 1.822118800, .177881200]

 

[2., 2.013752707, 0.13752707e-1]

 

[2., 2.225540928, .225540928]

 

[2., 2.459603111, .459603111]

 

[2., 2.718281828, .718281828]

(2)

``

``


 

Download fourthNONLINEARBOUD234.mw

 

Hello.

With the Curvefitting[Spline] command I calculate a piecewise function from discrete points. I perform this action 250 times and save the piecewise functions into a matrix. The process takes quite a while. Is it possible to save said matrix to a file such that I may call it from other maple worksheets, instead of re-calculating the matrix every time I want to use it?

Thanks. 

First 29 30 31 32 33 34 35 Last Page 31 of 44